Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runtime types - ability to define components in runtime (useful mostly for scripting) #13

Open
richardbiely opened this issue Oct 26, 2023 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@richardbiely
Copy link
Owner

No description provided.

@richardbiely richardbiely added the enhancement New feature or request label Nov 15, 2023
@richardbiely richardbiely self-assigned this Nov 27, 2023
@richardbiely
Copy link
Owner Author

richardbiely commented Nov 27, 2023

Technically exists already. We can now define run-time tags because components are defined as entities now.

ecs::World w;
ecs::Entity teamA = w.add(); // entity representing some teamA we made up at run-time
ecs::Entity teamB = w.add(); // entity representing some teamB we made up at run-time
ecs::Entity player1 = w.add();
ecs::Entity player2 = w.add();
ecs::Entity player3 = w.add();
w.add(player1, teamA); // player1 now belongs to teamA
w.add(player2, teamA); // player2 now belongs to teamA
w.add(player3, teamB); // player3 now belongs to teamB

For values, we'd have something like this:

struct IntVal { int value; };
struct FltVal { float value; };
GAIA_ID(IntVal) = w.add<IntVal>();
...
ecs::Entity health = w.add();
ecs::Entity currVal = w.add();
ecs::Entity maxVal = w.add();
w.add(currVal, GAIA_ID(IntVal));
w.add(maxVal, GAIA_ID(IntVal));
w.add(health, currVal, IntVal{ 10 });
w.add(health, maxVal, IntVal{ 100});
w.add(player, health);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Status: In Progress
Development

No branches or pull requests

1 participant