>>107016482
>>107017890
>>107017959
>>107018627
ecs is dumb because it obscures the true type of something and if you believe in ecs you're dumb. like struct Player, struct Enemy, ends up only existing in the programmers head and in the code its a collection of components.
just do
struct Game_State {.
std::vector<Player> players;
std::vector<Enemy> enemies;
std::vector<Lights> lights;
std::vector<Camera> cameras;
};
extern void each(std::function<void(Health, Transform)> foreach_comp_lambda);
// statically call on appropriate types
void each(std::function<void(Health, Transform)> foreach_comp_lambda) {
for(auto& ply : game_state.players)
foreach_comp_call(ply.health, ply.position);
for(auto& enemy : game_state.enemies)
foreach_comp_call(enemy.health, enemy.position);
}
// works with inheritance, composition, interfaces, etc. unlike ecs
// complete picture of the final type written in code, static component query lookup
extern void each(std::function<void(IOnEnterGame*)>()));
unfortunately c++ reflection only comes in 26 so it's ugly for now having to implement manually each permutation of the 'each' call, with macros or templates