amethyst / specs

Specs - Parallel ECS
https://amethyst.github.io/specs/
Apache License 2.0
2.49k stars 219 forks source link

[Question] Is it possible to group components together (to all be accessed by 1 system) #750

Closed DaQueenJodi closed 11 months ago

DaQueenJodi commented 2 years ago

I have a lot of *_Animation components and I want them all to be accessed by my Animator system is there a way I can group them together similar to how you can group entities together with NullStorage components? I want to do something like this:

impl<'a> System<'a> for Animator {
    type SystemData = (
        WriteStorage<'a, Animation>, // this is the group of animations
        WriteStorage<'a, Sprite>,
        ReadStorage<'a, AnimationState>,
    );
}
torkleyy commented 2 years ago

I think you could use something like this:

type AnimationData<'a> = (WriteStorage<'a, AnimationComponent1>, WriteStorage<AnimationComponent2>);

and then use AnimationData in your system.

DaQueenJodi commented 2 years ago

thanks that's exactly what I was looking for!

Imberflur commented 11 months ago

closing since the question was answered