66 lines
1.6 KiB
GDScript3
66 lines
1.6 KiB
GDScript3
class_name State
|
|
extends Resource
|
|
|
|
export var debug_state: bool = false
|
|
export var timeout_seconds: float = 0.0
|
|
|
|
#signal state_entered()
|
|
#signal state_exited()
|
|
|
|
# Declare member variables here. Examples:
|
|
|
|
var state_timeout: Timer
|
|
var state_ready: bool = true
|
|
|
|
export var name: String
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
# Resources don't have _ready callbacks I think
|
|
# You'd have to use the constructor callback _init
|
|
#func _ready():
|
|
# pass # Replace with function body.
|
|
|
|
#func _init():
|
|
# print ("Am I really a parent's constructor?")
|
|
|
|
# needed because _ready isn't called and state variables aren't
|
|
# populated yet. Don't want to use init or ready because they're
|
|
# too close to _init and _ready so we're going with setup
|
|
func setup():
|
|
# Only add timout node if timer value was specified.
|
|
if(timeout_seconds > 0.0):
|
|
print("init timer...")
|
|
state_timeout = Timer.new()
|
|
state_timeout.wait_time = timeout_seconds
|
|
state_timeout.one_shot = true
|
|
state_timeout.autostart = false
|
|
#add_child(state_timeout)
|
|
#get_tree().get_root().add_child(state_timeout)
|
|
#TODO: Need to figure out how to add this to tree
|
|
#modifier = StateModifier.new()
|
|
|
|
#Hopefully this passes by reference.
|
|
func copy(state: State) -> void:
|
|
state.name = name
|
|
return
|
|
|
|
func enter() -> void:
|
|
print("Got call to enter state ", name)
|
|
if state_timeout != null:
|
|
print(name, "-Starting Timer")
|
|
state_timeout.start()
|
|
pass
|
|
|
|
func exit() -> void:
|
|
pass
|
|
|
|
# Disable to test whether actually needed.
|
|
#func process_input(_event: InputEvent) -> String:
|
|
# return ''
|
|
#
|
|
#func process_frame(_delta: float) -> String:
|
|
# return ''
|
|
#
|
|
#func process_physics(_delta: float) -> String:
|
|
# return ''
|