pub trait EffectSystem {
type State;
type Effect;
// Required methods
fn apply(&self, state: &mut Self::State, effect: &Self::Effect);
fn react(
&self,
state: &mut Self::State,
effect: &Self::Effect,
) -> Vec<Self::Effect>;
}Expand description
A game that resolves effects through a queue.
The move logic (Game::apply) builds the initial
effects of a move and calls resolve_effects; the queue does the rest.
Required Associated Types§
Required Methods§
Sourcefn apply(&self, state: &mut Self::State, effect: &Self::Effect)
fn apply(&self, state: &mut Self::State, effect: &Self::Effect)
Applies one effect’s direct consequence to state.
Sourcefn react(
&self,
state: &mut Self::State,
effect: &Self::Effect,
) -> Vec<Self::Effect>
fn react( &self, state: &mut Self::State, effect: &Self::Effect, ) -> Vec<Self::Effect>
After effect is applied, performs state-based actions (deaths,
removals) and returns the follow-up effects they trigger, in
deterministic order. Returned effects are appended to the queue and
resolved later, never inline.