{"id":219007,"date":"2014-04-11T13:01:09","date_gmt":"2014-04-11T09:01:09","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=219007"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=219007","title":{"rendered":"<span class=\"post_title\">\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u044b \u0434\u043b\u044f Ash Entity System \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a<\/span>"},"content":{"rendered":"<div class=\"content html_format\">       \u0414\u0432\u0430 \u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0441\u044f \u0441 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0433\u0440 \u043d\u0430 Actionscript <a href=\"http:\/\/www.ashframework.org\/\">Ash <\/a> (\u043f\u043e\u0447\u0442\u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441 \u043d\u0438\u043c, \u043f\u0440\u0438\u0448\u043b\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u043f\u043e\u0434 \u043b\u044e\u0431\u043e\u0439 \u044f\u0437\u044b\u043a. \u0410 \u0435\u0449\u0435 \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043f\u043e\u0440\u0442\u044b \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u0438\u0435 \u044f\u0437\u044b\u043a\u0438 \u2014 \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f 7 \u0448\u0442\u0443\u043a). \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u043f\u0438\u0440\u0430\u043b\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u0445\u043e\u0434\u043a\u043e\u0439 \u0441 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c, \u043f\u043e\u043a\u0430 \u043c\u0435\u043d\u044f \u043d\u0435 \u043e\u043f\u0435\u0440\u0435\u0434\u0438\u043b\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/197920\/\">\u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u043d\u0430 \u0425\u0430\u0431\u0440\u0435<\/a>. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0434\u043e\u0433\u043e\u043d\u043a\u0443 \u0445\u043e\u0447\u0443 \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c\u043e\u0433\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430<i> Finite-State Machine<\/i> \u0434\u043b\u044f <i>Ash Entity System<\/i> \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430. <br \/>  <a name=\"habracut\"><\/a><br \/>  \u041f\u0440\u0438\u043c\u0435\u0447\u0430\u043d\u0438\u0435: \u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u044f \u0431\u0430\u0437\u043e\u0432\u044b\u0445 \u043f\u043e\u043d\u044f\u0442\u0438\u0439 \u0438\u0437 <i>Entity System<\/i> \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 (ES-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a) \u0431\u0443\u0434\u0443 \u043f\u0438\u0441\u0430\u0442\u044c \u0441 \u0437\u0430\u0433\u043b\u0430\u0432\u043d\u043e\u0439 \u0431\u0443\u043a\u0432\u044b \u2014 \u0447\u0442\u043e\u0431 \u0438\u0437\u0431\u0435\u0436\u0430\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0434\u0432\u0443\u0441\u043c\u044b\u0441\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439: \u0421\u0438\u0441\u0442\u0435\u043c\u0430(<i>System<\/i>), \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442(<i>Component<\/i>), \u041d\u043e\u0434(<i>Node<\/i>), \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u044c(<i>Entity<\/i>)<\/p>\n<h4>\u041f\u0430\u0442\u0442\u0435\u0440\u043d \u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0435 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u044b \u0434\u043b\u044f Ash Entity System \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a<\/h4>\n<p>  <a href=\"http:\/\/en.wikipedia.org\/wiki\/Finite-state_machine\">Finite state machines<\/a> (FSM) \u2014 \u043e\u0434\u043d\u0430 \u0438\u0437 \u0433\u043b\u0430\u0432\u043d\u044b\u0445 \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u0439 \u0432 \u0433\u0435\u0439\u043c\u0434\u0435\u0432\u0435. \u0412 \u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u0438\u0433\u0440\u044b \u0438\u0433\u0440\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u043a\u0442\u044b \u043c\u043e\u0433\u0443\u0442 \u043c\u043d\u043e\u0433\u043e\u043a\u0440\u0430\u0442\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u0432\u043e\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u044d\u0444\u0444\u0435\u043a\u0442\u0438\u0432\u043d\u043e\u0435 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u044d\u0442\u0438\u043c\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u043e.<\/p>\n<p>  \u0421\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441 FSM \u0432 ES-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0440\u0430\u0437\u0438\u0442\u044c \u043e\u0434\u043d\u0438\u043c \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435\u043c \u2014 FSM \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 ES-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c. \u041b\u044e\u0431\u043e\u0439 ES-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u043f\u043e\u0434\u0445\u043e\u0434, \u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 (data-oriented paradigm), \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0438\u0433\u0440\u043e\u0432\u044b\u0435 c\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0442\u0441\u044f \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u043c\u0438 \u041e\u041e\u041f \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438. \u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0443 \u0432\u0430\u0441 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c FSM \u0438\u043b\u0438 \u0435\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u044b. \u0412\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u2014 \u0432 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445, \u0432\u0441\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u2014 \u0432 \u0421\u0438\u0441\u0442\u0435\u043c\u0430\u0445.<\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u043e\u043d\u0438 \u043f\u0440\u043e\u0441\u0442\u044b\u0435, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0430\u0440\u044b\u0439 \u0434\u043e\u0431\u0440\u044b\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440 <i>switch<\/i> \u0432\u043d\u0443\u0442\u0440\u0438 \u0421\u0438\u0441\u0442\u0435\u043c\u044b, \u0435\u0441\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 C\u0443\u0449\u043d\u043e\u0441\u0442\u0438 (\u0437\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0435 \u0432 \u0441\u043e\u043e\u0442\u0432. \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u0445) \u0442\u0430\u043a\u0436\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u044d\u0442\u043e\u0439 \u0421\u0438\u0441\u0442\u0435\u043c\u043e\u0439. \u041d\u043e \u044f \u0431\u044b \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u043b.<\/p>\n<p>  \u041f\u0440\u0438 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 <a href=\"http:\/\/www.sticksports.com\/mobile\/stick-tennis.php\">Stick Tennis<\/a> \u044f \u0432\u0441\u0442\u0430\u043b \u043f\u0435\u0440\u0435\u0434 \u043f\u0435\u0440\u0435\u0434 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438. \u041f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u044d\u0442\u0438\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0439 \u0431\u044b\u043b\u0430 \u043f\u043e\u0445\u043e\u0436\u0430 \u043d\u0430 \u043d\u0435\u0447\u0442\u043e \u043f\u043e\u0434\u043e\u0431\u043d\u043e\u0435\u2026  <\/p>\n<ul>\n<li>\u043f\u0440\u0438\u0433\u043e\u0442\u043e\u0432\u0438\u0442\u044c\u0441\u044f \u043a \u043f\u043e\u0434\u0430\u0447\u0435<\/li>\n<li>\u043d\u0430\u0447\u0430\u043b\u043e \u043f\u043e\u0434\u0430\u0447\u0438<\/li>\n<li>\u043f\u043e\u0434\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u043d\u0438\u0435 \u043c\u044f\u0447\u0430<\/li>\n<li>\u0437\u0430\u043c\u0430\u0445 \u0440\u0430\u043a\u0435\u0442\u043a\u043e\u0439<\/li>\n<li>\u0443\u0434\u0430\u0440 \u043f\u043e \u043c\u044f\u0447\u0443<\/li>\n<li>\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0443\u0434\u0430\u0440\u0430<\/li>\n<li>\u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043a \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438<\/li>\n<li>\u0440\u0435\u0430\u043a\u0446\u0438\u044f \u043d\u0430 \u0443\u0434\u0430\u0440 \u043f\u043e \u043c\u044f\u0447\u0443 \u043e\u043f\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c<\/li>\n<li>\u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043d\u0430 \u043f\u0435\u0440\u0435\u0445\u0432\u0430\u0442 \u043c\u044f\u0447\u0430<\/li>\n<li>\u0437\u0430\u043c\u0430\u0445 \u0440\u0430\u043a\u0435\u0442\u043a\u043e\u0439<\/li>\n<li>\u0443\u0434\u0430\u0440 \u043f\u043e \u043c\u044f\u0447\u0443<\/li>\n<li>\u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0443\u0434\u0430\u0440\u0430<\/li>\n<li>\u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u043a \u0445\u043e\u0440\u043e\u0448\u0435\u0439 \u043f\u043e\u0437\u0438\u0446\u0438\u0438<\/li>\n<li>\u0440\u0435\u0430\u043a\u0446\u0438\u044f \u043d\u0430 \u0443\u0434\u0430\u0440 \u043f\u043e \u043c\u044f\u0447\u0443 \u043e\u043f\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c<\/li>\n<li>\u0438 \u0442.\u0434.<\/li>\n<\/ul>\n<p>  <i>Stick Tennis<\/i> \u2014 \u044d\u0442\u043e \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0438 \u044f \u043d\u0435 \u043c\u043e\u0433\u0443 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u043d\u044b\u0439 \u043a\u043e\u0434, \u0432\u043c\u0435\u0441\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u044f \u043f\u043e\u043a\u0430\u0436\u0443 \u0447\u0442\u043e-\u043d\u0438\u0431\u0443\u0434\u044c \u043f\u043e\u043f\u0440\u043e\u0449\u0435.<\/p>\n<p>  <b>\u041f\u0440\u0438\u043c\u0435\u0440<\/b><\/p>\n<p>  \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436 \u2014 \u043e\u0445\u0440\u0430\u043d\u043d\u0438\u043a. \u041e\u0445\u0440\u0430\u043d\u043d\u0438\u043a \u043f\u0430\u0442\u0440\u0443\u043b\u0438\u0440\u0443\u0435\u0442 \u0432\u0434\u043e\u043b\u044c \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u043c\u0430\u0440\u0448\u0440\u0443\u0442\u0430 \u0441\u043b\u0435\u0434\u043e\u0432\u0430\u043d\u0438\u044f, \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0433\u043b\u044f\u0434\u044b\u0432\u0430\u044f\u0441\u044c \u043f\u043e \u0441\u0442\u043e\u0440\u043e\u043d\u0430\u043c. \u041f\u0440\u0438 \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0435\u043d\u0438\u0438 \u0432\u0440\u0430\u0433\u0430, \u0430\u0442\u0430\u043a\u0443\u0435\u0442 \u0435\u0433\u043e.<\/p>\n<p>  \u0412 \u0442\u0440\u0430\u0434\u0438\u0446\u0438\u043e\u043d\u043d\u043e\u0439 \u041e\u041e\u041f-\u043e\u0440\u0438\u0435\u043d\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 FSM \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<pre><code class=\"actionscript\">public class PatrolState {     private var guard : Character;     private var path : Vector.&lt;Point&gt;;      public function PatrolState( guard : Character, path : Vector.&lt;Point&gt; )     {         this.guard = guard;         this.path = path;     }      public function update( time : Number ) : void     {         moveAlongPath( time );         var enemy : Character = lookForEnemies();         if( enemy )         {             guard.changeState( new AttackState( guard, enemy ) );         }     } } <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"actionscript\">public class AttackState {     private var guard : Character;     private var enemy : Character;      public function AttackState( guard : Character, enemy : Character )     {         this.guard = guard;         this.enemy = enemy;     }      public function update( time : Number ) : void     {         guard.attack( enemy );         if( enemy.isDead )         {             guard.changeState( new PatrolState( guard, PatrolPathFactory.getPath( guard.id ) );         }     } } <\/code><\/pre>\n<p>  \u0412 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435 <i>Entity System<\/i> \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043d\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0431\u0430\u0437\u043e\u0432\u044b\u0439 \u043f\u0440\u0438\u0446\u0438\u043f FSM, \u0433\u0434\u0435 \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432, \u043a\u043e\u0433\u0434\u0430 \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u043b\u0435\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435, \u0435\u0449\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c. \u0427\u0442\u043e\u0431 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c FSM \u0432 ES-\u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0435 \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u043d\u0443 \u0421\u0438\u0441\u0442\u0435\u043c\u0443 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0433\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/p>\n<pre><code class=\"actionscript\">public class PatrolSystem extends ListIteratingSystem {     public function PatrolSystem()     {         super( PatrolNode, updateNode );     }      private function updateNode( node : PatrolNode, time : Number ) : void     {         moveAlongPath( node );         var enemy : Enemy = lookForEnemies( node );         if( enemy )         {             node.entity.remove( Patrol );             var attack : Attack = new Attack();             attack.enemy = enemy;             node.entity.add( attack );         }     } } <\/code><\/pre>\n<p>  <\/p>\n<pre><code class=\"actionscript\">public class AttackSystem extends ListIteratingSystem {     public function AttackSystem()     {         super( AttackNode, updateNode );     }      private function updateNode( node : PatrolNode, time : Number ) : void     {         attack( node.entity, node.attack.enemy );         if( node.attack.enemy.get( Health ).energy == 0 )         {             node.entity.remove( Attack );             var patrol : Patrol = new Patrol();             patrol.path = PatrolPathFactory.getPath( node.entity.name );             node.entity.add( patrol );         }     } } <\/code><\/pre>\n<p>  \u0417\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436\u0430-\u043e\u0445\u0440\u0430\u043d\u043d\u0438\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c <i>PatrolSystem<\/i>, \u0435\u0441\u043b\u0438 \u0432 \u043d\u0435\u0433\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <i>PatrolComponent<\/i>, \u0418 \u0437\u0430 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u043f\u0440\u0438 \u0430\u0442\u0430\u043a\u0435 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c <i>AttakSystem<\/i> \u0435\u0441\u043b\u0438 \u0432 \u043d\u0435\u0433\u043e \u0432\u043a\u043b\u044e\u0447\u0435\u043d \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 <i>AttackComponent<\/i>. \u041c\u0435\u043d\u044f\u044f \u044d\u0442\u0438 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b, \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u043f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436\u0430-\u043e\u0445\u0440\u0430\u043d\u043d\u0438\u043a\u0430.<\/p>\n<p>  \u042d\u0442\u0438 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0438 \u041d\u043e\u0434\u044b \u0431\u0443\u0434\u0443\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a\u2026<\/p>\n<pre><code class=\"actionscript\">public class Patrol {     public var path : Vector.&lt;Point&gt;; } public class Attack {     public var enemy : Entity; } public class Position {     public var point : Point; } public class Health {     public var energy : Number; } public class PatrolNode extends Node {     public var patrol : Patrol;     public var position : Position; } public class AttackNode extends Node {     public var attack : Attack; } <\/code><\/pre>\n<p>  \u0418\u0442\u0430\u043a, \u043c\u0435\u043d\u044f\u044f \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043c\u044b \u043c\u0435\u043d\u044f\u0435\u043c \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438 \u0421\u0438\u0441\u0442\u0435\u043c\u044b, \u043e\u0442\u0432\u0447\u0430\u044e\u0449\u0438\u0435 \u0437\u0430 \u0438\u0445 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435.<\/p>\n<p>  <b>\u0414\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440<\/b><\/p>\n<p>  \u0422\u0443\u0442 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044e \u0434\u0440\u0443\u0433\u043e\u0439 \u043f\u0440\u0438\u043c\u0435\u0440, \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0438\u0437 \u0438\u0433\u0440\u044b <a href=\"https:\/\/github.com\/richardlord\/Asteroids\">Asteroids example game<\/a>, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u044f \u0438\u043b\u043b\u044e\u0441\u0442\u0440\u0438\u0440\u0443\u044e \u0440\u0430\u0431\u043e\u0442\u0443 <i>Ash Framework<\/i>. \u041c\u043d\u0435 \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0435\u0449\u0435 \u043e\u0434\u043d\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0434\u043b\u044f \u043a\u043e\u0441\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0440\u0430\u0431\u043b\u044f \u2014 \u0433\u0438\u0431\u0435\u043b\u044c \u043a\u043e\u0440\u0430\u0431\u043b\u044f. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431 \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u043e\u0441\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u0440\u0430\u0431\u043b\u044c \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u0433\u0438\u0431\u0435\u043b\u0438, \u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u044e \u043a\u043e\u0440\u043e\u0442\u043a\u0443\u044e \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e \u0435\u0433\u043e \u0440\u0430\u0437\u0440\u0443\u0448\u0435\u043d\u0438\u044f. \u041f\u043e\u043a\u0430 \u044f \u0434\u0435\u043c\u043e\u043d\u0441\u0442\u0440\u0438\u0440\u0443\u044e \u044d\u0442\u0443 \u0430\u043d\u0438\u043c\u0430\u0446\u0438\u044e, \u0438\u0433\u0440\u043e\u043a \u043b\u0438\u0448\u0435\u043d \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u043a\u043e\u0440\u0430\u0431\u043b\u0435\u043c, \u0430 \u0441\u0430\u043c \u043a\u043e\u0440\u0430\u0431\u043b\u044c \u043d\u0435 \u0443\u0447\u0430\u0441\u0442\u0432\u0443\u0435\u0442 \u0432 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0439 \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u043e\u0431\u044a\u0435\u043a\u0442\u0430\u043c\u0438.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043b\u0438\u0441\u044c \u0434\u0432\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043a\u043e\u0440\u0430\u0431\u043b\u044f:<\/p>\n<ol>\n<li>\u043a\u043e\u0440\u0430\u0431\u043b\u044c \u0436\u0438\u0432\n<ul>\n<li>\u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442, \u043a\u0430\u043a \u043a\u043e\u0441\u043c\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043e\u0440\u0430\u0431\u043b\u044c<\/li>\n<li>\u0438\u0433\u0440\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0438\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c<\/li>\n<li>\u0438\u0433\u0440\u043e\u043a \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c \u0438\u0437 \u0435\u0433\u043e \u043e\u0440\u0443\u0434\u0438\u044f<\/li>\n<li>\u043a\u043e\u0440\u0430\u0431\u043b\u044c \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0430\u0441\u0442\u0435\u0440\u043e\u0438\u0434\u0430\u043c\u0438<\/li>\n<\/ul>\n<\/li>\n<li>\u043a\u043e\u0440\u0430\u0431\u043b\u044c \u043c\u0435\u0440\u0442\u0432\n<ul>\n<li>\u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442, \u043a\u0430\u043a \u043e\u0431\u043b\u043e\u043c\u043a\u0438, \u0434\u0440\u0435\u0439\u0444\u0443\u044e\u0449\u0438\u0435 \u0432 \u043a\u043e\u0441\u043c\u043e\u0441\u0435<\/li>\n<li>\u0438\u0433\u0440\u043e\u043a \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0438\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c<\/li>\n<li>\u0438\u0433\u0440\u043e\u043a \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0440\u0435\u043b\u044f\u0442\u044c \u0438\u0437 \u0435\u0433\u043e \u043e\u0440\u0443\u0434\u0438\u044f<\/li>\n<li>\u043a\u043e\u0440\u0430\u0431\u043b\u044c \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u0441\u0442\u0430\u043b\u043a\u0438\u0432\u0430\u0442\u044c\u0441\u044f \u0441 \u0430\u0441\u0442\u0435\u0440\u043e\u0438\u0434\u0430\u043c\u0438<\/li>\n<li>\u0447\u0435\u0440\u0435\u0437 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u043a\u043e\u0440\u0430\u0431\u043b\u044c \u0443\u0434\u0430\u043b\u044f\u0435\u0442\u0441\u044f \u0438\u0437 \u0438\u0433\u0440\u044b<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p>  \u0421\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434, \u0433\u0434\u0435 \u043a\u043e\u0440\u0430\u0431\u043b\u044c \u043f\u043e\u0433\u0438\u0431\u0430\u0435\u0442, \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 <i>CollisionSystem<\/i>. \u0411\u0435\u0437 \u0432\u0442\u043e\u0440\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:  <\/p>\n<pre><code class=\"actionscript\">for ( spaceship = spaceships.head; spaceship; spaceship = spaceship.next ) {     for ( asteroid = asteroids.head; asteroid; asteroid = asteroid.next )     {         if ( Point.distance( asteroid.position.position, spaceship.position.position )             &lt;= asteroid.position.collisionRadius + spaceship.position.collisionRadius )         {             creator.destroyEntity( spaceship.entity );             break;         }     } } <\/code><\/pre>\n<p>  \u041a\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442, \u043d\u0435 \u0441\u0442\u043e\u043b\u043a\u043d\u0443\u043b\u0441\u044f \u043b\u0438 \u043a\u043e\u0440\u0430\u0431\u043b\u044c \u0441 \u0430\u0441\u0442\u0435\u0440\u043e\u0438\u0434\u043e\u043c, \u0438 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u043e, \u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u043a\u043e\u0440\u0430\u0431\u043b\u044c \u0438\u0437 \u0438\u0433\u0440\u044b. \u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b <a href=\"https:\/\/github.com\/richardlord\/Asteroids\/blob\/master\/src\/no-dependencies\/net\/richardlord\/asteroids\/systems\/GameManager.as\">GameManager<\/a> \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442 \u0441\u0438\u0442\u0443\u0430\u0446\u0438\u044e, \u043a\u043e\u0433\u0434\u0430 \u0432 \u0438\u0433\u0440\u0435 \u043d\u0435\u0442 \u043a\u043e\u0441\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0440\u0430\u0431\u043b\u044f, \u0438 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439. \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u201c\u0436\u0438\u0437\u043d\u0438\u201d \u0438\u0441\u0447\u0435\u0440\u043f\u0430\u043d\u044b \u2014 \u043a\u043e\u043d\u0435\u0446 \u0438\u0433\u0440\u044b. \u0422\u0430\u043a \u0432\u043e\u0442 \u2014 \u0432\u043c\u0435\u0441\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u043a\u043e\u0440\u0430\u0431\u043b\u044f \u0438\u0437 \u0438\u0433\u0440\u044b, \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u2014 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0440\u0430\u0437\u043b\u0435\u0442\u0430\u044e\u0449\u0438\u0435\u0441\u044f \u043e\u0431\u043b\u043e\u043c\u043a\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0435\u043c\u2026<\/p>\n<p>  \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u043b\u0438\u0448\u0438\u0442\u044c \u0438\u0433\u0440\u043e\u043a\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u0441\u0442\u043e \u0443\u0434\u0430\u043b\u0438\u0432 \u0438\u0437 \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043a\u043e\u0441\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0440\u0430\u0431\u043b\u044f (<i>spaceship entity<\/i>) \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b <a href=\"https:\/\/github.com\/richardlord\/Asteroids\/blob\/master\/src\/no-dependencies\/net\/richardlord\/asteroids\/components\/MotionControls.as\">MotionControls <\/a>\u0438 <a href=\"https:\/\/github.com\/richardlord\/Asteroids\/blob\/master\/src\/no-dependencies\/net\/richardlord\/asteroids\/components\/GunControls.as\">GunControls<\/a>. \u0422\u0430\u043a \u0436\u0435 \u043c\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0443\u0434\u0430\u043b\u0438\u0442\u044c \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b <a href=\"https:\/\/github.com\/richardlord\/Asteroids\/blob\/master\/src\/no-dependencies\/net\/richardlord\/asteroids\/components\/Motion.as\">Motion<\/a> \u0438 <a href=\"https:\/\/github.com\/richardlord\/Asteroids\/blob\/master\/src\/no-dependencies\/net\/richardlord\/asteroids\/components\/Gun.as\">Gun<\/a> \u0442\u0430\u043a \u043a\u0430\u043a \u043e\u043d\u0438 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u043d\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0431\u0435\u0437 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0432\u0443\u044e\u0449\u0438\u0445 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440\u043e\u0432. \u0422.\u0435. \u043c\u044b \u0438\u0437\u043c\u0435\u044f\u0435\u043c \u043a\u043e\u0434 \u0432\u044b\u0448\u0435:  <\/p>\n<pre><code class=\"actionscript\">for ( spaceship = spaceships.head; spaceship; spaceship = spaceship.next ) {     for ( asteroid = asteroids.head; asteroid; asteroid = asteroid.next )     {         if ( Point.distance( asteroid.position.position, spaceship.position.position )             &lt;= asteroid.position.collisionRadius + spaceship.position.collisionRadius )         {           spaceship.entity.remove( MotionControls );             spaceship.entity.remove( Motion );             spaceship.entity.remove( GunControls );             spaceship.entity.remove( Gun );           break;         }     } } <\/code><\/pre>\n<p>  \u0417\u0430\u0442\u0435\u043c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0441\u043c\u0435\u043d\u0438\u0442\u044c \u0432\u043d\u0435\u0448\u043d\u0438\u0439 \u0432\u0438\u0434 \u043a\u043e\u0440\u0430\u0431\u043b\u044f (\u043d\u0430 \u043e\u0431\u043b\u043e\u043c\u043a\u0438) \u0438 \u043e\u0442\u043c\u0435\u043d\u0438\u0442\u044c \u043e\u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441\u0442\u043e\u043b\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u0439:  <\/p>\n<pre><code class=\"actionscript\">for ( spaceship = spaceships.head; spaceship; spaceship = spaceship.next ) {     for ( asteroid = asteroids.head; asteroid; asteroid = asteroid.next )     {         if ( Point.distance( asteroid.position.position, spaceship.position.position )             &lt;= asteroid.position.collisionRadius + spaceship.position.collisionRadius )         {             spaceship.entity.remove( MotionControls );             spaceship.entity.remove( Motion );             spaceship.entity.remove( GunControls );             spaceship.entity.remove( Gun );             spaceship.entity.remove( Collision );                spaceship.entity.remove( Display );                spaceship.entity.add( new Display( new SpaceshipDeathView() ) );             break;         }     } }<\/code><\/pre>\n<p>  \u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446, \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0442\u044c \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u043e\u0431\u043b\u043e\u043c\u043a\u043e\u0432 \u043a\u043e\u0440\u0430\u0431\u043b\u044f \u0441\u043f\u0443\u0441\u0442\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043f\u0435\u0440\u0438\u043e\u0434 \u0432\u0440\u0435\u043c\u0435\u043d\u0438. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043d\u043e\u0432\u0430\u044f \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0438 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442:  <\/p>\n<pre><code class=\"actionscript\">public class DeathThroes {     public var countdown : Number;              public function DeathThroes( duration : Number )     {         countdown = duration;     } } public class DeathThroesNode extends Node {     public var death : DeathThroes; } public class DeathThroesSystem extends ListIteratingSystem {     private var creator : EntityCreator;          public function DeathThroesSystem( creator : EntityCreator )     {         super( DeathThroesNode, updateNode );         this.creator = creator;     }      private function updateNode( node : DeathThroesNode, time : Number ) : void     {         node.death.countdown -= time;         if ( node.death.countdown &lt;= 0 )         {             creator.destroyEntity( node.entity );         }     } } <\/code><\/pre>\n<p>  \u041c\u044b \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <i>DeathThroesSystem <\/i>\u0432 \u0438\u0433\u0440\u0443 \u0441 \u0441\u0430\u043c\u043e\u0433\u043e \u043d\u0430\u0447\u0430\u043b\u0430, \u0438 \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043e\u043d\u0430 \u0441\u0440\u0435\u0430\u0433\u0438\u0440\u0443\u0435\u0442 \u043d\u0430 \u201c\u0441\u043c\u0435\u0440\u0442\u044c\u201d \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c <i>DeathThroes <\/i>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0432 \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u044c \u043a\u043e\u0441\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0440\u0430\u0431\u043b\u044f.  <\/p>\n<pre><code class=\"actionscript\">for ( spaceship = spaceships.head; spaceship; spaceship = spaceship.next ) {     for ( asteroid = asteroids.head; asteroid; asteroid = asteroid.next )     {         if ( Point.distance( asteroid.position.position, spaceship.position.position )             &lt;= asteroid.position.collisionRadius + spaceship.position.collisionRadius )         {             spaceship.entity.remove( MotionControls );             spaceship.entity.remove( Motion );             spaceship.entity.remove( GunControls );             spaceship.entity.remove( Gun );             spaceship.entity.remove( Collision );             spaceship.entity.remove( Display );             spaceship.entity.add( new Display( new SpaceshiopDeathView() ) );             spaceship.entity.add( new DeathThroes( 5 ) );             break;         }     } } <\/code><\/pre>\n<p>  \u0412 \u0438\u0442\u043e\u0433\u0435 \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u043a\u043e\u0441\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0440\u0430\u0431\u043b\u044f. \u0421\u0430\u043c \u0436\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438 \u0431\u044b\u043b \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d \u201c\u043f\u0435\u0440\u0435\u0442\u0430\u0441\u043e\u0432\u043a\u043e\u0439\u201d \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u043a\u043e\u0441\u043c\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u043a\u043e\u0440\u0430\u0431\u043b\u044f.<\/p>\n<h4>\u041a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432 \u043d\u0430\u0431\u043e\u0440\u0435 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432<\/h4>\n<p>  \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u043e<i> Entity System Architecture<\/i> \u2014 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438\u043d\u043a\u0430\u043f\u0441\u0443\u043b\u0438\u0440\u043e\u0432\u0430\u043d\u043e \u0432 \u043d\u0430\u0431\u043e\u0440\u0435 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u0415\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0432\u044b \u0434\u043e\u043b\u0436\u043d\u044b \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432. \u0418\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u043d\u0430\u0431\u043e\u0440\u0430 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0432 \u0441\u0432\u043e\u044e \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0438\u0437\u043c\u0435\u043d\u0438\u0442 \u043d\u0430\u0431\u043e\u0440 \u0421\u0438\u0441\u0442\u0435\u043c \u2014 \u0438 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u0435 \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438\u0437\u043c\u0435\u043d\u0438\u0442\u0441\u044f.<\/p>\n<h5>\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u0434 \u0434\u043b\u044f FSM <\/h5>\n<p>  \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u0440\u0430\u0431\u043e\u0442\u044b \u0441 FSM, \u044f \u0434\u043e\u0431\u0430\u0432\u0438\u043b \u0432\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0439 \u043d\u0430\u0431\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 &#8212;<a href=\"https:\/\/github.com\/richardlord\/Ash\/tree\/master\/src\/ash\/fsm\"> standard state machine classes<\/a>. \u041d\u0430\u0431\u043e\u0440 \u044d\u0442\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u043d\u043e\u0432\u044b\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0438\u043c\u0438.<\/p>\n<p>  FSM \u2014 \u044d\u0442\u043e \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 <a href=\"https:\/\/github.com\/richardlord\/Ash\/blob\/master\/src\/ash\/fsm\/EntityStateMachine.as\">EntityStateMachine<\/a>. \u041f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430, \u0432\u044b \u043f\u0435\u0440\u0435\u0434\u0430\u0435\u0442\u0435 \u0435\u043c\u0443 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u044c, \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f\u043c\u0438 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c. \u0421\u0430\u043c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 <i>EntityStateMachine <\/i>\u043e\u0431\u044b\u0447\u043d\u043e \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043a\u0430\u043a\u043e\u043c-\u043d\u0438\u0431\u0443\u0434\u044c \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u0432 \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438 \u0442\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u043b\u044e\u0431\u0430\u044f \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0438\u043c\u0435\u0435\u0442 \u043a \u043d\u0435\u043c\u0443 \u0434\u043e\u0441\u0442\u0443\u043f.  <\/p>\n<pre><code class=\"actionscript\">var stateMachine : EntityStateMachine = new EntityStateMachine( guard ); <\/code><\/pre>\n<p>  FSM \u0445\u0440\u0430\u043d\u0438\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f, \u0438 \u044d\u0442\u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043c\u0435\u043d\u044f\u0442\u044c, \u0432\u044b\u0437\u044b\u0432\u0430\u044f \u043c\u0435\u0442\u043e\u0434 <i>EntityStateMachine.changeState()<\/i>. \u041a\u0430\u0436\u0434\u043e\u0435 \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0439 (\u0438\u043c\u0435\u043d\u0435\u043c), \u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0430\u0441\u0441\u043e\u0446\u0438\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u043f\u0440\u0438 \u0435\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u0438 \u0432\u044b\u0437\u043e\u0432\u0435 <i>EntityStateMachine.changeState(stateName)<\/i>.   <\/p>\n<pre><code class=\"actionscript\">var patrolState : EntityState = stateMachine.createState( &quot;patrol&quot; ); var attackState : EntityState = stateMachine.createState( &quot;attack&quot; ); <\/code><\/pre>\n<p>  <b>\u0417\u0430 \u0447\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u043e\u0435 \u0432 FSM \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435<\/b>  <\/p>\n<ol>\n<li>\u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u041a\u043e\u043c\u043f\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0432 \u044d\u0442\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435;<\/li>\n<li>\u0443\u0434\u0430\u043b\u044f\u0435\u0442 \u0440\u0430\u043d\u0435\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043f\u0440\u0438 \u0432\u044b\u0445\u043e\u0434\u0435 \u0438\u0437 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f.<\/li>\n<\/ol>\n<p>  \u041c\u0435\u0442\u043e\u0434 <i>EntityStateMachine.add()<\/i> \u0443\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u0442 \u0442\u0438\u043f \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u0434\u043b\u044f \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u043c\u043e\u0433\u043e \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438 \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0449\u0438\u043c \u043a\u0430\u043a \u0438\u043c\u0435\u043d\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442.  <\/p>\n<pre><code class=\"actionscript\">var patrol : Patrol = new Patrol(); patrol.path = PatrolPathFactory.getPath( node.entity.name ); patrolState.add( Patrol ).withInstance( patrol ); attackState.add( Attack ); <\/code><\/pre>\n<p>  <\/p>\n<h4>\u0418\u043c\u0435\u0435\u0442\u0441\u044f \u0447\u0435\u0442\u0440\u044b\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u0430:<\/h4>\n<p>  <b>entityState.add( type: Class );<\/b><br \/>  \u0411\u0435\u0437 \u0432\u0441\u044f\u043a\u0438\u0445 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0439 FSM \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0442\u0438\u043f\u0430, \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0435\u0433\u043e \u043a \u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438. \u0418 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u0442\u0441\u044f \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u043f\u043e\u0432\u0442\u043e\u0440\u043d\u044b\u0445 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0445 \u0432 \u0434\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<br \/>  <b>entityState.add( type: Class ).withType( otherType: Class );<\/b><br \/>  \u042d\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u0441\u043e\u0437\u0434\u0430\u0435\u0442 \u043d\u043e\u0432\u044b\u0439 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 otherType \u043a\u0430\u0436\u0434\u044b\u0439 \u0440\u0430\u0437 \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0435 \u0432 \u0434\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. <i>otherType <\/i>\u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0442\u0438\u043f\u0430 <i>type <\/i>\u043b\u0438\u0431\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u0435\u043c \u0442\u0438\u043f\u0430 <i>type<\/i><br \/>  <b>entityState.add( type: Class ).withInstance( instance: * );<\/b><br \/>  \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434 \u0434\u0430\u0435\u0442 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442-\u0436\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u043f\u0440\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435.<\/p>\n<p>  \u0418 \u043d\u0430\u043a\u043e\u043d\u0435\u0446<\/p>\n<p>  <b>entityState.add( type: Class ).withSingleton();<\/b><br \/>  \u0438\u043b\u0438<br \/>  <b>entityState.add( type: Class ).withSingleton( otherType: Class );<\/b><br \/>  \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0441\u0438\u043d\u0433\u043b\u0435\u0442\u043e\u043d \u0438 \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u043c \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u0432 \u0434\u0430\u043d\u043d\u043e\u0435 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435. \u042d\u0442\u043e \u0442\u043e\u0436\u0435 \u0441\u0430\u043c\u043e\u0435, \u0447\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <i>withInstance <\/i>, \u043d\u043e \u043c\u0435\u0442\u043e\u0434 <i>withSingleton <\/i>\u043d\u0435 \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430, \u043f\u043e\u043a\u0430 \u043d\u0435 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f. \u0415\u0441\u043b\u0438 <i>otherType <\/i>\u043d\u0435 \u0443\u043a\u0430\u0437\u0430\u043d, \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u0441\u0438\u043d\u0433\u043b\u0435\u0442\u043e\u043d \u0442\u0438\u043f\u0430 type. \u0415\u0441\u043b\u0438 <i>otherType <\/i>\u0443\u043a\u0430\u0437\u0430\u043d, \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0442\u0438\u043f\u0430 <i>type<\/i>, \u043b\u0438\u0431\u043e \u0440\u0430\u0441\u0448\u0438\u0440\u044f\u0442\u044c \u0435\u0433\u043e.<\/p>\n<p>  \u041d\u0430\u043a\u043e\u043d\u0435\u0446, \u0432\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0430\u043c\u0438 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u044c \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442, \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u044f \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <a href=\"https:\/\/github.com\/richardlord\/Ash\/blob\/master\/src\/ash\/fsm\/IComponentProvider.as\">IComponentProvider<\/a> <br \/>  <b>entityState.add( type: Class ).withProvider( provider: IComponentProvider );<\/b><br \/>  \u0418\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <i>IComponentProvider <\/i>\u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c  <\/p>\n<pre><code class=\"actionscript\">public interface IComponentProvider {     function getComponent() : *;     function get identifier() : *; } <\/code><\/pre>\n<p>  \u041c\u0435\u0442\u043e\u0434 <i>getComponent <\/i>\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430. \u0421\u0432\u043e\u0439\u0441\u0442\u0432\u043e <i>identifier <\/i>\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u043b\u044f \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432, \u0447\u0442\u043e\u0431\u044b \u0443\u0431\u0435\u0434\u0438\u0442\u044c\u0441\u044f, \u0447\u0442\u043e \u043e\u043d\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u044e\u0442 \u0442\u043e\u0442-\u0436\u0435 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442. \u041d\u0443\u0436\u043d\u043e \u044d\u0442\u043e \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0437\u0430\u043c\u0435\u0449\u0435\u043d\u0438\u0435 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430, \u0435\u0441\u043b\u0438 \u0434\u0432\u0430 \u0440\u0430\u0437\u043d\u044b\u0445 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 \u0442\u043e\u0442-\u0436\u0435 \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442.<\/p>\n<p>  \u041c\u0435\u0442\u043e\u0434\u044b \u0441\u043f\u0440\u043e\u0435\u043a\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u044b \u201c\u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0443\u201d, \u0447\u0442\u043e\u0431 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0433\u0438\u0431\u043a\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b, \u043a\u0430\u043a \u0432\u044b \u0443\u0432\u0438\u0434\u0438\u0442\u0435 \u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435.<\/p>\n<p>  <b>\u041d\u0430\u0437\u0430\u0434 \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c<\/b><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u043c\u044b \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c \u044d\u0442\u0438 \u043d\u043e\u0432\u044b\u0435 \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u044b \u043a \u043f\u0440\u0438\u043c\u0435\u0440\u0443 \u0441 \u043a\u043e\u0441\u043c\u0438\u0447\u0441\u043a\u0438\u043c \u043a\u043e\u0440\u0430\u0431\u043b\u0435\u043c, \u043a\u043e\u0434 \u043f\u0440\u0438\u043c\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434<\/p>\n<pre><code class=\"actionscript\">var fsm : EntityStateMachine = new EntityStateMachine( spaceshipEntity );  fsm.createState( &quot;playing&quot; )    .add( Motion ).withInstance( new Motion( 0, 0, 0, 15 ) )    .add( MotionControls )        .withInstance( new MotionControls( Keyboard.LEFT, Keyboard.RIGHT, Keyboard.UP, 100, 3 ) )    .add( Gun ).withInstance( new Gun( 8, 0, 0.3, 2 ) )    .add( GunControls ).withInstance( new GunControls( Keyboard.SPACE ) )    .add( Collision ).withInstance( new Collision( 9 ) )    .add( Display ).withInstance( new Display( new SpaceshipView() ) );  fsm.createState( &quot;destroyed&quot; )    .add( DeathThroes ).withInstance( new DeathThroes( 5 ) )    .add( Display ).withInstance( new Display( new SpaceshipDeathView() ) );  var spaceshipComponent : Spaceship = new Spaceship(); spaceshipComponent.fsm = fsm; spaceshipEntity.add( spaceshipComponent ); fsm.changeState( &quot;playing&quot; ); <\/code><\/pre>\n<p>  \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0441\u043c\u0435\u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0435\u0433\u043e \u0421\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u044f \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u0441\u044f \u043c\u0430\u043a\u0441\u0438\u043c\u0430\u043b\u044c\u043d\u043e:<\/p>\n<pre><code class=\"actionscript\">for ( spaceship = spaceships.head; spaceship; spaceship = spaceship.next ) {     for ( asteroid = asteroids.head; asteroid; asteroid = asteroid.next )     {         if ( Point.distance( asteroid.position.position, spaceship.position.position )             &lt;= asteroid.position.collisionRadius + spaceship.position.collisionRadius )         {             spaceship.spaceship.fsm.changeState( &quot;destroyed&quot; );             break;         }     } } <\/code><\/pre>\n<p>     \t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/219007\/\"> http:\/\/habrahabr.ru\/post\/219007\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\">       \u0414\u0432\u0430 \u0433\u043e\u0434\u0430 \u043d\u0430\u0437\u0430\u0434 \u043f\u043e\u0437\u043d\u0430\u043a\u043e\u043c\u0438\u043b\u0441\u044f \u0441 \u0437\u0430\u043c\u0435\u0447\u0430\u0442\u0435\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u043e\u043c \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0433\u0440 \u043d\u0430 Actionscript <a href=\"http:\/\/www.ashframework.org\/\">Ash <\/a> (\u043f\u043e\u0447\u0442\u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u0441\u0442\u0432\u0430 \u0441 \u043d\u0438\u043c, \u043f\u0440\u0438\u0448\u043b\u043e \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a \u043f\u043e\u0434\u043e\u0439\u0434\u0435\u0442 \u043f\u043e\u0434 \u043b\u044e\u0431\u043e\u0439 \u044f\u0437\u044b\u043a. \u0410 \u0435\u0449\u0435 \u0447\u0443\u0442\u044c-\u0447\u0443\u0442\u044c \u043f\u043e\u0437\u0436\u0435 \u043f\u043e\u044f\u0432\u0438\u043b\u0438\u0441\u044c \u043f\u043e\u0440\u0442\u044b \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u043f\u043e\u0434 \u0434\u0440\u0443\u0433\u0438\u0435 \u044f\u0437\u044b\u043a\u0438 \u2014 \u043d\u0430 \u043c\u043e\u043c\u0435\u043d\u0442 \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0435\u0432\u043e\u0434\u0430 \u0438\u043c\u0435\u0435\u0442\u0441\u044f 7 \u0448\u0442\u0443\u043a). \u041d\u0435\u043a\u043e\u0442\u043e\u0440\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0440\u0430\u0441\u043f\u0438\u0440\u0430\u043b\u043e \u0436\u0435\u043b\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043d\u0430\u0445\u043e\u0434\u043a\u043e\u0439 \u0441 \u0440\u0443\u0441\u0441\u043a\u043e\u044f\u0437\u044b\u0447\u043d\u044b\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u0441\u0442\u0432\u043e\u043c, \u043f\u043e\u043a\u0430 \u043c\u0435\u043d\u044f \u043d\u0435 \u043e\u043f\u0435\u0440\u0435\u0434\u0438\u043b\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/197920\/\">\u043f\u0435\u0440\u0435\u0432\u043e\u0434\u043e\u043c \u043d\u0430 \u0425\u0430\u0431\u0440\u0435<\/a>. \u0422\u0435\u043f\u0435\u0440\u044c \u0432\u0434\u043e\u0433\u043e\u043d\u043a\u0443 \u0445\u043e\u0447\u0443 \u0432\u044b\u043b\u043e\u0436\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u0432\u043e\u0434 \u043a\u0430\u0441\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043f\u043e\u0447\u0442\u0438 \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c\u043e\u0433\u043e \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u0430<i> Finite-State Machine<\/i> \u0434\u043b\u044f <i>Ash Entity System<\/i> \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430.   <\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-219007","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/219007","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=219007"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/219007\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=219007"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=219007"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=219007"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}