{"id":26284109,"url":"https://github.com/judelco/coreecs","last_synced_at":"2025-05-07T12:11:20.497Z","repository":{"id":77849953,"uuid":"210931678","full_name":"JuDelCo/CoreECS","owner":"JuDelCo","description":"Deterministic lightweight ECS framework","archived":false,"fork":false,"pushed_at":"2025-03-26T19:59:58.000Z","size":81,"stargazers_count":18,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-29T00:14:18.960Z","etag":null,"topics":["csharp","design-patterns","ecs","entity","entity-component","entity-component-system","entity-framework","game","game-development","game-engine","gamedev","performance","unity","unity3d"],"latest_commit_sha":null,"homepage":"","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/JuDelCo.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-25T20:10:56.000Z","updated_at":"2025-04-14T01:19:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"262883bb-2f01-41c0-b3d0-8d608d55d5f5","html_url":"https://github.com/JuDelCo/CoreECS","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuDelCo%2FCoreECS","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuDelCo%2FCoreECS/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuDelCo%2FCoreECS/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JuDelCo%2FCoreECS/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JuDelCo","download_url":"https://codeload.github.com/JuDelCo/CoreECS/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252873949,"owners_count":21817714,"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":["csharp","design-patterns","ecs","entity","entity-component","entity-component-system","entity-framework","game","game-development","game-engine","gamedev","performance","unity","unity3d"],"created_at":"2025-03-14T18:21:06.688Z","updated_at":"2025-05-07T12:11:20.489Z","avatar_url":"https://github.com/JuDelCo.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"JuCore ECS\n=====================\n\nJuCore ECS is a deterministic lightweight ECS framework.\n\nIt's heavily inspired in Entitas, but with some differences:\n\n- It's deterministic (does not rely on hashtables)\n- Does not use code generators (no reflection, less problems)\n- Easier to start using it (more straightforward, see documentation below)\n- No GC collections (when reusing destroyed entities)\n- Similar perfomance (10~15% less, but handles well all requirements for a game)\n\nAny feedback is welcome !\n\n\nSee also\n=====================\n\n- [JuCore](https://github.com/JuDelCo/Core) - Core package base (service locator and useful services)\n- [JuCore Math](https://github.com/JuDelCo/CoreMath) - Linear algebra math library, also 2D/3D physics, noise functions and IK\n\n\nInstall\n=====================\n\n- For **Unity**, update the dependencies in the ```/Packages/manifest.json``` file in your project folder by adding:\n\n```json\n\t\"com.judelco.core.ecs\": \"https://github.com/JuDelCo/CoreECS.git#v1.14.0\",\n```\n\n- For native **.NET projects**, **Godot**, etc... run the following command in the console of your .NET project to add the package:\n\n```bash\n\tdotnet add package JuDelCo.Lib.CoreECS\n```\n\n\nDocumentation\n=====================\n\nNote: All components should be structs for best performance and memory efficiency.\n\n#### Defining components\n\n```csharp\npublic struct Speed : IComponent\n{\n\tpublic float value;\n\n\tpublic Speed(float value) // Optional, syntactic sugar for later\n\t{\n\t\tthis.value = value;\n\t}\n}\n```\n\n#### Create a Context\n\n```csharp\n// IMPORTANT: You need to pass the count of component types you will use to the context\nconst int COMPONENT_TYPES_COUNT = 9;\n\nvar context = new Context(Constants.COMPONENT_TYPES_COUNT);\n```\n\n#### Creating entities\n\n```csharp\nvar entity = context.CreateEntity();\n\nentity.Add(new Speed(2f));\n```\n\n#### Entity management\n\n```csharp\nentity.Add(new Position(3, 7));\nentity.Replace(new Health(10));\nentity.Remove\u003cSpeed\u003e();\n\nvar hasSpeed = entity.Has\u003cSpeed\u003e();\nvar healthData = entity.Get\u003cHealth\u003e();\n\n// You can also chain methods!\ncontext.CreateEntity()\n\t.Add(new Speed(2f))\n\t.Add(new Position(3, 7))\n\t.Replace(new Health(10)) // Note: Replace will add the component if doesn't have it yet\n\t.Remove\u003cSpeed\u003e();\n```\n\n#### Group management\n\n```csharp\n// Returns a group containing always all entities with Position and Speed components.\nvar group = context.GetGroup(MatcherGenerator.AllOf\u003cPosition, Speed\u003e());\n\nvar entities = group.GetEntities();\n\nforeach (var e in entities)\n{\n\t// ...\n}\n```\n\n#### Execute systems\n\n```csharp\n// You can also use IInitializeSystem, ICleanupSystem and ITearDownSystem systems\npublic class MovementSystem : IExecuteSystem\n{\n\tprivate IGroup group;\n\n\tpublic MovementSystem(IContext context)\n\t{\n\t\t// You can also use a shorthand for AllOf components!\n\t\t// This is equivalent to: GetGroup(MatcherGenerator.AllOf\u003cPosition, Speed\u003e())\n\t\tgroup = context.GetGroup\u003cPosition, Speed\u003e();\n\t}\n\n\tpublic void Execute()\n\t{\n\t\tforeach (var e in group.GetEntities())\n\t\t{\n\t\t\tvar position = e.Get\u003cPosition\u003e();\n\t\t\tvar speed = e.Get\u003cSpeed\u003e().value;\n\t\t\tposition.x += speed;\n\n\t\t\te.Replace(position);\n\t\t}\n\t}\n}\n```\n\n#### Reactive systems\n\n```csharp\npublic class RenderPositionSystem : ReactiveSystem\n{\n\tprivate IContext context;\n\tprivate IGroup group;\n\n\tpublic RenderPositionSystem(IContext context) : base(context)\n\t{\n\t\tthis.context = context;\n\t}\n\n\tprotected override ICollector GetTrigger(IContext context)\n\t{\n\t\treturn context.GetGroup\u003cPosition, View\u003e().CreateCollector(GroupEvent.Added);\n\t}\n\n\tprotected override bool Filter(IEntity entity)\n\t{\n\t\t// Yes, you can use multiple types in Has\u003cT\u003e method !\n\t\treturn entity.Has\u003cPosition, View\u003e();\n\t}\n\n\tprotected override void Execute(List\u003cIEntity\u003e entities)\n\t{\n\t\tforeach (var e in entities)\n\t\t{\n\t\t\tvar position = e.Get\u003cPosition\u003e();\n\t\t\te.Get\u003cView\u003e().gameObject.transform.position = new Vector3(position.x, position.y, position.z);\n\t\t}\n\t}\n}\n```\n\n\nThe MIT License (MIT)\n=====================\n\nCopyright © 2019-2025 Juan Delgado (@JuDelCo)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in\nall copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\nTHE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjudelco%2Fcoreecs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjudelco%2Fcoreecs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjudelco%2Fcoreecs/lists"}