Skip to content
Discussion options

You must be logged in to vote

The trick is that you need to set the associated type to a type that implements ComponentStorage: currently SparseStorage or TableStorage.

/// Trait for implementable actions
trait Ability:  Component<Storage = SparseStorage>  {}

/// Event type that stores the action that is currently being executed
struct QueuedAbility {
    // Storage is the associated type of the Component trait
    // Here, we're setting it to be the standard enum type
    ability: Box<dyn Ability<Storage = SparseStorage>>,
}

impl QueuedAbility {
    fn new(ability: impl Ability) -> Self {
        QueuedAbility {
            ability: Box::new(ability),
        }
    }
}

#[derive(Component)]
// TableStorage is the d…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by alice-i-cecile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant