{"id":13713531,"url":"https://github.com/Falldot/Entitas-Go","last_synced_at":"2025-05-06T23:32:16.170Z","repository":{"id":47088603,"uuid":"403326530","full_name":"Falldot/Entitas-Go","owner":"Falldot","description":"Entitas-Go is a fast Entity Component System Framework (ECS) Go 1.17 port of Entitas v1.13.0 for C# and Unity.","archived":true,"fork":false,"pushed_at":"2021-09-14T04:27:20.000Z","size":22,"stargazers_count":26,"open_issues_count":4,"forks_count":9,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-14T00:33:58.359Z","etag":null,"topics":["design-pattern","design-patterns","ecs","entitas","entitas-go","entity","entity-component","entity-component-system","entity-framework","game","game-development","game-engine","gamedev","go","golang"],"latest_commit_sha":null,"homepage":"","language":"Go","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/Falldot.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}},"created_at":"2021-09-05T14:15:14.000Z","updated_at":"2023-10-13T05:58:07.000Z","dependencies_parsed_at":"2022-08-30T14:31:48.006Z","dependency_job_id":null,"html_url":"https://github.com/Falldot/Entitas-Go","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Falldot%2FEntitas-Go","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Falldot%2FEntitas-Go/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Falldot%2FEntitas-Go/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Falldot%2FEntitas-Go/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Falldot","download_url":"https://codeload.github.com/Falldot/Entitas-Go/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252787531,"owners_count":21804277,"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":["design-pattern","design-patterns","ecs","entitas","entitas-go","entity","entity-component","entity-component-system","entity-framework","game","game-development","game-engine","gamedev","go","golang"],"created_at":"2024-08-02T23:01:38.823Z","updated_at":"2025-05-06T23:32:15.776Z","avatar_url":"https://github.com/Falldot.png","language":"Go","funding_links":[],"categories":["Repositories"],"sub_categories":[],"readme":"# Entitas-Go\n\nEntitas-GO is a fast Entity Component System Framework (ECS) Go 1.17 port of [Entitas v1.13.0 for C# and Unity.](https://github.com/sschmid/Entitas-CSharp)\n\n# Code Generator\n\n1) Install the library in your project\n\n```\ngo get github.com/Falldot/Entitas-Go\n```\n\n2) Create context file, with components.\n```\n//Important! The file should contain this line\n//go:generate go run github.com/Falldot/Entitas-Go\n```\n\n### Game.go\n```golang\npackage main\n\n//go:generate go run github.com/Falldot/Entitas-Go\n\ntype Position struct {\n\tX, Y float64\n}\n\ntype Direction struct {\n\tX, Y float64\n}\n\ntype Speed int\n\ntype Health int\n\ntype Sprite struct {\n\ttag  string\n\tW, H int\n}\n```\n\n3) Use\n```\ngo generate\n```\n\n4) A folder 'Entitas' will be created in your project, please do not edit it\n\n5) Edit the context file, add methods and components, and then use again `go generate`\n\n# Examples\n\n## Entity\n```go\n// main.go file\npackage main\n\nimport (\n\tecs \"myProject/Entitas\"\n)\n\nfunc main() {\n\tcontexts := ecs.CreateContexts()\n    game := contexts.Game()\n\n    // System registration\n    systems := ecs.CreateSystemPool()\n    systems.Add(\u0026Translate{})\n    systems.Add(\u0026ReactiveTranslate{})\n\n    // Create entity\n    player := game.CreateEntity()\n\n    // Add component\n\tplayer.AddPosition(10, 30)\n\tplayer.AddDirection(0, 0)\n\tplayer.AddSpeed(5)\n\n    // Remove component\n    player.RemoveSpeed()\n\n    // Replace component\n    player.ReplacePosition(30, 10)\n\n    // On or Off component\n    player.OffDirection()\n    player.OnDirection()\n\n    // Destroy entity\n    player.Destroy()\n\n    // GameLoop\n    systems.Init(contexts)\n    for true {\n        systems.Execute()\n        systems.Clean()\n    }\n    systems.Exit(contexts)\n}\n```\n\n## System\n```go\ntype Translate struct {\n    group ecs.Group\n}\n\nfunc (s *Translate) Initer(contexts ecs.Contexts) {\n\tgame := contexts.Game()\n    s.group = game.Group(ecs.NewMatcher().AllOf(ecs.Position))\n}\n\nfunc (s *Translate) Executer() {\n\tfor _, e := range s.group.GetEntities() {\n        pos := e.GetPosition()\n\t\te.ReplacePosition(pos.X + 10, pos.X + 10)\n\t}\n}\n```\n\n## Reactive system\n```go\ntype ReactiveTranslate struct {\n}\n\nfunc (s *ReactiveTranslate) Trigger(contexts ecs.Contexts) ecs.Collector {\n\tgame := contexts.Game()\n\treturn game.Collector(ecs.NewMatcher().AllOf(ecs.Position)).OnUpdate().OnAdd()\n}\n\nfunc (s *ReactiveTranslate) Filter(entity *ecs.Entity) bool {\n\treturn entity.Has(ecs.Position)\n}\n\nfunc (s *ReactiveTranslate) Executer(entities []*ecs.Entity) {\n\tfor _, e := range entities {\n\t\tpos := e.GetPosition()\n\t\te.ReplacePosition(pos.X+10, pos.X+10)\n\t}\n}\n```\n\nThe MIT License (MIT)\n=====================\n\nCopyright © 2021 Vladislav Fedotov (Falldot)\n\nPermission is hereby granted, free of charge, to any person\nobtaining a copy of this software and associated documentation\nfiles (the “Software”), to deal in the Software without\nrestriction, including without limitation the rights to use,\ncopy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the\nSoftware is furnished to do so, subject to the following\nconditions:\n\nThe above copyright notice and this permission notice shall be\nincluded in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\nOF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\nHOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\nWHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\nFROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\nOTHER DEALINGS IN THE SOFTWARE.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFalldot%2FEntitas-Go","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FFalldot%2FEntitas-Go","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FFalldot%2FEntitas-Go/lists"}