bevy_logic
A logic gate simulation plugin for bevy.
Features
- A
LogicGraphresource for sorting (potentially cyclic) logic gate circuits. - A fixed timestep
LogicUpdateschedule that works just like bevy'sFixedUpdate. - A ternary approach to
Signal, enabling non-boolean circuits and analog machines. LogicGatetrait queries.- Builder traits for
WorldandCommandsthat ease gate hierarchy construction. Commands for synchronizing a graph with the game world.- Modular plugin design. Pick and choose which features you need.
Running examples
cargo run --release --example cycles
Quickstart
Add the LogicSimulationPlugin to your app, and configure the Time<LogicStep> resource
to tick at the desired speed.
const STEPS_PER_SECOND: f64 = 30.0;
app.add_plugins
.insert_resource;
Custom logic gates
You can create your own logic gates by implementing the LogicGate trait...
use *;
/// The XOR gate emits a signal if the number of "truthy" inputs is odd.
;
And then registering the component with bevy_trait_query...
;
You can use the logic::commands module to spawn gates and fans,
and then connect fans with wires. Make sure to compile() the logic graph.
Bevy Compatibility
bevy |
bevy_logic |
|---|---|
| 0.14 | 0.7.x |
| 0.13.2 | 0.6.x |