{"id":412346,"date":"2024-06-29T22:28:52","date_gmt":"2024-06-29T22:28:52","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=412346"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=412346","title":{"rendered":"<span>\u0410\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u043d\u0430 Unity \u0431\u0435\u0437 Zenject. \u0427\u0430\u0441\u0442\u044c 3<\/span>"},"content":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/388\/2bf\/e21\/3882bfe215a2a6f001d6151fea108c70.png\" width=\"780\" height=\"439\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/388\/2bf\/e21\/3882bfe215a2a6f001d6151fea108c70.png\"\/><\/figure>\n<div class=\"persona\" persona=\"true\"><img decoding=\"async\" persona=\"true\" class=\"image persona__image\" src=\"https:\/\/habrastorage.org\/r\/w780q1\/getpro\/habr\/upload_files\/c11\/523\/1ef\/c115231ef34a8a937484a2cc3261bf29.jpg\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c11\/523\/1ef\/c115231ef34a8a937484a2cc3261bf29.jpg\" data-blurred=\"true\"\/><\/p>\n<h5 class=\"persona__heading\" persona=\"true\">\u0410\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438: \u0418\u0433\u043e\u0440\u044c \u0413\u0443\u043b\u044c\u043a\u0438\u043d<\/h5>\n<p>Senior Unity Developer<\/p>\n<\/div>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! ?<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0418\u0433\u043e\u0440\u044c \u0413\u0443\u043b\u044c\u043a\u0438\u043d, \u0438 \u044f Unity \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a. \u0417\u0430 \u0441\u0432\u043e\u0438 5 \u043b\u0435\u0442 \u043d\u0430\u043a\u043e\u043f\u0438\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c\u0438 \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0438\u0433\u0440\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0433\u0438\u0431\u043a\u043e \u0431\u0435\u0437 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430. \u0426\u0435\u043b\u044c \u0434\u043e\u043a\u043b\u0430\u0434\u0430, \u0434\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0445\u043e\u0434 \u043c\u044b\u0441\u043b\u0435\u0439 \u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0441\u0442\u0440\u043e\u0438\u0442\u044c. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0447\u0438\u0442\u0430\u043b\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/725068\/\"><u>\u043f\u0435\u0440\u0432\u0443\u044e<\/u><\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/companies\/otus\/articles\/725308\/\"><u>\u0432\u0442\u043e\u0440\u0443\u044e<\/u><\/a> \u0447\u0430\u0441\u0442\u0438, \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043d\u0438\u0445 :).<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/d7f\/1c6\/58b\/d7f1c658b790a015aadd9ad1954eca3d.png\" alt=\"\" title=\"\" width=\"1278\" height=\"812\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/d7f\/1c6\/58b\/d7f1c658b790a015aadd9ad1954eca3d.png\"\/><\/figure>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 GRASP \u0441 \u0446\u0435\u043b\u044c\u044e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f\u2026<\/p>\n<h3>\u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b<\/h3>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d <a href=\"https:\/\/en.wikipedia.org\/wiki\/GRASP_(object-oriented_design)#Pure_fabrication\"><u>Pure Fabrication<\/u><\/a> \u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <code>GameMachine<\/code> \u0438 <code>GameLocator<\/code> \u0432 \u043d\u0435\u043a\u0438\u0439 <a href=\"https:\/\/refactoring.guru\/ru\/design-patterns\/facade\"><u>\u0424\u0430\u0441\u0430\u0434<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u043e\u0432\u0435\u043c <code>GameContext<\/code>:<\/p>\n<pre><code class=\"cpp\">public sealed class GameContext : MonoBehaviour, IGameLocator, IGameMachine     {         public GameState GameState         {             get { return this.gameMachine.GameState; }         }          private readonly GameMachine gameMachine = new();          private readonly GameLocator serviceLocator = new();        public GameContext()         {             this.serviceLocator.AddService(this.gameMachine);         }          [ContextMenu(\"Start Game\")]         public void StartGame()         {             this.gameMachine.StartGame();         }          [ContextMenu(\"Pause Game\")]         public void PauseGame()         {             this.gameMachine.PauseGame();         }          [ContextMenu(\"Resume Game\")]         public void ResumeGame()         {            this.gameMachine.ResumeGame();         }          [ContextMenu(\"Finish Game\")]         public void FinishGame()         {             this.gameMachine.FinishGame();         }          public void AddListener(object listener)         {             this.gameMachine.AddListener(listener);         }          public void RemoveListener(object listener)         {             this.gameMachine.RemoveListener(listener);         }                  public void AddService(object service)         {             this.serviceLocator.AddService(service);         }          public void RemoveService(object service)         {             this.serviceLocator.RemoveService(service);         }          public T GetService&lt;T>()         {             return this.serviceLocator.GetService&lt;T>();         }     } <\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0432 \u0448\u0430\u0431\u043b\u043e\u043d GRASP, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u043c\u043e\u043d\u043e\u0431\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0438\u0433\u0440\u044b. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c <code>GameContext<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b <code>IGameMachine<\/code> \u0438 <code>IGameLocator<\/code>, \u043d\u043e \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u0443\u0436\u0435 <strong>\u043e\u0431\u044b\u0447\u043d\u044b\u043c<\/strong> \u043a\u043b\u0430\u0441\u0441\u0430\u043c <code>GameMachine<\/code> \u0438 <code>GameLocator<\/code>.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c <code>GameContext<\/code> \u043d\u0430 \u0441\u0446\u0435\u043d\u0443:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/49f\/bfe\/1fa\/49fbfe1fa8ae5b4f500efe05f651c7d9.png\" alt=\"\" title=\"\" width=\"804\" height=\"404\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/49f\/bfe\/1fa\/49fbfe1fa8ae5b4f500efe05f651c7d9.png\"\/><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u0435\u0440\u044b \u0432 \u0441\u0445\u0435\u043c\u0435:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ab2\/3db\/fab\/ab23dbfab847c66e4532b21af01b738a.png\" alt=\"\" title=\"\" width=\"1278\" height=\"812\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ab2\/3db\/fab\/ab23dbfab847c66e4532b21af01b738a.png\"\/><\/figure>\n<p>\u0421 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u0435\u0440\u0430\u043c\u0438 \u0432\u0441\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435, \u0442\u0443\u0442 \u0443\u0436\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 GRASP, \u043d\u043e \u0441\u0430\u043c\u044b\u0439 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0431\u0443\u0434\u0435\u0442 <a href=\"https:\/\/en.wikipedia.org\/wiki\/GRASP_(object-oriented_design)#Indirection\"><u>Indirection<\/u><\/a>. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 <code>GameContext<\/code> \u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043a\u0438\u0439 <code>GameContextInstaller<\/code>.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c89\/aaa\/3e3\/c89aaa3e37f0bea4963f1fb33669665c.png\" alt=\"\" title=\"\" width=\"1600\" height=\"266\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c89\/aaa\/3e3\/c89aaa3e37f0bea4963f1fb33669665c.png\"\/><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c <code>GameContextInstaller<\/code> \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438 \u043b\u0438\u0441\u0442\u0435\u043d\u0435\u0440\u044b \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0410 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <code>GameObservableInstaller<\/code>, <code>GameServiceInstaller<\/code> \u0438 <code>GameAssembler<\/code> \u0431\u0443\u0434\u0443\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b <code>IGameServiceProvider<\/code>,\u00a0<code>IGameListenerProvider<\/code>, <code>IGameConstructor<\/code>. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432 \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"cpp\">public sealed class GameContextInstaller : MonoBehaviour     {         [SerializeField]         private GameContext gameContext;          [SerializeField]         private MonoBehaviour[] installers;          private void Awake()         {             foreach (var installer in this.installers)             {                 if (installer is IGameServiceProvider serviceProvider)                 {                     this.gameContext.AddServices(serviceProvider.GetServices());                 }                  if (installer is IGameListenerProvider listenerProvider)                 {                     this.gameContext.AddListeners(listenerProvider.GetListeners());                 }             }         }          private void Start()         {             foreach (var installer in this.installers)             {                 if (installer is IGameConstructor constructor)                 {                     constructor.ConstructGame(this.gameContext);                 }             }         }     } <\/code><\/pre>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <code>GameContextInstaller.Awake()<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 <code>GameContext<\/code>, \u0430 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>GameContextInstaller.Start()<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u043f\u0440\u043e \u043d\u043e\u0432\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b:<\/p>\n<p><strong>IGameListenerProvider<\/strong> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 <code>GameContext<\/code>.<\/p>\n<pre><code class=\"cpp\">public interface IGameListenerProvider     {         IEnumerable&lt;object> GetListeners();     }<\/code><\/pre>\n<p><strong>IGameServiceProvider<\/strong> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 <code>GameContext<\/code>.<\/p>\n<pre><code class=\"cpp\">public interface IGameServiceProvider     {         IEnumerable&lt;object> GetServices();     }<\/code><\/pre>\n<p><strong>IGameConstructor<\/strong> \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0435\u0441\u0442\u0440 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430.<\/p>\n<pre><code class=\"cpp\"> public interface IGameConstructor     {         void ConstructGame(IGameLocator serviceLocator);     }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b.\u00a0<\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043c\u043e\u0434\u0443\u043b\u044f: \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0438\u0433\u0440\u043e\u043a\u0430 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e<\/p>\n<ol>\n<li>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0435 <code>PlayerInstaller<\/code> \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438\u0433\u0440\u043e\u043a\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0435 <code>InputInstaller<\/code> \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0432\u0432\u043e\u0434\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438\u043b\u0430\u0433\u0430\u044e \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">public sealed class PlayerInstaller : MonoBehaviour,         IGameServiceProvider,         IGameListenerProvider,         IGameConstructor     {         [SerializeField]         private Player player;          [SerializeField]         private MoveController moveController;                  \/\/TODO: \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043a\u0430\u043c\u0435\u0440\u044b:         \/\/[SerializeField]         \/\/private CameraController cameraController;          IEnumerable&lt;object> IGameServiceProvider.GetServices()         {             yield return this.player;         }          IEnumerable&lt;object> IGameListenerProvider.GetListeners()         {             yield return this.moveController;             \/\/yield return this.cameraController;         }          void IGameConstructor.ConstructGame(IGameLocator serviceLocator)         {             var keyboardInput = serviceLocator.GetService&lt;IMoveInput>();             this.moveController.Construct(keyboardInput, this.player);                          \/\/var camera = serviceLocator.GetService&lt;WorldCamera>();             \/\/ this.cameraController.Construct(camera, this.player)         }     }   public sealed class InputInstaller : MonoBehaviour,         IGameServiceProvider,         IGameListenerProvider     {         [SerializeField]         private KeyboardInput keyboardInput;          \/\/TODO: \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432\u0432\u043e\u0434 \u0441 \u043c\u044b\u0448\u0438         \/\/[SerializeField]         \/\/private MouseInput mouseInput;          IEnumerable&lt;object> IGameServiceProvider.GetServices()         {             yield return this.keyboardInput;             \/\/yield return this.mouseInput;         }          IEnumerable&lt;object> IGameListenerProvider.GetListeners()         {             yield return this.keyboardInput;             \/\/yield return this.mouseInput;         }     }<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043a\u043e\u0434 \u043d\u0430\u043f\u0438\u0441\u0430\u043d! \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <code>GameContextInstaller<\/code>, <code>PlayerInstaller<\/code> \u0438 <code>InputInstaller<\/code> \u043d\u0430 \u0441\u0446\u0435\u043d\u0443:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/b91\/474\/e3c\/b91474e3cf481541b20acaf1ad900068.png\" alt=\"\" title=\"\" width=\"794\" height=\"1078\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/b91\/474\/e3c\/b91474e3cf481541b20acaf1ad900068.png\"\/><\/figure>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438\u0433\u0440\u0443. \u0421\u0435\u0439\u0447\u0430\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>GameContextInstaller.Awake()<\/code>, \u0430 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u2014 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>GameContextInstaller.Start()<\/code>. \u0414\u0430\u043b\u044c\u0448\u0435 \u0432 \u201c\u043c\u043e\u043d\u043e\u0431\u0435\u0445\u0435\u201d GameContext \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0435 \u043c\u0435\u043d\u044e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>GameContext.StartGame()<\/code>. \u0412\u0443\u0430\u043b\u044f, \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043d\u0430\u0448\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/417\/f38\/bd0\/417f38bd03984f52089fdf1b8deb9d7d.png\" alt=\"\" title=\"\" width=\"1276\" height=\"944\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/417\/f38\/bd0\/417f38bd03984f52089fdf1b8deb9d7d.png\"\/><\/figure>\n<h3>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0433\u0440\u044b<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0431\u044b\u043b\u043e \u0431\u044b\u043b\u043e \u0437\u0434\u043e\u0440\u043e\u0432\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448\u0430 \u0438\u0433\u0440\u043e\u0432\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u043b\u0430 \u043e\u0442 \u043c\u043e\u043d\u043e\u0431\u0435\u0445\u043e\u0432. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0442\u0430\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u0440\u043e\u0449\u0435 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043a\u043e\u0434\u0430. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0443\u0439\u0434\u044f \u043e\u0442 \u043c\u043e\u043d\u043e\u0431\u0435\u0445\u043e\u0432 \u0438 \u0433\u0435\u0439\u043c-\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0412 \u0442\u0440\u0435\u0442\u044c\u0438\u0445, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u043a\u043e\u0434\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 GameObject\u2019\u044b \u0438\u00a0 \u201c\u043c\u043e\u043d\u043e\u0431\u0435\u0445\u0438\u201d \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, MoveController \u0438 KeyboardInput \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u044d\u0442\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043f\u0440\u044f\u043c\u043e \u0432 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u0435\u0440\u0435:\u00a0<\/p>\n<pre><code class=\"cpp\"> public sealed class InputInstaller : MonoBehaviour,         IGameServiceProvider,         IGameListenerProvider     {         private readonly KeyboardInput keyboardInput = new();  \/\/Other code\u2026     }  public sealed class PlayerInstaller : MonoBehaviour,         IGameServiceProvider,         IGameListenerProvider,         IGameConstructor     {         private readonly MoveController moveController = new();          \/\/private readonly CameraController cameraController = new();  \/\/Other code\u2026            }<\/code><\/pre>\n<p>\u041d\u043e \u0443 KeyboardInput \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>Update()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0434\u0432\u0438\u0436\u043a\u0430, \u0447\u0442\u043e\u0431\u044b \u0442\u0440\u0435\u043a\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0432\u0432\u043e\u0434. \u042d\u0442\u043e\u0442 \u043d\u044e\u0430\u043d\u0441 \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>IUpdateGameListener<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>GameContext<\/code>:<\/p>\n<pre><code class=\"cpp\">public interface IUpdateGameListener     {         void OnUpdate(float deltaTime);     }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, <code>KeyboardInput<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\"> public sealed class KeyboardInput :         IMoveInput,         IStartGameListener,         IUpdateGameListener,         IFinishGameListener     {         public event Action&lt;Vector3> OnMove;          private bool isActive;          void IUpdateGameListener.OnUpdate(float deltaTime)         {             if (this.isActive)             {                 this.HandleKeyboard();             }         }  \/\/Other code\u2026 }<\/code><\/pre>\n<p>\u0410 \u0432 \u043a\u043b\u0430\u0441\u0441 <code>GameContext<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">public sealed class GameContext : MonoBehaviour, IGameLocator, IGameMachine     {         private readonly List&lt;IUpdateGameListener> updateListeners = new();          private void Awake()         {             this.enabled = false;         }          \/\/\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e, \u0435\u0441\u043b\u0438 \u0438\u0433\u0440\u0430 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430         private void Update()         {             var deltaTime = Time.deltaTime;             for (int i = 0, count = this.updateListeners.Count; i &lt; count; i++)             {                 var listener = this.updateListeners[i];                 listener.OnUpdate(deltaTime);             }         }  \/\/Other code\u2026 }<\/code><\/pre>\n<blockquote>\n<p><em>\u0420\u0435\u043c\u0430\u0440\u043a\u0430: \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a\u0436\u0435 \u043f\u0440\u0438\u043a\u0440\u0443\u0442\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b <\/em><code>FixedUpdate()<\/code><em> \u0438 <\/em><code>LateUpdate()<\/code><em>, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0432 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0443\u044e\u0449\u0438\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b: <\/em><code>IFixedUpdateListener<\/code><em> \u0438 <\/em><code>ILateUpdateListener<\/code><\/p>\n<\/blockquote>\n<p>\u0415\u0449\u0435 \u043e\u0434\u043d\u0438\u043c \u043f\u0440\u0435\u0438\u043c\u0443\u0449\u0435\u0441\u0442\u0432\u043e\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043a\u043e\u0434\u0430 \u0431\u0435\u0437 \u043c\u043e\u043d\u043e\u0431\u0435\u0445\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043f\u0440\u043e\u0435\u043a\u0442\u0430. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 \u043a\u043e\u0434 \u0438\u0433\u0440\u044b \u043f\u0438\u0448\u0435\u0442\u0441\u044f \u043d\u0430 \u0447\u0438\u0441\u0442\u043e\u043c C#, \u0442\u043e \u0438 \u0432\u0441\u0435 \u0432\u043d\u0435\u0441\u0435\u043d\u0438\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0442\u043e\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0448\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043e\u0434\u0430\u2026 \u0422\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u044d\u0442\u043e \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0442\u0440\u043e\u0433\u0430\u0442\u044c \u0438\u0433\u0440\u043e\u0432\u044b\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043f\u0440\u0438 \u043f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u043d\u0438\u0438 \u043a\u043e\u0434\u0430, \u0438 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0434\u0440\u0443\u0433\u0438\u043c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430\u043c, \u0442\u0430\u043a\u0438\u043c \u043a\u0430\u043a \u043b\u0435\u0432\u0435\u043b-\u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440\u0430\u043c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u0441\u0446\u0435\u043d\u0435 \u043f\u0430\u0440\u0430\u043b\u043b\u0435\u043b\u044c\u043d\u043e \u0441 \u0431\u043e\u043b\u044c\u0448\u0435\u0439 \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e, \u0447\u0442\u043e \u043e\u043d\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u0441\u043b\u043e\u043c\u0430\u044e\u0442 :).<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438 \u0432\u0438\u0434\u0438\u043c, \u0447\u0442\u043e \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u043d\u043e\u0431\u0435\u0445\u0438 \u0431\u043e\u043b\u044c\u0448\u0435 \u043d\u0435 \u043d\u0443\u0436\u043d\u044b, \u0442\u0430\u043a \u043a\u0430\u043a \u0441 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u043b\u043e\u0433\u0438\u043a\u043e\u0439 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043d\u0430 \u0443\u0440\u043e\u0432\u043d\u0435 \u043a\u043e\u0434\u0430:<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/793\/3e6\/2e5\/7933e62e53453f104f6864249333269d.png\" alt=\"\" title=\"\" width=\"450\" height=\"148\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/793\/3e6\/2e5\/7933e62e53453f104f6864249333269d.png\"\/><\/figure>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u044c \u0438\u0433\u0440\u044b\u2026 \u0412\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<h3>\u0415\u0434\u0438\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430<\/h3>\n<p>\u041d\u0435\u0441\u043b\u043e\u0436\u043d\u043e \u043e\u0431\u043d\u0430\u0440\u0443\u0436\u0438\u0442\u044c, \u0447\u0442\u043e \u043d\u0430 \u0438\u0433\u0440\u043e\u0432\u043e\u0439 \u0441\u0446\u0435\u043d\u0435 \u043d\u0435\u0442 \u0435\u0434\u0438\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u0438 \u0432\u0445\u043e\u0434\u0430, \u0438 \u0437\u0430\u043f\u0443\u0441\u043a \u0438\u0433\u0440\u044b \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043a\u0430\u043a \u043f\u043e\u043f\u0430\u043b\u043e:<\/p>\n<ol>\n<li>\n<p>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>GameContextInstaller.Awake()<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0412\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u00a0 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>GameContextInstaller.Start()<\/code>.<\/p>\n<\/li>\n<li>\n<p>\u0410 \u0438\u0433\u0440\u0430 \u0432\u043e\u043e\u0431\u0449\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u0442\u0441\u044f \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0441\u043f\u0435\u043a\u0442\u043e\u0440.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u043e\u043a\u0430 \u0447\u0442\u043e \u044d\u0442\u043e \u0432\u0441\u0435 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435\u043c\u043d\u043e\u0433\u043e ridiculous. \u0422\u0430\u043a \u0447\u0442\u043e \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0435\u0434\u0438\u043d\u0443\u044e \u0442\u043e\u0447\u043a\u0443 \u0432\u0445\u043e\u0434\u0430 \u0432 \u0438\u0433\u0440\u0443.<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438\u0433\u0440\u044b \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c, \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432 \u0432\u0441\u0435\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/960\/010\/de1\/960010de19ca980d9eb33f0548f6acbf.png\" alt=\"\" title=\"\" width=\"1600\" height=\"184\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/960\/010\/de1\/960010de19ca980d9eb33f0548f6acbf.png\"\/><\/figure>\n<p>\u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u044b\u0434\u0435\u043b\u0438\u043c \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0441\u0442\u044c \u043d\u043e\u0432\u043e\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 <code>GameLauncher<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0437\u0430\u043f\u0443\u0441\u043a\u043e\u043c \u0438\u0433\u0440\u044b \u0432 \u043e\u0434\u043d\u043e\u043c \u043c\u0435\u0441\u0442\u0435.<\/p>\n<pre><code class=\"cpp\"> public sealed class GameLauncher : MonoBehaviour     {         [SerializeField]         private GameContextInstaller installer;          [SerializeField]         private GameContext context;          [ContextMenu(\"Launch Game\")]         public void LaunchGame()         {             this.installer.RegisterComponents();             this.installer.ConstructGame();             this.context.StartGame();         }     }<\/code><\/pre>\n<p>\u0415\u0441\u043b\u0438 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u043d\u0430 \u043a\u043b\u0430\u0441\u0441 <code>GameLauncher<\/code>, \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 <code>GameContextInstaller.RegisterComponents()<\/code> \u0438 <code>GameContextInstaller.ConstructGame()<\/code> \u0441\u0442\u0430\u043b\u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u043c\u0438. \u0422\u0435\u043f\u0435\u0440\u044c \u043e\u043d\u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>GameLauncher.LaunchGame()<\/code>, \u0430 \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434\u044b <code>Awake()<\/code> \u0438 <code>Start()<\/code>, \u043a\u0430\u043a \u0431\u044b\u043b\u043e \u0440\u0430\u043d\u0435\u0435. \u042d\u0442\u043e \u0441\u0434\u0435\u043b\u0430\u043d\u043e, \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0432\u0441\u0435\u0433\u0434\u0430 \u0431\u044b\u043b <strong>\u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c<\/strong> \u043d\u0430\u0434 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0438 \u044d\u0442\u043e \u0445\u043e\u0440\u043e\u0448\u043e \ud83d\ude42<\/p>\n<p>\u041e\u043f\u044b\u0442\u043d\u044b\u0435 \u0447\u0438\u0442\u0430\u0442\u0435\u043b\u0438, \u0432\u0437\u0433\u043b\u044f\u043d\u0443\u0432 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441 <code>GameLauncher<\/code>, \u0431\u044b\u0441\u0442\u0440\u043e \u0437\u0430\u043c\u0435\u0442\u044f\u0442, \u0447\u0442\u043e \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0440\u0443\u0448\u0430\u0435\u0442 2-\u0439 \u043f\u0440\u0438\u043d\u0446\u0438\u043f SOLID <a href=\"https:\/\/ru.wikipedia.org\/wiki\/%D0%9F%D1%80%D0%B8%D0%BD%D1%86%D0%B8%D0%BF_%D0%BE%D1%82%D0%BA%D1%80%D1%8B%D1%82%D0%BE%D1%81%D1%82%D0%B8\/%D0%B7%D0%B0%D0%BA%D1%80%D1%8B%D1%82%D0%BE%D1%81%D1%82%D0%B8\"><u>Open-Closed<\/u><\/a>, \u0442\u0430\u043a \u043f\u0440\u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0438 \u0438\u043b\u0438 \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u0432 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u043d\u0430\u043c \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0438\u0437\u043c\u0435\u043d\u044f\u0442\u044c \u044d\u0442\u043e\u0442 \u043a\u043b\u0430\u0441\u0441. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043e\u0442\u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043c GameLauncher, \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043f\u043e\u043b\u0438\u043c\u043e\u0440\u0444\u0438\u0437\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0440\u044f\u0434\u043e\u043a \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u044b\u043b \u0431\u043e\u043b\u0435\u0435 \u0433\u0438\u0431\u043a\u0438\u043c:<\/p>\n<pre><code class=\"cpp\">public abstract class GameTask : ScriptableObject     {         public abstract Task Do();     }  public sealed class GameLauncher : MonoBehaviour     {         [SerializeField]         private bool autoRun = true;                  [SerializeField]         private List&lt;GameTask> taskList;          private async void Start()         {             if (this.autoRun)             {                 await this.LaunchGame();             }         }          [ContextMenu(\"Launch Game\")]         public async Task LaunchGame()         {             foreach (var task in this.taskList)             {                 await task.Do();             }         }     }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448 \u043f\u0430\u0439\u043f\u043b\u0430\u0439\u043d \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447 \u0438 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0442\u044c\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0433\u0430\u043b\u043e\u0447\u043a\u0438 autoRun. \u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0430\u044f \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0430 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u043f\u043e\u0434\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0438 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u0438\u0433\u0440\u043e\u043a\u0430 \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445, \u0447\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0442\u0440\u0435\u0431\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u043d\u0430 \u0431\u043e\u0435\u0432\u043e\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435.<\/p>\n<p>\u041a\u0430\u0436\u0434\u0443\u044e \u0437\u0430\u0434\u0430\u0447\u0443 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c ScriptableObject\u2019\u043e\u043c, \u0447\u0442\u043e\u0431\u044b \u043f\u043e\u0442\u043e\u043c \u043b\u0435\u0433\u043a\u043e \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0432 \u043a\u043e\u0434\u0435:<\/p>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432:<\/p>\n<pre><code class=\"cpp\"> [CreateAssetMenu(         fileName = \"Task \u00abRegister Components\u00bb\",         menuName = \"GameTasks\/Task \u00abRegister Components\u00bb\"     )]     public sealed class GameTask_RegisterComponents : GameTask     {         public override Task Do()         {             var installer = FindObjectOfType&lt;GameContextInstaller>(); installer.RegisterComponents();             return Task.CompletedTask;         }     }<\/code><\/pre>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439:<\/p>\n<pre><code class=\"cpp\"> [CreateAssetMenu(         fileName = \"Task \u00abConstruct Game\u00bb\",         menuName = \"GameTasks\/Task \u00abConstruct Game\u00bb\"     )]     public sealed class GameTask_ConstructGame : GameTask     {         public override Task Do()         {             var installer = FindObjectOfType&lt;GameContextInstaller>();             installer.ConstructGame();             return Task.CompletedTask;         }     }<\/code><\/pre>\n<p>\u0417\u0430\u0434\u0430\u0447\u0430 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u0438\u0433\u0440\u044b:<\/p>\n<pre><code>  [CreateAssetMenu(         fileName = \"Task \u00abStart Game\u00bb\",         menuName = \"GameTasks\/Task \u00abStart Game\u00bb\"     )]     public sealed class GameTask_StartGame : GameTask     {         public override Task Do()         {             var gameContext = FindObjectOfType&lt;GameContext>();             gameContext.StartGame();             return Task.CompletedTask;         }     }<\/code><\/pre>\n<blockquote>\n<p><em>\u0420\u0435\u043c\u0430\u0440\u043a\u0430: \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043c\u044b \u0432\u0438\u0434\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 <\/em><code>GameObject.FindObjectOfType<\/code><em>, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u044e\u0442 \u043d\u0430\u0439\u0442\u0438 \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u043d\u0430 \u0441\u0446\u0435\u043d\u0435. \u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u0442\u043e, \u0447\u0442\u043e \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u0430 <\/em><code>GameObject.FindObjectOfType<\/code><em> \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u043a\u043e\u043b-\u0432\u0430 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u0441\u0446\u0435\u043d\u0435, \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0437\u0430\u043f\u0443\u0441\u043a\u0430 \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u043a\u0440\u0438\u0442\u0438\u0447\u043d\u043e, \u0442\u0430\u043a \u043a\u0430\u043a \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438 \u043d\u0435 \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0433\u0435\u0439\u043c\u043f\u043b\u0435\u044e \u0438\u0433\u0440\u044b.<\/em><\/p>\n<\/blockquote>\n<blockquote>\n<p><em>\u0420\u0435\u043c\u0430\u0440\u043a\u0430: \u0415\u0441\u043b\u0438 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0437\u0430\u0434\u0430\u0447\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u0438, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0438\u0441\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u0447\u0435\u0440\u0435\u0437 \u043c\u0435\u0442\u043e\u0434 <\/em><code>GameObject.FindWithTag(\u201cGame\u201d)<\/code><em>. \u041f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 Unity \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 \u043f\u043e \u0442\u0435\u0433\u0443 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432\u044b, \u0442\u043e \u0442\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0433\u043e\u0440\u0430\u0437\u0434\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435. \u041d\u0443 \u0438\u043b\u0438 \u0432 \u0441\u0430\u043c\u043e\u043c-\u0441\u0430\u043c\u043e\u043c \u043a\u0440\u0430\u0439\u043d\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0434\u0435\u043b\u0430\u0439\u0442\u0435 \u0441\u0438\u043d\u0433\u043b\u0442\u043e\u043d <\/em><code>GameContext.Instance<\/code><em>, \u043a \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u0440\u0430\u0449\u0430\u0442\u044c\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438\u2026<\/em><\/p>\n<\/blockquote>\n<p>\u041d\u0443 \u0447\u0442\u043e \u0436, \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <code>GameLauncher<\/code> \u043d\u0430 \u0441\u0446\u0435\u043d\u0443, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u0430\u0434\u0430\u0447:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/c6a\/ecd\/859\/c6aecd859b746703bac641a905f01779.png\" alt=\"\" title=\"\" width=\"866\" height=\"860\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/c6a\/ecd\/859\/c6aecd859b746703bac641a905f01779.png\"\/><\/figure>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438\u0433\u0440\u0443\u2026 \u0412\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \ud83d\ude42<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 <code>GameContextInstaller<\/code> \u0438 \u043f\u0435\u0440\u0435\u043d\u0435\u0441\u0442\u0438 \u0435\u0433\u043e \u043b\u043e\u0433\u0438\u043a\u0443 \u0432 \u0437\u0430\u0434\u0430\u0447\u0438, \u0447\u0442\u043e\u0431\u044b \u0443\u043f\u0440\u043e\u0441\u0442\u0438\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443:<\/p>\n<pre><code class=\"cpp\">[CreateAssetMenu(         fileName = \"Task \u00abConstruct Game\u00bb\",         menuName = \"GameTasks\/Task \u00abConstruct Game\u00bb\"     )]     public sealed class GameTask_ConstructGame : GameTask     {         public override Task Do()         {             var gameContext = GameObject                 .FindGameObjectWithTag(TagManager.GAME_CONTEXT)                 .GetComponent&lt;GameContext>();                          var installers = GameObject                 .FindGameObjectsWithTag(TagManager.GAME_INSTALLER);                             foreach (var installer in installers)             {                 if (installer.TryGetComponent(out IGameServiceProvider serviceProvider))                 {                     gameContext.AddServices(serviceProvider.GetServices());                 }                  if (installer.TryGetComponent(out IGameListenerProvider listenerProvider))                 {                     gameContext.AddListeners(listenerProvider.GetListeners());                 }             }                          foreach (var installer in installers)             {                 if (installer.TryGetComponent(out IGameConstructor constructor))                 {                     constructor.ConstructGame(gameContext);                 }             }                          return Task.CompletedTask;         }     }   [CreateAssetMenu(         fileName = \"Task \u00abStart Game\u00bb\",         menuName = \"GameTasks\/Task \u00abStart Game\u00bb\"     )]     public sealed class GameTask_StartGame : GameTask     {         public override Task Do()         {             GameObject                 .FindGameObjectWithTag(TagManager.GAME_CONTEXT)                 .GetComponent&lt;GameContext>()                 .StartGame();              return Task.CompletedTask;         }     } <\/code><\/pre>\n<p>\u0424\u0438\u043d\u0430\u043b\u044c\u043d\u0430\u044f \u0441\u0445\u0435\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/cc2\/715\/de5\/cc2715de5888552881cef7c9486e9f92.png\" alt=\"\" title=\"\" width=\"1062\" height=\"788\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/cc2\/715\/de5\/cc2715de5888552881cef7c9486e9f92.png\"\/><\/figure>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u0443 \u043d\u0430\u0441 \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0435\u0434\u0438\u043d\u0430\u044f \u0442\u043e\u0447\u043a\u0430 \u0432\u0445\u043e\u0434\u0430 \u0432 \u0438\u0433\u0440\u0443. \u0418 \u0435\u0441\u043b\u0438, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0435\u0449\u0435 \u043f\u043e\u0434\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0438\u0433\u0440\u044b \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u043e\u0431\u044a\u0435\u043a\u0442\u044b \u043d\u0430 \u044d\u0442\u0430\u043f\u0435 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0438, \u0442\u043e \u044d\u0442\u0438 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u044b \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0434\u043e \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439:<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/0f6\/627\/ef1\/0f6627ef1228a5f52cda359c98c7843b.png\" alt=\"\" title=\"\" width=\"868\" height=\"342\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/0f6\/627\/ef1\/0f6627ef1228a5f52cda359c98c7843b.png\"\/><\/figure>\n<p>\u0410 \u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0430\u043f\u043e\u0432 \u043f\u043e\u0441\u0442 \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438: \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0437\u0430\u0433\u0440\u0443\u0437\u0438\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441 \u0438\u0433\u0440\u043e\u043a\u0430 \u2014 \u0442\u043e \u044d\u0442\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/92a\/42a\/73e\/92a42a73e0e467ea3c84ace6a13ed949.png\" alt=\"\" title=\"\" width=\"868\" height=\"348\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/92a\/42a\/73e\/92a42a73e0e467ea3c84ace6a13ed949.png\"\/><\/figure>\n<p>\u0412 \u043e\u0431\u0449\u0435\u043c \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u044b \u0441\u0430\u043c\u0438, \u043a\u0430\u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a, \u0440\u0435\u0448\u0430\u0435\u0442\u0435, \u043a\u043e\u0433\u0434\u0430 \u0438 \u043a\u0430\u043a \u0432 \u0432\u0430\u0448\u0435\u0439 \u0438\u0433\u0440\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0437\u0430\u043f\u0443\u0441\u043a. \u0421\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u0432\u044b \u0432\u0441\u0435\u0433\u0434\u0430 \u0437\u043d\u0430\u0435\u0442\u0435, \u0447\u0442\u043e \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c GameLauncher, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0435\u0434\u0438\u043d\u043e\u0439 \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u0445\u043e\u0434\u0430 \u0432 \u0438\u0433\u0440\u0443, \u0430 GameContext \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0435\u0435 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u043c \u0438 \u0445\u0440\u0430\u043d\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b.<\/p>\n<h3>\u0412\u044b\u0432\u043e\u0434\u044b<\/h3>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, \u043c\u044b \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043f\u0440\u043e\u0441\u0442\u0443\u044e \u0438 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0438\u0433\u0440\u044b \u043d\u0430 Unity \u0431\u0435\u0437 Zenject \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043a\u0443\u0431\u0438\u043a\u0430.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/e9d\/e03\/1e2\/e9de031e250f78cd1fc930d5f3f177b0.png\" alt=\"\" title=\"\" width=\"1600\" height=\"827\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/e9d\/e03\/1e2\/e9de031e250f78cd1fc930d5f3f177b0.png\"\/><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0432 \u043d\u0430\u0448\u0435\u0439 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0435:<\/p>\n<ol>\n<li>\n<p>\u0415\u0441\u0442\u044c <code>GameLauncher<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u0447\u043a\u043e\u0439 \u0432\u0445\u043e\u0434\u0430 \u0432 \u0438\u0433\u0440\u0443 \u0438 \u0434\u0435\u043b\u0430\u0435\u0442 \u0437\u0430\u043f\u0443\u0441\u043a \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u0437\u0430\u0434\u0430\u0447.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u0442\u044c <code>GameContext<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0438\u0433\u0440\u044b \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442 Update \u0443 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u043e\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<\/li>\n<li>\n<p>\u0415\u0441\u0442\u044c \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d \u0432 \u043a\u043e\u0434\u0435 \u0447\u0435\u0440\u0435\u0437 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u0435\u0440\u044b \u0438 \u0441\u0435\u0440\u0432\u0438\u0441-\u043b\u043e\u043a\u0430\u0442\u043e\u0440.<\/p>\n<\/li>\n<li>\n<p>\u0412\u0441\u044f \u0438\u0433\u0440\u043e\u0432\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u0430 \u043d\u0430 \u043a\u043b\u0430\u0441\u0441\u0430\u0445 C#.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435 \u2014 \u0443 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 \u0435\u0441\u0442\u044c \u043f\u043e\u043b\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u044c \u043d\u0430\u0434 \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439, \u0438 \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u0442\u0430\u0447\u0438\u0432\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u043f\u043e\u0434 \u0441\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442, \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0432\u043b\u0438\u044f\u0442\u044c \u043d\u0430 \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044e \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f Zenject.<\/p>\n<\/li>\n<\/ol>\n<blockquote>\n<p><em>\u0420\u0435\u043c\u0430\u0440\u043a\u0430: \u0432 \u0431\u0443\u0434\u0443\u0449\u0435\u043c, \u0435\u0441\u043b\u0438 \u0432\u044b \u0445\u043e\u0442\u0438\u0442\u0435 \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0432\u0430\u0448\u0438 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u0435\u0440\u044b \u0431\u043e\u043b\u0435\u0435 \u0434\u0435\u043a\u043b\u0430\u0440\u0430\u0442\u0438\u0432\u043d\u043e, \u0442\u043e \u0432\u0430\u043c \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0440\u0435\u0444\u043b\u0435\u043a\u0441\u0438\u044f \u0438 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u0434\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0431\u0438\u0440\u0430\u0442\u044c \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u0439 \u0438 \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u0430 \u0442\u0430\u043a\u0436\u0435 \u0436\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0443 \u043c\u0435\u043d\u044f \u0432 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u044d\u0442\u043e \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/em><\/p>\n<\/blockquote>\n<pre><code class=\"cpp\">public sealed class PlayerInstaller : GameInstaller     {         [GameService]         [SerializeField]         private Player player;          [GameListener]         private readonly MoveController moveController = new();          [GameListener]         private readonly CameraController cameraController = new()     }   public sealed class InputInstaller : GameInstaller     {         [GameService, GameListener]         private readonly KeyboardInput keyboardInput = new();          [GameService, GameListener]         private readonly MouseInput mouseInput = new();     }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0443\u044e \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0432 \u0441\u0432\u043e\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445:\u00a0<\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/play.google.com\/store\/apps\/details?id=com.pigbig.tankpuzzlers\"><u>Tank Puzzlers<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/play.google.com\/store\/apps\/details?id=com.catansgames.triballand\"><u>Tribal Land<\/u><\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/youtu.be\/ud8Ju-ITIkA?t=55\"><u>\u0414\u0435\u043c\u043e-\u043f\u0440\u043e\u0435\u043a\u0442 \u0434\u043b\u044f \u043a\u0443\u0440\u0441\u0430<\/u><\/a><\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u0442 \u043f\u0440\u0435\u0434\u0435\u043b\u0430 \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u0441\u0442\u0432\u0443, \u0441\u0430\u043c\u043e\u0435 \u0433\u043b\u0430\u0432\u043d\u043e\u0435, \u0432\u044b\u0431\u0438\u0440\u0430\u0439\u0442\u0435 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0438\u0433\u0440\u044b \u0441 \u0443\u043c\u043e\u043c, \u0432\u0435\u0434\u044c \u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u0442\u0440\u0435\u0431\u043e\u0432\u0430\u043d\u0438\u044f, \u0434\u0435\u0434\u043b\u0430\u0439\u043d \u0438 \u043a\u043e\u043c\u0430\u043d\u0434\u0430, \u043a\u0430\u043a \u0431\u044b \u044d\u0442\u043e \u0431\u0430\u043d\u0430\u043b\u044c\u043d\u043e \u043d\u0435 \u0437\u0432\u0443\u0447\u0430\u043b\u043e\u00a0.<\/p>\n<p>\u041f\u0440\u0438\u043b\u0430\u0433\u0430\u044e \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 <a href=\"https:\/\/disk.yandex.ru\/d\/iakJ76ATRPqxUg\"><u>\u043a\u043e\u0434<\/u><\/a> \u043a \u0441\u0442\u0430\u0442\u044c\u0435.<\/p>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0445\u043e\u0447\u0443 \u043f\u043e\u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u043e\u0432\u0430\u0442\u044c \u0432\u0430\u043c \u0435\u0449\u0435 \u043e\u0434\u0438\u043d <a href=\"https:\/\/otus.pw\/I168\/\">\u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0439 \u0443\u0440\u043e\u043a<\/a>, \u0433\u0434\u0435 \u0438\u0437\u0443\u0447\u0438\u043c \u043f\u0430\u0442\u0442\u0435\u0440\u043d Model-View-Presenter \u043d\u0430 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u043e\u043f\u0430\u043f\u0430 (pop-up) \u043c\u0430\u0433\u0430\u0437\u0438\u043d\u0430. \u041f\u043e\u0434\u0440\u043e\u0431\u043d\u0435\u0435 \u043f\u0440\u043e \u0443\u0440\u043e\u043a \u043c\u043e\u0436\u0435\u0442\u0435 <a href=\"https:\/\/otus.pw\/I168\/\">\u0443\u0437\u043d\u0430\u0442\u044c \u043f\u043e \u044d\u0442\u043e\u0439 \u0441\u0441\u044b\u043b\u043a\u0435<\/a>.<\/p>\n<p>\u041d\u0430 \u044d\u0442\u043e\u043c \u0443 \u043c\u0435\u043d\u044f \u0432\u0441\u0435, \u0432\u0441\u0435\u043c \u0441\u043f\u0430\u0441\u0438\u0431\u043e \u0437\u0430 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \ud83d\ude42<\/p>\n<\/p>\n<\/div>\n<\/div>\n<\/div>\n<p><!----><!----><\/div>\n<p><!----><!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/729888\/\"> https:\/\/habr.com\/ru\/articles\/729888\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><!--[--><!--]--><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<figure class=\"full-width\"><\/figure>\n<div class=\"persona\" persona=\"true\">\n<h5 class=\"persona__heading\" persona=\"true\">\u0410\u0432\u0442\u043e\u0440 \u0441\u0442\u0430\u0442\u044c\u0438: \u0418\u0433\u043e\u0440\u044c \u0413\u0443\u043b\u044c\u043a\u0438\u043d<\/h5>\n<p>Senior Unity Developer<\/p>\n<\/div>\n<p>\u0412\u0441\u0435\u043c \u043f\u0440\u0438\u0432\u0435\u0442! ?<\/p>\n<p>\u041c\u0435\u043d\u044f \u0437\u043e\u0432\u0443\u0442 \u0418\u0433\u043e\u0440\u044c \u0413\u0443\u043b\u044c\u043a\u0438\u043d, \u0438 \u044f Unity \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a. \u0417\u0430 \u0441\u0432\u043e\u0438 5 \u043b\u0435\u0442 \u043d\u0430\u043a\u043e\u043f\u0438\u043b\u043e\u0441\u044c \u043c\u043d\u043e\u0433\u043e \u043e\u043f\u044b\u0442\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u044d\u0442\u043e\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0445\u043e\u0442\u0435\u043b \u0431\u044b \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0430\u043c\u0438 \u0438 \u043f\u043e\u0434\u0445\u043e\u0434\u0430\u043c\u0438, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0443 \u0438\u0433\u0440\u044b \u043f\u0440\u043e\u0441\u0442\u043e \u0438 \u0433\u0438\u0431\u043a\u043e \u0431\u0435\u0437 \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430. \u0426\u0435\u043b\u044c \u0434\u043e\u043a\u043b\u0430\u0434\u0430, \u0434\u0430\u0442\u044c \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e \u0433\u043e\u0442\u043e\u0432\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435, \u0430 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u0445\u043e\u0434 \u043c\u044b\u0441\u043b\u0435\u0439 \u0438 \u043f\u0430\u0442\u0442\u0435\u0440\u043d\u044b, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0441\u0442\u0440\u043e\u0438\u0442\u044c. \u0415\u0441\u043b\u0438 \u0432\u044b \u043d\u0435 \u0447\u0438\u0442\u0430\u043b\u0438 <a href=\"https:\/\/habr.com\/ru\/company\/otus\/blog\/725068\/\"><u>\u043f\u0435\u0440\u0432\u0443\u044e<\/u><\/a> \u0438 <a href=\"https:\/\/habr.com\/ru\/companies\/otus\/articles\/725308\/\"><u>\u0432\u0442\u043e\u0440\u0443\u044e<\/u><\/a> \u0447\u0430\u0441\u0442\u0438, \u0442\u043e \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u044e \u043d\u0430\u0447\u0430\u0442\u044c \u0441 \u043d\u0438\u0445 :).<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0438\u043c, \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0432 \u043a\u043e\u043d\u0446\u0435 \u0432\u0442\u043e\u0440\u043e\u0439 \u0447\u0430\u0441\u0442\u0438:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0412\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043d\u044f\u0442\u043d\u043e, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 GRASP \u0441 \u0446\u0435\u043b\u044c\u044e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043f\u043e\u043d\u0438\u043c\u0430\u043d\u0438\u044f\u2026<\/p>\n<h3>\u0420\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u043d\u0433 \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u044b<\/h3>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0448\u0430\u0431\u043b\u043e\u043d <a href=\"https:\/\/en.wikipedia.org\/wiki\/GRASP_(object-oriented_design)#Pure_fabrication\"><u>Pure Fabrication<\/u><\/a> \u0438 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u043b\u043e\u0433\u0438\u043a\u0443 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <code>GameMachine<\/code> \u0438 <code>GameLocator<\/code> \u0432 \u043d\u0435\u043a\u0438\u0439 <a href=\"https:\/\/refactoring.guru\/ru\/design-patterns\/facade\"><u>\u0424\u0430\u0441\u0430\u0434<\/u><\/a>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0430\u0437\u043e\u0432\u0435\u043c <code>GameContext<\/code>:<\/p>\n<pre><code class=\"cpp\">public sealed class GameContext : MonoBehaviour, IGameLocator, IGameMachine     {         public GameState GameState         {             get { return this.gameMachine.GameState; }         }          private readonly GameMachine gameMachine = new();          private readonly GameLocator serviceLocator = new();        public GameContext()         {             this.serviceLocator.AddService(this.gameMachine);         }          [ContextMenu(\"Start Game\")]         public void StartGame()         {             this.gameMachine.StartGame();         }          [ContextMenu(\"Pause Game\")]         public void PauseGame()         {             this.gameMachine.PauseGame();         }          [ContextMenu(\"Resume Game\")]         public void ResumeGame()         {            this.gameMachine.ResumeGame();         }          [ContextMenu(\"Finish Game\")]         public void FinishGame()         {             this.gameMachine.FinishGame();         }          public void AddListener(object listener)         {             this.gameMachine.AddListener(listener);         }          public void RemoveListener(object listener)         {             this.gameMachine.RemoveListener(listener);         }                  public void AddService(object service)         {             this.serviceLocator.AddService(service);         }          public void RemoveService(object service)         {             this.serviceLocator.RemoveService(service);         }          public T GetService&lt;T>()         {             return this.serviceLocator.GetService&lt;T>();         }     } <\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u043d\u0438\u0432 \u0448\u0430\u0431\u043b\u043e\u043d GRASP, \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043e\u0434\u0438\u043d \u043c\u043e\u043d\u043e\u0431\u0435\u0445, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u0441\u044e \u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 \u0438 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0435\u043c \u0438\u0433\u0440\u044b. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c <code>GameContext<\/code> \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b <code>IGameMachine<\/code> \u0438 <code>IGameLocator<\/code>, \u043d\u043e \u0431\u0438\u0437\u043d\u0435\u0441-\u043b\u043e\u0433\u0438\u043a\u0443 \u0434\u0435\u043b\u0435\u0433\u0438\u0440\u0443\u0435\u0442 \u0442\u0435\u043f\u0435\u0440\u044c \u0443\u0436\u0435 <strong>\u043e\u0431\u044b\u0447\u043d\u044b\u043c<\/strong> \u043a\u043b\u0430\u0441\u0441\u0430\u043c <code>GameMachine<\/code> \u0438 <code>GameLocator<\/code>.<\/p>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c <code>GameContext<\/code> \u043d\u0430 \u0441\u0446\u0435\u043d\u0443:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0433\u043b\u044f\u043d\u0435\u043c \u043d\u0430 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u0435\u0440\u044b \u0432 \u0441\u0445\u0435\u043c\u0435:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0421 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u0435\u0440\u0430\u043c\u0438 \u0432\u0441\u0435 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u0435\u0435, \u0442\u0443\u0442 \u0443\u0436\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0448\u0430\u0431\u043b\u043e\u043d\u043e\u0432 GRASP, \u043d\u043e \u0441\u0430\u043c\u044b\u0439 \u043a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u0438\u0437 \u043d\u0438\u0445 \u0431\u0443\u0434\u0435\u0442 <a href=\"https:\/\/en.wikipedia.org\/wiki\/GRASP_(object-oriented_design)#Indirection\"><u>Indirection<\/u><\/a>. \u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u0430 \u043c\u0435\u0436\u0434\u0443 <code>GameContext<\/code> \u0438 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430\u043c\u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0431\u0443\u0434\u0435\u0442 \u043d\u0435\u043a\u0438\u0439 <code>GameContextInstaller<\/code>.<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c <code>GameContextInstaller<\/code> \u0431\u0443\u0434\u0435\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0438 \u043b\u0438\u0441\u0442\u0435\u043d\u0435\u0440\u044b \u0438 \u0437\u0430\u043d\u0438\u043c\u0430\u0442\u044c\u0441\u044f \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439. \u0410 \u0432\u043c\u0435\u0441\u0442\u043e \u043a\u043b\u0430\u0441\u0441\u043e\u0432 <code>GameObservableInstaller<\/code>, <code>GameServiceInstaller<\/code> \u0438 <code>GameAssembler<\/code> \u0431\u0443\u0434\u0443\u0442 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b <code>IGameServiceProvider<\/code>,\u00a0<code>IGameListenerProvider<\/code>, <code>IGameConstructor<\/code>. \u0412\u043e\u0442 \u043a\u0430\u043a \u044d\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0432 \u043a\u043e\u0434\u0435:<\/p>\n<pre><code class=\"cpp\">public sealed class GameContextInstaller : MonoBehaviour     {         [SerializeField]         private GameContext gameContext;          [SerializeField]         private MonoBehaviour[] installers;          private void Awake()         {             foreach (var installer in this.installers)             {                 if (installer is IGameServiceProvider serviceProvider)                 {                     this.gameContext.AddServices(serviceProvider.GetServices());                 }                  if (installer is IGameListenerProvider listenerProvider)                 {                     this.gameContext.AddListeners(listenerProvider.GetListeners());                 }             }         }          private void Start()         {             foreach (var installer in this.installers)             {                 if (installer is IGameConstructor constructor)                 {                     constructor.ConstructGame(this.gameContext);                 }             }         }     } <\/code><\/pre>\n<p>\u0412 \u043c\u0435\u0442\u043e\u0434\u0435 <code>GameContextInstaller.Awake()<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u0439 \u0432 <code>GameContext<\/code>, \u0430 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>GameContextInstaller.Start()<\/code> \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0430\u0440\u0443 \u0441\u043b\u043e\u0432 \u043f\u0440\u043e \u043d\u043e\u0432\u044b\u0435 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441\u044b:<\/p>\n<p><strong>IGameListenerProvider<\/strong> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u043b\u0443\u0448\u0430\u0442\u0435\u043b\u0435\u0439 \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 <code>GameContext<\/code>.<\/p>\n<pre><code class=\"cpp\">public interface IGameListenerProvider     {         IEnumerable&lt;object> GetListeners();     }<\/code><\/pre>\n<p><strong>IGameServiceProvider<\/strong> \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u0434\u043b\u044f \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u0438 \u0432 <code>GameContext<\/code>.<\/p>\n<pre><code class=\"cpp\">public interface IGameServiceProvider     {         IEnumerable&lt;object> GetServices();     }<\/code><\/pre>\n<p><strong>IGameConstructor<\/strong> \u0437\u0430\u043d\u0438\u043c\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0435\u0439, \u043f\u043e\u043b\u0443\u0447\u0430\u044f \u0446\u0435\u043d\u0442\u0440\u0430\u043b\u044c\u043d\u044b\u0439 \u0440\u0435\u0435\u0441\u0442\u0440 \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u0430.<\/p>\n<pre><code class=\"cpp\"> public interface IGameConstructor     {         void ConstructGame(IGameLocator serviceLocator);     }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u0443\u0434\u0443\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u044d\u0442\u0438 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b.\u00a0<\/p>\n<p>\u0412 \u043d\u0430\u0448\u0435\u043c \u043f\u0440\u043e\u0435\u043a\u0442\u0435, \u0444\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0435\u0441\u0442\u044c \u0434\u0432\u0430 \u043c\u043e\u0434\u0443\u043b\u044f: \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0438\u0433\u0440\u043e\u043a\u0430 \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u043e\u0434\u0443\u043b\u044f \u0438 \u043d\u0430\u043f\u0438\u0448\u0435\u043c \u0441\u0432\u043e\u044e \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e<\/p>\n<ol>\n<li>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0435 <code>PlayerInstaller<\/code> \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0438\u0433\u0440\u043e\u043a\u0430.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043a\u043b\u0430\u0441\u0441\u0435 <code>InputInstaller<\/code> \u0431\u0443\u0434\u0435\u043c \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0432\u0432\u043e\u0434\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u041f\u0440\u0438\u043b\u0430\u0433\u0430\u044e \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">public sealed class PlayerInstaller : MonoBehaviour,         IGameServiceProvider,         IGameListenerProvider,         IGameConstructor     {         [SerializeField]         private Player player;          [SerializeField]         private MoveController moveController;                  \/\/TODO: \u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u043a\u043e\u043d\u0442\u0440\u043e\u043b\u043b\u0435\u0440 \u043a\u0430\u043c\u0435\u0440\u044b:         \/\/[SerializeField]         \/\/private CameraController cameraController;          IEnumerable&lt;object> IGameServiceProvider.GetServices()         {             yield return this.player;         }          IEnumerable&lt;object> IGameListenerProvider.GetListeners()         {             yield return this.moveController;             \/\/yield return this.cameraController;         }          void IGameConstructor.ConstructGame(IGameLocator serviceLocator)         {             var keyboardInput = serviceLocator.GetService&lt;IMoveInput>();             this.moveController.Construct(keyboardInput, this.player);                          \/\/var camera = serviceLocator.GetService&lt;WorldCamera>();             \/\/ this.cameraController.Construct(camera, this.player)         }     }   public sealed class InputInstaller : MonoBehaviour,         IGameServiceProvider,         IGameListenerProvider     {         [SerializeField]         private KeyboardInput keyboardInput;          \/\/TODO: \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u044c \u0432\u0432\u043e\u0434 \u0441 \u043c\u044b\u0448\u0438         \/\/[SerializeField]         \/\/private MouseInput mouseInput;          IEnumerable&lt;object> IGameServiceProvider.GetServices()         {             yield return this.keyboardInput;             \/\/yield return this.mouseInput;         }          IEnumerable&lt;object> IGameListenerProvider.GetListeners()         {             yield return this.keyboardInput;             \/\/yield return this.mouseInput;         }     }<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043a\u043e\u0434 \u043d\u0430\u043f\u0438\u0441\u0430\u043d! \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c <code>GameContextInstaller<\/code>, <code>PlayerInstaller<\/code> \u0438 <code>InputInstaller<\/code> \u043d\u0430 \u0441\u0446\u0435\u043d\u0443:<\/p>\n<figure class=\"full-width\"><\/figure>\n<p>\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0438\u0433\u0440\u0443. \u0421\u0435\u0439\u0447\u0430\u0441 \u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0430\u0446\u0438\u044f \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>GameContextInstaller.Awake()<\/code>, \u0430 \u0432\u043d\u0435\u0434\u0440\u0435\u043d\u0438\u0435 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u2014 \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 <code>GameContextInstaller.Start()<\/code>. \u0414\u0430\u043b\u044c\u0448\u0435 \u0432 \u201c\u043c\u043e\u043d\u043e\u0431\u0435\u0445\u0435\u201d GameContext \u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u0435 \u043c\u0435\u043d\u044e \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u043c \u043c\u0435\u0442\u043e\u0434 <code>GameContext.StartGame()<\/code>. \u0412\u0443\u0430\u043b\u044f, \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442!<\/p>\n<p>\u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043d\u0430\u0448\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0442\u0430\u043a:<\/p>\n<figure class=\"full-width\"><\/figure>\n<h3>\u041e\u043f\u0442\u0438\u043c\u0438\u0437\u0430\u0446\u0438\u044f \u0438\u0433\u0440\u044b<\/h3>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0431\u044b\u043b\u043e \u0431\u044b\u043b\u043e \u0437\u0434\u043e\u0440\u043e\u0432\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0430\u0448\u0430 \u0438\u0433\u0440\u043e\u0432\u0430\u044f \u043b\u043e\u0433\u0438\u043a\u0430 \u043d\u0435 \u0437\u0430\u0432\u0438\u0441\u0435\u043b\u0430 \u043e\u0442 \u043c\u043e\u043d\u043e\u0431\u0435\u0445\u043e\u0432. \u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445, \u0442\u0430\u043a\u0438\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043f\u0440\u043e\u0449\u0435 \u043f\u0435\u0440\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u0432 \u043b\u044e\u0431\u043e\u043c \u043c\u0435\u0441\u0442\u0435 \u043a\u043e\u0434\u0430. \u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445, \u0443\u0439\u0434\u044f \u043e\u0442 \u043c\u043e\u043d\u043e\u0431\u0435\u0445\u043e\u0432 \u0438 \u0433\u0435\u0439\u043c-\u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432, \u043c\u043e\u0436\u043d\u043e \u043e\u043f\u0442\u0438\u043c\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u044c \u0438 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. \u0412 \u0442\u0440\u0435\u0442\u044c\u0438\u0445, \u043f\u043e\u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0432 \u043c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u043a\u043e\u0434\u0435, \u043f\u043e\u0441\u043a\u043e\u043b\u044c\u043a\u0443 GameObject\u2019\u044b \u0438\u00a0 \u201c\u043c\u043e\u043d\u043e\u0431\u0435\u0445\u0438\u201d \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0432 \u0433\u043b\u0430\u0432\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435<\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, MoveController \u0438 KeyboardInput \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u044b\u043c\u0438 \u043a\u043b\u0430\u0441\u0441\u0430\u043c\u0438 \u0438 \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u044b \u044d\u0442\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432 \u043f\u0440\u044f\u043c\u043e \u0432 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u0435\u0440\u0435:\u00a0<\/p>\n<pre><code class=\"cpp\"> public sealed class InputInstaller : MonoBehaviour,         IGameServiceProvider,         IGameListenerProvider     {         private readonly KeyboardInput keyboardInput = new();  \/\/Other code\u2026     }  public sealed class PlayerInstaller : MonoBehaviour,         IGameServiceProvider,         IGameListenerProvider,         IGameConstructor     {         private readonly MoveController moveController = new();          \/\/private readonly CameraController cameraController = new();  \/\/Other code\u2026            }<\/code><\/pre>\n<p>\u041d\u043e \u0443 KeyboardInput \u0435\u0441\u0442\u044c \u043c\u0435\u0442\u043e\u0434 <code>Update()<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0438\u0437 \u0434\u0432\u0438\u0436\u043a\u0430, \u0447\u0442\u043e\u0431\u044b \u0442\u0440\u0435\u043a\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u0432\u0432\u043e\u0434. \u042d\u0442\u043e\u0442 \u043d\u044e\u0430\u043d\u0441 \u0442\u043e\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0448\u0438\u0442\u044c, \u0435\u0441\u043b\u0438 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0439 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 <code>IUpdateGameListener<\/code>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c <code>GameContext<\/code>:<\/p>\n<pre><code class=\"cpp\">public interface IUpdateGameListener     {         void OnUpdate(float deltaTime);     }<\/code><\/pre>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c, <code>KeyboardInput<\/code> \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u043b\u044f\u0434\u0435\u0442\u044c \u0442\u0430\u043a:<\/p>\n<pre><code class=\"cpp\"> public sealed class KeyboardInput :         IMoveInput,         IStartGameListener,         IUpdateGameListener,         IFinishGameListener     {         public event Action&lt;Vector3> OnMove;          private bool isActive;          void IUpdateGameListener.OnUpdate(float deltaTime)         {             if (this.isActive)             {                 this.HandleKeyboard();             }         }  \/\/Other code\u2026 }<\/code><\/pre>\n<p>\u0410 \u0432 \u043a\u043b\u0430\u0441\u0441 <code>GameContext<\/code> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043a\u043e\u0434:<\/p>\n<pre><code class=\"cpp\">public sealed class GameContext : MonoBehaviour, IGameLocator, IGameMachine     {         private readonly List&lt;IUpdateGameListener> updateListeners = new();          private void Awake()         {             this.enabled = false;         }          \/\/\u0412\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e, \u0435\u0441\u043b\u0438 \u0438\u0433\u0440\u0430 \u0437\u0430\u043f\u0443\u0449\u0435\u043d\u0430         private void Update()         {             var deltaTime = Time.deltaTime;             for (int i = 0, count = this.updateListeners.Count; i &lt; count; i++)             {           <\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\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-412346","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/412346","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=412346"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/412346\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=412346"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=412346"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=412346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}