Add plates accept MEALS and SIDES
This commit is contained in:
+51
-13
@@ -8,9 +8,10 @@ extends Node3D
|
|||||||
@onready var xr_pickable: XRToolsPickable = get_parent() as XRToolsPickable
|
@onready var xr_pickable: XRToolsPickable = get_parent() as XRToolsPickable
|
||||||
|
|
||||||
@onready var _meal_container: Node3D = $MealContainer
|
@onready var _meal_container: Node3D = $MealContainer
|
||||||
@onready var _sides_container: Node3D = $SidesContainer
|
@onready var _side_container: Node3D = $SidesContainer
|
||||||
|
|
||||||
|
var contained_items: Array[FoodItem] # Expose nice list of others to read
|
||||||
|
|
||||||
var contained_items: Array[FoodItem]
|
|
||||||
|
|
||||||
# Called when the node enters the scene tree for the first time.
|
# Called when the node enters the scene tree for the first time.
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
@@ -21,22 +22,59 @@ func _ready() -> void:
|
|||||||
push_error("XRPickable node not found in container.gd")
|
push_error("XRPickable node not found in container.gd")
|
||||||
|
|
||||||
|
|
||||||
func _on_body_entered (body) -> void:
|
func _on_body_entered(body: Node3D) -> void:
|
||||||
if not body.is_in_group(target_group):
|
if not body.is_in_group(target_group):
|
||||||
return
|
return
|
||||||
print("Body is platable: %s" % body.name)
|
|
||||||
var picked_by = xr_pickable.get_picked_up_by()
|
var picked_by = xr_pickable.get_picked_up_by()
|
||||||
if picked_by and picked_by.is_in_group("station"):
|
if picked_by and picked_by.is_in_group("station"):
|
||||||
print("Container in station")
|
|
||||||
|
# If compatible and enough space, add item
|
||||||
var food_item = body.get_node("FoodItem")
|
var food_item = body.get_node("FoodItem")
|
||||||
if food_item.type == FoodItem.Type.MEAL or food_item.type == FoodItem.Type.SIDE:
|
print("Container in station found %s of type %s: %s" % [target_group, FoodItem.Type.keys()[food_item.type], body.name])
|
||||||
print("Food is meal or side!")
|
if food_item.type == FoodItem.Type.MEAL and _meal_container.get_child_count() < meal_positions.size():
|
||||||
# if we're full of that type:
|
print("Container adding meal")
|
||||||
# return
|
_add_item(body, meal_positions, _meal_container)
|
||||||
# body disble pickable
|
if food_item.type == FoodItem.Type.SIDE and _side_container.get_child_count() < side_positions.size():
|
||||||
# container parent to self
|
print("Container adding side")
|
||||||
# body set position to apropriate slot
|
_add_item(body, side_positions, _side_container)
|
||||||
pass
|
|
||||||
|
|
||||||
|
func _add_item(item: Node3D, positions: Array[Node3D], container_root: Node3D) -> void:
|
||||||
|
var pickable = item as XRToolsPickable
|
||||||
|
var rigidbody = item as RigidBody3D
|
||||||
|
|
||||||
|
# Drop item
|
||||||
|
if pickable:
|
||||||
|
if pickable.is_picked_up():
|
||||||
|
pickable.drop()
|
||||||
|
pickable.enabled = false
|
||||||
|
|
||||||
|
# Freeze the rigid body and disable its collisions so it doesn't fight the container
|
||||||
|
if rigidbody:
|
||||||
|
rigidbody.freeze = true
|
||||||
|
rigidbody.freeze_mode = RigidBody3D.FREEZE_MODE_KINEMATIC
|
||||||
|
rigidbody.process_mode = PROCESS_MODE_DISABLED
|
||||||
|
# Optional: Disable collision layer/mask so it doesn't bump into other food
|
||||||
|
rigidbody.collision_layer = 0
|
||||||
|
rigidbody.collision_mask = 0
|
||||||
|
|
||||||
|
item.reparent(container_root, false) # false = discard global transform
|
||||||
|
|
||||||
|
# Get target position index
|
||||||
|
var target_slot_index = container_root.get_child_count() - 1
|
||||||
|
if target_slot_index < positions.size():
|
||||||
|
item.position = positions[target_slot_index].position
|
||||||
|
item.rotation = positions[target_slot_index].rotation
|
||||||
|
|
||||||
|
# Add to list
|
||||||
|
var food_node = item.get_node_or_null("FoodItem")
|
||||||
|
if food_node:
|
||||||
|
contained_items.append(food_node as FoodItem)
|
||||||
|
|
||||||
|
func clear() -> void:
|
||||||
|
# delete all nodes in containers and contained_items
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
#plate (Pickalbe)
|
#plate (Pickalbe)
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://cucc3gaqu2nab" path="res://Items/Charcoal.tscn" id="8_a0a5b"]
|
[ext_resource type="PackedScene" uid="uid://cucc3gaqu2nab" path="res://Items/Charcoal.tscn" id="8_a0a5b"]
|
||||||
[ext_resource type="PackedScene" uid="uid://7earnjgdmwgx" path="res://Prefabs/cookable_item.tscn" id="10_65ccv"]
|
[ext_resource type="PackedScene" uid="uid://7earnjgdmwgx" path="res://Prefabs/cookable_item.tscn" id="10_65ccv"]
|
||||||
[ext_resource type="Script" uid="uid://coidnv8b2yvxr" path="res://Prefabs/combine_recipe.gd" id="11_recipe"]
|
[ext_resource type="Script" uid="uid://coidnv8b2yvxr" path="res://Prefabs/combine_recipe.gd" id="11_recipe"]
|
||||||
|
[ext_resource type="PackedScene" uid="uid://bfj80jh13t6e5" path="res://Prefabs/food_item.tscn" id="11_vjw41"]
|
||||||
|
|
||||||
[sub_resource type="BoxShape3D" id="BoxShape3D_m1xbq"]
|
[sub_resource type="BoxShape3D" id="BoxShape3D_m1xbq"]
|
||||||
size = Vector3(0.1, 0.1, 0.1)
|
size = Vector3(0.1, 0.1, 0.1)
|
||||||
@@ -37,7 +38,7 @@ ingredient_id = &"cube"
|
|||||||
result = ExtResource("8_a0a5b")
|
result = ExtResource("8_a0a5b")
|
||||||
metadata/_custom_type_script = "uid://coidnv8b2yvxr"
|
metadata/_custom_type_script = "uid://coidnv8b2yvxr"
|
||||||
|
|
||||||
[node name="PickableObject" unique_id=1675596942 instance=ExtResource("1_dbtw8")]
|
[node name="PickableObject" unique_id=1675596942 groups=["platalbe_item"] instance=ExtResource("1_dbtw8")]
|
||||||
|
|
||||||
[node name="CollisionShape3D" parent="." index="0"]
|
[node name="CollisionShape3D" parent="." index="0"]
|
||||||
shape = SubResource("BoxShape3D_m1xbq")
|
shape = SubResource("BoxShape3D_m1xbq")
|
||||||
@@ -58,3 +59,7 @@ id = &"cube"
|
|||||||
recipes = Array[ExtResource("11_recipe")]([SubResource("Resource_i8ixk")])
|
recipes = Array[ExtResource("11_recipe")]([SubResource("Resource_i8ixk")])
|
||||||
|
|
||||||
[node name="CookableItem" parent="." index="5" unique_id=280820828 instance=ExtResource("10_65ccv")]
|
[node name="CookableItem" parent="." index="5" unique_id=280820828 instance=ExtResource("10_65ccv")]
|
||||||
|
|
||||||
|
[node name="FoodItem" parent="." index="6" unique_id=63948206 instance=ExtResource("11_vjw41")]
|
||||||
|
id = "cube"
|
||||||
|
type = 1
|
||||||
|
|||||||
+57
-15
@@ -4,7 +4,7 @@
|
|||||||
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://XROrigin.tscn" id="2_o1b3t"]
|
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://XROrigin.tscn" id="2_o1b3t"]
|
||||||
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://Textures/dev_material_3d.tres" id="3_irf4n"]
|
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://Textures/dev_material_3d.tres" id="3_irf4n"]
|
||||||
[ext_resource type="PackedScene" uid="uid://j7caslh27nor" path="res://Stations/Hob.tscn" id="4_ctden"]
|
[ext_resource type="PackedScene" uid="uid://j7caslh27nor" path="res://Stations/Hob.tscn" id="4_ctden"]
|
||||||
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://Stations/Counter.tscn" id="5_di04w"]
|
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="5_57ppd"]
|
||||||
[ext_resource type="PackedScene" uid="uid://e4i6o5oriecx" path="res://Items/PickupCube.tscn" id="6_eoxxy"]
|
[ext_resource type="PackedScene" uid="uid://e4i6o5oriecx" path="res://Items/PickupCube.tscn" id="6_eoxxy"]
|
||||||
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://Textures/sky/NightSkyHDRI009_16K.tres" id="7_n8fyw"]
|
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://Textures/sky/NightSkyHDRI009_16K.tres" id="7_n8fyw"]
|
||||||
[ext_resource type="PackedScene" uid="uid://c0lknik4noobs" path="res://Items/BurgerBuns.tscn" id="8_rraok"]
|
[ext_resource type="PackedScene" uid="uid://c0lknik4noobs" path="res://Items/BurgerBuns.tscn" id="8_rraok"]
|
||||||
@@ -20,6 +20,13 @@ size = Vector3(5, 0.1, 5)
|
|||||||
material = ExtResource("3_irf4n")
|
material = ExtResource("3_irf4n")
|
||||||
size = Vector3(5, 0.1, 5)
|
size = Vector3(5, 0.1, 5)
|
||||||
|
|
||||||
|
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
|
||||||
|
|
||||||
|
[sub_resource type="BoxMesh" id="BoxMesh_i5j2u"]
|
||||||
|
|
||||||
|
[sub_resource type="SphereShape3D" id="SphereShape3D_dlkho"]
|
||||||
|
radius = 0.3
|
||||||
|
|
||||||
[sub_resource type="Environment" id="Environment_bvwq1"]
|
[sub_resource type="Environment" id="Environment_bvwq1"]
|
||||||
background_mode = 2
|
background_mode = 2
|
||||||
sky = ExtResource("7_n8fyw")
|
sky = ExtResource("7_n8fyw")
|
||||||
@@ -50,14 +57,31 @@ mesh = SubResource("BoxMesh_24d3s")
|
|||||||
[node name="Hob" parent="." unique_id=1687971542 instance=ExtResource("4_ctden")]
|
[node name="Hob" parent="." unique_id=1687971542 instance=ExtResource("4_ctden")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.29336345, 0.8981018, -1.484)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.29336345, 0.8981018, -1.484)
|
||||||
|
|
||||||
[node name="Counter" parent="." unique_id=1487893288 instance=ExtResource("5_di04w")]
|
[node name="Counter" type="StaticBody3D" parent="." unique_id=1487893288 groups=["station"]]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.73186195, 0.8981018, -1.484)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.73186195, 0.8981018, -1.484)
|
||||||
|
|
||||||
[node name="PickableObject" parent="." unique_id=1675596942 instance=ExtResource("6_eoxxy")]
|
[node name="CollisionShape3D" type="CollisionShape3D" parent="Counter" unique_id=692568688]
|
||||||
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, 0.5842906, 1.5761534, -1.8163961)
|
shape = SubResource("BoxShape3D_24d3s")
|
||||||
|
|
||||||
[node name="PickableObject2" parent="." unique_id=713087634 instance=ExtResource("6_eoxxy")]
|
[node name="MeshInstance3D" type="MeshInstance3D" parent="Counter/CollisionShape3D" unique_id=127773521]
|
||||||
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, -0.14558735, 1.5607953, -1.8242048)
|
mesh = SubResource("BoxMesh_i5j2u")
|
||||||
|
|
||||||
|
[node name="Label3D" type="Label3D" parent="Counter/CollisionShape3D" unique_id=149978729]
|
||||||
|
transform = Transform3D(0.9999992, 0, 0, 0, 0.99999946, 0, 0, 0, 0.9999992, 0.002797456, 0.6309581, -0.2812457)
|
||||||
|
text = "Counter"
|
||||||
|
|
||||||
|
[node name="XRToolsSnapZone" type="Area3D" parent="Counter" unique_id=1647380272 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("5_57ppd")
|
||||||
|
snap_mode = 1
|
||||||
|
initial_object = NodePath("../../Plate")
|
||||||
|
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
|
||||||
|
|
||||||
|
[node name="CollisionShape3D2" type="CollisionShape3D" parent="Counter/XRToolsSnapZone" unique_id=969340130]
|
||||||
|
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, -0.000975132, 0)
|
||||||
|
shape = SubResource("SphereShape3D_dlkho")
|
||||||
|
|
||||||
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
|
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
|
||||||
environment = SubResource("Environment_bvwq1")
|
environment = SubResource("Environment_bvwq1")
|
||||||
@@ -68,23 +92,41 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8162017, 1.6081157, -1.471
|
|||||||
[node name="BurgerBunsDispenser" parent="." unique_id=1720683779 instance=ExtResource("9_sq0s2")]
|
[node name="BurgerBunsDispenser" parent="." unique_id=1720683779 instance=ExtResource("9_sq0s2")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.832131, 0.40028095, -1.4813508)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.832131, 0.40028095, -1.4813508)
|
||||||
|
|
||||||
[node name="BurgerBuns2" parent="." unique_id=1909843084 instance=ExtResource("8_rraok")]
|
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.1282921, 1.4976386, -1.0923254)
|
|
||||||
|
|
||||||
[node name="Plate" parent="." unique_id=190487773 instance=ExtResource("10_ay2w6")]
|
[node name="Plate" parent="." unique_id=190487773 instance=ExtResource("10_ay2w6")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.53572595, 1.4458435, -1.135189)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.72025335, 1.4458435, -1.5107731)
|
||||||
|
|
||||||
[node name="burger" parent="." unique_id=1417604760 instance=ExtResource("11_qn1ku")]
|
[node name="burger" parent="." unique_id=1417604760 instance=ExtResource("11_qn1ku")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.91607785, 1.4235804, -1.0899508)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.1439226, 1.4195822, -1.2004558)
|
||||||
|
|
||||||
[node name="burger2" parent="." unique_id=1584460510 instance=ExtResource("11_qn1ku")]
|
[node name="burger2" parent="." unique_id=1584460510 instance=ExtResource("11_qn1ku")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.23121053, 1.4235804, -1.3225337)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.1396115, 1.5300478, -1.2016745)
|
||||||
|
|
||||||
[node name="burger3" parent="." unique_id=1884095916 instance=ExtResource("11_qn1ku")]
|
[node name="burger3" parent="." unique_id=1884095916 instance=ExtResource("11_qn1ku")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.22395861, 1.4235804, -1.1413177)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.1424646, 1.4969791, -1.210453)
|
||||||
|
|
||||||
[node name="burger4" parent="." unique_id=1844818864 instance=ExtResource("11_qn1ku")]
|
[node name="burger4" parent="." unique_id=1844818864 instance=ExtResource("11_qn1ku")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.40808713, 1.4235804, -1.1413177)
|
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")]
|
[node name="Hamburger" parent="." unique_id=761091445 instance=ExtResource("12_hfwnn")]
|
||||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5295425, 1.994761, -1.1201752)
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.18456237, 1.5438088, -1.3716147)
|
||||||
|
|
||||||
|
[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)
|
||||||
|
|
||||||
|
[node name="PickableObject2" parent="." unique_id=713087634 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.029038578, 1.4639391, -1.1673055)
|
||||||
|
|
||||||
|
[node name="PickableObject3" parent="." unique_id=879935619 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.15074077, 1.4792972, -1.0473135)
|
||||||
|
|
||||||
|
[node name="PickableObject4" parent="." unique_id=198541902 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.13733894, 1.4639391, -1.1673055)
|
||||||
|
|
||||||
|
[node name="Hamburger2" parent="." unique_id=1349934579 instance=ExtResource("12_hfwnn")]
|
||||||
|
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.15603885, 1.5329368, -1.6386203)
|
||||||
|
|
||||||
|
[node name="PickableObject5" parent="." unique_id=1021333509 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.06786254, 1.4792972, -1.0473135)
|
||||||
|
|
||||||
|
[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)
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
[sub_resource type="BoxMesh" id="BoxMesh_i5j2u"]
|
[sub_resource type="BoxMesh" id="BoxMesh_i5j2u"]
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_dlkho"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_dlkho"]
|
||||||
|
radius = 0.3
|
||||||
|
|
||||||
[node name="Counter" type="StaticBody3D" unique_id=1487893288 groups=["station"]]
|
[node name="Counter" type="StaticBody3D" unique_id=1487893288 groups=["station"]]
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ uv1_triplanar = true
|
|||||||
material = SubResource("StandardMaterial3D_m5xe2")
|
material = SubResource("StandardMaterial3D_m5xe2")
|
||||||
|
|
||||||
[sub_resource type="SphereShape3D" id="SphereShape3D_vlqg6"]
|
[sub_resource type="SphereShape3D" id="SphereShape3D_vlqg6"]
|
||||||
|
radius = 0.3
|
||||||
|
|
||||||
[node name="Hob" type="StaticBody3D" unique_id=1687971542 groups=["station"]]
|
[node name="Hob" type="StaticBody3D" unique_id=1687971542 groups=["station"]]
|
||||||
script = ExtResource("1_7jc4g")
|
script = ExtResource("1_7jc4g")
|
||||||
|
|||||||
Reference in New Issue
Block a user