An experimental, status effects-as-entities system for Bevy.
1#![doc = include_str!("../README.md")]
2
3mod bundle_inspector;
4mod command;
5mod component;
6mod registry;
7mod relation;
8mod spawnable_list;
9
10use bevy_app::{App, Plugin};
11use bevy_ecs::prelude::*;
12use bevy_reflect::Reflect;
13use bevy_reflect::prelude::ReflectDefault;
14
15use crate::bundle_inspector::BundleInspector;
16pub use command::*;
17pub use component::*;
18pub use registry::*;
19pub use relation::*;
20pub use spawnable_list::*;
21
22/// Setup required types and systems for `bevy_alchemy`.
23pub struct AlchemyPlugin;
24
25impl Plugin for AlchemyPlugin {
26 fn build(&self, app: &mut App) {
27 app.register_type::<EffectMode>()
28 .register_type::<Effecting>()
29 .register_type::<EffectedBy>()
30 .register_type::<Lifetime>()
31 .register_type::<Delay>()
32 .register_type::<TimerMergeMode>()
33 .init_resource::<BundleInspector>()
34 .init_resource::<EffectMergeRegistry>()
35 .add_plugins(TimerPlugin)
36 .add_plugins(StackPlugin);
37 }
38}
39
40/// Describes the logic used when multiple of the same effect are applied to an entity.
41#[derive(Component, Reflect, Eq, PartialEq, Debug, Default, Copy, Clone)]
42#[reflect(Component, PartialEq, Debug, Default, Clone)]
43pub enum EffectMode {
44 /// Multiple of the same effect can exist at once, so when an effect is added, its components will be spawned as a new entity.
45 #[default]
46 Stack,
47 /// When an effect is added, its components will be inserted into a matching effect.
48 /// If there are no matches, the components will be spawned as a new entity.
49 Insert,
50 /// When an effect is added, its components will be merged into any matching effect.
51 /// By default, the incoming component will replace the old one, same as [`Insert`](Self::Insert).
52 /// This can be configured on a per-component basis using the [`EffectMergeRegistry`] resource.
53 ///
54 /// If there are no matching effects, the components will be spawned as a new entity.
55 Merge,
56}