BOnce class
Runs action only once for the lifetime of this instance and then is
considered finished (returns true from then on).
Useful for one-shot steps inside a sequence (BList) or when combined with BInterval to run periodically:
BList(
behaviors: [
BOnce(action: (dt, comp, game) => comp.animation?.playOnce(attackAnim)),
BMoveToComponent(target: player),
],
)
Note: since the "once" state lives in the instance, keep your behavior list in a
late finalfield so it isn't recreated every frame.
Constructors
- BOnce({required void action(double dt, GameComponent comp, BonfireGameInterface game), dynamic id})
Properties
- action → void Function(double dt, GameComponent comp, BonfireGameInterface game)
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- id → dynamic
-
finalinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
process(
double dt, GameComponent comp, BonfireGameInterface game) → bool -
Processes this behavior for the current frame.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited