Compare commits
5 Commits
88007d247a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8d00b1a40f | ||
|
|
e32a58f416 | ||
|
|
a0efc6b9b8 | ||
|
|
9bab0ff0f3 | ||
|
|
b5d5d4a818 |
@@ -52,10 +52,12 @@ size = Vector3(5.62061, 2.52063, 2.12427)
|
||||
[sub_resource type="SphereShape3D" id="SphereShape3D_c1046"]
|
||||
radius = 0.870929
|
||||
|
||||
[node name="DoubleBeds" type="Node3D" node_paths=PackedStringArray("meshInstance")]
|
||||
[node name="DoubleBeds" type="Node3D" node_paths=PackedStringArray("meshInstance", "ActionNode", "static_body")]
|
||||
script = ExtResource("1_nn5da")
|
||||
meshInstance = NodePath("DoubleBeds")
|
||||
preview_shader = SubResource("ShaderMaterial_dn7et")
|
||||
ActionNode = NodePath("ActionNode")
|
||||
static_body = NodePath("StaticBody3D")
|
||||
|
||||
[node name="DoubleBeds" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(-4.37114e-08, 0, 1, 0, 1, 0, -1, 0, -4.37114e-08, -1.83435, -0.42751, 0)
|
||||
@@ -71,9 +73,10 @@ input_ray_pickable = false
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.218994, -0.287048, 0.10144)
|
||||
shape = SubResource("BoxShape3D_sp2kd")
|
||||
|
||||
[node name="ActionNode" type="Node3D" parent="."]
|
||||
[node name="ActionNode" type="Node3D" parent="." node_paths=PackedStringArray("area")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 1.3739)
|
||||
script = ExtResource("8_c1046")
|
||||
area = NodePath("Area3d")
|
||||
|
||||
[node name="Area3d" type="Area3D" parent="ActionNode"]
|
||||
input_ray_pickable = false
|
||||
@@ -90,4 +93,8 @@ visible = false
|
||||
wait_time = 4.0
|
||||
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"]
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
[gd_scene load_steps=6 format=3 uid="uid://dqrqq5vg8hek3"]
|
||||
[gd_scene load_steps=11 format=3 uid="uid://dqrqq5vg8hek3"]
|
||||
|
||||
[ext_resource type="ArrayMesh" uid="uid://dwd6ylq5xn6kj" path="res://Blends/Person/Person.obj" id="1_11yxf"]
|
||||
[ext_resource type="Script" uid="uid://d308e5vxshc06" path="res://Scripts/person.gd" id="1_dh77o"]
|
||||
[ext_resource type="Shader" uid="uid://bm15rdsdxldwl" path="res://Shaders/shirt.gdshader" id="3_dbviw"]
|
||||
[ext_resource type="Shader" uid="uid://c08eg1piwoy3t" path="res://Shaders/outline.gdshader" id="4_kmh38"]
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kmh38"]
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_tupbo"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("3_dbviw")
|
||||
shader_parameter/shirt_color = Vector3(0, 0, 0)
|
||||
@@ -12,6 +13,30 @@ shader_parameter/shirt_color = Vector3(0, 0, 0)
|
||||
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_dbviw"]
|
||||
points = PackedVector3Array(0.465296, 4.41226, 2.90193, 0.333481, 5.90986, 1.44973, -0.46535, 4.41226, 2.90193, 0.465296, 2.1221, 2.90193, 0.88668, -1.00046, 1.81769, 0.465296, 4.41226, -1.76192, 0.333481, 5.90986, -0.25128, -0.333667, 5.90986, 1.44973, -0.46535, 4.41226, -1.76192, -0.46535, 2.1221, 2.90193, 0.88668, -1.35832, 1.81769, 0.88668, -1.00046, -0.616956, 0.465296, 2.1221, -1.76192, -0.333667, 5.90986, -0.25128, -0.46535, 2.1221, -1.76192, -0.46535, 1.86882, 1.75606, -0.424191, -1.35832, 1.81769, 0.88668, -1.35832, -0.616956, -0.424191, -1.35832, -0.616956, -0.46535, 1.86882, -0.6165)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_8v2cd"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("4_kmh38")
|
||||
shader_parameter/is_active = true
|
||||
shader_parameter/color = Vector3(0.95, 0.71, 0.01)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_kmh38"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("4_kmh38")
|
||||
shader_parameter/is_active = true
|
||||
shader_parameter/color = Vector3(0.95, 0.71, 0.01)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_b8w03"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("4_kmh38")
|
||||
shader_parameter/is_active = true
|
||||
shader_parameter/color = Vector3(0.95, 0.71, 0.01)
|
||||
|
||||
[sub_resource type="ShaderMaterial" id="ShaderMaterial_una45"]
|
||||
render_priority = 0
|
||||
shader = ExtResource("4_kmh38")
|
||||
shader_parameter/is_active = true
|
||||
shader_parameter/color = Vector3(0.95, 0.71, 0.01)
|
||||
|
||||
[node name="Person" type="CharacterBody3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.150706, 0, -0.313651)
|
||||
script = ExtResource("1_dh77o")
|
||||
@@ -19,7 +44,7 @@ script = ExtResource("1_dh77o")
|
||||
[node name="MeshInstance3D" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(-1.31134e-08, 0, 0.3, 0, 0.3, 0, -0.3, 0, -1.31134e-08, 0, 0, 0.368102)
|
||||
mesh = ExtResource("1_11yxf")
|
||||
surface_material_override/1 = SubResource("ShaderMaterial_kmh38")
|
||||
surface_material_override/1 = SubResource("ShaderMaterial_tupbo")
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="."]
|
||||
transform = Transform3D(-1.31134e-08, 0, 0.3, 0, 0.3, 0, -0.3, 0, -1.31134e-08, 0, 0, 0.368102)
|
||||
@@ -33,6 +58,18 @@ debug_enabled = true
|
||||
wait_time = 4.0
|
||||
one_shot = true
|
||||
|
||||
[node name="MeshOutline" type="MeshInstance3D" parent="."]
|
||||
transform = Transform3D(-1.31134e-08, 0, 0.3, 0, 0.3, 0, -0.3, 0, -1.31134e-08, 0, 0, 0.368102)
|
||||
visible = false
|
||||
mesh = ExtResource("1_11yxf")
|
||||
surface_material_override/0 = SubResource("ShaderMaterial_8v2cd")
|
||||
surface_material_override/1 = SubResource("ShaderMaterial_kmh38")
|
||||
surface_material_override/2 = SubResource("ShaderMaterial_b8w03")
|
||||
surface_material_override/3 = SubResource("ShaderMaterial_una45")
|
||||
|
||||
[connection signal="input_event" from="." to="." method="_on_input_event"]
|
||||
[connection signal="mouse_entered" from="." to="." method="_on_mouse_entered"]
|
||||
[connection signal="mouse_exited" from="." to="." method="_on_mouse_exited"]
|
||||
[connection signal="navigation_finished" from="NavigationAgent3D" to="." method="_on_navigation_agent_3d_navigation_finished"]
|
||||
[connection signal="target_reached" from="NavigationAgent3D" to="." method="_on_navigation_agent_3d_target_reached"]
|
||||
[connection signal="timeout" from="Timer" to="." 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="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://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="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"]
|
||||
render_priority = 0
|
||||
@@ -60,13 +62,19 @@ shader_parameter/color = Vector3(0.95, 0.71, 0.01)
|
||||
next_pass = SubResource("ShaderMaterial_dn6sd")
|
||||
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")
|
||||
meshInstance = NodePath("Pot")
|
||||
preview_shader = SubResource("ShaderMaterial_vv7mx")
|
||||
ActionNode = NodePath("ActionNode")
|
||||
static_body = NodePath("StaticBody3D")
|
||||
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="."]
|
||||
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"]
|
||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, 0.916585, 0.0207213)
|
||||
@@ -79,3 +87,19 @@ surface_material_override/0 = SubResource("StandardMaterial3D_dn6sd")
|
||||
surface_material_override/1 = SubResource("StandardMaterial3D_uhv8u")
|
||||
surface_material_override/2 = SubResource("StandardMaterial3D_dn6sd")
|
||||
surface_material_override/3 = SubResource("StandardMaterial3D_rbvpf")
|
||||
|
||||
[node name="ActionNode" type="Node3D" parent="." node_paths=PackedStringArray("area")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -1.26206, 2.41965)
|
||||
script = ExtResource("12_r71lq")
|
||||
area = NodePath("Area3d")
|
||||
|
||||
[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("")
|
||||
|
||||
@@ -43,7 +43,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.138559, 0)
|
||||
navigation_mesh = SubResource("NavigationMesh_ru0md")
|
||||
|
||||
[node name="ground" type="StaticBody3D" parent="Cart-bottom/NavigationRegion3D"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1.12006, 0.135911, 0.169229, -0.0448687)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1.12006, 0.135911, -0.0747662, -0.0448687)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="Cart-bottom/NavigationRegion3D/ground"]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.930367, -0.452148, 0.568024)
|
||||
|
||||
@@ -1,12 +1,24 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://d3l2w1076ttb0"]
|
||||
[gd_scene load_steps=5 format=3 uid="uid://d3l2w1076ttb0"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://tedmijw81j46" path="res://Blends/Items/Food/food.gltf" id="1_613iy"]
|
||||
[ext_resource type="Script" uid="uid://bd3vhk86ac1nu" path="res://Scripts/Items/food_item.gd" id="2_cemcp"]
|
||||
[ext_resource type="Material" uid="uid://detpb4ww2vvsf" path="res://Blends/Items/Food/Material.tres" id="3_cemcp"]
|
||||
|
||||
[node name="food" instance=ExtResource("1_613iy")]
|
||||
[sub_resource type="ConvexPolygonShape3D" id="ConvexPolygonShape3D_cemcp"]
|
||||
points = PackedVector3Array(0.916143, 0.0653669, 0.916143, -1.04586, -0.458043, -1.04586, -0.987529, -0.722254, -0.987529, -1.04586, -0.458043, 1.04586, 0.942723, -0.750116, 0.942926, 1.04586, -0.458043, -1.04586, -0.916143, 0.0653669, -0.916143, -0.916143, 0.0653669, 0.916143, 0.916143, 0.0653669, -0.916143, 0.942723, -0.750116, -0.942926, -0.942723, -0.750116, 0.942926, 1.0134, -0.196704, 1.04617, -1.04617, -0.196704, -1.0134, 1.0134, -0.196704, -1.04617, 1.04586, -0.458043, 1.04586, -1.04617, -0.196704, 1.0134, -0.942723, -0.750116, -0.942926, 0.987529, -0.722254, 0.987529, 1.04617, -0.196704, -1.0134, 0.987529, -0.722254, -0.987529, -0.987529, -0.722254, 0.987529, 1.04617, -0.196704, 1.0134, -1.0132, -0.196704, -1.04617, -1.0132, -0.196704, 1.04617, -0.948223, 0.0324106, -0.948428, 0.948223, 0.0324106, 0.948428, -0.948223, 0.0324106, 0.948428, 0.948223, 0.0324106, -0.948428)
|
||||
|
||||
[node name="food" node_paths=PackedStringArray("mesh") instance=ExtResource("1_613iy")]
|
||||
transform = Transform3D(0.3, -1.53807e-05, 1.30802e-05, 1.53807e-05, 0.3, -5.5671e-06, -1.30802e-05, 5.5671e-06, 0.3, 0, 0, 0)
|
||||
script = ExtResource("2_cemcp")
|
||||
mesh = NodePath("Cube")
|
||||
|
||||
[node name="Cube" parent="." index="0"]
|
||||
[node name="StaticBody3D" type="StaticBody3D" parent="." index="0"]
|
||||
process_mode = 4
|
||||
transform = Transform3D(1, -1.44862e-12, -1.09139e-11, -1.56369e-12, 1, 1.81899e-12, 7.27596e-12, 0, 1, 0, 0, 0)
|
||||
|
||||
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" index="0"]
|
||||
transform = Transform3D(1, 2.18947e-12, 7.27596e-12, 2.07429e-12, 1, -1.81899e-12, -7.27596e-12, 0, 1, 0, 0, 0)
|
||||
shape = SubResource("ConvexPolygonShape3D_cemcp")
|
||||
|
||||
[node name="Cube" parent="." index="1"]
|
||||
surface_material_override/0 = ExtResource("3_cemcp")
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://cyaesj3qjb5um"]
|
||||
[gd_scene load_steps=4 format=3 uid="uid://cyaesj3qjb5um"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bqh6f4f4sc4ba" path="res://Scripts/ui/panel_build_select.gd" id="1_dew6i"]
|
||||
[ext_resource type="Script" uid="uid://3bsllk6udire" path="res://Scripts/button_select_build.gd" id="1_yp16r"]
|
||||
[ext_resource type="Script" uid="uid://di0njko68ahky" path="res://Scripts/ContextMenu.gd" id="3_yve02"]
|
||||
|
||||
[node name="MainGameUi" type="Control"]
|
||||
layout_mode = 3
|
||||
@@ -83,6 +84,42 @@ text = "Shelf"
|
||||
script = ExtResource("1_yp16r")
|
||||
id = 3
|
||||
|
||||
[node name="Panel3" type="Panel" parent="."]
|
||||
visible = false
|
||||
clip_contents = true
|
||||
layout_mode = 0
|
||||
offset_right = 119.0
|
||||
offset_bottom = 92.0
|
||||
script = ExtResource("3_yve02")
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="Panel3"]
|
||||
layout_mode = 1
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel3/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="Button" type="Button" parent="Panel3/ScrollContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Action #1"
|
||||
|
||||
[node name="Button2" type="Button" parent="Panel3/ScrollContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Action #2"
|
||||
|
||||
[node name="Button3" type="Button" parent="Panel3/ScrollContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Action #1"
|
||||
|
||||
[node name="Button4" type="Button" parent="Panel3/ScrollContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Action #1"
|
||||
|
||||
[connection signal="pressed" from="Panel2/HBoxContainer/ButtonCreateBed" to="Panel2/HBoxContainer/ButtonCreateBed" method="_on_pressed"]
|
||||
[connection signal="pressed" from="Panel2/HBoxContainer/ButtonCreatePot" to="Panel2/HBoxContainer/ButtonCreatePot" method="_on_pressed"]
|
||||
[connection signal="pressed" from="Panel2/HBoxContainer/ButtonCreatePot2" to="Panel2/HBoxContainer/ButtonCreatePot2" method="_on_pressed"]
|
||||
|
||||
47
Scripts/ContextMenu.gd
Normal file
47
Scripts/ContextMenu.gd
Normal file
@@ -0,0 +1,47 @@
|
||||
extends Panel
|
||||
|
||||
|
||||
signal show_context_menu
|
||||
signal hide_context_menu
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
Global.show_context_menu.connect(_on_show_menu)
|
||||
Global.hide_context_menu.connect(_on_hide_menu)
|
||||
|
||||
func _on_show_menu():
|
||||
if self.visible != true:
|
||||
show_menu()
|
||||
else:
|
||||
Global.hide_context_menu.emit()
|
||||
func _on_hide_menu():
|
||||
hide_menu()
|
||||
|
||||
|
||||
func show_menu():
|
||||
Global.is_context_menu_active = true
|
||||
self.position = get_viewport().get_mouse_position()
|
||||
get_context_actions()
|
||||
self.visible = true
|
||||
func hide_menu():
|
||||
Global.is_context_menu_active = false
|
||||
self.visible = false
|
||||
|
||||
|
||||
func get_context_actions():
|
||||
var container = $ScrollContainer/VBoxContainer
|
||||
remove_children(container)
|
||||
var newButtons
|
||||
print(Global.object_selected.name)
|
||||
if Global.object_selected.name == "Person":
|
||||
newButtons = PersonAction.get_context_buttons()
|
||||
|
||||
for button in newButtons:
|
||||
container.add_child(button)
|
||||
|
||||
|
||||
func remove_children(object: Node):
|
||||
var children = object.get_children()
|
||||
|
||||
for child in children:
|
||||
object.remove_child(child)
|
||||
1
Scripts/ContextMenu.gd.uid
Normal file
1
Scripts/ContextMenu.gd.uid
Normal file
@@ -0,0 +1 @@
|
||||
uid://di0njko68ahky
|
||||
@@ -5,6 +5,10 @@ signal action_stoped
|
||||
signal object_placed()
|
||||
|
||||
|
||||
@export var area: Area3D
|
||||
var build_name: String = "None"
|
||||
|
||||
|
||||
var can_pick: bool
|
||||
|
||||
var can_store: bool
|
||||
@@ -36,6 +40,7 @@ func set_person_pos(person):
|
||||
for pose in persons_position:
|
||||
if pose.is_free:
|
||||
pose.set_person(person)
|
||||
break
|
||||
|
||||
|
||||
func find_pose(person):
|
||||
|
||||
@@ -1,9 +1,34 @@
|
||||
extends Node3D
|
||||
class_name Item
|
||||
|
||||
|
||||
|
||||
var item_name
|
||||
var shelf_owner
|
||||
var is_being_used: bool
|
||||
|
||||
var outline_material: ShaderMaterial
|
||||
var static_body: StaticBody3D
|
||||
|
||||
func _ready() -> void:
|
||||
set_outline_shader()
|
||||
|
||||
func use():
|
||||
print(str(self) + "is used")
|
||||
|
||||
|
||||
func set_outline_shader():
|
||||
static_body = $StaticBody3D
|
||||
static_body.mouse_entered.connect(_on_mouse_enter)
|
||||
static_body.mouse_exited.connect(_on_mouse_exit)
|
||||
|
||||
func _on_mouse_enter():
|
||||
enable_outline()
|
||||
func _on_mouse_exit():
|
||||
disable_outline()
|
||||
|
||||
|
||||
func enable_outline():
|
||||
outline_material.set_shader_parameter("is_active", true)
|
||||
func disable_outline():
|
||||
outline_material.set_shader_parameter("is_active", false)
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
extends Item
|
||||
|
||||
|
||||
@export var mesh: MeshInstance3D
|
||||
|
||||
func _init() -> void:
|
||||
item_name = "food"
|
||||
is_being_used = false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
outline_material = mesh.get_surface_override_material(0).next_pass
|
||||
set_outline_shader()
|
||||
|
||||
func use():
|
||||
print("Object eaten")
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -11,6 +11,8 @@ var default_shaders: Array
|
||||
#var ActionNode: Node3D
|
||||
var is_placed: bool = false
|
||||
|
||||
var is_selected: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
BuildManager.preview_created.connect(_on_preview_create)
|
||||
BuildManager.object_placed.connect(_on_object_placed)
|
||||
@@ -61,15 +63,19 @@ func _on_object_placed(build_postion):
|
||||
|
||||
|
||||
func enable_outline():
|
||||
Global.object_over_mouse_selected_signal.emit(self)
|
||||
for i in meshInstance.get_surface_override_material_count():
|
||||
var material = meshInstance.get_surface_override_material(i)
|
||||
if material.next_pass != null:
|
||||
meshInstance.get_surface_override_material(i).next_pass.set_shader_parameter("is_active", true)
|
||||
func disable_outline():
|
||||
for i in meshInstance.get_surface_override_material_count():
|
||||
var material = meshInstance.get_surface_override_material(i)
|
||||
if material.next_pass != null:
|
||||
meshInstance.get_surface_override_material(i).next_pass.set_shader_parameter("is_active", false)
|
||||
Global.object_over_mouse_unselected_signal.emit(self)
|
||||
|
||||
if is_selected == false:
|
||||
for i in meshInstance.get_surface_override_material_count():
|
||||
var material = meshInstance.get_surface_override_material(i)
|
||||
if material.next_pass != null:
|
||||
meshInstance.get_surface_override_material(i).next_pass.set_shader_parameter("is_active", false)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,7 +36,7 @@ func _process(delta: float) -> void:
|
||||
#print(self.position.dot(ownRigidBody.position))
|
||||
|
||||
func _input(event: InputEvent) -> void: # zoom control
|
||||
if(event.is_action("camera_zoom")):
|
||||
if(event.is_action("camera_zoom") and !Global.is_context_menu_active):
|
||||
if (event.as_text() == "Mouse Wheel Up"):
|
||||
#self.position = self.position.lerp(Vector3.ZERO,global_delta * 5.0)
|
||||
zoom_pos += global_delta * 45.0
|
||||
|
||||
@@ -22,6 +22,7 @@ func _on_object_placed(build_postion):
|
||||
newObject.static_body.input_ray_pickable = true
|
||||
newObject.global_position = build_postion
|
||||
BuildManager.add_object_to_array(newObject)
|
||||
newObject.ActionNode.create()
|
||||
if newObject.ActionNode != null:
|
||||
newObject.ActionNode.create()
|
||||
#newObject.restore_default_shaders()
|
||||
self.add_child(newObject)
|
||||
|
||||
@@ -6,8 +6,57 @@ extends Node3D
|
||||
|
||||
signal interact(person,interact_object)
|
||||
|
||||
signal object_selected_signal
|
||||
signal object_unselected_signal
|
||||
signal object_over_mouse_selected_signal(object)
|
||||
signal object_over_mouse_unselected_signal(object)
|
||||
|
||||
signal show_context_menu
|
||||
signal hide_context_menu
|
||||
var is_context_menu_active: bool = false
|
||||
|
||||
var object_selected
|
||||
var object_over_mouse
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
interact.connect(_on_interact)
|
||||
|
||||
|
||||
object_selected_signal.connect(_on_object_selected)
|
||||
object_unselected_signal.connect(_on_object_unselected)
|
||||
|
||||
object_over_mouse_selected_signal.connect(_on_mouse_object_selected)
|
||||
object_over_mouse_unselected_signal.connect(_on_mouse_object_unselected)
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event.is_action_released("mouse_click") and !is_context_menu_active:
|
||||
if object_over_mouse != null:
|
||||
object_selected_signal.emit(object_over_mouse)
|
||||
else:
|
||||
object_unselected_signal.emit()
|
||||
if event.is_action_released("right_mouse_click"):
|
||||
show_context_menu.emit()
|
||||
|
||||
func _on_interact(person, object):
|
||||
object.start_action(person, object)
|
||||
if object.name == "ActionNode":
|
||||
object.start_action(person, object)
|
||||
else:
|
||||
object.ActionNode.start_action(person, object)
|
||||
|
||||
func _on_object_selected(object):
|
||||
if object_selected != null and object != object_selected:
|
||||
object_unselected_signal.emit()
|
||||
object_selected = object
|
||||
object_selected.is_selected = true
|
||||
print(object_selected)
|
||||
func _on_object_unselected():
|
||||
if object_selected != null:
|
||||
object_selected.is_selected = false
|
||||
object_selected.disable_outline()
|
||||
object_selected = null
|
||||
|
||||
func _on_mouse_object_selected(object):
|
||||
object_over_mouse = object
|
||||
func _on_mouse_object_unselected(object):
|
||||
object_over_mouse = null
|
||||
|
||||
@@ -11,6 +11,9 @@ func set_person_target_item(person,item_name):
|
||||
result.is_being_used = true
|
||||
person.target_item = result
|
||||
person.set_target(result.shelf_owner)
|
||||
return true
|
||||
else:
|
||||
return null
|
||||
|
||||
|
||||
|
||||
@@ -53,3 +56,5 @@ func get_item_from_id(id):
|
||||
|
||||
|
||||
|
||||
func create_item(item_id):
|
||||
return ItemManager.get_item(0).instantiate()
|
||||
|
||||
@@ -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.visible = false
|
||||
set_person_pos(person)
|
||||
person.set_timer(5)
|
||||
|
||||
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))
|
||||
@@ -18,7 +19,7 @@ func _ready() -> void:
|
||||
|
||||
|
||||
func start_action(person, object):
|
||||
if person.target_action == "take":
|
||||
if person.target_action == "take" or person.target_action == "eat":
|
||||
give_out(person)
|
||||
|
||||
|
||||
@@ -31,9 +32,10 @@ func give_out(person):
|
||||
|
||||
func add_item(item):
|
||||
stored_items.append(item)
|
||||
print(item_poses)
|
||||
|
||||
for pose in item_poses:
|
||||
if pose.is_free:
|
||||
print(pose)
|
||||
pose.add_item(item)
|
||||
break
|
||||
|
||||
@@ -46,6 +48,6 @@ func get_item_pose(item):
|
||||
func create():
|
||||
for pose in items_pos_master.get_children():
|
||||
item_poses.append(pose)
|
||||
var newItem = ItemManager.get_item(0).instantiate()
|
||||
ItemManager.add_shelf(self)
|
||||
ItemManager.add_item_to_shelf(self, newItem)
|
||||
ItemManager.add_item_to_shelf(self, ItemManager.create_item(0))
|
||||
ItemManager.add_item_to_shelf(self, ItemManager.create_item(0))
|
||||
|
||||
@@ -25,6 +25,8 @@ var target_item
|
||||
|
||||
var target_action: String
|
||||
|
||||
var is_selected: bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
nav_agent = $NavigationAgent3D
|
||||
meshI = $MeshInstance3D
|
||||
@@ -77,19 +79,28 @@ 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())
|
||||
|
||||
if target_object.name != "ActionNode":
|
||||
target_object.ActionNode.area.body_entered.connect(on_target_reached)
|
||||
else:
|
||||
target_object.area.body_entered.connect(on_target_reached)
|
||||
#nav_agent.target_position = start_pos
|
||||
|
||||
|
||||
func on_target_reached(body):
|
||||
print("I reached ")
|
||||
if body == self:
|
||||
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)
|
||||
func _on_navigation_agent_3d_target_reached() -> void:
|
||||
if target_object != null:
|
||||
print(22)
|
||||
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:
|
||||
@@ -98,6 +109,7 @@ func _on_timer_timeout() -> void:
|
||||
|
||||
|
||||
func hold_item(item):
|
||||
is_holding_item = true
|
||||
var newItem = item.duplicate()
|
||||
holdingItem = newItem
|
||||
holdingItem.position = Vector3(0,0.976, -0.065)
|
||||
@@ -110,5 +122,24 @@ func drop_item():
|
||||
|
||||
func _on_item_received():
|
||||
if holdingItem != null:
|
||||
pass
|
||||
#holdingItem.use()
|
||||
if target_action == "eat" and holdingItem.name == "food":
|
||||
holdingItem.use()
|
||||
print("I ate it")
|
||||
|
||||
|
||||
|
||||
|
||||
func _on_mouse_entered() -> void:
|
||||
Global.object_over_mouse_selected_signal.emit(self)
|
||||
enable_outline()
|
||||
|
||||
|
||||
func _on_mouse_exited() -> void:
|
||||
if is_selected == false:
|
||||
disable_outline()
|
||||
|
||||
|
||||
func enable_outline():
|
||||
$MeshOutline.visible = true
|
||||
func disable_outline():
|
||||
$MeshOutline.visible = false
|
||||
|
||||
@@ -1,9 +1,67 @@
|
||||
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.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
|
||||
|
||||
|
||||
func cook(person, object):
|
||||
person.set_timer(5)
|
||||
|
||||
|
||||
@@ -15,4 +15,5 @@ func add_item(new_item):
|
||||
|
||||
|
||||
func remove_item():
|
||||
is_free = true
|
||||
self.remove_child(item)
|
||||
|
||||
@@ -59,3 +59,8 @@ test={
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":97,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
right_mouse_click={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(92, 20),"global_position":Vector2(101, 68),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user