RewindableState
Inherits: Node
Base class for states to be used with RewindableStateMachine.
Description
Provides multiple callback methods for a state's lifecycle, which can be overridden by extending classes.
Must have a RewindableStateMachine as a parent.
Tutorials
Properties
| Type | Name | Default |
|---|---|---|
| RewindableStateMachine | state_machine |
Methods
| Return Type | Name |
|---|---|
| void | tick(float delta, int tick, bool is_fresh) |
| void | enter(RewindableState previous_state, int tick) |
| void | exit(RewindableState next_state, int tick) |
| bool | can_enter(RewindableState previous_state) |
| void | display_enter(RewindableState previous_state, int tick) |
| void | display_exit(RewindableState next_state, int tick) |
Signals
on_enter ( RewindableState previous_state, int tick, Callable prevent )
Emitted when entering the state
on_tick ( float delta, int tick, bool is_fresh )
Emitted on every rollback tick while the state is active
on_exit ( RewindableState next_state, int tick, Callable prevent )
Emitted when exiting the state
on_display_enter ( RewindableState previous_state, int tick )
Emitted before displaying this state
on_display_exit ( RewindableState next_state, int tick )
Emitted before displaying another state
Property Descriptions
RewindableStateMachine state_machine
The RewindableStateMachine this state belongs to.
read-only
Method Descriptions
void tick ( float delta, int tick, bool is_fresh )
Callback to run a single tick. This method is called by the RewindableStateMachine during the rollback tick loop to update game state.
override to implement game logic
void enter ( RewindableState previous_state, int tick )
Callback for entering the state. This method is called whenever the state machine enters this state.
It is best practice to only modify game state here, i.e. properties that are configured as state in a RollbackSynchronizer.
override to implement game logic reacting to state transitions
void exit ( RewindableState next_state, int tick )
Callback for exiting the state. This method is called whenever the state machine exits this state.
It is best practice to only modify game state here, i.e. properties that are configured as state in a RollbackSynchronizer.
override to implement game logic reacting to state transitions
bool can_enter ( RewindableState previous_state )
Callback for validating state transitions. Whenever the RewindableStateMachine attempts to enter this state, it will call this method to ensure that the transition is valid.
If this method returns true, the transition is valid and the state machine will enter this state. Otherwise, the transition is invalid, and nothing happens.
override to implement custom transition validation logic
void display_enter ( RewindableState previous_state, int tick )
Callback for displaying the state. After each tick loop, the RewindableStateMachine checks the final state, i.e. the state that will be active until the next tick loop. If that state has changed to this one, the RewindableStateMachine will call this method.
override to implement visuals / effects reacting to state transitions
void display_exit ( RewindableState next_state, int tick )
Callback for displaying a different state. After each tick loop, the RewindableStateMachine checks the final state, i.e. the state that will be active until the next tick loop. If that state has changed from this one, the RewindableStateMachine will call this method.
override to implement visuals / effects reacting to state transitions