{"id":331943,"date":"2022-04-14T21:00:08","date_gmt":"2022-04-14T21:00:08","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=331943"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=331943","title":{"rendered":"<span>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 dungeon crawler&#8217;\u0430 \u0441 LeoECS Lite. \u0427\u0430\u0441\u0442\u044c 1<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><em>\u0414\u0440\u0443\u0437\u044c\u044f, \u044d\u0442\u043e \u043d\u0430\u0447\u0430\u043b\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u0433\u0440\u044b \u0436\u0430\u043d\u0440\u0430 dungeon crawler \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 LeoECS Lite, \u0438 \u0435\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2013 \u043f\u043e\u043c\u043e\u0447\u044c \u0432\u0430\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c LeoECS Lite \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0433\u0440 \u043d\u0430 Unity \u0438 \u0440\u0435\u0448\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0438\u0434\u044b \u043f\u0440\u043e\u0431\u043b\u0435\u043c.<\/em><\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/372\/b1c\/ad3\/372b1cad308788dac56f8db1ea16b9c9.png\" width=\"1427\" height=\"874\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/372\/b1c\/ad3\/372b1cad308788dac56f8db1ea16b9c9.png\"\/><figcaption><\/figcaption><\/figure>\n<p><a href=\"https:\/\/github.com\/Leopotam\/ecslite\" rel=\"noopener noreferrer nofollow\">LeoECS Lite<\/a> &#8212; \u043d\u043e\u0432\u0430\u044f, \u0431\u043e\u043b\u0435\u0435 \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 LeoECS, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b <a href=\"https:\/\/habr.com\/ru\/post\/573028\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u044b<\/a>. \u041f\u0443\u0441\u0442\u044c \u0441\u043b\u043e\u0432\u043e &#171;Lite&#187; \u043d\u0435 \u0432\u0432\u043e\u0434\u0438\u0442 \u0432\u0430\u0441 \u0432 \u0437\u0430\u0431\u043b\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u2013 \u043e\u043d\u0430 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u043e\u0441\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0425\u043e\u0442\u044f \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043f\u0440\u0438\u0432\u044b\u043a \u043a API \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043f\u0438\u0441\u043e\u043a \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 API<\/summary>\n<div class=\"spoiler__content\">\n<ul>\n<li>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c\/\u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0443\u043b\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>Dependency Injection \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0444\u043b\u0435\u043a\u0448\u043d \u0443\u0431\u0440\u0430\u043d \u0438\u0437 \u044f\u0434\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u043c\u0438\u0440, \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u0438\u043b\u0438 \u043d\u043e\u0432\u044b\u0435 \u043f\u0443\u043b\u044b \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u0445 \u0441\u0438\u0441\u0442\u0435\u043c &#8212; \u043d\u0443\u0436\u043d\u043e \u0438\u043b\u0438 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435, \u0438\u043b\u0438 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0440\u0430\u043d\u0435\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u0447\u0438\u0441\u0442\u043e\u043c \u0432\u0438\u0434\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 int&#8217;\u044b. \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0445 \u0433\u0434\u0435-\u0442\u043e \u0438 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043d\u0435 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0430 \u043b\u0438 \u044d\u043d\u0442\u0438\u0442\u0438, \u043d\u0443\u0436\u043d\u043e \u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 \u043c\u0438\u0440.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 README \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f.<\/p>\n<\/div>\n<\/details>\n<p>\u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u043e\u0441\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u0442\u0430\u043b\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u044f\u0434\u0440\u043e. \u041e\u043d\u043e \u0441\u0442\u0430\u043b\u043e \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u043c &#8212; \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0444\u0438\u0448\u0435\u043a \u043f\u0435\u0440\u0435\u0435\u0445\u0430\u043b\u0430 \u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e. \u0421 \u0438\u0445 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 API, \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0443, \u0438 \u0432\u043e\u0442 \u043a\u0430\u043a\u0438\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438\u0433\u0440\u044b: <a href=\"https:\/\/github.com\/Leopotam\/ecslite-di\" rel=\"noopener noreferrer nofollow\">ecslite-di<\/a>, <a href=\"https:\/\/github.com\/Leopotam\/ecslite-extendedsystems\" rel=\"noopener noreferrer nofollow\">ecslite-extended-systems<\/a>, <a href=\"https:\/\/github.com\/Leopotam\/ecslite-unityeditor\" rel=\"noopener noreferrer nofollow\">ecslite-unityeditor<\/a>, <a href=\"https:\/\/github.com\/Leopotam\/ecslite-unity-ugui\" rel=\"noopener noreferrer nofollow\">ecslite-unity-ugui<\/a>.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0438 \u043d\u0430\u0447\u043d\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0440\u043f\u0442\u0430\u043f-\u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class Game : MonoBehaviour {         [SerializeField] SceneData _sceneData;         [SerializeField] Configuration _configuration;         EcsSystems _systems;          void Start () {             var world = new EcsWorld ();             _systems = new EcsSystems (world);              _systems #if UNITY_EDITOR                 .Add (new Leopotam.EcsLite.UnityEditor.EcsWorldDebugSystem ()) #endif                 .Inject (_sceneData)                 .Init ();         }          void Update () {             _systems?.Run ();         }          void OnDestroy () {             _systems?.Destroy ();             _systems?.GetWorld ()?.Destroy ();             _systems = null;         }     } }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 LeoECS, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043c\u043d\u043e\u0433\u043e. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 MonoBehaviour \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 SceneData, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441\u043e \u0441\u0446\u0435\u043d\u043e\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043b\u0430\u0441\u0441 Configuration, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c Scriptable Object&#8217;\u0430.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class SceneData : MonoBehaviour {     } }<\/code><\/pre>\n<pre><code class=\"cs\">namespace Client {     [CreateAssetMenu]     sealed class Configuration : ScriptableObject {     \/\/ \u0428\u0438\u0440\u0438\u043d\u0430 \u0438 \u0432\u044b\u0441\u043e\u0442\u0430 \u0441\u0435\u0442\u043a\u0438.         public int GridWidth;         public int Gridheight;     } }<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0443 \u043a\u043b\u0435\u0442\u043e\u043a. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 MonoBehaviour \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043a \u043f\u0440\u0435\u0444\u0430\u0431\u0443 \u043a\u043b\u0435\u0442\u043a\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u0435\u043c\u0443 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c \u043a\u043b\u0435\u0442\u043a\u0438 \u0432 \u0441\u0446\u0435\u043d\u0435 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043c\u0430\u0433\u043d\u0438\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0443\u0436\u043d\u044b\u043c \u043c\u0435\u0441\u0442\u0430\u043c, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b.<\/p>\n<pre><code class=\"cs\">namespace Client {     [ExecuteAlways] \/\/ \u041a\u043e\u0434 \u043d\u0438\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u0433\u0434\u0430.     [SelectionBase] \/\/ \u0415\u0441\u043b\u0438 \u0432\u044b \u043a\u043b\u0438\u043a\u043d\u0435\u0442\u0435 \u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0437\u0430\u043f\u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0435\u0444\u0430\u0431\u0430, \u0442\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442     sealed class CellView : MonoBehaviour {         public Transform Transform;         public float XzStep = 3f;         public float YStep = 1f;          void Awake () {             Transform = transform;         }  #if UNITY_EDITOR         void Update () {             if (!Application.isPlaying &amp;&amp; Transform.hasChanged) {                 var newPos = Vector3.zero;                 var curPos = Transform.localPosition;                 newPos.x = Mathf.RoundToInt (curPos.x \/ XzStep) * XzStep;                 newPos.z = Mathf.RoundToInt (curPos.z \/ XzStep) * XzStep;                 newPos.y = Mathf.RoundToInt (curPos.y \/ YStep) * YStep;                 Transform.localPosition = newPos; \/\/ \u041c\u0430\u0433\u043d\u0438\u0442\u0438\u043c \u043a\u043b\u0435\u0442\u043a\u0443 \u043a \u0441\u0435\u0442\u043a\u0435.             }         }          void OnDrawGizmos () {             var selected = Selection.Contains (gameObject); \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0432\u044b\u0434\u0435\u043b\u0435\u043d \u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442             Gizmos.color = selected ? Color.green : Color.cyan; \/\/ \u0415\u0441\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d, \u0446\u0432\u0435\u0442 \u0433\u0438\u0437\u043c\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0437\u0435\u043b\u0435\u043d\u044b\u0439, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 - \u0433\u043e\u043b\u0443\u0431\u043e\u0439             var yAdd = selected ? 0.02f : 0f; \/\/ \u0415\u0441\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d, \u0442\u043e \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u0440\u0438\u043f\u043e\u0434\u043d\u0438\u043c\u0435\u043c \u043a\u043b\u0435\u0442\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0435             var curPos = Transform.localPosition; \/\/ \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430             var leftDown = curPos - Vector3.right * XzStep \/ 2 - Vector3.forward * XzStep \/ 2 + Vector3.up * yAdd;             var leftUp = curPos - Vector3.right * XzStep \/ 2 + Vector3.forward * XzStep \/ 2 + Vector3.up * yAdd;             var rightDown = curPos + Vector3.right * XzStep \/ 2 - Vector3.forward * XzStep \/ 2 + Vector3.up * yAdd;             var rightUp = curPos + Vector3.right * XzStep \/ 2 + Vector3.forward * XzStep \/ 2 + Vector3.up * yAdd;             Gizmos.DrawLine (leftDown, leftUp); \/\/ \u0420\u0438\u0441\u0443\u0435\u043c \u043a\u0432\u0430\u0434\u0440\u0430\u0442             Gizmos.DrawLine (leftUp, rightUp);             Gizmos.DrawLine (rightUp, rightDown);             Gizmos.DrawLine (rightDown, leftDown);             Gizmos.DrawSphere (curPos, 0.1f);         } #endif     } }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a\u043b\u0435\u0442\u043e\u043a \u0432 \u043e\u043a\u043d\u0435 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0441 Gizmos.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/ca0\/4aa\/02e\/ca04aa02ecd248dcc1d171ee546a9dc6.png\" width=\"886\" height=\"546\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/ca0\/4aa\/02e\/ca04aa02ecd248dcc1d171ee546a9dc6.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0443 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435, \u0441\u043e\u0437\u0434\u0430\u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043b\u0435\u0442\u043a\u0438, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0443\u0440\u043e\u0432\u043d\u044f. \u0422\u043e \u0435\u0441\u0442\u044c, \u043b\u0435\u0432\u0435\u043b \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440 \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u0430\u0440\u0442\u0443, \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u0442 \u043a\u043b\u0435\u0442\u043a\u0438, \u0430 \u043c\u044b \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u0433\u0440\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043a\u043b\u0435\u0442\u043e\u043a \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a \u043d\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 SceneData \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u043c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class SceneData : MonoBehaviour {         public CellView[] Cells;          [ContextMenu (\"Find Cells\")] #if UNITY_EDITOR         void FindCells () {             Cells = FindObjectsOfType&lt;CellView> ();             Debug.Log ($\"Successfully found {Cells.Length} cells!\");         } #endif     } }<\/code><\/pre>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u043c\u0443 \u043c\u0435\u043d\u044e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043d\u0430\u0439\u0442\u0438 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043a\u043b\u0435\u0442\u043a\u0438 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0438 \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u0438\u0433\u0440\u044b, \u043d\u043e \u0437\u0430\u0447\u0435\u043c \u0435\u0433\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0442\u044c, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043f\u0430\u0440\u0443 \u043c\u0438\u043d\u0443\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0440\u0442\u0430?<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0435\u0442\u043a\u0443, \u043b\u0443\u0447\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class GridService {         readonly int[] _cells;         readonly int _width;         readonly int _height;                  public GridService (int width, int height) {             _cells = new int[width * height];             _width = width;              _height = height;         }          public (int, bool) GetCell (Int2 coords) {             var entity = _cells[_width * coords.Y + coords.X] - 1;             return (entity, entity >= 0);         }                  public void AddCell (Int2 coords, int entity) {             _cells[_width * coords.Y + coords.X] = entity + 1;         }     } } <\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 Int2 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u041e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u0447\u0435\u043c \u0448\u0442\u0430\u0442\u043d\u044b\u0439 Vector2Int.<\/p>\n<pre><code class=\"cs\">namespace Client {     struct Int2 {         public int X;         public int Y;          public Int2 (int x, int y) {             X = x;             Y = y;         }          public static Int2 operator + (Int2 a, Int2 b) {             return new Int2 (a.X + b.X, a.Y + b.Y);         }          public static Int2 operator * (Int2 a, int multiplier) {             return new Int2 (a.X * multiplier, a.Y * multiplier);         }     } }<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0441 API \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u0435\u0442\u043e\u043a.<\/p>\n<pre><code class=\"cs\">namespace Client {  \/\/ \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043a\u043b\u0435\u0442\u043a\u0438.     struct Cell {         public CellView View;     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0438\u043d\u0438\u0442-\u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class GridInitSystem : IEcsInitSystem {         readonly EcsCustomInject&lt;GridService> _gs = default;         readonly EcsCustomInject&lt;SceneData> _sceneData = default;                readonly EcsPoolInject&lt;Cell> _cellPool = default;          public void Init (EcsSystems systems) {             var world = _cellPool.Value.GetWorld ();             for (var i = 0; i &lt; _sceneData.Value.Cells.Length; i++) {                 var cellView = _sceneData.Value.Cells[i];                 var entity = world.NewEntity ();                 ref var cell = ref _cellPool.Value.Add (entity);                 var position = cellView.transform.position;                 var x = (int) (position.x \/ cellView.XzStep);                 var y = (int) (position.z \/ cellView.XzStep);                 cell.View = cellView;                 _gs.Value.AddCell (new Int2 (x, y), entity);             }         }     } }<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043c\u044b \u0441\u043e\u043e\u0440\u0443\u0434\u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u043a\u0430\u0440\u0442\u044b \u0438 \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u0432 \u043d\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043a\u043b\u0435\u0442\u043a\u0430\u0445 \u043d\u0430 \u0441\u0446\u0435\u043d\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 TimeService, &#8212; \u043d\u0435\u043a\u0443\u044e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 Unity &#8212; \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class TimeService {         public float Time;         public float DeltaTime;         public float UnscaledDeltaTime;         public float UnscaledTime;     } }<\/code><\/pre>\n<pre><code class=\"cs\">namespace Client {     sealed class TimeSystem : IEcsRunSystem {         readonly EcsCustomInject&lt;TimeService> _ts = default;          public void Run (EcsSystems systems) {             _ts.Value.Time = Time.time;             _ts.Value.UnscaledTime = Time.unscaledTime;             _ts.Value.DeltaTime = Time.deltaTime;             _ts.Value.UnscaledDeltaTime = Time.unscaledDeltaTime;         }     } }<\/code><\/pre>\n<p>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u0442\u0430\u043f, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0442\u0443\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u043d\u043e\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c:<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class Game : MonoBehaviour {         [SerializeField] SceneData _sceneData;         [SerializeField] Configuration _configuration;         EcsSystems _systems;          void Start () {             var world = new EcsWorld ();             _systems = new EcsSystems (world);             var ts = new TimeService ();             var gs = new GridService (_configuration.GridWidth, _configuration.Gridheight);              _systems                 .Add (new GridInitSystem ())                 .Add (new TimeSystem ()) #if UNITY_EDITOR                 .Add (new Leopotam.EcsLite.UnityEditor.EcsWorldDebugSystem ()) #endif                 .Inject (ts, gs, _sceneData)                 .Init ();         }          void Update () {             _systems?.Run ();         }          void OnDestroy () {             _systems?.Destroy ();             _systems?.GetWorld ()?.Destroy ();             _systems = null;         }     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0437\u0430\u043d\u044f\u0442\u044c\u0441\u044f \u0441\u043f\u0430\u0443\u043d\u043e\u043c \u0438\u0433\u0440\u043e\u043a\u0430.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class PlayerInitSystem : IEcsInitSystem {         readonly EcsPoolInject&lt;Unit> _unitPool = default;         readonly EcsPoolInject&lt;ControlledByPlayer> _controlledByPlayerPool = default;          public void Init (EcsSystems systems) {             var playerEntity = _unitPool.Value.GetWorld ().NewEntity ();              ref var unit = ref _unitPool.Value.Add (playerEntity);             _controlledByPlayerPool.Value.Add (playerEntity);                          var playerPrefab = Resources.Load (\"Player\");             var playerGo = (GameObject) Object.Instantiate (playerPrefab, Vector3.zero, Quaternion.identity);              unit.Direction = 0;             unit.CellCoords = new Int2 (0, 0);             unit.Transform = playerGo.transform;             unit.Position = Vector3.zero;             unit.Rotation = Quaternion.identity;             \/\/ \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u044f.             unit.MoveSpeed = 3f;             unit.RotateSpeed = 10f;         }     } }<\/code><\/pre>\n<pre><code class=\"cs\">namespace Client {     struct Unit {         public Direction Direction;         public Int2 CellCoords;         public Transform Transform;         public Vector3 Position;         public Quaternion Rotation;         public float MoveSpeed;         public float RotateSpeed;     } }<\/code><\/pre>\n<pre><code class=\"cs\">namespace Client {     struct ControlledByPlayer { } }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438, \u043a \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0438\u0433\u0440\u043e\u043a\u0430 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u044b \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b Unit \u0438 ControlledByPlayer. \u041f\u043e\u0447\u0435\u043c\u0443 \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0430\u043a?<\/p>\n<p>\u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0432 \u043d\u0430\u0448\u0435\u0439 \u0438\u0433\u0440\u0435 \u0438 \u0438\u0433\u0440\u043e\u043a, \u0438 \u043c\u043e\u043d\u0441\u0442\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u0434\u0432\u0438\u0433\u0430\u0442\u044c\u0441\u044f \u043f\u043e \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430\u043c. \u041b\u043e\u0433\u0438\u043a\u0430 (\u043a\u043e\u0434) \u043f\u0435\u0440\u0435\u043c\u0435\u0449\u0435\u043d\u0438\u044f \u043f\u043e \u043a\u043b\u0435\u0442\u043a\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u044e\u043d\u0438\u0442\u043e\u0432. \u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0435, \u0447\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u043b\u0438\u0447\u0430\u0442\u044c\u0441\u044f &#8212; \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a \u043a\u043e\u043c\u0430\u043d\u0434. \u042e\u043d\u0438\u0442 \u0438\u0433\u0440\u043e\u043a\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b \u043e\u0442 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u0441\u043a\u043e\u0433\u043e \u0432\u0432\u043e\u0434\u0430, \u0432\u0440\u0430\u0433\u0438 &#8212; \u043e\u0442 \u0418\u0418.<\/p>\n<figure class=\"full-width\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/4f0\/5cb\/912\/4f05cb912f8726630d05decf997d9eec.png\" alt=\"\u0411\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430 \u044e\u043d\u0438\u0442\u043e\u0432 (\u0441\u0435\u0442\u0438 \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442)\" title=\"\u0411\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430 \u044e\u043d\u0438\u0442\u043e\u0432 (\u0441\u0435\u0442\u0438 \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442)\" width=\"540\" height=\"280\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/4f0\/5cb\/912\/4f05cb912f8726630d05decf997d9eec.png\"\/><figcaption>\u0411\u043b\u043e\u043a-\u0441\u0445\u0435\u043c\u0430 \u044e\u043d\u0438\u0442\u043e\u0432 (\u0441\u0435\u0442\u0438 \u0443 \u043d\u0430\u0441 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442)<\/figcaption><\/figure>\n<p>\u0418 \u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u0432\u044b \u0432 \u0441\u0438\u043b\u0443 \u043d\u0435\u043e\u043f\u044b\u0442\u043d\u043e\u0441\u0442\u0438 \u044d\u0442\u043e\u0433\u043e \u043d\u0435 \u0437\u0430\u043c\u0435\u0442\u0438\u043b\u0438 \u0431\u044b \u0438 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043a\u043e\u0434 \u0438 \u0434\u043b\u044f \u0438\u0433\u0440\u043e\u043a\u0430, \u0438 \u0434\u043b\u044f \u0432\u0440\u0430\u0433\u043e\u0432, \u043f\u043e\u0432\u0442\u043e\u0440\u044f\u044e\u0449\u0438\u0435\u0441\u044f \u0441\u0442\u0440\u043e\u043a\u0438 \u043d\u0430\u0442\u043e\u043b\u043a\u043d\u0443\u0442 \u0432\u0430\u0441 \u043d\u0430 \u043c\u044b\u0441\u043b\u044c \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0438\u043c\u0435\u0435\u0442 \u0441\u043c\u044b\u0441\u043b \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0438\u0445 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430. \u0418 \u0441 ECS \u044d\u0442\u043e \u0432\u0441\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0449\u0435 \u0438 \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u043e\u0442\u0440\u0435\u0444\u0430\u043a\u0442\u043e\u0440\u0438\u0442\u044c, \u0442\u0430\u043a \u043a\u0430\u043a \u043a\u0430\u0436\u0434\u0430\u044f \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c &#8212; \u043d\u0430\u0431\u043e\u0440 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u0434\u0435\u043b\u0430\u0435\u043c \u0430\u0436 \u0442\u0440\u0438 \u0441\u043f\u043e\u0441\u043e\u0431\u0430 \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043f\u0435\u0440\u0441\u043e\u043d\u0430\u0436\u0435\u043c: \u0447\u0435\u0440\u0435\u0437 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0443, \u0447\u0435\u0440\u0435\u0437 \u043a\u043d\u043e\u043f\u043a\u0438 \u0438 \u0447\u0435\u0440\u0435\u0437 \u043c\u044b\u0448\u044c. \u041d\u043e \u0432\u0441\u0435 \u043f\u043e \u043f\u043e\u0440\u044f\u0434\u043a\u0443.<\/p>\n<p>\u041d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u043f\u0435\u0440\u0435\u0434-\u043d\u0430\u0437\u0430\u0434 \u0431\u0443\u0434\u0443\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f, \u0432\u043b\u0435\u0432\u043e-\u0432\u043f\u0440\u0430\u0432\u043e \u0434\u043b\u044f \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432.<\/p>\n<p>\u041d\u0430\u0447\u043d\u0435\u043c \u0441 \u043f\u0440\u043e\u0441\u0442\u043e\u0433\u043e. \u0423\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u043a\u043b\u0430\u0432\u0438\u0430\u0442\u0443\u0440\u0443. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class UserKeyboardInputSystem : IEcsRunSystem {         readonly EcsFilterInject&lt;Inc&lt;Unit, ControlledByPlayer>> _units = default;          readonly EcsPoolInject&lt;MoveCommand> _moveCommandPool = default;         readonly EcsPoolInject&lt;RotateCommand> _rotateCommandPool = default;          public void Run (EcsSystems systems) {             foreach (var entity in _units.Value) {                 var vertInput = Input.GetAxisRaw (Idents.Input.VerticalAxis);                 var horizInput = Input.GetAxisRaw (Idents.Input.HorizontalAxis);                                  switch (vertInput) {                     case 1f:                         _moveCommandPool.Value.Add (entity);                         break;                     case -1f:                         ref var moveCmd = ref _moveCommandPool.Value.Add (entity);                         moveCmd.Backwards = true;                         break;                 }                  if (horizInput != 0f) {                     ref var rotCmd = ref _rotateCommandPool.Value.Add (entity);                     rotCmd.Side = (int) horizInput;                 }             }         }     } }<\/code><\/pre>\n<pre><code class=\"cs\">namespace Client {   \/\/ \u0421\u043e\u0431\u044b\u0442\u0438\u0435 \u043e \u043a\u043e\u043c\u0430\u043d\u0434\u0435 \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f     struct MoveCommand {         public bool Backwards;     } }<\/code><\/pre>\n<pre><code class=\"cs\">namespace Client {   \/\/ \u0418 \u043e \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u0435     struct RotateCommand {         public int Side;     } }<\/code><\/pre>\n<p>\u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0431\u044b\u0441\u0442\u0440\u043e \u043c\u0435\u043d\u044f\u0442\u044c \u0438\u0445 \u0432\u0435\u0437\u0434\u0435, \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 Idents.<\/p>\n<pre><code class=\"cs\">namespace Client {     static class Idents {         public static class Input {             public const string VerticalAxis = \"Vertical\";           public const string HorizontalAxis = \"Horizontal\";         }     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0437\u0430\u0439\u043c\u0435\u043c\u0441\u044f \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u043e\u0439 UI.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/16c\/3ec\/293\/16c3ec29343d1e443fd8790b2008a094.png\" alt=\"\u0412\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u044f \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u043b \u0432 \u043d\u0438\u0436\u043d\u0435\u043c \u043f\u0440\u0430\u0432\u043e\u043c \u0443\u0433\u043b\u0443 \u043a\u0430\u043d\u0432\u0430\u0441\u0430\" title=\"\u0412\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u044f \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u043b \u0432 \u043d\u0438\u0436\u043d\u0435\u043c \u043f\u0440\u0430\u0432\u043e\u043c \u0443\u0433\u043b\u0443 \u043a\u0430\u043d\u0432\u0430\u0441\u0430\" width=\"417\" height=\"398\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/16c\/3ec\/293\/16c3ec29343d1e443fd8790b2008a094.png\"\/><figcaption>\u0412\u043e\u0442 \u0442\u0430\u043a\u0438\u0435 \u043a\u043d\u043e\u043f\u043a\u0438 \u044f \u0440\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0438\u043b \u0432 \u043d\u0438\u0436\u043d\u0435\u043c \u043f\u0440\u0430\u0432\u043e\u043c \u0443\u0433\u043b\u0443 \u043a\u0430\u043d\u0432\u0430\u0441\u0430<\/figcaption><\/figure>\n<p>\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c 4 \u043a\u043d\u043e\u043f\u043a\u0438 \u0438 \u043f\u043e\u0432\u0435\u0441\u0438\u043c \u043d\u0430 \u043d\u0438\u0445 \u043d\u0443\u0436\u043d\u044b\u0435 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b \u0434\u043b\u044f \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0441\u043e\u0431\u044b\u0442\u0438\u0439 UI.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/9f2\/819\/e05\/9f2819e052aea1722fc420ec137a1288.png\" alt=\"\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438\" title=\"\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438\" width=\"506\" height=\"420\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/9f2\/819\/e05\/9f2819e052aea1722fc420ec137a1288.png\"\/><figcaption>\u0410\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u043a\u043d\u043e\u043f\u043a\u0430\u043c\u0438<\/figcaption><\/figure>\n<p>\u041d\u0430 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0439 \u043e\u0431\u044a\u0435\u043a\u0442 UI \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 EcsUguiEmitter. \u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0435\u0433\u043e \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<pre><code class=\"cs\">... [SerializeField] EcsUguiEmitter _uguiEmitter; \/\/ \u043d\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0432 \u043a\u043b\u0430\u0441\u0441\u0435 Game ...<\/code><\/pre>\n<pre><code class=\"cs\">... .Inject (ts, gs, _sceneData) .InjectUgui (_uguiEmitter) .Init (); ...<\/code><\/pre>\n<p>\u0412 EcsLite \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0438\u0440 \u0434\u043b\u044f \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0436\u0438\u0432\u0443\u0449\u0438\u0445 \u044d\u043d\u0442\u0438\u0442\u0438-\u0438\u0432\u0435\u043d\u0442\u043e\u0432, \u0442\u0430\u043a \u043a\u0430\u043a \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043c\u0438\u0440\u0430 \u043f\u0443\u043b\u044b \u0438\u043c\u0435\u044e\u0442 \u0440\u0430\u0437\u043c\u0435\u0440 <strong>[\u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439; \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 * 2]<\/strong> \u0432\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e (\u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0442\u043e\u0433\u043e, \u043a\u043e\u0433\u0434\u0430 \u0431\u044b\u043b \u0438\u0437\u043c\u0435\u043d\u0435\u043d \u0438\u0445 \u0440\u0430\u0437\u043c\u0435\u0440). \u0422\u043e \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0432 \u043c\u0438\u0440\u0435 100 \u0442\u044b\u0441\u044f\u0447 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u044e\u043d\u0438\u0442\u043e\u0432, \u0438 \u0432\u044b \u0432\u0434\u0440\u0443\u0433 \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0435 \u043e\u0434\u043d\u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044c-\u0438\u0432\u0435\u043d\u0442 \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c &#171;Click&#187;, \u0442\u043e \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0430 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u043d \u043f\u0443\u043b \u0441 \u043e\u0433\u0440\u043e\u043c\u043d\u044b\u043c \u0440\u0430\u0437\u043c\u0435\u0440\u043e\u043c, \u0447\u0442\u043e \u0432 \u043a\u043e\u043d\u0435\u0447\u043d\u043e\u043c \u0438\u0442\u043e\u0433\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u0442 \u043a \u043d\u0435\u0440\u0430\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e\u043c\u0443 \u0440\u0430\u0441\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u044e \u043f\u0430\u043c\u044f\u0442\u0438.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class Game : MonoBehaviour {         [SerializeField] SceneData _sceneData;         [SerializeField] Configuration _configuration;         [SerializeField] EcsUguiEmitter _uguiEmitter;         EcsSystems _systems;          void Start () {             var world = new EcsWorld ();             _systems = new EcsSystems (world);             var ts = new TimeService ();             var gs = new GridService (_configuration.GridWidth, _configuration.Gridheight);              _systems                 .Add (new GridInitSystem ())                 .Add (new TimeSystem ())                 .Add (new PlayerInitSystem ())                 .DelHere&lt;MoveCommand> ()                 .Add (new UserKeyboardInputSystem ())                                  .AddWorld (new EcsWorld (), Idents.Worlds.Events) #if UNITY_EDITOR                 .Add (new Leopotam.EcsLite.UnityEditor.EcsWorldDebugSystem ())                 .Add (new Leopotam.EcsLite.UnityEditor.EcsWorldDebugSystem (Idents.Worlds.Events)) #endif                 .Inject (ts, gs, _sceneData)                 .InjectUgui (_uguiEmitter, Idents.Worlds.Events)                 .Init ();         }          void Update () {             _systems?.Run ();         }          void OnDestroy () {             _systems?.Destroy ();             _systems?.GetWorld ()?.Destroy ();             _systems = null;         }     } }<\/code><\/pre>\n<p>\u0414\u043e\u0431\u0430\u0432\u0438\u043c \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435 \u043c\u0438\u0440\u0430 \u0434\u043b\u044f \u0441\u043e\u0431\u044b\u0442\u0438\u0439 \u0438 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f \u043a\u043d\u043e\u043f\u043e\u043a \u0432 \u043a\u043b\u0430\u0441\u0441 Idents.<\/p>\n<pre><code class=\"cs\">namespace Client {     static class Idents {         public static class Input {             public const string VerticalAxis = \"Vertical\";           public const string HorizontalAxis = \"Horizontal\";         }          public static class Worlds {             public const string Events = \"Events\";         }          public static class Ui {             public const string Forward = \"Forward\";             public const string Back = \"Back\";           public const string Left = \"Left\";           public const string Right = \"Right\";         }     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u043b\u043e\u0432\u0438\u0442\u044c \u0441\u043e\u0431\u044b\u0442\u0438\u044f \u0441 \u043a\u043d\u043e\u043f\u043e\u043a.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class UserButtonsInputSystem : EcsUguiCallbackSystem {         readonly EcsFilterInject&lt;Inc&lt;Unit, ControlledByPlayer>> _units = default;          readonly EcsPoolInject&lt;MoveCommand> _moveCommandPool = default;         readonly EcsPoolInject&lt;RotateCommand> _rotateCommandPool = default;          [Preserve]         [EcsUguiClickEvent (Idents.Ui.Forward, Idents.Worlds.Events)]         void OnClickForward (in EcsUguiClickEvent e) {             foreach (var entity in _units.Value) {                 _moveCommandPool.Value.Add (entity);             }         }                  [Preserve]         [EcsUguiClickEvent (Idents.Ui.Back, Idents.Worlds.Events)]         void OnClickBack (in EcsUguiClickEvent e) {             foreach (var entity in _units.Value) {                 ref var moveCmd = ref _moveCommandPool.Value.Add (entity);                 moveCmd.Backwards = true;                 break;             }         }          [Preserve]         [EcsUguiClickEvent (Idents.Ui.Left, Idents.Worlds.Events)]         void OnClickLeft (in EcsUguiClickEvent e) {             foreach (var entity in _units.Value) {                 ref var rotCmd = ref _rotateCommandPool.Value.Add (entity);                 rotCmd.Side = -1;             }         }                  [Preserve]         [EcsUguiClickEvent (Idents.Ui.Right, Idents.Worlds.Events)]         void OnClickRight (in EcsUguiClickEvent e) {             foreach (var entity in _units.Value) {                 ref var rotCmd = ref _rotateCommandPool.Value.Add (entity);                 rotCmd.Side = 1;             }         }     } }<\/code><\/pre>\n<p>\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043b\u0438\u0448\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0443 \u0441\u0432\u0430\u0439\u043f\u043e\u0432. \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u043b\u043d\u043e\u044d\u043a\u0440\u0430\u043d\u043d\u044b\u0439 \u043d\u0435\u0432\u0438\u0434\u0438\u043c\u044b\u0439 \u0432\u0438\u0434\u0436\u0435\u0442 \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e.<\/p>\n<figure class=\"\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/habrastorage.org\/r\/w1560\/getpro\/habr\/upload_files\/169\/877\/3b9\/1698773b90b08b74d3015ea98ffa2784.png\" width=\"502\" height=\"365\" data-src=\"https:\/\/habrastorage.org\/getpro\/habr\/upload_files\/169\/877\/3b9\/1698773b90b08b74d3015ea98ffa2784.png\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0418 \u043d\u043e\u0432\u0443\u044e \u0441\u0438\u0441\u0442\u0435\u043c\u0443:<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class UserSwipeInputSystem : EcsUguiCallbackSystem {         readonly EcsFilterInject&lt;Inc&lt;Unit, ControlledByPlayer>> _units = default;          readonly EcsPoolInject&lt;MoveCommand> _moveCommandPool = default;         readonly EcsPoolInject&lt;RotateCommand> _rotateCommandPool = default;          const float MinSwipeMagnitude = 0.2f;          Vector2 _lastTouchPos = default;          [Preserve]         [EcsUguiDownEvent (Idents.Ui.TouchListener, Idents.Worlds.Events)]         void OnDownTouchListener (in EcsUguiDownEvent e) {             _lastTouchPos = e.Position;         }          [Preserve]         [EcsUguiUpEvent (Idents.Ui.TouchListener, Idents.Worlds.Events)]         void OnUpTouchListener (in EcsUguiUpEvent e) {             var swipe = e.Position - _lastTouchPos;             var swipeHorizontal = swipe.x \/ Screen.width;             var swipeVertical = swipe.y \/ Screen.height;              if (Mathf.Abs (swipeVertical) >= MinSwipeMagnitude) {                 foreach (var entity in _units.Value) {                     ref var moveCmd = ref _moveCommandPool.Value.Add (entity);                     moveCmd.Backwards = swipeVertical &lt; 0f;                     break;                 }             } else if (Mathf.Abs (swipeHorizontal) >= MinSwipeMagnitude) {                 foreach (var entity in _units.Value) {                     ref var rotCmd = ref _rotateCommandPool.Value.Add (entity);                     var side = swipeHorizontal > 0f ? 1 : -1;                     rotCmd.Side = side;                 }             }         }     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0434\u043b\u044f \u0434\u0432\u0438\u0436\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class UnitStartMovingSystem : IEcsRunSystem {         readonly EcsFilterInject&lt;Inc&lt;Unit, MoveCommand>, Exc&lt;Animated>> _units = default;          readonly EcsPoolInject&lt;Animated> _animatedPool = default;         readonly EcsPoolInject&lt;Moving> _movingPool = default;         readonly EcsPoolInject&lt;Cell> _cellPool = default;          readonly EcsCustomInject&lt;GridService> _gs = default;          public void Run (EcsSystems systems) {             foreach (var entity in _units.Value) {                 ref var unit = ref _units.Pools.Inc1.Get (entity);                 ref var cmd = ref _units.Pools.Inc2.Get (entity);                  var step = cmd.Backwards ? -1 : 1;                  var pos3d = Quaternion.Euler (0f, 90f * (int) unit.Direction, 0f) * Vector3.forward;                 var newCellCoords = unit.CellCoords + new Int2 (Mathf.RoundToInt (pos3d.x), Mathf.RoundToInt (pos3d.z)) * step;                                  var (newCell, ok) = _gs.Value.GetCell (newCellCoords);                 if (ok) {                     ref var cell = ref _cellPool.Value.Get (newCell);                     _animatedPool.Value.Add (entity);                     ref var moving = ref _movingPool.Value.Add (entity);                     moving.Point = cell.View.Transform.localPosition;                     unit.CellCoords = newCellCoords;                 }             }         }     } }<\/code><\/pre>\n<p>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 Animated &#8212; \u044d\u0442\u043e \u043c\u0430\u0440\u043a\u0435\u0440, \u0433\u043e\u0432\u043e\u0440\u044f\u0449\u0438\u0439 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u044e\u043d\u0438\u0442 \u0441\u0435\u0439\u0447\u0430\u0441 \u0437\u0430\u043d\u044f\u0442, \u0438 \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043c\u043e\u0436\u0435\u0442 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0442\u044c \u043a\u043e\u043c\u0430\u043d\u0434\u044b.<\/p>\n<pre><code class=\"cs\">namespace Client {     struct Animated { } }<\/code><\/pre>\n<pre><code class=\"cs\">namespace Client {     struct Moving {         public Vector3 Point;     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0442\u0432\u0438\u043d\u0438\u043d\u0433\u0430 \u043c\u0435\u0436\u0434\u0443 \u043a\u043b\u0435\u0442\u043a\u0430\u043c\u0438:<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class UnitMoveSystem : IEcsRunSystem {         readonly EcsFilterInject&lt;Inc&lt;Unit, Moving>> _movingUnits = default;          readonly EcsPoolInject&lt;Animated> _animatedPool = default;          readonly EcsCustomInject&lt;TimeService> _ts = default;          const float DistanceToStop = 0.1f;          public void Run (EcsSystems systems) {             foreach (var entity in _movingUnits.Value) {                 ref var unit = ref _movingUnits.Pools.Inc1.Get (entity);                 ref var move = ref _movingUnits.Pools.Inc2.Get (entity);                                  unit.Position = Vector3.Lerp (unit.Position, move.Point, unit.MoveSpeed * _ts.Value.DeltaTime);                 unit.Transform.localPosition = unit.Position;                  if ((unit.Position - move.Point).sqrMagnitude &lt;= DistanceToStop) {                     _animatedPool.Value.Del (entity);                     _movingUnits.Pools.Inc2.Del (entity);                 }             }         }     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432:<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class UnitStartRotatingSystem : IEcsRunSystem {         readonly EcsFilterInject&lt;Inc&lt;Unit, RotateCommand>, Exc&lt;Animated>> _units = default;                  readonly EcsPoolInject&lt;Animated> _animatedPool = default;         readonly EcsPoolInject&lt;Rotating> _rotatingPool = default;                  public void Run (EcsSystems systems) {             foreach (var entity in _units.Value) {                 ref var unit = ref _units.Pools.Inc1.Get (entity);                 ref var rot = ref _units.Pools.Inc2.Get (entity);                  var newDir = (int) unit.Direction + rot.Side;                 if (newDir == -1) {                     newDir += 4;                 }                 newDir %= 4;                 unit.Direction = (Direction) newDir;                 var actualDir = Quaternion.Euler (0f, 90f * (int) unit.Direction, 0f);                 ref var rotating = ref _rotatingPool.Value.Add (entity);                 _animatedPool.Value.Add (entity);                 rotating.Target = actualDir;             }         }     } }<\/code><\/pre>\n<p>\u0418 \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043f\u043e\u0432\u043e\u0440\u043e\u0442\u043e\u0432:<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class UnitRotateSystem : IEcsRunSystem {         readonly EcsFilterInject&lt;Inc&lt;Unit, Rotating>> _rotatingUnits = default;          readonly EcsPoolInject&lt;Animated> _animatedPool = default;          readonly EcsCustomInject&lt;TimeService> _ts = default;          public void Run (EcsSystems systems) {             foreach (var entity in _rotatingUnits.Value) {                 ref var unit = ref _rotatingUnits.Pools.Inc1.Get (entity);                 ref var rotate = ref _rotatingUnits.Pools.Inc2.Get (entity);                  unit.Rotation = Quaternion.Lerp (unit.Rotation, rotate.Target, _ts.Value.DeltaTime * unit.RotateSpeed);                 unit.Transform.localRotation = unit.Rotation;                  if ((unit.Rotation.eulerAngles - rotate.Target.eulerAngles).sqrMagnitude &lt;= 0.1f) {                     _animatedPool.Value.Del (entity);                     _rotatingUnits.Pools.Inc2.Del (entity);                 }             }         }     } }<\/code><\/pre>\n<p>\u0418 \u043d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432\u0441\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0432 \u0441\u0442\u0430\u0440\u0442\u0430\u043f.<\/p>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u0448 \u0433\u0435\u0440\u043e\u0439 \u0434\u0432\u0438\u0436\u0435\u0442\u0441\u044f \u0438 \u043f\u043e\u0432\u043e\u0440\u0430\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f!<\/p>\n<figure><img decoding=\"async\" src=\"\"\/><figcaption><\/figcaption><\/figure>\n<p>\u0412 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0447\u0430\u0441\u0442\u0438 \u043c\u044b \u0440\u0430\u0437\u0431\u0435\u0440\u0435\u043c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u043a\u0438 \u0438 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043f\u043e\u0432\u0435\u0434\u0435\u043d\u0438\u044f \u0432\u0440\u0430\u0433\u043e\u0432.<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/github.com\/supremestranger\/dungeon-crawler\" rel=\"noopener noreferrer nofollow\">\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u0439 \u0441 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u043c<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/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\/post\/661085\/\"> https:\/\/habr.com\/ru\/post\/661085\/<\/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_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p><em>\u0414\u0440\u0443\u0437\u044c\u044f, \u044d\u0442\u043e \u043d\u0430\u0447\u0430\u043b\u043e \u043d\u043e\u0432\u043e\u0433\u043e \u0446\u0438\u043a\u043b\u0430 \u0441\u0442\u0430\u0442\u0435\u0439 \u043f\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438\u0433\u0440\u044b \u0436\u0430\u043d\u0440\u0430 dungeon crawler \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 LeoECS Lite, \u0438 \u0435\u0433\u043e \u0437\u0430\u0434\u0430\u0447\u0430 \u2013 \u043f\u043e\u043c\u043e\u0447\u044c \u0432\u0430\u043c \u0431\u044b\u0441\u0442\u0440\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u0442\u044c LeoECS Lite \u0434\u043b\u044f \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0438\u0433\u0440 \u043d\u0430 Unity \u0438 \u0440\u0435\u0448\u0438\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0438\u0434\u044b \u043f\u0440\u043e\u0431\u043b\u0435\u043c.<\/em><\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p><a href=\"https:\/\/github.com\/Leopotam\/ecslite\" rel=\"noopener noreferrer nofollow\">LeoECS Lite<\/a> &#8212; \u043d\u043e\u0432\u0430\u044f, \u0431\u043e\u043b\u0435\u0435 \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 LeoECS, \u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u044b <a href=\"https:\/\/habr.com\/ru\/post\/573028\/\" rel=\"noopener noreferrer nofollow\">\u0442\u0443\u0442\u043e\u0440\u0438\u0430\u043b\u044b<\/a>. \u041f\u0443\u0441\u0442\u044c \u0441\u043b\u043e\u0432\u043e &#171;Lite&#187; \u043d\u0435 \u0432\u0432\u043e\u0434\u0438\u0442 \u0432\u0430\u0441 \u0432 \u0437\u0430\u0431\u043b\u0443\u0436\u0434\u0435\u043d\u0438\u0435 \u2013 \u043e\u043d\u0430 \u043f\u043e\u0434\u0447\u0435\u0440\u043a\u0438\u0432\u0430\u0435\u0442 \u0438\u043c\u0435\u043d\u043d\u043e \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u043e\u0441\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430, \u0430 \u043d\u0435 \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f. \u0425\u043e\u0442\u044f \u0441\u0430\u043c \u043f\u043e \u0441\u0435\u0431\u0435 \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e\u0439, \u043e\u043d \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u043f\u0440\u0438\u0432\u044b\u0447\u043d\u044b\u043c \u0434\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u043f\u0440\u0438\u0432\u044b\u043a \u043a API \u043a\u043b\u0430\u0441\u0441\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438.<\/p>\n<details class=\"spoiler\">\n<summary>\u0421\u043f\u0438\u0441\u043e\u043a \u043a\u043b\u044e\u0447\u0435\u0432\u044b\u0445 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0432 API<\/summary>\n<div class=\"spoiler__content\">\n<ul>\n<li>\n<p>\u0427\u0442\u043e\u0431\u044b \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c\/\u0443\u0434\u0430\u043b\u0438\u0442\u044c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u0443 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u0432\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0434\u043e\u0441\u0442\u0443\u043f \u043a \u043f\u0443\u043b\u0443 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u0432.<\/p>\n<\/li>\n<li>\n<p>Dependency Injection \u0447\u0435\u0440\u0435\u0437 \u0440\u0435\u0444\u043b\u0435\u043a\u0448\u043d \u0443\u0431\u0440\u0430\u043d \u0438\u0437 \u044f\u0434\u0440\u0430, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u043c\u0438\u0440, \u0444\u0438\u043b\u044c\u0442\u0440\u044b \u0438\u043b\u0438 \u043d\u043e\u0432\u044b\u0435 \u043f\u0443\u043b\u044b \u0432 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u0430\u0445 \u0441\u0438\u0441\u0442\u0435\u043c &#8212; \u043d\u0443\u0436\u043d\u043e \u0438\u043b\u0438 \u0437\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0442\u044c \u0438\u0445 \u0432 \u0440\u0430\u043d\u0442\u0430\u0439\u043c\u0435, \u0438\u043b\u0438 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0437\u0430\u0440\u0430\u043d\u0435\u0435.<\/p>\n<\/li>\n<li>\n<p>\u0421\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0442\u0435\u043f\u0435\u0440\u044c \u0432 \u0447\u0438\u0441\u0442\u043e\u043c \u0432\u0438\u0434\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0441\u043e\u0431\u043e\u0439 \u043e\u0431\u044b\u0447\u043d\u044b\u0435 int&#8217;\u044b. \u0427\u0442\u043e\u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0438\u0445 \u0433\u0434\u0435-\u0442\u043e \u0438 \u0438\u043c\u0435\u0442\u044c \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c, \u043d\u0435 \u0443\u043d\u0438\u0447\u0442\u043e\u0436\u0435\u043d\u0430 \u043b\u0438 \u044d\u043d\u0442\u0438\u0442\u0438, \u043d\u0443\u0436\u043d\u043e \u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0438\u0445 \u0447\u0435\u0440\u0435\u0437 \u043c\u0438\u0440.<\/p>\n<\/li>\n<\/ul>\n<p>\u041f\u0440\u043e \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0432 README \u0440\u0435\u043f\u043e\u0437\u0438\u0442\u043e\u0440\u0438\u044f.<\/p>\n<\/div>\n<\/details>\n<p>\u0421 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0442\u043e\u0440\u043e\u043d\u044b, \u043b\u0435\u0433\u043a\u043e\u0432\u0435\u0441\u043d\u043e\u0441\u0442\u044c \u0444\u0440\u0435\u0439\u043c\u0432\u043e\u0440\u043a\u0430 \u0437\u0430\u043a\u043b\u044e\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u0442\u0430\u043b\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u044f\u0434\u0440\u043e. \u041e\u043d\u043e \u0441\u0442\u0430\u043b\u043e \u043c\u043e\u0434\u0443\u043b\u044c\u043d\u044b\u043c &#8212; \u0431\u043e\u043b\u044c\u0448\u0430\u044f \u0447\u0430\u0441\u0442\u044c \u0444\u0438\u0448\u0435\u043a \u043f\u0435\u0440\u0435\u0435\u0445\u0430\u043b\u0430 \u0432 \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043e\u043f\u0446\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u043e. \u0421 \u0438\u0445 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043f\u0440\u0438\u044f\u0442\u043d\u044b\u0439 API, \u043d\u0430\u043f\u043e\u043c\u0438\u043d\u0430\u044e\u0449\u0438\u0439 \u043a\u043b\u0430\u0441\u0441\u0438\u043a\u0443, \u0438 \u0432\u043e\u0442 \u043a\u0430\u043a\u0438\u0435 \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438\u0433\u0440\u044b: <a href=\"https:\/\/github.com\/Leopotam\/ecslite-di\" rel=\"noopener noreferrer nofollow\">ecslite-di<\/a>, <a href=\"https:\/\/github.com\/Leopotam\/ecslite-extendedsystems\" rel=\"noopener noreferrer nofollow\">ecslite-extended-systems<\/a>, <a href=\"https:\/\/github.com\/Leopotam\/ecslite-unityeditor\" rel=\"noopener noreferrer nofollow\">ecslite-unityeditor<\/a>, <a href=\"https:\/\/github.com\/Leopotam\/ecslite-unity-ugui\" rel=\"noopener noreferrer nofollow\">ecslite-unity-ugui<\/a>.<\/p>\n<p>\u0418\u0442\u0430\u043a, \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u043f\u0435\u0440\u0435\u0439\u0434\u0435\u043c \u043a \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u0438 \u043d\u0430\u0447\u043d\u0435\u043c \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443 \u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0442\u0430\u0440\u043f\u0442\u0430\u043f-\u043a\u043b\u0430\u0441\u0441\u0430.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class Game : MonoBehaviour {         [SerializeField] SceneData _sceneData;         [SerializeField] Configuration _configuration;         EcsSystems _systems;          void Start () {             var world = new EcsWorld ();             _systems = new EcsSystems (world);              _systems #if UNITY_EDITOR                 .Add (new Leopotam.EcsLite.UnityEditor.EcsWorldDebugSystem ()) #endif                 .Inject (_sceneData)                 .Init ();         }          void Update () {             _systems?.Run ();         }          void OnDestroy () {             _systems?.Destroy ();             _systems?.GetWorld ()?.Destroy ();             _systems = null;         }     } }<\/code><\/pre>\n<p>\u0414\u043b\u044f \u0442\u0435\u0445, \u043a\u0442\u043e \u0437\u043d\u0430\u043a\u043e\u043c \u0441 LeoECS, \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0442\u0430\u043a \u0443\u0436 \u0438 \u043c\u043d\u043e\u0433\u043e. \u041c\u044b \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 MonoBehaviour \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 SceneData, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0431\u0443\u0434\u0443\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441\u043e \u0441\u0446\u0435\u043d\u043e\u0439, \u0430 \u0442\u0430\u043a\u0436\u0435 \u043a\u043b\u0430\u0441\u0441 Configuration, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u043c Scriptable Object&#8217;\u0430.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class SceneData : MonoBehaviour {     } }<\/code><\/pre>\n<pre><code class=\"cs\">namespace Client {     [CreateAssetMenu]     sealed class Configuration : ScriptableObject {     \/\/ \u0428\u0438\u0440\u0438\u043d\u0430 \u0438 \u0432\u044b\u0441\u043e\u0442\u0430 \u0441\u0435\u0442\u043a\u0438.         public int GridWidth;         public int Gridheight;     } }<\/code><\/pre>\n<p>\u041f\u0435\u0440\u0432\u044b\u043c \u0434\u0435\u043b\u043e\u043c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0443 \u043a\u043b\u0435\u0442\u043e\u043a. \u041c\u044b \u043c\u043e\u0436\u0435\u043c \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e\u0439 MonoBehaviour \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d \u043a \u043f\u0440\u0435\u0444\u0430\u0431\u0443 \u043a\u043b\u0435\u0442\u043a\u0438. \u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u043d\u0435\u043c\u0443 \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0442\u044c \u043a\u043b\u0435\u0442\u043a\u0438 \u0432 \u0441\u0446\u0435\u043d\u0435 \u0441 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u043c \u0438\u043d\u0442\u0435\u0440\u0432\u0430\u043b\u043e\u043c. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442 \u043c\u0430\u0433\u043d\u0438\u0442\u0438\u0442\u044c\u0441\u044f \u043a \u043d\u0443\u0436\u043d\u044b\u043c \u043c\u0435\u0441\u0442\u0430\u043c, \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0435 \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b.<\/p>\n<pre><code class=\"cs\">namespace Client {     [ExecuteAlways] \/\/ \u041a\u043e\u0434 \u043d\u0438\u0436\u0435 \u0434\u043e\u043b\u0436\u0435\u043d \u0438\u0441\u043f\u043e\u043b\u043d\u044f\u0442\u044c\u0441\u044f \u0432\u0441\u0435\u0433\u0434\u0430.     [SelectionBase] \/\/ \u0415\u0441\u043b\u0438 \u0432\u044b \u043a\u043b\u0438\u043a\u043d\u0435\u0442\u0435 \u043d\u0430 \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u044e\u044e \u0437\u0430\u043f\u0447\u0430\u0441\u0442\u044c \u043f\u0440\u0435\u0444\u0430\u0431\u0430, \u0442\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u044d\u0442\u043e\u0442 \u043e\u0431\u044a\u0435\u043a\u0442     sealed class CellView : MonoBehaviour {         public Transform Transform;         public float XzStep = 3f;         public float YStep = 1f;          void Awake () {             Transform = transform;         }  #if UNITY_EDITOR         void Update () {             if (!Application.isPlaying &amp;&amp; Transform.hasChanged) {                 var newPos = Vector3.zero;                 var curPos = Transform.localPosition;                 newPos.x = Mathf.RoundToInt (curPos.x \/ XzStep) * XzStep;                 newPos.z = Mathf.RoundToInt (curPos.z \/ XzStep) * XzStep;                 newPos.y = Mathf.RoundToInt (curPos.y \/ YStep) * YStep;                 Transform.localPosition = newPos; \/\/ \u041c\u0430\u0433\u043d\u0438\u0442\u0438\u043c \u043a\u043b\u0435\u0442\u043a\u0443 \u043a \u0441\u0435\u0442\u043a\u0435.             }         }          void OnDrawGizmos () {             var selected = Selection.Contains (gameObject); \/\/ \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c, \u0432\u044b\u0434\u0435\u043b\u0435\u043d \u043b\u0438 \u043e\u0431\u044a\u0435\u043a\u0442             Gizmos.color = selected ? Color.green : Color.cyan; \/\/ \u0415\u0441\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d, \u0446\u0432\u0435\u0442 \u0433\u0438\u0437\u043c\u043e\u0441 \u0431\u0443\u0434\u0435\u0442 \u0437\u0435\u043b\u0435\u043d\u044b\u0439, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 - \u0433\u043e\u043b\u0443\u0431\u043e\u0439             var yAdd = selected ? 0.02f : 0f; \/\/ \u0415\u0441\u043b\u0438 \u0432\u044b\u0434\u0435\u043b\u0435\u043d, \u0442\u043e \u0441\u043b\u0435\u0433\u043a\u0430 \u043f\u0440\u0438\u043f\u043e\u0434\u043d\u0438\u043c\u0435\u043c \u043a\u043b\u0435\u0442\u043a\u0443, \u0447\u0442\u043e\u0431\u044b \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u0435\u0435             var curPos = Transform.localPosition; \/\/ \u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c \u0432\u044b\u0447\u0438\u0441\u043b\u044f\u0442\u044c \u043a\u043e\u043e\u0440\u0434\u0438\u043d\u0430\u0442\u044b \u043a\u0432\u0430\u0434\u0440\u0430\u0442\u0430             var leftDown = curPos - Vector3.right * XzStep \/ 2 - Vector3.forward * XzStep \/ 2 + Vector3.up * yAdd;             var leftUp = curPos - Vector3.right * XzStep \/ 2 + Vector3.forward * XzStep \/ 2 + Vector3.up * yAdd;             var rightDown = curPos + Vector3.right * XzStep \/ 2 - Vector3.forward * XzStep \/ 2 + Vector3.up * yAdd;             var rightUp = curPos + Vector3.right * XzStep \/ 2 + Vector3.forward * XzStep \/ 2 + Vector3.up * yAdd;             Gizmos.DrawLine (leftDown, leftUp); \/\/ \u0420\u0438\u0441\u0443\u0435\u043c \u043a\u0432\u0430\u0434\u0440\u0430\u0442             Gizmos.DrawLine (leftUp, rightUp);             Gizmos.DrawLine (rightUp, rightDown);             Gizmos.DrawLine (rightDown, leftDown);             Gizmos.DrawSphere (curPos, 0.1f);         } #endif     } }<\/code><\/pre>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u0438\u0442\u0435, \u043c\u044b \u0442\u0430\u043a\u0436\u0435 \u0441\u0434\u0435\u043b\u0430\u043b\u0438 \u0443\u0434\u043e\u0431\u043d\u043e\u0435 \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u043a\u043b\u0435\u0442\u043e\u043a \u0432 \u043e\u043a\u043d\u0435 \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0430 \u0441 Gizmos.<\/p>\n<figure class=\"full-width\"><figcaption><\/figcaption><\/figure>\n<p>\u041d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u0430\u0440\u0442\u0443 \u0432 \u0441\u0430\u043c\u043e\u043c \u043d\u0430\u0447\u0430\u043b\u0435, \u0441\u043e\u0437\u0434\u0430\u0432 \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043a\u043b\u0435\u0442\u043a\u0438, \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0441 \u0443\u0440\u043e\u0432\u043d\u044f. \u0422\u043e \u0435\u0441\u0442\u044c, \u043b\u0435\u0432\u0435\u043b \u0434\u0438\u0437\u0430\u0439\u043d\u0435\u0440 \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u0430\u0440\u0442\u0443, \u0440\u0430\u0437\u043c\u0435\u0449\u0430\u0435\u0442 \u043a\u043b\u0435\u0442\u043a\u0438, \u0430 \u043c\u044b \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u0433\u0440\u044b \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438 \u043a\u043b\u0435\u0442\u043e\u043a \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043a \u043d\u0438\u043c \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u044b.<\/p>\n<p>\u0414\u0430\u0432\u0430\u0439\u0442\u0435 \u0432\u0435\u0440\u043d\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0448\u0435\u043c\u0443 \u043a\u043b\u0430\u0441\u0441\u0443 SceneData \u0438 \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u043f\u043e\u043c\u0435\u043d\u044f\u0435\u043c \u0435\u0433\u043e:<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class SceneData : MonoBehaviour {         public CellView[] Cells;          [ContextMenu (\"Find Cells\")] #if UNITY_EDITOR         void FindCells () {             Cells = FindObjectsOfType&lt;CellView> ();             Debug.Log ($\"Successfully found {Cells.Length} cells!\");         } #endif     } }<\/code><\/pre>\n<p>\u0411\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u044f \u044d\u0442\u043e\u043c\u0443 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u043d\u043e\u043c\u0443 \u043c\u0435\u043d\u044e \u043c\u044b \u0441\u043c\u043e\u0436\u0435\u043c \u0437\u0430\u0440\u0430\u043d\u0435\u0435 \u043d\u0430\u0439\u0442\u0438 \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u043a\u043b\u0435\u0442\u043a\u0438 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0438 \u043d\u0430 \u0441\u0442\u0430\u0440\u0442\u0435 \u0438\u0433\u0440\u044b, \u043d\u043e \u0437\u0430\u0447\u0435\u043c \u0435\u0433\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0442\u044c, \u0435\u0441\u043b\u0438 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u043f\u0430\u0440\u0443 \u043c\u0438\u043d\u0443\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u043d\u0430 \u043a\u0435\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0443\u0441\u043a\u043e\u0440\u0435\u043d\u0438\u0435 \u0441\u0442\u0430\u0440\u0442\u0430?<\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0441\u0435\u0442\u043a\u0443, \u043b\u0443\u0447\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class GridService {         readonly int[] _cells;         readonly int _width;         readonly int _height;                  public GridService (int width, int height) {             _cells = new int[width * height];             _width = width;              _height = height;         }          public (int, bool) GetCell (Int2 coords) {             var entity = _cells[_width * coords.Y + coords.X] - 1;             return (entity, entity >= 0);         }                  public void AddCell (Int2 coords, int entity) {             _cells[_width * coords.Y + coords.X] = entity + 1;         }     } } <\/code><\/pre>\n<p>\u0422\u0430\u043a\u0436\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 Int2 \u0434\u043b\u044f \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0434\u0432\u0443\u0445 \u0446\u0435\u043b\u044b\u0445 \u0447\u0438\u0441\u0435\u043b. \u041e\u043d\u0430 \u0431\u0443\u0434\u0435\u0442 \u0431\u043e\u043b\u0435\u0435 \u043f\u0440\u043e\u0441\u0442\u0430\u044f, \u0447\u0435\u043c \u0448\u0442\u0430\u0442\u043d\u044b\u0439 Vector2Int.<\/p>\n<pre><code class=\"cs\">namespace Client {     struct Int2 {         public int X;         public int Y;          public Int2 (int x, int y) {             X = x;             Y = y;         }          public static Int2 operator + (Int2 a, Int2 b) {             return new Int2 (a.X + b.X, a.Y + b.Y);         }          public static Int2 operator * (Int2 a, int multiplier) {             return new Int2 (a.X * multiplier, a.Y * multiplier);         }     } }<\/code><\/pre>\n<p>\u041c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u0435 \u043d\u0430 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u0438, \u043d\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0441 API \u0434\u043b\u044f \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u043a\u043b\u0435\u0442\u043e\u043a.<\/p>\n<pre><code class=\"cs\">namespace Client {  \/\/ \u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u043a\u043b\u0435\u0442\u043a\u0438.     struct Cell {         public CellView View;     } }<\/code><\/pre>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0438\u043d\u0438\u0442-\u0441\u0438\u0441\u0442\u0435\u043c\u0443, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u0430.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class GridInitSystem : IEcsInitSystem {         readonly EcsCustomInject&lt;GridService> _gs = default;         readonly EcsCustomInject&lt;SceneData> _sceneData = default;                readonly EcsPoolInject&lt;Cell> _cellPool = default;          public void Init (EcsSystems systems) {             var world = _cellPool.Value.GetWorld ();             for (var i = 0; i &lt; _sceneData.Value.Cells.Length; i++) {                 var cellView = _sceneData.Value.Cells[i];                 var entity = world.NewEntity ();                 ref var cell = ref _cellPool.Value.Add (entity);                 var position = cellView.transform.position;                 var x = (int) (position.x \/ cellView.XzStep);                 var y = (int) (position.z \/ cellView.XzStep);                 cell.View = cellView;                 _gs.Value.AddCell (new Int2 (x, y), entity);             }         }     } }<\/code><\/pre>\n<p>\u041e\u0442\u043b\u0438\u0447\u043d\u043e, \u043c\u044b \u0441\u043e\u043e\u0440\u0443\u0434\u0438\u043b\u0438 \u0441\u0435\u0440\u0432\u0438\u0441 \u043a\u0430\u0440\u0442\u044b \u0438 \u0441\u043e\u0431\u0440\u0430\u043b\u0438 \u0432 \u043d\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043e \u043a\u043b\u0435\u0442\u043a\u0430\u0445 \u043d\u0430 \u0441\u0446\u0435\u043d\u0435.<\/p>\n<p>\u0422\u0435\u043f\u0435\u0440\u044c \u0434\u0430\u0432\u0430\u0439\u0442\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 TimeService, &#8212; \u043d\u0435\u043a\u0443\u044e \u0430\u0431\u0441\u0442\u0440\u0430\u043a\u0446\u0438\u044e \u043e\u0442 \u0432\u0440\u0435\u043c\u0435\u043d\u0438 Unity &#8212; \u0434\u0430\u043d\u043d\u044b\u0435 \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u043a\u0430\u0434\u0440\u0430.<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class TimeService {         public float Time;         public float DeltaTime;         public float UnscaledDeltaTime;         public float UnscaledTime;     } }<\/code><\/pre>\n<pre><code class=\"cs\">namespace Client {     sealed class TimeSystem : IEcsRunSystem {         readonly EcsCustomInject&lt;TimeService> _ts = default;          public void Run (EcsSystems systems) {             _ts.Value.Time = Time.time;             _ts.Value.UnscaledTime = Time.unscaledTime;             _ts.Value.DeltaTime = Time.deltaTime;             _ts.Value.UnscaledDeltaTime = Time.unscaledDeltaTime;         }     } }<\/code><\/pre>\n<p>\u041d\u0435 \u0437\u0430\u0431\u0443\u0434\u044c\u0442\u0435 \u043e\u0431\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0442\u0430\u0440\u0442\u0430\u043f, \u0434\u043e\u0431\u0430\u0432\u0438\u0432 \u0442\u0443\u0434\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u0441\u0435\u0440\u0432\u0438\u0441\u043e\u0432 \u0438 \u043d\u043e\u0432\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c:<\/p>\n<pre><code class=\"cs\">namespace Client {     sealed class Game : MonoBehaviour {         [SerializeField] SceneData _sceneData;         [SerializeField] Configuration _configuration;         EcsSystems _systems;          void Start () {             var world = new EcsWorld ();             _systems = new EcsSystems (world);             var ts = new<\/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-331943","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331943","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=331943"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/331943\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=331943"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=331943"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=331943"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}