63 lines
1.6 KiB
GDScript
63 lines
1.6 KiB
GDScript
extends Node
|
|
|
|
func get_context_buttons():
|
|
var buttons = Array()
|
|
# go eat
|
|
var go_eat_button = Button.new()
|
|
go_eat_button.text = "Go Eat"
|
|
go_eat_button.pressed.connect(go_eat)
|
|
buttons.append(go_eat_button)
|
|
# go sleep
|
|
var go_sleep_button = Button.new()
|
|
go_sleep_button.text = "Go Sleep"
|
|
go_sleep_button.pressed.connect(go_sleep)
|
|
buttons.append(go_sleep_button)
|
|
|
|
# go cook
|
|
var go_cook_button = Button.new()
|
|
go_cook_button.text = "Go Cook"
|
|
go_cook_button.pressed.connect(go_cook)
|
|
buttons.append(go_cook_button)
|
|
return buttons
|
|
|
|
func go_eat():
|
|
print("I will go eat")
|
|
print(Global.object_selected)
|
|
var selected_person = Global.object_selected
|
|
selected_person.target_action = "eat"
|
|
var result = ItemManager.set_person_target_item(selected_person, "food")
|
|
if result == null:
|
|
print("I cant find food")
|
|
else:
|
|
print("I found food")
|
|
Global.hide_context_menu.emit()
|
|
|
|
func go_sleep():
|
|
print("I will go to sleep")
|
|
var selected_person = Global.object_selected
|
|
selected_person.target_action = "sleep"
|
|
var result = BuildManager.set_person_target_build("bed", true)
|
|
print(result)
|
|
if result != null:
|
|
selected_person.set_target(result.ActionNode)
|
|
else:
|
|
print("I cant find free bed")
|
|
|
|
func sleep(person, object, action):
|
|
person.action = action
|
|
person.timer.wait_time = 2.0
|
|
person.timer.one_shot = true
|
|
person.timer.start()
|
|
person.timer.timeout.connect(person._on_timer_timeout)
|
|
|
|
|
|
func go_cook():
|
|
print("I will go cooking")
|
|
var selected_person = Global.object_selected
|
|
var result = BuildManager.set_person_target_build("pot", true)
|
|
if result != null:
|
|
selected_person.set_target(result)
|
|
else:
|
|
print("I cant find free pot")
|
|
pass
|