An experimental, status effects-as-entities system for Bevy.
1use crate::ReflectComponent;
2use bevy_ecs::prelude::{Component, Entity};
3use bevy_reflect::Reflect;
4
5/// Stores the entity that is being effected by this status effect.
6#[derive(Component, Reflect, Eq, PartialEq, Debug, Clone)]
7#[relationship(relationship_target = EffectedBy)]
8#[reflect(Component, PartialEq, Debug, Clone)]
9pub struct Effecting(pub Entity);
10
11/// Stores all the status effects that are effecting this entity.
12#[derive(Component, Reflect, Eq, PartialEq, Debug, Clone)]
13#[relationship_target(relationship = Effecting, linked_spawn)]
14#[reflect(Component, PartialEq, Debug, Clone)]
15pub struct EffectedBy(Vec<Entity>);
16
17impl<'a> IntoIterator for &'a EffectedBy {
18 type Item = <Self::IntoIter as Iterator>::Item;
19
20 type IntoIter = std::slice::Iter<'a, Entity>;
21
22 #[inline(always)]
23 fn into_iter(self) -> Self::IntoIter {
24 self.0.iter()
25 }
26}