Cleaner way to access components and entities from entities and components
realtradam opened this issue · 1 comments
realtradam commented
Introduce .entity
and .component
syntax for access if those elements.
Currently to access the first(and oftentimes only) entity that a component is attached to you need to do my_component.entities[0]
and if you need to get some other component from that entity you often do my_component.entities[0].components[FF::Cmp::Other][0]
. With the new proposed optional syntax this would just look like: my_component.entity.component[FF::Cmp::Other]
and would function the same.
Perhaps throw a warning when you are using this syntax to access an array larger then size 1 as oftentimes programmers would want to iterate over those.
realtradam commented
Implemented, and in a kinda cool way :^)