{"id":13528893,"url":"https://github.com/eliasku/ecx","last_synced_at":"2025-04-01T14:33:32.163Z","repository":{"id":86937979,"uuid":"62444536","full_name":"eliasku/ecx","owner":"eliasku","description":"ECX is Entity Component System framework for Haxe","archived":true,"fork":false,"pushed_at":"2019-09-06T19:12:46.000Z","size":199,"stargazers_count":52,"open_issues_count":11,"forks_count":10,"subscribers_count":9,"default_branch":"develop","last_synced_at":"2024-11-02T15:36:32.489Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Haxe","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eliasku.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-07-02T09:51:13.000Z","updated_at":"2024-03-15T06:38:35.000Z","dependencies_parsed_at":"2023-05-29T22:00:12.214Z","dependency_job_id":null,"html_url":"https://github.com/eliasku/ecx","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/eliasku%2Fecx","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasku%2Fecx/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasku%2Fecx/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eliasku%2Fecx/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eliasku","download_url":"https://codeload.github.com/eliasku/ecx/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246655411,"owners_count":20812630,"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-01T07:00:27.622Z","updated_at":"2025-04-01T14:33:27.152Z","avatar_url":"https://github.com/eliasku.png","language":"Haxe","funding_links":[],"categories":["Libraries","Architecture"],"sub_categories":["Haxe"],"readme":"# ecx\n\n[![Lang](https://img.shields.io/badge/language-haxe-orange.svg)](http://haxe.org)\n[![Version](https://img.shields.io/badge/version-v0.1.1-green.svg)](https://github.com/eliasku/ecx)\n[![Dependencies](https://img.shields.io/badge/dependencies-none-green.svg)](https://github.com/eliasku/ecx/blob/master/haxelib.json)\n[![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT)\n\n[![Build Status](https://travis-ci.org/eliasku/ecx.svg?branch=develop)](https://travis-ci.org/eliasku/ecx)\n[![Build Status](https://ci.appveyor.com/api/projects/status/t0ql3d9hjp5f72jt?svg=true)](https://ci.appveyor.com/project/eliasku/ecx)\n\nECX is Entity Component System framework for Haxe\n\n- [Asteroids Example](https://github.com/eliasku/ecx-richardlord-asteroids)\n- [Documentation](https://eliasku.github.io/ecx/api-minimal)\n- [Benchmarks](https://github.com/eliasku/ecx-benchmarks)\n\nLibraries (work in progress):\n- [ecx-common](https://github.com/eliasku/ecx-common): Common utilities\n- [ecx-scene2d](https://github.com/eliasku/ecx-scene2d): Scene graph library example\n\n## World\n\n### Initialization\n\n```haxe\nvar config = new WorldConfig([...]);\nvar world = Engine.createWorld(config, ?capacity);\n```\n\n## Entity\n\nEntity is just integer id value. `0` is reserved as invalid id.\n\n## Service\n\nAll services are known at world creation. World provides possibility to resolve services. `World::resolve` use constant `Class\u003cService\u003e` for resolving. At compile-time these expressions will be translated to lookup array access by constant index with unsafe cast (pseudo example: `cast _services[8]`). For `hxcpp` poiter trick is used to avoid generating `dynamic_cast`.\n\n### Injection\n\nEach service could have dependencies on different services. With `Wire\u003cT:Service\u003e` you could inject your dependencies to instance fields.\n\nFor example we need to inject TimeSystem system to our MovementSystem\n\n```haxe\nclass MovementSystem extends System {\n    var _time:Wire\u003cTimeSystem\u003e;\n    ...\n    override function update() {\n        var dt = _time.dt;\n        ...\n    }\n}\n```\n\n### Family\n\nFor all `System` types.\nFor example we need to track all active(live) entities with components: Transform, Node and Renderable.\n\n```haxe\nclass MovementSystem extends System {\n    var _entities:Family\u003cTransform, Node, Renderable\u003e;\n    ...\n    override function update() {\n        // Note: typeof _entities is Array\u003cEntity\u003e\n        for(entity in _entities) {\n            // only entities with required component will be displayed\n            trace(entity.id);\n        }\n    }\n}\n```\n\nSometimes it could be useful to mark some optional component in Family declaration just for readability.\nYou can wrap each optional Component type in parentheses `()` and it will be ignored by Family, but\nwill be notated.\n\n```haxe\nvar _entities:Family\u003cTransform, Node, Renderable, (Scissors)\u003e;\n```\n\n### System Flags\n\n* `IDLE`: System doesn't override `update` method. Should not be updated.\n* `CONFIG`: System is defined with `@:config` meta. This system is just configurator. It will be deleted after World initialization phase.\n\n## Component\n\nComponent is a way to associate [data] per `Entity`. You could just use component-builders to define your own components.\n\n```haxe\nclass Position extends AutoComp\u003cPoint\u003e {}\n\n/// later just use it like Point class per entity\n_position.get(entity).x = 10;\n```\n\nOr you could create any custom crazy ComponentStorage / ComponentManager.\n\n```haxe\nclass Color extends Service implements Component {\n    // BitmapData is used just to demonstrate that you are not limited to anything to store \u003ccomponent data\u003e per \u003centity\u003e\n    // Each pixel is color for entity\n    var _colors:BitmapData;\n\n    ...\n\n    inline public function get(entity:Entity):Int {\n        _colors.getPixel32(entity.id % _stride, Std.int(entity.id / _stride));\n    }\n\n    ....\n}\n```\n\n**Injection:** World `Component` is `Service`, so you are able to invoke all messages directly to other services.\n**Implementation:** `Component` is just interface, you could iterate all registered components and access their base API per entity. It's handy for automatically cloning or serialization.\n\n## CTTI\n`ServiceType`, `ServiceSpec`, `ComponentType`, `ClassMacroTools`\n\n## RTTI\n`TypeManager` (WIP)\n\n## Debug\n\n`-D ecx_debug` for debugging\n\n`-D ecx_macro_debug` for macro debugging\n\n`-D ecx_report` to get and analyse `ecx_wires.html` and `ecx_matrix.html` report files generated during compilation\n\n## TODO:\n\n- Rethink world initialization:\n- - Are we are ok that instance of service could be created outside by default?\n- Rethink system-flags\n- Delete configurator services\n- Add more information on specific cases of AutoComp\u003cT\u003e\n- Pack\u003cT\u003e for dense storage\n- Entity Generations\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliasku%2Fecx","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feliasku%2Fecx","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feliasku%2Fecx/lists"}