Bevy Alchemy
An experimental, status effects-as-entities system for Bevy.
Applying Effects
Effects can be applied using with_effect or with_effects (similar to with_child and with_children respectively).
commands.entity.with_effect;
They can also be added using spawn-style syntax.
commands.spawn;
Effect Modes
For some effects it makes sense to allow stacking, so a single entity could be effected by an effect multiple times.
Other effects should only be applied once, either replacing or merging with the previous one.
This behaviour can be selected using an effect's MergeMode, which has the following cases:
| Mode | Behaviour |
|---|---|
| Stack | Multiple of the same effect can exist at once. |
| Insert | New applications will overwrite the existing one. |
| Merge | New applications are merged with the existing one, using a configurable merge function. |
Effects are considered the same if they have the same name.
Implementing Effects
Effects can be implemented using simple systems. Below is an excerpt from the poison example.
/// Runs every frame and deals the poison damage.
Utility Components
A handful of components are included that are intended to make it easier to create common effects.
| Component | Description |
|---|---|
Lifetime |
A timer that despawns the effect when the timer finishes. |
Delay |
A repeating timer used for the delay between effect applications. |
EffectStacks |
Tracks the number of times a merge-mode effect has been applied to an entity. |
Bevy Version Compatibility
| Bevy | Bevy Alchemy |
|---|---|
0.18 |
0.2 - 0.3 |
0.17 |
0.1 |