An experimental, status effects-as-entities system for Bevy.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 28 lines 962 B view raw
1use crate::{AddEffectCommand, Effecting}; 2use bevy_ecs::prelude::*; 3use bevy_ecs::ptr::MovingPtr; 4use bevy_ecs::spawn::SpawnableList; 5 6/// A wrapper over a [`Bundle`] indicating that an effect should be applied with that [`Bundle`]. 7/// This is intended to be used in [`EffectedBy::spawn`](SpawnRelated::spawn). 8/// 9/// This *might* spawn a new entity, depending on what effects are already applied to the target. 10/// # Example 11#[doc = include_str!("../docs/effected_by_spawn_example.md")] 12#[derive(Default)] 13pub struct Effect<B: Bundle>(pub B); 14 15// Todo This is probably bad practice/has larger performance cost. 16impl<B: Bundle + Clone> SpawnableList<Effecting> for Effect<B> { 17 fn spawn(this: MovingPtr<'_, Self>, world: &mut World, target: Entity) { 18 let bundle = this.read(); 19 world.commands().queue(AddEffectCommand { 20 target, 21 bundle: bundle.0, 22 }); 23 } 24 25 fn size_hint(&self) -> usize { 26 0 27 } 28}