bevy-magic
Education is experience, and the essence of experience is self-reliance. - "The Once and Future King" by T.H. White
A lightweight spellcasting system built on Bevy. It provides abstractions for spells, runes, and a simple message-driven cast pipeline.
[!NOTE] This is mainly for my personal use and future use, however, you may use it in your projects or contribute if you find it useful!
Use
[]
= "0.18"
= "0.18"
Example
Below is a minimal example illustrating configuration of the plugin, definition of custom runes, creation of a spell, and triggering a cast in a Bevy app.
use *;
use ;
// --- custom rune types -----------------------------------------------------
// --- app setup -------------------------------------------------------------
// For on-demand (event-driven) enchanting, use:
// commands.trigger_enchantment(source_entity, "Burning Aura", Some(vec![target_entity]));
// after applying the enchantment with `.with_trigger(EnchantmentTrigger::OnDemand)`.
// `source_entity` is the enchanted object (e.g. sword), and `targets` are the entities
// affected by the triggered effect (e.g. hit enemy).
You can also drop spell files (RON) into assets/spells/ and load them with AssetServer.
Timing: Delays and Intervals
Runes support per-rune delays and intervals. When a spell is cast, the plugin automatically schedules each rune on the caster's ActiveSpells component and ticks them each frame.
When this rune is part of a spell:
- The first execution is delayed by 0.5 seconds.
- Then it repeats every 1.0 second.
Runes without timing (both delay() and interval() return Duration::ZERO) execute
immediately and once, just like the DamageRune example above.
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
License
MIT License. See the LICENSE file for details.