BlackMATov / ecs.hpp

C++17 Entity Component System
https://blackmatov.github.io/ecs.hpp
MIT License
38 stars 4 forks source link

add component dependencies #44

Open BlackMATov opened 4 years ago

DeirhX commented 3 years ago

Your API looks really slick! So far missing a way to create component dependencies: e.g. I have a turret on a tank that should base its position on the position and rotation of the tank (but also allow its own rotation with regard to the tank). Any way to do it with the existing engine? Seeing the existing sparse containers, all seems to be set up to link things together.

BlackMATov commented 3 years ago

Hello DeirhX! You need hierarchies for your task.

Components: parent, local_transform, world_transform and System: local_to_world to update world_transform from local_transform and parent components.

There are many ways to do it. Some useful links: https://docs.unity3d.com/Packages/com.unity.entities@0.0/manual/transform_system.html https://github.com/amethyst/legion_transform https://skypjack.github.io/2019-08-20-ecs-baf-part-4-insights/

DeirhX commented 3 years ago

Hi BlackMATov, thanks for your response! I'll go brush up my ECS skills. Started my 2D game on as-needed basis but also decided to write every system by hand for it to be a learning experience, especially for compile-time metaprogramming. Went more of a flat-map way but discovering now that more links are needed between entities and also longer-living entities now being introduced, wondering whether a sparse-map you decided to use wouldn't be a better choice to battle fragmentation. Or a colony that some folks are now trying to push into the standard. But prefer to try to understand and write the things myself first, at least as a learning experience.

Did you already use your engine for a full-fledged game of your own? If not, do you think it can already be used as it is? Any further development planned? :)