update
This commit is contained in:
@@ -4,6 +4,8 @@ extends Node
|
||||
signal action_stoped
|
||||
signal object_placed()
|
||||
|
||||
var build_name: String = "None"
|
||||
|
||||
|
||||
var can_pick: bool
|
||||
|
||||
|
||||
@@ -59,3 +59,18 @@ func _on_object_selected():
|
||||
func add_object_to_array(object):
|
||||
builded_objects.append(object)
|
||||
object_added.emit(object)
|
||||
|
||||
|
||||
func set_person_target_build(build_name, is_free):
|
||||
var result = find_building(build_name, is_free)
|
||||
if result != null:
|
||||
return result
|
||||
else:
|
||||
return result
|
||||
|
||||
func find_building(build_name,is_free):
|
||||
for build in builded_objects:
|
||||
if build.ActionNode.build_name == build_name:
|
||||
if build.ActionNode.can_be_used() == is_free:
|
||||
return build
|
||||
return null
|
||||
|
||||
@@ -4,11 +4,12 @@ func _init() -> void:
|
||||
can_pick = false
|
||||
can_store = false
|
||||
max_person_using = 2
|
||||
|
||||
build_name = "bed"
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
persons_position.append($PersonPos1)
|
||||
persons_position.append($PersonPos2)
|
||||
|
||||
func start_action(person, object):
|
||||
person.visible = false
|
||||
|
||||
17
Scripts/objects/pot_object.gd
Normal file
17
Scripts/objects/pot_object.gd
Normal file
@@ -0,0 +1,17 @@
|
||||
extends Interactable
|
||||
|
||||
|
||||
func _init() -> void:
|
||||
max_person_using = 1
|
||||
build_name = "pot"
|
||||
|
||||
func _ready() -> void:
|
||||
persons_position.append($PersonPos1)
|
||||
|
||||
|
||||
func start_action(person, object):
|
||||
person.action = self
|
||||
person.set_timer(5)
|
||||
|
||||
func stop_action(person, object):
|
||||
print("action stoped")
|
||||
1
Scripts/objects/pot_object.gd.uid
Normal file
1
Scripts/objects/pot_object.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://cpg631v6q60xo
|
||||
@@ -10,6 +10,7 @@ var item_poses: Array
|
||||
func _init() -> void:
|
||||
max_person_using = 1
|
||||
can_store = true
|
||||
build_name = "shelf"
|
||||
func _ready() -> void:
|
||||
self.owner = $".."
|
||||
#object_placed.connect(_on_object_placed.bind(self))
|
||||
|
||||
@@ -79,18 +79,22 @@ func set_target_position():
|
||||
var newPos = target_object.global_position
|
||||
newPos.y = self.position.y
|
||||
nav_agent.target_position = newPos
|
||||
print(target_object.can_be_used())
|
||||
|
||||
#nav_agent.target_position = start_pos
|
||||
|
||||
|
||||
func _on_navigation_agent_3d_target_reached() -> void:
|
||||
if target_object != null:
|
||||
print("I reached a target")
|
||||
is_target_reached = true
|
||||
nav_agent.target_position = self.global_position
|
||||
Global.interact.emit(self, target_object)
|
||||
pass
|
||||
|
||||
func set_timer(time):
|
||||
timer.wait_time = time
|
||||
timer.one_shot = true
|
||||
timer.start()
|
||||
|
||||
func _on_timer_timeout() -> void:
|
||||
if action != null:
|
||||
|
||||
@@ -7,7 +7,17 @@ func get_context_buttons():
|
||||
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():
|
||||
@@ -22,9 +32,31 @@ func go_eat():
|
||||
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.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
|
||||
|
||||
Reference in New Issue
Block a user