NSSTC / sim-ecs

Batteries included TypeScript ECS
https://nsstc.github.io/sim-ecs/
Mozilla Public License 2.0
81 stars 12 forks source link

Implement support for Array-Components #40

Closed minecrawler closed 2 years ago

minecrawler commented 2 years ago

The trick is to create an Object known to the system which contains an array of a certain component. Whenever sim-ecs is confronted with this type or object, it knows how to handlw it. The user API could look like this:

createWorld().withComponent(Array(Component)).build();
minecrawler commented 2 years ago

After investigating this for some time, a good implementation leads to a type mess, and there is a simple workaround: create a component which wraps an array. PRs are welcome, if someone comes up with a clever implementation!