update
This commit is contained in:
@@ -92,4 +92,8 @@ visible = false
|
|||||||
wait_time = 4.0
|
wait_time = 4.0
|
||||||
one_shot = true
|
one_shot = true
|
||||||
|
|
||||||
|
[node name="PersonPos2" parent="ActionNode" instance=ExtResource("9_k1k40")]
|
||||||
|
transform = Transform3D(0.0323901, -0.298156, -0.00732965, 0.298245, 0.0323998, 0, 0.000791598, -0.00728678, 0.29991, -0.0940391, 0.820194, -1.60941)
|
||||||
|
visible = false
|
||||||
|
|
||||||
[connection signal="timeout" from="ActionNode/Timer" to="ActionNode" method="_on_timer_timeout"]
|
[connection signal="timeout" from="ActionNode/Timer" to="ActionNode" method="_on_timer_timeout"]
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=20 format=3 uid="uid://bcme5mx8nf5kf"]
|
[gd_scene load_steps=23 format=3 uid="uid://bcme5mx8nf5kf"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://c61rr6to3q566" path="res://Scripts/build_object.gd" id="1_c5d30"]
|
[ext_resource type="Script" uid="uid://c61rr6to3q566" path="res://Scripts/build_object.gd" id="1_c5d30"]
|
||||||
[ext_resource type="ArrayMesh" uid="uid://dqs5joeucls8u" path="res://Blends/Pot/pot.obj" id="1_ps8qt"]
|
[ext_resource type="ArrayMesh" uid="uid://dqs5joeucls8u" path="res://Blends/Pot/pot.obj" id="1_ps8qt"]
|
||||||
@@ -11,6 +11,8 @@
|
|||||||
[ext_resource type="Texture2D" uid="uid://bxgm6oovlxdjq" path="res://Blends/Pot/wood_n.png" id="6_r71lq"]
|
[ext_resource type="Texture2D" uid="uid://bxgm6oovlxdjq" path="res://Blends/Pot/wood_n.png" id="6_r71lq"]
|
||||||
[ext_resource type="Texture2D" uid="uid://run700pxmcyc" path="res://Blends/Pot/brick_t.png" id="7_e7ek7"]
|
[ext_resource type="Texture2D" uid="uid://run700pxmcyc" path="res://Blends/Pot/brick_t.png" id="7_e7ek7"]
|
||||||
[ext_resource type="Shader" uid="uid://c08eg1piwoy3t" path="res://Shaders/outline.gdshader" id="7_gtq0i"]
|
[ext_resource type="Shader" uid="uid://c08eg1piwoy3t" path="res://Shaders/outline.gdshader" id="7_gtq0i"]
|
||||||
|
[ext_resource type="Script" uid="uid://cpg631v6q60xo" path="res://Scripts/objects/pot_object.gd" id="12_r71lq"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://f7nkbsrxy4r6" path="res://Scenes/Prefabs/PersonPos.tscn" id="13_e7ek7"]
|
||||||
|
|
||||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_vv7mx"]
|
[sub_resource type="ShaderMaterial" id="ShaderMaterial_vv7mx"]
|
||||||
render_priority = 0
|
render_priority = 0
|
||||||
@@ -60,13 +62,19 @@ shader_parameter/color = Vector3(0.95, 0.71, 0.01)
|
|||||||
next_pass = SubResource("ShaderMaterial_dn6sd")
|
next_pass = SubResource("ShaderMaterial_dn6sd")
|
||||||
albedo_texture = ExtResource("7_e7ek7")
|
albedo_texture = ExtResource("7_e7ek7")
|
||||||
|
|
||||||
[node name="Pot" type="Node3D" node_paths=PackedStringArray("meshInstance")]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_dn6sd"]
|
||||||
|
radius = 0.870929
|
||||||
|
|
||||||
|
[node name="Pot" type="Node3D" node_paths=PackedStringArray("meshInstance", "ActionNode", "static_body")]
|
||||||
script = ExtResource("1_c5d30")
|
script = ExtResource("1_c5d30")
|
||||||
meshInstance = NodePath("Pot")
|
meshInstance = NodePath("Pot")
|
||||||
preview_shader = SubResource("ShaderMaterial_vv7mx")
|
preview_shader = SubResource("ShaderMaterial_vv7mx")
|
||||||
|
ActionNode = NodePath("ActionNode")
|
||||||
|
static_body = NodePath("StaticBody3D")
|
||||||
|
|
||||||
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.14194, 0)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -2.14194, 0)
|
||||||
|
input_ray_pickable = false
|
||||||
|
|
||||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D"]
|
||||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0.916585, 0.0207213)
|
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0.916585, 0.0207213)
|
||||||
@@ -79,3 +87,18 @@ surface_material_override/0 = SubResource("StandardMaterial3D_dn6sd")
|
|||||||
surface_material_override/1 = SubResource("StandardMaterial3D_uhv8u")
|
surface_material_override/1 = SubResource("StandardMaterial3D_uhv8u")
|
||||||
surface_material_override/2 = SubResource("StandardMaterial3D_dn6sd")
|
surface_material_override/2 = SubResource("StandardMaterial3D_dn6sd")
|
||||||
surface_material_override/3 = SubResource("StandardMaterial3D_rbvpf")
|
surface_material_override/3 = SubResource("StandardMaterial3D_rbvpf")
|
||||||
|
|
||||||
|
[node name="ActionNode" type="Node3D" parent="."]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.26206, 2.41965)
|
||||||
|
script = ExtResource("12_r71lq")
|
||||||
|
|
||||||
|
[node name="Area3d" type="Area3D" parent="ActionNode"]
|
||||||
|
input_ray_pickable = false
|
||||||
|
|
||||||
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="ActionNode/Area3d"]
|
||||||
|
shape = SubResource("SphereShape3D_dn6sd")
|
||||||
|
|
||||||
|
[node name="PersonPos1" parent="ActionNode" instance=ExtResource("13_e7ek7")]
|
||||||
|
transform = Transform3D(-1.31134e-08, 0, 0.3, 0, 0.3, 0, -0.3, 0, -1.31134e-08, 0, -0.452533, -0.708748)
|
||||||
|
visible = false
|
||||||
|
skeleton = NodePath("")
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ extends Node
|
|||||||
signal action_stoped
|
signal action_stoped
|
||||||
signal object_placed()
|
signal object_placed()
|
||||||
|
|
||||||
|
var build_name: String = "None"
|
||||||
|
|
||||||
|
|
||||||
var can_pick: bool
|
var can_pick: bool
|
||||||
|
|
||||||
|
|||||||
@@ -59,3 +59,18 @@ func _on_object_selected():
|
|||||||
func add_object_to_array(object):
|
func add_object_to_array(object):
|
||||||
builded_objects.append(object)
|
builded_objects.append(object)
|
||||||
object_added.emit(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_pick = false
|
||||||
can_store = false
|
can_store = false
|
||||||
max_person_using = 2
|
max_person_using = 2
|
||||||
|
build_name = "bed"
|
||||||
|
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
persons_position.append($PersonPos1)
|
persons_position.append($PersonPos1)
|
||||||
|
persons_position.append($PersonPos2)
|
||||||
|
|
||||||
func start_action(person, object):
|
func start_action(person, object):
|
||||||
person.visible = false
|
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:
|
func _init() -> void:
|
||||||
max_person_using = 1
|
max_person_using = 1
|
||||||
can_store = true
|
can_store = true
|
||||||
|
build_name = "shelf"
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
self.owner = $".."
|
self.owner = $".."
|
||||||
#object_placed.connect(_on_object_placed.bind(self))
|
#object_placed.connect(_on_object_placed.bind(self))
|
||||||
|
|||||||
@@ -79,18 +79,22 @@ func set_target_position():
|
|||||||
var newPos = target_object.global_position
|
var newPos = target_object.global_position
|
||||||
newPos.y = self.position.y
|
newPos.y = self.position.y
|
||||||
nav_agent.target_position = newPos
|
nav_agent.target_position = newPos
|
||||||
print(target_object.can_be_used())
|
|
||||||
|
|
||||||
#nav_agent.target_position = start_pos
|
#nav_agent.target_position = start_pos
|
||||||
|
|
||||||
|
|
||||||
func _on_navigation_agent_3d_target_reached() -> void:
|
func _on_navigation_agent_3d_target_reached() -> void:
|
||||||
if target_object != null:
|
if target_object != null:
|
||||||
|
print("I reached a target")
|
||||||
is_target_reached = true
|
is_target_reached = true
|
||||||
nav_agent.target_position = self.global_position
|
nav_agent.target_position = self.global_position
|
||||||
Global.interact.emit(self, target_object)
|
Global.interact.emit(self, target_object)
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
func set_timer(time):
|
||||||
|
timer.wait_time = time
|
||||||
|
timer.one_shot = true
|
||||||
|
timer.start()
|
||||||
|
|
||||||
func _on_timer_timeout() -> void:
|
func _on_timer_timeout() -> void:
|
||||||
if action != null:
|
if action != null:
|
||||||
|
|||||||
@@ -7,7 +7,17 @@ func get_context_buttons():
|
|||||||
go_eat_button.text = "Go Eat"
|
go_eat_button.text = "Go Eat"
|
||||||
go_eat_button.pressed.connect(go_eat)
|
go_eat_button.pressed.connect(go_eat)
|
||||||
buttons.append(go_eat_button)
|
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
|
return buttons
|
||||||
|
|
||||||
func go_eat():
|
func go_eat():
|
||||||
@@ -22,9 +32,31 @@ func go_eat():
|
|||||||
print("I found food")
|
print("I found food")
|
||||||
Global.hide_context_menu.emit()
|
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):
|
func sleep(person, object, action):
|
||||||
person.action = action
|
person.action = action
|
||||||
person.timer.wait_time = 2.0
|
person.timer.wait_time = 2.0
|
||||||
person.timer.one_shot = true
|
person.timer.one_shot = true
|
||||||
person.timer.start()
|
person.timer.start()
|
||||||
person.timer.timeout.connect(person._on_timer_timeout)
|
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