Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 265dd12b37 | |||
| a1cb484ca5 |
+16
-1
@@ -14,6 +14,7 @@ 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)
|
||||
@@ -77,9 +78,23 @@ func _add_item(item: Node3D, positions: Array[Node3D], container_root: Node3D) -
|
||||
if food_node:
|
||||
contained_items.append(food_node as FoodItem)
|
||||
|
||||
|
||||
func erase_item(item: FoodItem) -> void:
|
||||
for container_root in [_meal_container, _side_container]:
|
||||
for child in container_root.get_children():
|
||||
var food_item = child.get_node_or_null("FoodItem") as FoodItem
|
||||
if food_item.id == item.id:
|
||||
contained_items.erase(item)
|
||||
child.queue_free()
|
||||
|
||||
|
||||
func clear() -> void:
|
||||
# delete all nodes in containers and contained_items
|
||||
pass
|
||||
for child in _meal_container.get_children():
|
||||
child.queue_free()
|
||||
for child in _side_container.get_children():
|
||||
child.queue_free()
|
||||
contained_items.clear()
|
||||
|
||||
|
||||
#plate (Pickalbe)
|
||||
|
||||
@@ -6,13 +6,14 @@ extends Node
|
||||
|
||||
@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:
|
||||
func _process(_delta: float) -> void:
|
||||
if is_dirty:
|
||||
container.enabled = false
|
||||
dirty_node.visible = true
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
class_name GameManager
|
||||
extends Node
|
||||
|
||||
static var money: int
|
||||
static var meals_in_play: Array[String]
|
||||
static var sides_in_play: Array[String]
|
||||
|
||||
|
||||
static func get_random_meal() -> String:
|
||||
if meals_in_play.size() == 0:
|
||||
push_error("GameManager: get_random_meal() called but meals_in_play is empty")
|
||||
return ""
|
||||
var rand_index = randi() % meals_in_play.size()
|
||||
print("GameManager: get_random_meal() returning ", meals_in_play[rand_index])
|
||||
return meals_in_play[rand_index]
|
||||
|
||||
|
||||
static func get_random_side() -> String:
|
||||
if sides_in_play.size() == 0:
|
||||
push_error("GameManager: get_random_side() called but sides_in_play is empty")
|
||||
return ""
|
||||
var rand_index = randi() % sides_in_play.size()
|
||||
print("GameManager: get_random_side() returning ", sides_in_play[rand_index])
|
||||
return sides_in_play[rand_index]
|
||||
@@ -0,0 +1 @@
|
||||
uid://y4sol8l8vih1
|
||||
@@ -78,4 +78,6 @@ sides = 16
|
||||
material = SubResource("StandardMaterial3D_6l01i")
|
||||
|
||||
[node name="FoodItem" parent="." index="5" unique_id=63948206 instance=ExtResource("7_yy3y8")]
|
||||
id = "hamburger"
|
||||
type = 0
|
||||
sell_value = 4
|
||||
|
||||
@@ -6,3 +6,4 @@ enum Type { MEAL, SIDE, INGREDIENT, NONE }
|
||||
|
||||
@export var id: String
|
||||
@export var type: Type = Type.NONE
|
||||
@export var sell_value = 1
|
||||
|
||||
+16
-6
@@ -65,7 +65,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.70551, 1.545408, -1.4873823)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5717233, 1.5454081, 1.5373346)
|
||||
|
||||
[node name="burger" parent="." unique_id=1417604760 instance=ExtResource("11_qn1ku")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.6888188, 1.4195822, -1.7110313)
|
||||
@@ -80,7 +80,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.69027674, 1.4969791, -1.721
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.69134104, 1.4543622, -1.7210286)
|
||||
|
||||
[node name="Hamburger" parent="." unique_id=761091445 instance=ExtResource("12_hfwnn")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.19655037, 1.623975, -1.4350286)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.9352558, 1.623975, 1.2447833)
|
||||
|
||||
[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.6225724, 1.4792972, -1.0473135)
|
||||
@@ -95,7 +95,7 @@ transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6
|
||||
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, -5.293956e-23, -2.6077032e-08, 1.4901161e-08, 1, 0.5276739, 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)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.9857153, 1.5329368, 0.9472374)
|
||||
|
||||
[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.73287535, 1.4792972, -1.0473135)
|
||||
@@ -110,7 +110,7 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.3140475, 0.9061539, -1.4941
|
||||
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)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5730225, 1.499024, 0.59790254)
|
||||
|
||||
[node name="CookedBurger" parent="." unique_id=1127807542 instance=ExtResource("15_ctden")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.30671906, 1.4131018, -1.0928738)
|
||||
@@ -119,13 +119,13 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.30671906, 1.4131018, -1.09
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.30671906, 1.4496142, -1.0928738)
|
||||
|
||||
[node name="CookedBurger3" parent="." unique_id=992183367 instance=ExtResource("15_ctden")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.3303163, 1.4398065, -0.5783213)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.3344773, 1.4398065, -0.7096845)
|
||||
|
||||
[node name="CookedBurger4" parent="." unique_id=1837607086 instance=ExtResource("15_ctden")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.30671906, 1.525444, -1.0928738)
|
||||
|
||||
[node name="BurgerBuns2" parent="." unique_id=1210358958 instance=ExtResource("8_rraok")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.3984022, 1.4110342, -0.2721244)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.3596323, 1.4110342, -0.22482127)
|
||||
|
||||
[node name="PickableObject7" parent="." unique_id=641653545 instance=ExtResource("6_eoxxy")]
|
||||
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, -1.3556751, 1.4792972, 0.28881657)
|
||||
@@ -153,3 +153,13 @@ transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.7
|
||||
|
||||
[node name="Table" parent="." unique_id=1863572470 instance=ExtResource("16_di04w")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.50244665, 0.9030438, -0.20709503)
|
||||
initial_thinking_time = 8.0
|
||||
initial_primary_time = 40.0
|
||||
initial_friend_time = 3.0
|
||||
initial_eating_time = 3.0
|
||||
|
||||
[node name="Hamburger3" parent="." unique_id=369573848 instance=ExtResource("12_hfwnn")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.7201865, 1.5329367, 0.14773655)
|
||||
|
||||
[node name="Plate3" parent="." unique_id=2004250522 instance=ExtResource("10_ay2w6")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5818124, 1.499024, -0.4634577)
|
||||
|
||||
+74
-13
@@ -1,13 +1,15 @@
|
||||
extends StaticBody3D
|
||||
|
||||
@export var initial_thinking_time: float = 8
|
||||
@export var initial_primary_time: float = 3
|
||||
@export var initial_friend_time: float = 3
|
||||
@export var initial_eating_time: float = 3
|
||||
const GAME_MANAGER = preload("res://GameManager.gd")
|
||||
|
||||
@export var initial_thinking_time: float = 6
|
||||
@export var initial_primary_time: float = 60
|
||||
@export var initial_friend_time: float = 10
|
||||
@export var initial_eating_time: float = 4
|
||||
|
||||
@onready var label_3d: Label3D = $Label3D
|
||||
@onready var label_3d_time: Label3D = $Label3DTime
|
||||
@onready var snap_zone: XRToolsSnapZone = $XRToolsSnapZone
|
||||
@onready var snap_zones: Array[XRToolsSnapZone] = []
|
||||
|
||||
const lbl_thinking: String = "Thinking..."
|
||||
const lbl_waiting_primary: String = "Waiting for food"
|
||||
@@ -25,32 +27,75 @@ enum TableState {
|
||||
}
|
||||
var _state = TableState.EMPTY # use _setState(), never set directly
|
||||
var _state_time: float = 0.0
|
||||
|
||||
var _unsatisfied_orders: Array[String]
|
||||
|
||||
func _ready() -> void:
|
||||
if not label_3d:
|
||||
push_error("Table is missing reference to Label3D")
|
||||
if not label_3d_time:
|
||||
push_error("Table is missing reference to Label3DTime")
|
||||
if not snap_zone:
|
||||
push_error("Table is missing reference to XRToolsSnapZone")
|
||||
|
||||
snap_zone.has_picked_up.connect(_on_object_picked_up)
|
||||
snap_zone.has_dropped.connect(_on_object_dropped)
|
||||
# Get snap_zones for plates, store in array snap_zones
|
||||
for child in get_children():
|
||||
var snap_zone_node = child as XRToolsSnapZone
|
||||
if snap_zone_node:
|
||||
snap_zones.append(snap_zone_node)
|
||||
|
||||
if snap_zones.is_empty():
|
||||
push_error("Table is missing XRToolsSnapZone children")
|
||||
return
|
||||
|
||||
for snap_zone_node in snap_zones:
|
||||
snap_zone_node.has_picked_up.connect(_on_object_picked_up)
|
||||
snap_zone_node.has_dropped.connect(_on_object_dropped)
|
||||
_setState(TableState.EMPTY)
|
||||
|
||||
|
||||
func _on_object_picked_up(_item) -> void:
|
||||
print("Table: object picked up: ", _item)
|
||||
_absorb_item_if_correct(_item)
|
||||
|
||||
|
||||
|
||||
func _on_object_dropped() -> void:
|
||||
print("Table: object dropped ")
|
||||
|
||||
|
||||
func _get_plate_from_item(_item: Node) -> PlateController:
|
||||
return _item.get_children().filter(func(c): return c is PlateController).front() as PlateController
|
||||
|
||||
|
||||
func _absorb_item_if_correct(_item: Node) -> void:
|
||||
# Get plate controller in childer of _item (hopefully a plate XRpickable)
|
||||
var plate = _get_plate_from_item(_item)
|
||||
if not plate:
|
||||
print("Table: held object is not a Plate")
|
||||
return
|
||||
print("Table: held a Plate!")
|
||||
|
||||
# Absorm items from the plate we want
|
||||
for food_item in plate.container.contained_items:
|
||||
print("Table: held a plate with FoodItem: ", food_item.id)
|
||||
if food_item.id in _unsatisfied_orders:
|
||||
print("Table: held FoodItem is in unsatisfied orders, removing it")
|
||||
_unsatisfied_orders.erase(food_item.id)
|
||||
GAME_MANAGER.money += food_item.sell_value
|
||||
_setState(TableState.WAITING_FRIEND)
|
||||
_update_order_text()
|
||||
|
||||
# Table has everything it wants. Start eating
|
||||
if _unsatisfied_orders.is_empty():
|
||||
_setState(TableState.EATING)
|
||||
|
||||
|
||||
func place_order() -> void:
|
||||
print("Table: place_order()")
|
||||
label_3d.text = "order!"
|
||||
_unsatisfied_orders.append(GAME_MANAGER.get_random_meal())
|
||||
_unsatisfied_orders.append(GAME_MANAGER.get_random_meal())
|
||||
|
||||
|
||||
func _update_order_text() -> void:
|
||||
label_3d.text = "%s\n%s" % [TableState.keys()[_state], "\n".join(_unsatisfied_orders)]
|
||||
|
||||
|
||||
func _setState(newState: TableState) -> void:
|
||||
@@ -65,10 +110,11 @@ func _setState(newState: TableState) -> void:
|
||||
|
||||
if newState == TableState.WAITING_PRIMARY:
|
||||
_state_time = initial_primary_time
|
||||
label_3d.text = lbl_waiting_primary
|
||||
_update_order_text()
|
||||
|
||||
if newState == TableState.WAITING_FRIEND:
|
||||
_state_time = initial_friend_time
|
||||
_update_order_text()
|
||||
|
||||
if newState == TableState.EATING:
|
||||
_state_time = initial_eating_time
|
||||
@@ -84,17 +130,32 @@ func _process(delta: float) -> void:
|
||||
label_3d_time.text = "%.1f" % _state_time
|
||||
return
|
||||
|
||||
# When state timer is finished, do this stuff before moving to next state
|
||||
match _state:
|
||||
TableState.EMPTY:
|
||||
_setState(TableState.THINKING)
|
||||
|
||||
TableState.THINKING:
|
||||
place_order()
|
||||
_setState(TableState.WAITING_PRIMARY)
|
||||
place_order()
|
||||
_update_order_text()
|
||||
|
||||
|
||||
TableState.WAITING_PRIMARY:
|
||||
label_3d.text = lbl_gameover
|
||||
|
||||
TableState.WAITING_FRIEND:
|
||||
label_3d.text = lbl_gameover
|
||||
|
||||
TableState.EATING:
|
||||
for snap_zone_node in snap_zones:
|
||||
var held_object = snap_zone_node.picked_up_object
|
||||
if not held_object:
|
||||
continue
|
||||
|
||||
var plate = _get_plate_from_item(held_object)
|
||||
if plate:
|
||||
plate.container.clear()
|
||||
plate.is_dirty = true
|
||||
_setState(TableState.EMPTY)
|
||||
|
||||
|
||||
+41
-3
@@ -18,7 +18,7 @@ script = ExtResource("1_2vcpj")
|
||||
shape = SubResource("BoxShape3D_24d3s")
|
||||
|
||||
[node name="XRToolsSnapZone" type="Area3D" parent="." unique_id=1947858647 groups=["station"]]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5270121, 0)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.31874347, 0.5270121, 0)
|
||||
collision_layer = 65536
|
||||
collision_mask = 65536
|
||||
script = ExtResource("1_8j1nt")
|
||||
@@ -29,6 +29,42 @@ metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
|
||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, -0.000975132, 0)
|
||||
shape = SubResource("SphereShape3D_dlkho")
|
||||
|
||||
[node name="XRToolsSnapZone2" type="Area3D" parent="." unique_id=694448387 groups=["station"]]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.34755045, 0.5270121, 0)
|
||||
collision_layer = 65536
|
||||
collision_mask = 65536
|
||||
script = ExtResource("1_8j1nt")
|
||||
snap_mode = 1
|
||||
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
|
||||
|
||||
[node name="CollisionShape3D2" type="CollisionShape3D" parent="XRToolsSnapZone2" unique_id=650960099]
|
||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, -0.000975132, 0)
|
||||
shape = SubResource("SphereShape3D_dlkho")
|
||||
|
||||
[node name="XRToolsSnapZone3" type="Area3D" parent="." unique_id=1734026785 groups=["station"]]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.012355864, 0.5270121, 0.33038777)
|
||||
collision_layer = 65536
|
||||
collision_mask = 65536
|
||||
script = ExtResource("1_8j1nt")
|
||||
snap_mode = 1
|
||||
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
|
||||
|
||||
[node name="CollisionShape3D2" type="CollisionShape3D" parent="XRToolsSnapZone3" unique_id=1271210642]
|
||||
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, -0.000975132, 0)
|
||||
shape = SubResource("SphereShape3D_dlkho")
|
||||
|
||||
[node name="XRToolsSnapZone4" type="Area3D" parent="." unique_id=1358457948 groups=["station"]]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.022546828, 0.5270121, -0.36528283)
|
||||
collision_layer = 65536
|
||||
collision_mask = 65536
|
||||
script = ExtResource("1_8j1nt")
|
||||
snap_mode = 1
|
||||
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
|
||||
|
||||
[node name="CollisionShape3D2" type="CollisionShape3D" parent="XRToolsSnapZone4" unique_id=1880499470]
|
||||
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=2085635675]
|
||||
|
||||
[node name="CSGBox3D" type="CSGBox3D" parent="CSGCombiner3D" unique_id=411048765]
|
||||
@@ -108,12 +144,14 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.1444692, -0.18527734, -0.15
|
||||
size = Vector3(0.05, 0.6713196, 0.05)
|
||||
|
||||
[node name="Label3D" type="Label3D" parent="." unique_id=662960977]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.1781815, 0)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.3247777, 0)
|
||||
billboard = 2
|
||||
text = "table state"
|
||||
vertical_alignment = 0
|
||||
line_spacing = -15.0
|
||||
|
||||
[node name="Label3DTime" type="Label3D" parent="." unique_id=1534849507]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.0412213, 0)
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.3306234, 0)
|
||||
pixel_size = 0.003
|
||||
billboard = 2
|
||||
text = "20.1s"
|
||||
|
||||
@@ -1,11 +1,15 @@
|
||||
extends Node3D
|
||||
|
||||
const RECIPE_MANAGER = preload("res://RecipeManager.gd")
|
||||
const GAME_MANAGER = preload("res://GameManager.gd")
|
||||
|
||||
var xr_interface :XRInterface
|
||||
|
||||
func _ready():
|
||||
RECIPE_MANAGER.print_all_recipes()
|
||||
|
||||
GAME_MANAGER.meals_in_play.append("hamburger")
|
||||
|
||||
xr_interface = XRServer.find_interface("OpenXR")
|
||||
if xr_interface and xr_interface.is_initialized():
|
||||
print("OpenXR started :)")
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
uid://dqqu56yetl8ok
|
||||
Reference in New Issue
Block a user