{"id":13663535,"url":"https://github.com/SinyavtsevIlya/NanoECS","last_synced_at":"2025-04-25T17:31:19.044Z","repository":{"id":158411841,"uuid":"177970457","full_name":"SinyavtsevIlya/NanoECS","owner":"SinyavtsevIlya","description":"c#-Unity ECS framework ","archived":false,"fork":false,"pushed_at":"2021-10-16T13:04:08.000Z","size":596,"stargazers_count":129,"open_issues_count":1,"forks_count":5,"subscribers_count":13,"default_branch":"master","last_synced_at":"2024-08-03T05:18:34.000Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SinyavtsevIlya.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2019-03-27T10:24:38.000Z","updated_at":"2024-07-31T17:04:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"36f8587a-ee71-4d44-afd8-3976befab6a3","html_url":"https://github.com/SinyavtsevIlya/NanoECS","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SinyavtsevIlya%2FNanoECS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SinyavtsevIlya%2FNanoECS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SinyavtsevIlya%2FNanoECS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SinyavtsevIlya%2FNanoECS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SinyavtsevIlya","download_url":"https://codeload.github.com/SinyavtsevIlya/NanoECS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224011475,"owners_count":17240941,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-02T05:02:29.969Z","updated_at":"2024-11-10T20:30:45.634Z","avatar_url":"https://github.com/SinyavtsevIlya.png","language":"C#","funding_links":[],"categories":["ECS Libraries","C\\#","Open Source Repositories","Framework"],"sub_categories":["ECS Framework"],"readme":"\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://i.imgur.com/M5RdOCm.png\" alt=\"NanoECS\"\u003e\n\u003c/p\u003e\n\n\u003c!---\u003cp align=\"center\"\u003e\n    \u003cimg src=\"https://discordapp.com/assets/f8389ca1a741a115313bede9ac02e2c0.svg\" alt=\"NanoECS\" width=\"40\" height=\"40\"\u003e\nDiscord IL#6472\n\u003c/p\u003e---\u003e\n\n# NanoECS - C#/Unity entity-component-system framework    \n\n# Features\n\n- Handy and easy-to-read API\n- Reactive components (changing component values triggers collectors, giving you the ability to react to changes in ordered ecs manner)\n- Visual debugging (you can create/change contexts, entities and components inside the editor (Optional))\n- Seamless code gen (code generates on background in a standalone app, no manual actions required)\n- Unique components (singleton-like accessing components via contexts) \n\n# Showcase\n\nThe projects below made with NanoECS and Unity:\n\nMobile strategy **[Save The Earth][STE]**\n\n\u003ca href=\"https://play.google.com/store/apps/details?id=com.gamefirst.free.strategy.save.the.earth\"\u003e\n        \u003cimg src=\"https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/STE.jpg\" alt=\"Save The Earth\" height=\"285\"\u003e\u003c/a\u003e\n\n*(clickable)*\n\nHyper Casual projects:\n\n\u003cp align=\"left\"\u003e\n    \u003ca href=\"http://www.youtube.com/watch?v=ZAdR9D2l9MI\"\u003e\n        \u003cimg src=\"https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/HyperRace.jpg\" alt=\"Hyper Race 3D\" height=\"365\"\u003e\u003c/a\u003e\n    \u003ca href=\"http://www.youtube.com/watch?v=ZGNpU__BdQk\"\u003e\n        \u003cimg src=\"https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/KnifeAway.jpg\" alt=\"Knife Away\" height=\"365\"\u003e\u003c/a\u003e\n    \u003ca href=\"http://www.youtube.com/watch?v=IsTCmLSTZBU\"\u003e\n        \u003cimg src=\"https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/Numio.png\" alt=\"Num.io\" height=\"365\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n*(clickable)*\n\n# First look\n\n## Entity\n\nCreate a new entity:\n\n```csharp\nvar player = contexts.Core.CreateEntity()\t\n    .AddPosition(Vector3.zero)\n    .AddHealth(100)\n    .AddSkin(\"Butterfly\");\n```\n\n## Group\n\nGet entities with \"position\" and \"view\" components and without \"movable\" component:\n\n```csharp\nCoreGroup group = contexts.Core.GetGroup()\n    .With.Position\n    .With.View\n    .Without.Movable;\n```\n\nUsage:\n\nHandle filtered entities:\n\n```csharp\nforeach (e in group) \n{\t\n\tPrint(e.Position.Value);\n\tPrint(e.View.Value);\n\tPrint(e.View.IsMovable);\n}\n```\n\n## Collector\n\nGet all entities with \"Speed\" and \"Position\" **only** when the position value is changed:\n\n```csharp\nCoreCollector collector = contexts.Core.GetGroup()\n    .With.Speed\n    .With.Position\n    .OnPositionChange();\n```\n\nHandle these entities:\n\n```csharp\nforeach (e in collector) \n{\t\n\tPrint(\"My position has changed! : {0}\", e.Position.Value);\n}\ncollector.Clear();\n```\n\n## Accessing component values\n\nexample 1:\n\n```csharp\ne.Position.Value += e.Direction.Value.ToVector3() * e.Speed.Value * delta;\n```\nexample 2:\n\n```csharp\nforeach (var player in defeatedPlayers)\n{\n    player.IsDestroyed = true;\n    player.DefeatsCounter.Value++;\n\n    if (!player.IsAIDriven)\n    {\n\tcontexts.Request.CreateEntity()\n\t    .AddDelay(0.6f)\n\t    .IsGameOverRequest = true;\n    }\n}\n```\n\n# Visual Debugging\n- Reactive editing support (modifiyng component values)\n\n\u003cp align=\"left\"\u003e\n    \u003cimg src=\"https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/NanoEcs_Editor2.gif\" alt=\"entity editor\"\u003e\n\u003c/p\u003e\n\n- Natural auto-complete workflow for adding new components, Foldouts, Create/Destroy buttons  \n\u003cp align=\"left\"\u003e\n    \u003cimg src=\"https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/NanoEcs_Editor.gif\" alt=\"entity editor\"\u003e\n\u003c/p\u003e\n\n- GameObject linking (jump from the entity to the view game object and vice versa)\n- Lists, custom types, enums, Unity Objects are supported\n- Doesn't affect realease builds performance. (And can be disabled / enabled manually in the settings)\n\n# Code Generation\n\n\u003cp align=\"left\"\u003e\n    \u003cimg src=\"https://github.com/SinyavtsevIlya/ShowCaseAssets/blob/main/NanoEcs_Console_p.jpg\" alt=\"entity editor\"\u003e\n\u003c/p\u003e\n\n- Generation works without reflection, so you can generate \u003cb\u003e even if your project doesn't compile at all \u003c/b\u003e \n- Doesn't requere any manual actions from user to trigger generation. Just write the code and see how the new API appears. (Optional)\n- Customizable generation snippets. \n\n## How to use generator?\n- Go to *Packages -\u003e NanoECS -\u003e Generator* and run NanoEcsGenerator\n- Insure that you have a folder named Components somewhere inside your Assets folder\n- Create new component there, for example:\n\n```csharp\nclass Score\n{\n    int value;\n}\n```\n\nGenerator will automatically detect changes and create API fow you.\nYou dont need to leave your IDE, just keep writing your code.\n\nA few tips:\n\n- yes, you dont need to write \"public\" access modifier. It's just a \"blueprint\" for a real component.\n- use camelCase for fields (real property will be PascalCased)\n- Fieldless components (e.g. `class Movable { }`) looks this way in the result: \n```entity.IsMovable = true```\n- you can use namespaces\n- you can use different `contexts` by adding a corresponding attribute(s). If you don't specify any context at all, the first one from `NanoECS settings` will be chosen.\n- if you prefer performance over convicience, you could disable default reactive behavior for component accessors by untiping the toggle in NanoEcs Settings. (But you still able to selectivly use it by applying [Reactive] attribute above your component.\n- if use want to extend generation behavior, you can change code snippets. \n\n## NanoEcs Generator sources\n\nIf you for some reasons want to edit NanoEcs generator, the sources are available [here][generator-link].\n\n# Inspiration and goals\n\nThe framework is inspired a lot by such projects as [Entitas][Entitas-link], [Actors][Actors-link], [LeoECS][LeoECS-link].\n\nBut I found that Entitas has some design problems to me:\n- need of writing `Replace()` methods every time you want to change a component value and make sure reactive system \"know\" about it.\n- `Filter` validation along with Matcher is redundant. User is forced to write both of them to make sure components are still there.\n- `Matcher` declaration has a lot of boilerplate.\n\nThe goal of this project was to make API as much fluent as possible, and keep performance as well.\n\n# Documentation\n\n[Wiki][Wiki-link]\n\n# How to install\n- Create a new Unity Project\n- Open the manifest.json file in the Packages folder inside of the Project\n- Add ```\"com.nanory.nanoecs\": \"https://github.com/SinyavtsevIlya/NanoECS.git\",``` next to ```\"dependencies\": {```\n- Go to *Packages -\u003e NanoECS -\u003e Install* and import ```ProjectStructure.unitypackage```\n\n# Should I use it?\n\n Before making a decision, pay attention to a few points:\n- if you want super performance, just take DOTS.\n- support and bug fixes are active\n- new features are not planned\n\n# Feedback\nIf you find a bug, have some suggestions or just want to discuss, let me know: \n\u003c!--* \u003cb\u003ediscord\u003c/b\u003e [![Discord](https://img.shields.io/discord/565885959598768148.svg)](https://discord.gg/u7zrtq) --\u003e\n* \u003cb\u003eDiscord\u003c/b\u003e  https://discordapp.com/channels/@me/IL#6472/\n* \u003cb\u003egmail\u003c/b\u003e sinyavtsevilya@gmail.com\n\n[Wiki-link]: https://github.com/SinyavtsevIlya/NanoECS/wiki\n[Entitas-link]: https://github.com/sschmid/Entitas-CSharp/blob/master/README.md \"Entitas\"\n[Actors-link]: https://github.com/dimmpixeye/ecs.unity \"Actors\"\n[LeoECS-link]: https://github.com/Leopotam/ecs \"LeoECS\"\n[generator-link]: https://github.com/SinyavtsevIlya/NanoECSGenerator\n[STE]: https://play.google.com/store/apps/details?id=com.gamefirst.free.strategy.save.the.earth\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSinyavtsevIlya%2FNanoECS","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FSinyavtsevIlya%2FNanoECS","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FSinyavtsevIlya%2FNanoECS/lists"}