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

Allowing for adding owned switchables to prefabs #378

Open
jtferson opened this issue Apr 16, 2021 · 0 comments
Open

Allowing for adding owned switchables to prefabs #378

jtferson opened this issue Apr 16, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@jtferson
Copy link
Sponsor Contributor

Describe the problem you are trying to solve.
Currently, if we define switchable tags for prefabs, they don't match with the instance entities.

Describe the solution you'd like

struct IdleState { };
struct FlyingState { };
struct FightingState { };
auto ShipBehaviourType = ecs.type("ShipBehaviour");
ShipBehaviourType.add(ecs.component<IdleState>());
ShipBehaviourType.add(ecs.component<FlyingState>());
ShipBehaviourType.add(ecs.component<FightingState>());

auto ShipPrefab = ecs.prefab()
    .add<Weapon>()
    .add_switch(ShipBehaviourType)
    .add_owned(ShipBehaviourType) //<-- Set Switch as owned
    .add_case<IdleState>()
    .add_owned<IdleState>(); //<-- Set Case as owned
ecs.entity("Rocinante")
    .add_instanceof(ShipPrefab)
    .add_case<FightingState>(); //<--- Override the default case

ecs.query<>("SWITCH | FightingState, CASE | FightingState").iter([ ](flecs::iter& It)
{
    //Matches Rocinante with FightingState
});
@jtferson jtferson added the enhancement New feature or request label Apr 16, 2021
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
None yet
Development

No branches or pull requests

1 participant