A State Nachine whit visual nodes and connections for your game
class_name State extends RefCounted
var _name: String
## Target of state
var target: Node
## Inputs list linked to custom function
var inputs: Array[StateInput]
## Outputs list of the state
var outputs: Array[StateOutput]
## Called when State is created from a State Machine
func _init_state() -> void:
pass
## Called when the State Machine is Ready
func _on_statemachine_ready() -> void:
pass
## Called when [StateOutput] is connected
func _on_enter() -> void:
pass
## Called when any [StateOutput] in state is emited
func _on_exit() -> void:
pass
## This function executes on each frame of the finite state machine's process
func _process(delta: float) -> void:
pass
## This function executes on each frame of the finite state machine's physic process
func _physics_process(delta: float) -> void:
pass
## In case you want to customize how this state handle the
## inputs in your game this is the place to do that.
func _input(event: InputEvent) -> void:
pass
State
var input = StateInput.new(2, Color.AQUA)
var other_input = StateInput.new(MyEnum.Second, Color(0.5, 0.5, 0.5))
func _init() -> void:
input.method = method
other_input.method = other_method
inputs.append(input)
inputs.append(other_input)
func method():
pass
func other_method():
pass
var output = StateOutput.new(2, Color.AQUA, "Return To Menu")
var other_output = StateOutput.new(MyEnum.Second, Color(0.5, 0.5, 0.5), output_name)
func _init() -> void:
inputs.append(output)
inputs.append(other_output)