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

Add component wrapping for non-table values #12

Merged
merged 4 commits into from
Nov 13, 2024

Conversation

hautajoki
Copy link
Collaborator

interface Player extends Tag {}
interface Health extends Wrap<number> {}

add function can now only be used with tags

add<Player>(entity); // works with tags
add<Health>(entity); // use set() for components with data

you can now spawn/insert entities with tags (closes #10):

spawn<[Player, Alive]>();
insert<[Player, Alive]>(entity);

// Trailing tags can be omitted
insert<[Name, Health, Player]>(entity, ["Bob", 100]);

also added reset() to restore initial state while keeping references intact - solves the problem presented in #11

@hautajoki hautajoki requested a review from Ukendio November 12, 2024 15:10
@Ukendio Ukendio merged commit ce4e2de into master Nov 13, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cannot spawn entity with tag component
2 participants