Add Dirty plates and sink. Dirty plates don't accept food

This commit is contained in:
JonShard
2026-07-17 11:52:21 +02:00
parent b0fd26f3da
commit 840908e9ff
13 changed files with 277 additions and 9 deletions
+7 -2
View File
@@ -1,5 +1,7 @@
class_name ItemContainer
extends Node3D
@export var enabled: bool = true
@export var target_group : String # Items with this tag can be added to the container
@export var meal_positions: Array[Node3D] = []
@export var side_positions: Array[Node3D] = []
@@ -12,7 +14,6 @@ extends Node3D
var contained_items: Array[FoodItem] # Expose nice list of others to read
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
area_3d.body_entered.connect(_on_body_entered)
@@ -23,9 +24,13 @@ func _ready() -> void:
func _on_body_entered(body: Node3D) -> void:
print("Container enabled: ", enabled)
if not enabled:
print("Container disabled in _on_body_entered body")
return
if not body.is_in_group(target_group):
return
print("Container _on_body_entered body: ", body)
var picked_by = xr_pickable.get_picked_up_by()
if picked_by and picked_by.is_in_group("station"):
+51
View File
@@ -2,6 +2,7 @@
[ext_resource type="Script" uid="uid://bfrlpbsqg5lqr" path="res://addons/godot-xr-tools/objects/pickable.gd" id="1_nq5sa"]
[ext_resource type="PackedScene" uid="uid://du31pqeytu8as" path="res://Containers/container.tscn" id="1_s5yhh"]
[ext_resource type="Script" uid="uid://iqjqsk4v6qfh" path="res://Containers/plate_controller.gd" id="1_vjsmi"]
[ext_resource type="PackedScene" uid="uid://c25yxb0vt53vc" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_left.tscn" id="2_3bkoa"]
[ext_resource type="Animation" uid="uid://db62hs5s4n2b3" path="res://addons/godot-xr-tools/hands/animations/left/Grip 4.res" id="3_6v47p"]
[ext_resource type="Script" uid="uid://dvobm6vcfnqe8" path="res://addons/godot-xr-tools/hands/poses/hand_pose_settings.gd" id="4_dhtvl"]
@@ -22,12 +23,18 @@ script = ExtResource("4_dhtvl")
closed_pose = ExtResource("6_el51w")
metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_vlqg6"]
albedo_color = Color(0.36656043, 0.16690676, 0.12531222, 1)
[node name="Plate" type="RigidBody3D" unique_id=190487773]
collision_layer = 4
collision_mask = 196615
freeze_mode = 1
script = ExtResource("1_nq5sa")
[node name="PlateController" type="Node" parent="." unique_id=1503264193]
script = ExtResource("1_vjsmi")
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1365637864]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.007171631, 0)
shape = SubResource("CylinderShape3D_kek77")
@@ -83,3 +90,47 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.08457637, 0, 0.08950478)
[node name="Slot4" type="Node3D" parent="Container/SidePositions" unique_id=379534402]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06938871, 0, 0.072598234)
[node name="Dirty" type="Node3D" parent="." unique_id=319270152]
visible = false
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="Dirty" unique_id=1075901752]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.074060306, -1.4901161e-08, -0.021821946)
radius = 0.02
height = 0.005
sides = 16
material = SubResource("StandardMaterial3D_vlqg6")
[node name="CSGCylinder3D2" type="CSGCylinder3D" parent="Dirty" unique_id=1566886557]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.035480514, 0, 0.09590546)
radius = 0.04
height = 0.005
sides = 16
material = SubResource("StandardMaterial3D_vlqg6")
[node name="CSGCylinder3D3" type="CSGCylinder3D" parent="Dirty" unique_id=1761966340]
transform = Transform3D(0.9644101, 0.26441094, 0, -0.26441094, 0.9644101, 0, 0, 0, 1, -0.11377221, 0.005669184, 0.010442272)
radius = 0.05
height = 0.005
sides = 16
material = SubResource("StandardMaterial3D_vlqg6")
[node name="CSGCylinder3D4" type="CSGCylinder3D" parent="Dirty" unique_id=1869071428]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.023516195, 0, -0.088724144)
radius = 0.024
height = 0.005
sides = 16
material = SubResource("StandardMaterial3D_vlqg6")
[node name="CSGTorus3D" type="CSGTorus3D" parent="Dirty" unique_id=753275027]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0009794924, -0.005010009, -0.0004204195)
inner_radius = 0.10664626
outer_radius = 0.14543402
sides = 16
material = SubResource("StandardMaterial3D_vlqg6")
[node name="CSGPolygon3D" type="CSGPolygon3D" parent="Dirty" unique_id=280929999]
transform = Transform3D(0.21189868, 0, 0, 0, -9.2623855e-09, 0.21189868, 0, -0.21189868, -9.2623855e-09, -0.04347625, 0, 0.017095774)
polygon = PackedVector2Array(-0.053057775, 0.2586278, 0.09469998, 0.40791017, 0.31746316, 0.26044407, 0.4514293, -0.05809097, 0.105977096, -0.11683442, -4.3913722e-05, 0.02302903)
depth = 0.02
material = SubResource("StandardMaterial3D_vlqg6")
+21
View File
@@ -0,0 +1,21 @@
class_name PlateController
extends Node
@onready var dirty_node: Node3D = $"../Dirty"
@onready var container: ItemContainer = $"../Container"
@export var is_dirty: bool = false
func _ready() -> void:
if not dirty_node:
push_error("Plate is missing its dirty_node")
dirty_node.visible = is_dirty
func _process(delta: float) -> void:
if is_dirty:
container.enabled = false
dirty_node.visible = true
else:
container.enabled = true
dirty_node.visible = false
+1
View File
@@ -0,0 +1 @@
uid://iqjqsk4v6qfh
+16 -2
View File
@@ -12,6 +12,8 @@
[ext_resource type="PackedScene" uid="uid://bp3v1jl8pctro" path="res://Containers/plate.tscn" id="10_ay2w6"]
[ext_resource type="PackedScene" uid="uid://dpot5qie20vf6" path="res://Items/burger.tscn" id="11_qn1ku"]
[ext_resource type="PackedScene" uid="uid://b3m2ag8g5rj4r" path="res://Items/hamburger.tscn" id="12_hfwnn"]
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://Stations/sink.tscn" id="13_o1b3t"]
[ext_resource type="PackedScene" uid="uid://cnjwtnhwh0i8q" path="res://Scenes/dirt_station.tscn" id="14_irf4n"]
[sub_resource type="BoxShape3D" id="BoxShape3D_vlqg6"]
size = Vector3(5, 0.1, 5)
@@ -93,7 +95,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8162017, 1.6081157, -1.471
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.832131, 0.40028095, -1.4813508)
[node name="Plate" parent="." unique_id=190487773 instance=ExtResource("10_ay2w6")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.72025335, 1.4458435, -1.5107731)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.79203784, 1.6058162, -1.4441451)
[node name="burger" parent="." unique_id=1417604760 instance=ExtResource("11_qn1ku")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.1439226, 1.4195822, -1.2004558)
@@ -108,7 +110,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.1424646, 1.4969791, -1.210
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.1414003, 1.4543622, -1.210453)
[node name="Hamburger" parent="." unique_id=761091445 instance=ExtResource("12_hfwnn")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.18456237, 1.5438088, -1.3716147)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.19655037, 1.623975, -1.4350286)
[node name="PickableObject" parent="." unique_id=1675596942 instance=ExtResource("6_eoxxy")]
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, -0.042440414, 1.4792972, -1.0473135)
@@ -130,3 +132,15 @@ transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6
[node name="PickableObject6" parent="." unique_id=1268843669 instance=ExtResource("6_eoxxy")]
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, -5.293956e-23, -2.6077032e-08, 1.4901161e-08, 1, 0.08126438, 1.4639391, -1.1673055)
[node name="Sink" parent="." unique_id=2055277359 instance=ExtResource("13_o1b3t")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.3140475, 0.9061539, -1.4941733)
[node name="DirtStation" parent="." unique_id=160842153 instance=ExtResource("14_irf4n")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.0864775, 0.8981018, -1.244947)
[node name="Plate2" parent="." unique_id=356790445 instance=ExtResource("10_ay2w6")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.17896795, 1.499024, -1.7930261)
[node name="Plate3" parent="." unique_id=1550985497 instance=ExtResource("10_ay2w6")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.4482152, 1.6058162, -1.1127436)
+15
View File
@@ -0,0 +1,15 @@
extends StaticBody3D
@onready var snap_zone: XRToolsSnapZone = $XRToolsSnapZone
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
snap_zone.has_picked_up.connect(_makeDirty)
func _makeDirty(item) -> void:
var plate: PlateController = item.get_node_or_null("PlateController") as PlateController
if not plate.is_dirty:
plate.is_dirty = true
print("Dirt Station could not find Dirty in: ", item)
+1
View File
@@ -0,0 +1 @@
uid://q7tpwmrbmu1m
+43
View File
@@ -0,0 +1,43 @@
[gd_scene format=3 uid="uid://cnjwtnhwh0i8q"]
[ext_resource type="Script" uid="uid://q7tpwmrbmu1m" path="res://Scenes/dirt_station.gd" id="1_hc1d4"]
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="2_v0ytd"]
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
size = Vector3(0.5, 1, 0.5)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_qn1ku"]
albedo_color = Color(0.45262197, 0.26770625, 0.2601587, 1)
[sub_resource type="BoxMesh" id="BoxMesh_ay2w6"]
material = SubResource("StandardMaterial3D_qn1ku")
size = Vector3(0.5, 1, 0.5)
[sub_resource type="SphereShape3D" id="SphereShape3D_dlkho"]
radius = 0.3
[node name="DirtStation" type="StaticBody3D" unique_id=160842153 groups=["station"]]
script = ExtResource("1_hc1d4")
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1400366312]
shape = SubResource("BoxShape3D_24d3s")
[node name="MeshInstance3D" type="MeshInstance3D" parent="CollisionShape3D" unique_id=55726639]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.008318901, 0, -0.022509098)
mesh = SubResource("BoxMesh_ay2w6")
[node name="Label3D" type="Label3D" parent="CollisionShape3D" unique_id=1251766743]
transform = Transform3D(0.9999992, 0, 0, 0, 0.99999946, 0, 0, 0, 0.9999992, 0.002797456, 0.6309581, -0.2812457)
text = "Dirt"
[node name="XRToolsSnapZone" type="Area3D" parent="." unique_id=333161027 groups=["station"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5270121, 0)
collision_layer = 65536
collision_mask = 65536
script = ExtResource("2_v0ytd")
snap_mode = 1
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
[node name="CollisionShape3D2" type="CollisionShape3D" parent="XRToolsSnapZone" unique_id=1398712192]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, -0.000975132, 0)
shape = SubResource("SphereShape3D_dlkho")
+40
View File
@@ -0,0 +1,40 @@
extends StaticBody3D
const plate_wash_time: float = 3.0
@export var plate_scene : PackedScene
@export_range(0.0, 10.0, 0.1) var wash_speed: float = 1.0
@onready var snap_zone: XRToolsSnapZone = $XRToolsSnapZone
var progress: float = 0.0
func _ready() -> void:
if not plate_scene:
push_error("Sink is missing reference to plate scene")
func _process(delta: float) -> void:
var item = snap_zone.picked_up_object
if not item:
progress = 0
return # Exit early since there's nothing to process
var plate: PlateController = item.get_node_or_null("PlateController") as PlateController
if plate:
# Not dirty? Nothing to wash
if not plate.is_dirty:
return
# Washing logic using the encapsulated property
if progress >= plate_wash_time:
plate.is_dirty = false # This automatically updates visibility and the container state!
print("Sink washing complete!")
else:
progress += wash_speed * delta
print("Sink washing plate: ", progress)
# Sink empty, reset progress
if not snap_zone.picked_up_object:
progress = 0
+1
View File
@@ -0,0 +1 @@
uid://byh5j25mwt3oc
+57
View File
@@ -0,0 +1,57 @@
[gd_scene format=3 uid="uid://dvrk268s7gkxh"]
[ext_resource type="Script" uid="uid://byh5j25mwt3oc" path="res://Stations/sink.gd" id="1_7hh4b"]
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="2_3ocod"]
[ext_resource type="PackedScene" uid="uid://bp3v1jl8pctro" path="res://Containers/plate.tscn" id="2_ai6d4"]
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
[sub_resource type="SphereShape3D" id="SphereShape3D_dlkho"]
radius = 0.3
[node name="Sink" type="StaticBody3D" unique_id=2055277359 groups=["station"]]
script = ExtResource("1_7hh4b")
plate_scene = ExtResource("2_ai6d4")
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=964735164]
shape = SubResource("BoxShape3D_24d3s")
[node name="Label3D" type="Label3D" parent="CollisionShape3D" unique_id=878280948]
transform = Transform3D(0.9999992, 0, 0, 0, 0.99999946, 0, 0, 0, 0.9999992, 0.002797456, 0.6309581, -0.2812457)
text = "Sink
"
[node name="XRToolsSnapZone" type="Area3D" parent="." unique_id=1762550988 groups=["station"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5163779, 0)
collision_layer = 65536
collision_mask = 65536
script = ExtResource("2_3ocod")
snap_mode = 1
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
[node name="CollisionShape3D2" type="CollisionShape3D" parent="XRToolsSnapZone" unique_id=860566355]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, -0.000975132, 0)
shape = SubResource("SphereShape3D_dlkho")
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="." unique_id=311064646]
[node name="CSGBox3D" type="CSGBox3D" parent="CSGCombiner3D" unique_id=1147823280]
[node name="CSGSphere3D" type="CSGSphere3D" parent="CSGCombiner3D" unique_id=2129615695]
transform = Transform3D(1.1506689, 0, 0, 0, 2.7299998, 0, 0, 0, 1, 0, 1.3568852, 0.06031096)
operation = 2
radial_segments = 20
[node name="CSGTorus3D" type="CSGTorus3D" parent="CSGCombiner3D" unique_id=2055166617]
transform = Transform3D(-4.371139e-08, -1, 0, 1, -4.371139e-08, 0, 0, 0, 0.84928787, 0, 0.5107032, -0.20686007)
inner_radius = 0.2
outer_radius = 0.3
sides = 16
[node name="CSGBox3D" type="CSGBox3D" parent="CSGCombiner3D/CSGTorus3D" unique_id=1722820789]
transform = Transform3D(0.5128697, 0, 0, 0, 0.3125893, 0, 0, 0, 1, -0.29027426, 2.3841858e-07, 0)
operation = 2
[node name="CSGBox3D2" type="CSGBox3D" parent="CSGCombiner3D/CSGTorus3D" unique_id=1812160684]
transform = Transform3D(0.7700283, 1.4431469e-09, 0.15563977, 3.974847e-09, 0.3125893, -6.8032304e-09, -0.38511342, 6.1118572e-09, 0.3111993, -0.2084502, 8.34465e-07, 0.36219144)
operation = 2
+3
View File
@@ -1,3 +1,6 @@
- Move recipes into a Yaml file that is read, and handles symetry through a Static manager class?
A `FoodItem` has an ID.
Example:
+20 -4
View File
@@ -11,10 +11,10 @@
"uuid": "94333de9-ebf5-4f38-b95b-9477f4bb9dde",
"title": "Todo",
"tasks": [
"eee1990e-f957-4499-84b6-e68003fcb78e",
"854c7e1e-7521-4bcd-83ff-bb3fecec3142",
"4e2ca8d1-84e1-4913-ad8f-834007d52160",
"a4dd35ae-dc8e-42a3-9044-bf1cb1af281a"
"dd822d14-88e5-4790-808e-7d2cf7f79133",
"784d5cd3-333a-40a9-b35f-3d0c73f00761"
]
},
{
@@ -22,14 +22,16 @@
"title": "Doing",
"tasks": [
"d9cebd68-792e-4d01-a916-7df5f128b4a8",
"cde44fb1-3fdf-4ea0-8267-d28d894e4e7d"
"eee1990e-f957-4499-84b6-e68003fcb78e"
]
},
{
"uuid": "fab8a81b-7ca9-4026-96bb-ed66ea58ef2e",
"title": "Done",
"tasks": [
"4ab36c89-a377-4f25-86a1-ac276aadf4a2"
"4ab36c89-a377-4f25-86a1-ac276aadf4a2",
"cde44fb1-3fdf-4ea0-8267-d28d894e4e7d",
"a4dd35ae-dc8e-42a3-9044-bf1cb1af281a"
]
}
],
@@ -155,6 +157,20 @@
"description": "",
"category": "bf4ec62e-526e-4027-876f-0b22bd17f79a",
"steps": []
},
{
"uuid": "dd822d14-88e5-4790-808e-7d2cf7f79133",
"title": "Decide how to do gestures",
"description": "\n- Pop1 style \n- Ghost tools appear as you get close\n- Physical",
"category": "bf4ec62e-526e-4027-876f-0b22bd17f79a",
"steps": []
},
{
"uuid": "784d5cd3-333a-40a9-b35f-3d0c73f00761",
"title": "Plate rak",
"description": "See if we can use the Container.gd to do this.\nWe could possible change it to support extracting items if that is enabled.",
"category": "bf4ec62e-526e-4027-876f-0b22bd17f79a",
"steps": []
}
],
"layout": {