Vast improvements and a working finite state machine, working on new guild member registration.
This commit is contained in:
39
fsm/interact_with_employee.gd
Normal file
39
fsm/interact_with_employee.gd
Normal file
@@ -0,0 +1,39 @@
|
||||
extends StateNode
|
||||
|
||||
@export var employee_name : String = ""
|
||||
@export var speech_bubble : String = ""
|
||||
@export var wait_duration : float = 1
|
||||
@export var interaction_args : Array[String] = []
|
||||
var wait_remaining : float = 0
|
||||
|
||||
var employee : GuildEmployee
|
||||
var actor
|
||||
|
||||
func exit() -> void:
|
||||
actor.show_speech_bubble("")
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if wait_remaining > 0:
|
||||
wait_remaining -= delta
|
||||
if wait_remaining <= 0:
|
||||
wait_remaining = 0
|
||||
employee.interact(self, interaction_args[0])
|
||||
complete_state()
|
||||
|
||||
func execute(subject, ...args : Array) -> void:
|
||||
wait_remaining = wait_duration
|
||||
actor = subject
|
||||
|
||||
if len(args) > 0 and args[0] != "":
|
||||
subject.show_speech_bubble(speech_bubble)
|
||||
|
||||
#TODO: Possibly an error later with preexisting and extended lists
|
||||
for arg in args.slice(1):
|
||||
interaction_args.append(arg)
|
||||
var emp = Guild.hall.employees.get(employee_name)
|
||||
|
||||
if emp == null:
|
||||
printerr("Employee %s not found!" % employee_name)
|
||||
complete_state()
|
||||
else:
|
||||
employee = emp
|
||||
Reference in New Issue
Block a user