ReactionTable class final
Reactions keyed by event type: the game's own table of what each event looks and feels like.
The game decides; this only keeps the decisions in one place. A rule
is registered for an event class and is handed every event of that class
and its subclasses, in the order the events happened; an event no rule
names shows nothing. Within one event, rules run in registration order,
so a table written as a list reads the way a switch over the events did.
final table = ReactionTable()
..on<Landed>((r) => r.out.jolts.add(Felt.kick(Vector3(0, -0.1, 0))))
..on<Exploded>((r) {
r.out.bursts.add(Shown(Effects.fire, r.event.at));
r.out.flash = true;
});
final reaction = table.react(events);
A game makes its own table with ReactionTable() and fills it with on.
Constructors
Properties
Methods
-
decide(
Iterable< BusEvent> events, ReactionBuilder out) → void -
Writes what
eventslook like intoout. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
on<
T extends BusEvent> (ReactionRule< T> rule) → void -
Adds
rulefor every event that is aT. -
react(
Iterable< BusEvent> events) → Reaction -
What
eventslook like. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited