74 Commits

Author SHA1 Message Date
algodoogle ee835ea295 Split the multiplayer test harness into modules
mp_test_driver.gd was 1458 lines doing six unrelated jobs. It is now
orchestration only — the scripted sequence, the RPC plumbing between peers, and
the manual keyboard controls — with the work in modules that each have one:

  MpWorldView  finding things in the world and describing what they are doing
  MpSteps      the simulated player actions (reach, grab, carry, drop)
  MpAsserts    the per-step checks
  MpSnapshot   the cross-peer sync audit
  MpReport     the ledger, the log, the overlay, the screenshots

The scenario list and the audit logic carry over unchanged. That audit compares
what is actually RENDERED on both peers, not just the replicated values behind
it, which is the only thing that catches a plate whose contents arrived but
whose visuals were never rebuilt — so it was worth moving verbatim.

Assertions that tested the old model now test the new one: "who is holding
this" is the authority of the object's NetXform, not of the object itself.

Suite: 146/146 passing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-28 23:22:58 +01:00
algodoogle 61d92052ac Rebuild multiplayer on the stock spawner and synchronizer
Adding an object to the game no longer requires any networking code. The
MultiplayerSpawner runs in its default mode — no spawn_function, no payload
dictionary — and NetReplication builds each object's SceneReplicationConfig
from a convention, so scenes carry no hand-authored replication at all.

Every replicated node gets two generated synchronizers: NetSync for script
state, always server-owned, and NetXform for position, handed to whoever is
holding the object. That split is what makes grab prediction work — a
synchronizer never applies inbound state on the peer that owns it, so a
player's own hand drives an object with no round trip while is_dirty and
friends keep flowing one way from the server.

Interaction is now two RPCs for the whole game (NetGrab), and client gating is
one rule applied to every object (NetWorld). Deleted: net_pickable.gd, the
replicated net_held_by field and its held-state juggling, the
grant/reject/force-release negotiation, the static-item despawn RPC, and the
per-scene replication configs. Authority is the single source of truth for who
simulates an object.

Two things the convention had to learn, both found by the test suite:

  * Addon scripts are excluded. godot-xr-tools' snap zones and pickables expose
    a public `enabled`, which is exactly the flag each peer must set for itself
    — so replicating it meant the server sent `enabled = true` back over every
    client's gate, and stations went on grabbing objects out of the local
    player's hands.
  * Arrays of nodes are excluded. Array[Node3D] and Array[FoodItem] would
    otherwise try to serialise live node references.

table.gd's replicated state loses its underscore prefix, which now marks a
variable as private and unreplicated; two in-place array mutations there were
skipping their setters, and the progress bar could divide by zero on a client.

Suite: 146/146 passing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-28 22:04:22 +01:00
algodoogle 0ebd0a4a85 Design + spike for high-level replication rebuild
Rebuild the multiplayer layer on stock MultiplayerSpawner/Synchronizer so
adding an object to the game needs no networking code.

MultiplayerSpawner only replicates node creation and deletion, so "sync
everything regardless of what it is" has to come from a SceneReplicationConfig
built by convention in code. NetReplication does that, giving every node two
generated synchronizers: NetSync for script state (always server-owned) and
NetXform for position (handed to whoever is holding the object).

test/spike/ establishes the four engine behaviours the design rests on. Two
are worth flagging: per-peer visibility CANNOT be used to stop the server
fighting a client's held object, because MultiplayerSpawner despawns and
respawns the node on every visibility flip; and set_visibility_for is only an
override on top of public_visibility, so calling it alone does nothing.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-28 21:42:30 +01:00
JonShard 59c62b73e6 Test multi cube 2026-07-28 21:16:35 +02:00
algodoogle a2bad29f2a mp fix2 2026-07-28 19:48:40 +01:00
algodoogle 0ddada4568 Merge branch 'master' of https://git.offcoursegames.com/JonShard/VRyHungry1 2026-07-28 19:41:34 +01:00
algodoogle 96ea2dd1ea mp fix 2026-07-28 19:41:31 +01:00
JonShard 8b6f444d55 Fix XRTools library bug that didn't nil check in pickup 2026-07-28 19:16:35 +02:00
JonShard 29326f4b78 Apply money sound effect to table 2026-07-28 19:15:52 +02:00
JonShard e5aa13cef7 Add money sound effect 2026-07-28 19:06:28 +02:00
algodoogle 7479cbd656 multy thing 2026-07-28 18:01:27 +01:00
algodoogle f760c8c9f7 Merge branch 'master' of https://git.offcoursegames.com/JonShard/VRyHungry1 2026-07-28 15:21:12 +01:00
algodoogle 8e14fb0f29 fix hob efect 2026-07-28 15:20:46 +01:00
JonShard 6346d563e0 Fix bug in table 2026-07-28 15:33:13 +02:00
algodoogle fd7f9f3a22 Merge branch 'master' of https://git.offcoursegames.com/JonShard/VRyHungry1 2026-07-28 14:32:55 +01:00
algodoogle e002c2fb4a tabel time 2026-07-28 14:32:52 +01:00
JonShard 0872271c8c Fix player collides with items on floor 2026-07-28 14:47:24 +02:00
JonShard b9c9a3b73a Add more snap_zone sounds 2026-07-28 13:11:53 +02:00
JonShard 7d694de307 Add DespawningItem 2026-07-28 10:39:34 +02:00
JonShard 3f951fef64 Add Items slide off dispensers 2026-07-28 10:39:15 +02:00
JonShard 11b4d3c138 Merge branch 'master' of https://git.offcoursegames.com/JonShard/VRyHungry1 2026-07-28 09:24:28 +02:00
JonShard bbf982c2f6 Add thrown plates absorb food on station 2026-07-28 09:22:03 +02:00
algodoogle 69175e7b5e ju 2026-07-27 22:32:07 +01:00
algodoogle 1a893ba9aa Visual indicator 2026-07-27 18:56:28 +01:00
algodoogle 29083a4250 some thig 2026-07-27 16:24:54 +01:00
algodoogle 57f1cd167a Merge branch 'master' of https://git.offcoursegames.com/JonShard/VRyHungry1 2026-07-27 16:14:52 +01:00
algodoogle f3abe69eb4 small things 2026-07-27 16:14:13 +01:00
JonShard b1a2098a08 Merge branch 'master' of https://git.offcoursegames.com/JonShard/VRyHungry1 2026-07-27 17:07:21 +02:00
JonShard 71580ad183 Fix Snap_zones not range grabbing 2026-07-27 17:07:18 +02:00
JonShard d0c13effa2 Import sounds 2026-07-27 17:03:51 +02:00
algodoogle 688eca13fa Merge branch 'master' of https://git.offcoursegames.com/JonShard/VRyHungry1 2026-07-27 13:47:54 +01:00
algodoogle c758771a75 gameover 2026-07-27 13:47:50 +01:00
JonShard d2f5e1fd4f jon scene: preview grid scales 2026-07-27 14:41:10 +02:00
JonShard 5dae9c5779 Add Plate dispenser 2026-07-27 14:40:38 +02:00
JonShard 488feff7dc Add raw burger and cube dispenser 2026-07-27 14:20:44 +02:00
JonShard b7775e9de6 Add progress bar to Table 2026-07-27 13:32:04 +02:00
JonShard 01587e3b9c Add progress bar to Sink 2026-07-27 12:53:33 +02:00
JonShard f4b2e687b5 Add Progress bar to Hob 2026-07-27 10:16:44 +02:00
JonShard 34a649f507 Kanban 2026-07-26 16:14:29 +02:00
JonShard e04c5519d0 Move stations to floor 2026-07-26 16:00:30 +02:00
algodoogle 7ac87984bc Merge branch 'multi2' of https://git.offcoursegames.com/JonShard/VRyHungry1 into multi2 2026-07-26 14:33:20 +01:00
algodoogle 776aaa3020 bug fix 2026-07-26 14:33:15 +01:00
JonShard 5ca64b8dff Fix error about custom_solver_bias not supported 2026-07-26 15:05:05 +02:00
algodoogle ae3e7ec674 jiff 2026-07-26 13:49:46 +01:00
algodoogle 23ec41c1d6 Fix five multiplayer sync bugs, add automated two-instance test
Adds test/multiPlayerTest.tscn plus a driver that runs the kitchen flow
across two game instances: grab/drop, dirt station, sink washing, hob
cooking, counter combining and plating. Runs headless (run_mp_test.ps1),
in two visible windows (run_mp_test_windowed.ps1), or by hand with
keyboard controls (play_mp_test.ps1). 108 checks, exits non-zero on
failure.

After every step both peers snapshot every item's position and rendered
state and the server diffs them. Targeted assertions only look at the
thing a step touched, which misses desyncs elsewhere - that audit is
what caught the last bug below.

Bugs found and fixed:

- net_pickable: apply_held_state() only wrote `enabled` in its
  non-authority branch, so once a client grabbed an item every other
  peer set enabled=false and regaining authority never restored it. The
  server could then never pick that item up again, and a station would
  "snap" it (emitting has_picked_up, so a plate still got marked dirty)
  while pick_up() bailed out on the disabled item - leaving the zone
  holding an item with no grab driver.

- network_manager: station gating only happened in the spawn path, so
  stations baked into a scene file kept running their snap zones on
  clients and grabbed items straight out of the local hand. Added
  gate_existing_stations().

- network_manager: despawn_item() only freed the server's copy. Items
  baked into a scene aren't tracked by the MultiplayerSpawner, so
  consuming one left a ghost on every client, which then blocked the
  station it sat in and got grabbed instead of its replacement.

- network_manager: the snap-into-station decision read the server's own
  copy of the item position, but the reliable release RPC routinely
  overtakes the synchronizer's unordered position updates - so it acted
  on a stale position and teleported items back into the station they
  had just been carried away from. The releasing peer now sends its
  final transform and the server adopts it first.

- container: contained_ids.append()/erase() mutate the array in place,
  which never fires the setter that rebuilds the plate's visuals. The
  peer that put food on a plate was the only peer that never redrew it;
  remote peers looked right because the synchronizer assigns there.

Also null-guards XRServer.get_tracker() in the vendored xr-tools hand
grab point, which threw on every successful grab without an XR runtime,
and adds multiplayer_world.populate_from_layout so debug scenes can bake
their own content instead of spawning the whole kitchen.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-26 02:00:50 +01:00
algodoogle 33ef81306d asd 2026-07-25 21:58:14 +01:00
JonShard 50efeeb353 Merge branch 'multi2' of https://git.offcoursegames.com/JonShard/VRyHungry1 into multi2 2026-07-25 22:11:03 +02:00
JonShard 71d01e5be1 Add game export preset 2026-07-25 22:09:46 +02:00
algodoogle 87641dd55c Enable file logging to logs/, gitignore its output
Pairs with the debug-log-heavy investigation workflow: Godot writes its
own engine log to logs/godot.log alongside the existing NetworkManager
temp-file log, and the directory is excluded from version control since
it's runtime output, not source.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-25 21:07:29 +01:00
algodoogle d65b2ca863 Add diagnostic logging for item grab/authority state transitions
The snap-zone crash fixed just before this was invisible in the logs
until traced through addon source by hand — the log showed grabs,
drops, and authority handoffs, but nothing about which peer/hand/zone
actually held an item at each step, or when a guard clause silently
changed behavior.

Adds a _holder_desc() helper (reports "loose", "hand(<path>)",
"zone(<station>)", or "other(...)") and logs every net_held_by
transition, every reclaim that has to restore freeze_mode/collision_mask
from a stuck state, every time the grab-race guard protects an actively-
held item from a stale sync, every force-drop triggered by a losing
authority race, and every pickup/drop event including the ones that
don't get forwarded (picked up by something other than a hand, or
dropped while not authority — exactly the silent case behind the
snap-zone crash). NetworkManager's snap/release-from-zone calls get the
same treatment: which station an item is pulled from, and whether a
snap attempt succeeded, was skipped by the race guard, or found nothing
in range.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-25 21:07:21 +01:00
algodoogle 0af0c1bfc1 Merge branch 'multi2' of https://git.offcoursegames.com/JonShard/VRyHungry1 into multi2 2026-07-25 20:49:38 +01:00
JonShard 428f00a812 Ignore .log 2026-07-25 21:49:19 +02:00
JonShard 773cf647d8 Add invisible walls 2026-07-25 21:48:58 +02:00
algodoogle 61ea80b933 Fix self-targeted RPC breaking host-side item grab/release
request_item_authority and release_item_authority were always sent as
an RPC to peer 1, even when the caller already WAS peer 1 (the host's
own player). Godot rejects rpc_id() targeting your own peer id ("RPC on
yourself is not allowed by selected mode"), so every host-side grab or
release was silently failing to run its server-side half: no denial
check on grab, and — the more damaging part — no
_try_snap_into_station()/_release_from_snap_zones() call on release,
leaving a station's snap zone holding a stale reference once the host
picked something back up. That's what made the host "no longer able to
interact" with an item after a client had handled it.

Split each entry point into a public function that runs the logic
directly when we're already the server, and a private @rpc handler used
only when an actual remote client calls it. force_release_item gets the
same treatment for the symmetric case (server rejecting its own grab
attempt).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-25 20:47:03 +01:00
algodoogle f6ac103233 Fix join-floor fall-through, grab race, drop physics, and remote hand sync
Four bugs from real cross-network play:

- Player/net_player.gd: the per-peer spawn-spread offset (added to avoid
  stacking joiners on top of each other) could push a joining client up
  to 12 units from center, but the floor is only 15x15 (~7.5 unit
  half-extent) — landing a client off the edge. Bounded to ~2.7 units.

- Player/net_player.gd: the glove scenes used for remote-hand visuals
  carry hand.gd (XRToolsHand), whose root node sets top_level = true and
  repositions itself to its parent's transform every physics frame,
  expecting to be parented under a live XRController3D. Parented under
  the plain avatar node instead, it fought both the local transform copy
  and the replicated sync every tick — whichever wrote last that frame
  won, which read as hands stuck near origin except momentarily. Disabled
  physics processing on those nodes; nothing else in the script matters
  without a real controller ancestor.

- Net/net_pickable.gd: grabbing an item sends an RPC to the server to
  confirm authority, but the item's regular state sync travels on a
  different channel with no ordering guarantee against that RPC. A
  stale "still loose" sync packet could arrive after an optimistic local
  grab but before the confirmation, and was being treated as a real
  authority loss, force-dropping the item — explaining "first attempt
  fails, second succeeds". Now a sync update can't yank an item out of
  our own hand mid-grab; only an explicit rejection or an actual loss of
  authority can.

- Net/net_pickable.gd: the non-authority path zeroes collision_mask and
  forces freeze_mode to KINEMATIC, but nothing ever restored either when
  a peer regained authority (e.g. the server after a client's release) —
  so a released item stayed collision-less forever, looking physics-less.
  Now both are restored from the item's own baked values whenever a peer
  owns a loose (not actively held) item again.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-25 20:16:29 +01:00
algodoogle 17d20440da Fix catastrophic player spawn-offset overflow for real peer ids
The per-peer spread offset used the raw ENet peer id directly
((peer_id - 1) * 1.5), assuming ids are small sequential numbers. Real
peer ids are large effectively-random 32-bit values, so a joining
client's XR rig was being shifted by hundreds of millions of units off
the origin — the world had actually replicated correctly, the player
was just teleported far away from all of it, with float precision bad
enough at that range to jitter the view and destabilize physics.

Bound the offset to a small deterministic slot instead; the host still
keeps its original baked spot.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-25 19:59:36 +01:00
JonShard a9ca11fd17 Merge branch 'multi2' of https://git.offcoursegames.com/JonShard/VRyHungry1 into multi2 2026-07-25 20:48:39 +02:00
JonShard 13567e5dd3 Add global key events to close game 2026-07-25 20:48:36 +02:00
algodoogle 4ca0a05d1b Fix world population race and add multiplayer diagnostics
The world was populated before NetworkManager.world_ready() actually
called host()/join(), so owns_world() read true for every peer
(including a joining client) and each one built its own local,
unreplicated copy instead of the client receiving the server's spawn
through the MultiplayerSpawner. Population now happens after the
session is actually established.

Also adds net-log coverage for spawn/despawn, station gating, item
authority handoff, station snapping, avatar spawn/despawn, and scene
transitions, so multiplayer behavior is visible in
%TEMP%\vryhungry_net_<pid>.log instead of failing silently.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-07-25 19:42:49 +01:00
algodoogle 596d777fae asd 2026-07-25 19:26:43 +01:00
algodoogle f7024db98d added multi 2026-07-25 18:20:12 +01:00
JonShard 265dd12b37 Add Table 2026-07-25 18:18:17 +02:00
JonShard a1cb484ca5 Add Table picks an order 2026-07-22 15:15:30 +02:00
JonShard ab6cce3d9a Add table with finite state machine 2026-07-20 13:43:18 +02:00
JonShard b6372c532a Improve look of stations 2026-07-20 09:37:06 +02:00
JonShard fc2c854305 Kanban 2026-07-19 11:15:35 +02:00
JonShard bd2ee722df Support multiple cooking recipes for same item 2026-07-19 10:48:41 +02:00
JonShard a48611c0ff Refactor hob to use Recipemanager 2026-07-19 10:48:22 +02:00
JonShard f0e3ba705d Load chopping, rolling and augmenting recipes from YAML 2026-07-19 10:48:21 +02:00
JonShard 714d813344 Reafactoring Recipemanager 2026-07-19 10:48:21 +02:00
JonShard 847af48394 Clean up what the AI did 2026-07-19 10:48:21 +02:00
JonShard 4d06e72bc1 Add Recipemanager that loads recipes from YAML 2026-07-19 10:47:28 +02:00
JonShard 840908e9ff Add Dirty plates and sink. Dirty plates don't accept food 2026-07-17 11:52:21 +02:00
JonShard b0fd26f3da Kanban 2026-07-16 18:22:11 +02:00
276 changed files with 17166 additions and 723 deletions
+4
View File
@@ -1,3 +1,7 @@
# Godot 4+ specific ignores
.godot/
.build/
/android/
/logs
*.log
+3
View File
@@ -0,0 +1,3 @@
{
"godotTools.editorPath.godot4": "c:\\Program Files (x86)\\Godot\\Godot_v4.7-stable_win64.exe"
}
+154 -33
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] = []
@@ -22,59 +24,178 @@ func _ready() -> void:
push_error("XRPickable node not found in container.gd")
# Absorbing items is a server decision (the container's holder is server-
# snapped into a station, matching table.gd/hob.gd's convention).
func _on_body_entered(body: Node3D) -> void:
if not NetworkManager.owns_world():
return
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)
# If one of us is in a station
var picked_by = xr_pickable.get_picked_up_by()
if picked_by and picked_by.is_in_group("station"):
var body_pickable = body as XRToolsPickable
var body_picked_by = body_pickable.get_picked_up_by() if body_pickable else null
if (picked_by and picked_by.is_in_group("station")) or (body_picked_by and body_picked_by.is_in_group("station")):
# If compatible and enough space, add item
# If enough space, add item
var food_item = body.get_node("FoodItem")
print("Container in station found %s of type %s: %s" % [target_group, FoodItem.Type.keys()[food_item.type], body.name])
if food_item.type == FoodItem.Type.MEAL and _meal_container.get_child_count() < meal_positions.size():
var meal_count := contained_items.filter(func(f): return f.type == FoodItem.Type.MEAL).size()
var side_count := contained_items.filter(func(f): return f.type == FoodItem.Type.SIDE).size()
if food_item.type == FoodItem.Type.MEAL and meal_count < meal_positions.size():
print("Container adding meal")
_add_item(body, meal_positions, _meal_container)
if food_item.type == FoodItem.Type.SIDE and _side_container.get_child_count() < side_positions.size():
_add_item(body)
if food_item.type == FoodItem.Type.SIDE and side_count < side_positions.size():
print("Container adding side")
_add_item(body, side_positions, _side_container)
_add_item(body)
func _add_item(item: Node3D, positions: Array[Node3D], container_root: Node3D) -> void:
# Contents are synced as data (ids on the plate's PlateController), not
# reparented nodes: reparenting a MultiplayerSpawner-tracked item out of
# WorldContent would despawn it on every client the instant it happened.
func _add_item(item: Node3D) -> void:
var pickable = item as XRToolsPickable
var rigidbody = item as RigidBody3D
# Drop item
if pickable:
if pickable.is_picked_up():
if pickable and 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
var food_node := item.get_node_or_null("FoodItem") as FoodItem
if not food_node:
return
item.reparent(container_root, false) # false = discard global transform
# Copy the data out before despawning the real item.
var data := FoodItem.new()
data.id = food_node.id
data.type = food_node.type
data.sell_value = food_node.sell_value
contained_items.append(data)
# 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
var plate_controller := xr_pickable.get_node_or_null("PlateController") as PlateController
if plate_controller:
# Reassign rather than append in place. contained_ids has a setter that
# rebuilds the plate's visuals, and mutating the array never triggers it —
# so the peer that actually added the food was the one peer that never
# redrew the plate. Remote peers looked right (the synchronizer assigns
# the value there, which does fire the setter), and the stale peer only
# caught up if someone else took the plate and sent the value back.
# duplicate() keeps the Array[String] typing that the property requires.
var updated := plate_controller.contained_ids.duplicate()
updated.append(food_node.id)
plate_controller.contained_ids = updated
NetworkManager.despawn_item(item)
func erase_item(item: FoodItem) -> void:
contained_items.erase(item)
var plate_controller := xr_pickable.get_node_or_null("PlateController") as PlateController
if plate_controller:
# Same reason as _add_item: assign so the visuals actually refresh.
var remaining := plate_controller.contained_ids.duplicate()
remaining.erase(item.id)
plate_controller.contained_ids = remaining
# 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
contained_items.clear()
var plate_controller := xr_pickable.get_node_or_null("PlateController") as PlateController
if plate_controller:
plate_controller.contained_ids = []
## Rebuilds the purely-cosmetic visual representation of the plate's contents
## from a synced id list. Runs on every peer (called from PlateController
## whenever contained_ids changes, whether set locally or by the network).
func refresh_visuals(ids: Array[String]) -> void:
for child in _meal_container.get_children():
child.queue_free()
for child in _side_container.get_children():
child.queue_free()
var meal_idx := 0
var side_idx := 0
for id in ids:
var scene := RecipeManager.get_item_scene(id)
if not scene:
continue
var visual := scene.instantiate()
var food_node := visual.get_node_or_null("FoodItem") as FoodItem
var container_root: Node3D
var positions: Array[Node3D]
var idx: int
if food_node and food_node.type == FoodItem.Type.MEAL and meal_idx < meal_positions.size():
container_root = _meal_container
positions = meal_positions
idx = meal_idx
meal_idx += 1
elif food_node and food_node.type == FoodItem.Type.SIDE and side_idx < side_positions.size():
container_root = _side_container
positions = side_positions
idx = side_idx
side_idx += 1
else:
visual.queue_free()
continue
_make_cosmetic(visual)
container_root.add_child(visual)
# Must happen after add_child: entering the world is what puts the body
# into the physics space, so it can only be taken out again afterwards.
_remove_from_physics(visual)
visual.position = positions[idx].position
visual.rotation = positions[idx].rotation
# Strip interactivity from a display-only copy. It is instantiated straight from
# its scene rather than spawned through NetWorld, so it is not part of the
# replicated world at all — it exists only to be looked at, and must not be
# grabbable or collidable.
#
# It gets no synchronizers either: NetReplication.attach only ever runs for
# direct children of the content root, and this is parented under a plate.
func _make_cosmetic(visual: Node3D) -> void:
var despawn_timer := visual.get_node_or_null("DespawningItem")
if despawn_timer:
# Detached and freed outright rather than queue_free()d: this runs before
# `visual` is added to the tree, and a merely-queued node still enters the
# tree with its parent and runs a frame of _process before the queued
# deletion lands at the end of the frame.
visual.remove_child(despawn_timer)
despawn_timer.free()
if visual is RigidBody3D:
visual.freeze = true
# STATIC, not KINEMATIC: a kinematic body is still driven by the physics
# engine (see _remove_from_physics), and "static decoration" is what this
# actually is.
visual.freeze_mode = RigidBody3D.FREEZE_MODE_STATIC
visual.collision_layer = 0
visual.collision_mask = 0
if visual is XRToolsPickable:
visual.enabled = false
visual.set_process(false)
visual.set_physics_process(false)
# Take a display-only copy out of the physics simulation completely.
#
# Freezing is not enough. Under Jolt (this project's physics engine) a frozen
# KINEMATIC RigidBody3D is still simulated: it is driven toward its target
# transform by velocity rather than being teleported. Parented to a plate that
# gets picked up and carried, it therefore lags behind, keeps its velocity, and
# overshoots — so the food visibly slid off the plate and ended up metres away,
# differently on each peer since each simulates its own copy. A body with no
# space is never touched by the engine, so it simply follows its parent.
func _remove_from_physics(visual: Node3D) -> void:
if visual is RigidBody3D:
PhysicsServer3D.body_set_space((visual as RigidBody3D).get_rid(), RID())
#plate (Pickalbe)
+1 -1
View File
@@ -3,7 +3,7 @@
[ext_resource type="Script" uid="uid://6lyhyial1fh5" path="res://Containers/container.gd" id="1_r4cle"]
[sub_resource type="SphereShape3D" id="SphereShape3D_vlqg6"]
radius = 0.2
radius = 0.3
[node name="Container" type="Node3D" unique_id=377793422 node_paths=PackedStringArray("meal_positions")]
script = ExtResource("1_r4cle")
+52
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,48 @@ 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")
+48
View File
@@ -0,0 +1,48 @@
class_name PlateController
extends Node
@onready var dirty_node: Node3D = $"../Dirty"
@onready var container: ItemContainer = $"../Container"
@export var is_dirty: bool = false
## Synced plate contents (item ids), replacing reparented child nodes so
## contents survive replication (a MultiplayerSpawner-tracked item would
## despawn on every client the instant it was reparented out of WorldContent).
## Server writes it via ItemContainer; every peer (server included) renders
## the cosmetic result via the setter below.
@export var contained_ids: Array[String] = []: set = _set_contained_ids
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
func _set_contained_ids(value: Array[String]) -> void:
# Only rebuild when the contents actually changed. refresh_visuals() frees and
# re-instantiates a scene per item, so a redundant call is thousands of
# throwaway nodes over a session. NetReplication uses ON_CHANGE for state, so
# the synchronizer should not be assigning this unless it really changed — but
# a local write can still repeat a value, and this stays cheap either way.
if contained_ids == value:
return
contained_ids = value
# Deferred: this can be written by the replicated spawn payload before
# this node's own @onready vars (container) have resolved.
_refresh_visuals.call_deferred()
func _refresh_visuals() -> void:
if container:
container.refresh_visuals(contained_ids)
+1
View File
@@ -0,0 +1 @@
uid://iqjqsk4v6qfh
+45
View File
@@ -0,0 +1,45 @@
class_name GameManager
extends Node
static var money: int
static var meals_in_play: Array[String]
static var sides_in_play: Array[String]
enum GameState {
RUNNING,
GAME_OVER
}
static var game_state: GameState = GameState.RUNNING
static func _restart():
print("restart Game")
game_state = GameState.RUNNING
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]
static func game_over():
print("Game Over")
game_state = GameState.GAME_OVER
Signals.game_over.emit()
+1
View File
@@ -0,0 +1 @@
uid://y4sol8l8vih1
+9 -11
View File
@@ -7,8 +7,8 @@
[ext_resource type="PackedScene" uid="uid://c25yxb0vt53vc" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_left.tscn" id="5_wqyr2"]
[ext_resource type="Animation" uid="uid://bediglpx0rj7i" path="res://addons/godot-xr-tools/hands/animations/left/Grip 5.res" id="6_ftab3"]
[ext_resource type="PackedScene" uid="uid://3lr2dhy62rhk" path="res://Prefabs/combinable_item.tscn" id="7_wb51u"]
[ext_resource type="Script" uid="uid://coidnv8b2yvxr" path="res://Prefabs/combine_recipe.gd" id="8_wqyr2"]
[ext_resource type="PackedScene" uid="uid://b3m2ag8g5rj4r" path="res://Items/hamburger.tscn" id="9_wb51u"]
[ext_resource type="PackedScene" uid="uid://bfj80jh13t6e5" path="res://Prefabs/food_item.tscn" id="8_t9y3x"]
[ext_resource type="PackedScene" uid="uid://b5ukku8i0hilb" path="res://Prefabs/despawning_item.tscn" id="10_46e7r"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_vlqg6"]
height = 0.10708985
@@ -27,12 +27,6 @@ metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_hoqox"]
albedo_color = Color(0.6784191, 0.54546416, 0.016760282, 1)
[sub_resource type="Resource" id="Resource_hwyyd"]
script = ExtResource("8_wqyr2")
ingredient_id = &"cooked_burger"
result = ExtResource("9_wb51u")
metadata/_custom_type_script = "uid://coidnv8b2yvxr"
[node name="BurgerBuns" unique_id=1088240294 instance=ExtResource("1_g1t48")]
[node name="CollisionShape3D" parent="." index="0"]
@@ -74,6 +68,10 @@ sides = 16
cone = true
material = SubResource("StandardMaterial3D_hoqox")
[node name="CombinableItem" parent="." index="4" unique_id=996936271 instance=ExtResource("7_wb51u")]
id = &"burger_buns"
recipes = Array[ExtResource("8_wqyr2")]([SubResource("Resource_hwyyd")])
[node name="FoodItem" parent="." index="4" unique_id=123456789 instance=ExtResource("8_t9y3x")]
id = "burger_buns"
type = 2
[node name="CombinableItem" parent="." index="5" unique_id=996936271 instance=ExtResource("7_wb51u")]
[node name="DespawningItem" parent="." index="7" unique_id=303090111 instance=ExtResource("10_46e7r")]
+11 -1
View File
@@ -6,9 +6,11 @@
[ext_resource type="Script" uid="uid://dvobm6vcfnqe8" path="res://addons/godot-xr-tools/hands/poses/hand_pose_settings.gd" id="4_mgacb"]
[ext_resource type="PackedScene" uid="uid://ctw7nbntd5pcj" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_right.tscn" id="5_vw7i6"]
[ext_resource type="Animation" uid="uid://d1xnpyc08njjx" path="res://addons/godot-xr-tools/hands/animations/right/Grip 4.res" id="6_cp3eg"]
[ext_resource type="PackedScene" uid="uid://bfj80jh13t6e5" path="res://Prefabs/food_item.tscn" id="7_mde49"]
[ext_resource type="PackedScene" uid="uid://3lr2dhy62rhk" path="res://Prefabs/combinable_item.tscn" id="8_wmrff"]
[ext_resource type="PackedScene" uid="uid://b5ukku8i0hilb" path="res://Prefabs/despawning_item.tscn" id="10_6ypk4"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_gkni8"]
custom_solver_bias = 0.1
height = 0.1
radius = 0.1
@@ -46,3 +48,11 @@ hand_pose = SubResource("Resource_lc22d")
[node name="GrabPointHandRight" parent="." index="3" unique_id=514404634 instance=ExtResource("5_vw7i6")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06531982, 0.042291984, -0.08604182)
hand_pose = SubResource("Resource_qyiot")
[node name="FoodItem" parent="." index="4" unique_id=345678912 instance=ExtResource("7_mde49")]
id = "charcoal"
type = 2
[node name="CombinableItem" parent="." index="5" unique_id=996936271 instance=ExtResource("8_wmrff")]
[node name="DespawningItem" parent="." index="7" unique_id=303090111 instance=ExtResource("10_6ypk4")]
+6 -16
View File
@@ -7,9 +7,7 @@
[ext_resource type="PackedScene" uid="uid://ctw7nbntd5pcj" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_right.tscn" id="5_a0a5b"]
[ext_resource type="Animation" uid="uid://d1xnpyc08njjx" path="res://addons/godot-xr-tools/hands/animations/right/Grip 4.res" id="6_bdp75"]
[ext_resource type="PackedScene" uid="uid://3lr2dhy62rhk" path="res://Prefabs/combinable_item.tscn" id="7_bdp75"]
[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="Script" uid="uid://coidnv8b2yvxr" path="res://Prefabs/combine_recipe.gd" id="11_recipe"]
[ext_resource type="PackedScene" uid="uid://b5ukku8i0hilb" path="res://Prefabs/despawning_item.tscn" id="10_uygc5"]
[ext_resource type="PackedScene" uid="uid://bfj80jh13t6e5" path="res://Prefabs/food_item.tscn" id="11_vjw41"]
[sub_resource type="BoxShape3D" id="BoxShape3D_m1xbq"]
@@ -32,12 +30,6 @@ script = ExtResource("4_hc3f7")
closed_pose = ExtResource("6_bdp75")
metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[sub_resource type="Resource" id="Resource_i8ixk"]
script = ExtResource("11_recipe")
ingredient_id = &"cube"
result = ExtResource("8_a0a5b")
metadata/_custom_type_script = "uid://coidnv8b2yvxr"
[node name="PickableObject" unique_id=1675596942 groups=["platalbe_item"] instance=ExtResource("1_dbtw8")]
[node name="CollisionShape3D" parent="." index="0"]
@@ -54,12 +46,10 @@ hand_pose = SubResource("Resource_lc22d")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06531982, 0.042291984, -0.08604182)
hand_pose = SubResource("Resource_qyiot")
[node name="CombinableItem" parent="." index="4" unique_id=996936271 instance=ExtResource("7_bdp75")]
id = &"cube"
recipes = Array[ExtResource("11_recipe")]([SubResource("Resource_i8ixk")])
[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")]
[node name="FoodItem" parent="." index="4" unique_id=63948206 instance=ExtResource("11_vjw41")]
id = "cube"
type = 1
[node name="CombinableItem" parent="." index="5" unique_id=996936271 instance=ExtResource("7_bdp75")]
[node name="DespawningItem" parent="." index="7" unique_id=303090111 instance=ExtResource("10_uygc5")]
+8 -5
View File
@@ -7,8 +7,8 @@
[ext_resource type="Script" uid="uid://dvobm6vcfnqe8" path="res://addons/godot-xr-tools/hands/poses/hand_pose_settings.gd" id="5_w8sii"]
[ext_resource type="PackedScene" uid="uid://ctw7nbntd5pcj" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_right.tscn" id="6_mvnl5"]
[ext_resource type="Animation" uid="uid://d1xnpyc08njjx" path="res://addons/godot-xr-tools/hands/animations/right/Grip 4.res" id="7_wqxjj"]
[ext_resource type="PackedScene" uid="uid://7earnjgdmwgx" path="res://Prefabs/cookable_item.tscn" id="9_hwyyd"]
[ext_resource type="PackedScene" uid="uid://cfc4ho67u4r5e" path="res://Items/cooked_burger.tscn" id="9_r8jvx"]
[ext_resource type="PackedScene" uid="uid://b5ukku8i0hilb" path="res://Prefabs/despawning_item.tscn" id="10_l4hsd"]
[ext_resource type="PackedScene" uid="uid://bfj80jh13t6e5" path="res://Prefabs/food_item.tscn" id="10_yxtxs"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_fco8w"]
height = 0.0338974
@@ -27,7 +27,7 @@ script = ExtResource("5_w8sii")
closed_pose = ExtResource("7_wqxjj")
metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[node name="burger" unique_id=1675596942 instance=ExtResource("1_fco8w")]
[node name="raw_burger" unique_id=1675596942 instance=ExtResource("1_fco8w")]
[node name="CollisionShape3D" parent="." index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.00077831745, 0)
@@ -47,5 +47,8 @@ hand_pose = SubResource("Resource_lc22d")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06531982, 0.042291984, -0.08604182)
hand_pose = SubResource("Resource_qyiot")
[node name="CookableItem" parent="." index="4" unique_id=280820828 instance=ExtResource("9_hwyyd")]
turns_into = ExtResource("9_r8jvx")
[node name="FoodItem" parent="." index="4" unique_id=63948206 instance=ExtResource("10_yxtxs")]
id = "raw_burger"
type = 2
[node name="DespawningItem" parent="." index="6" unique_id=303090111 instance=ExtResource("10_l4hsd")]
+8 -12
View File
@@ -6,10 +6,9 @@
[ext_resource type="Script" uid="uid://dvobm6vcfnqe8" path="res://addons/godot-xr-tools/hands/poses/hand_pose_settings.gd" id="5_ychvb"]
[ext_resource type="PackedScene" uid="uid://ctw7nbntd5pcj" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_right.tscn" id="6_etdv2"]
[ext_resource type="Animation" uid="uid://d1xnpyc08njjx" path="res://addons/godot-xr-tools/hands/animations/right/Grip 4.res" id="7_rl64h"]
[ext_resource type="PackedScene" uid="uid://b5ukku8i0hilb" path="res://Prefabs/despawning_item.tscn" id="10_6p8pj"]
[ext_resource type="PackedScene" uid="uid://3lr2dhy62rhk" path="res://Prefabs/combinable_item.tscn" id="10_ut7mg"]
[ext_resource type="PackedScene" uid="uid://7earnjgdmwgx" path="res://Prefabs/cookable_item.tscn" id="11_5ch2b"]
[ext_resource type="Script" uid="uid://coidnv8b2yvxr" path="res://Prefabs/combine_recipe.gd" id="11_rjayc"]
[ext_resource type="PackedScene" uid="uid://b3m2ag8g5rj4r" path="res://Items/hamburger.tscn" id="11_ut7mg"]
[ext_resource type="PackedScene" uid="uid://bfj80jh13t6e5" path="res://Prefabs/food_item.tscn" id="10_zz42p"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_fco8w"]
height = 0.04777527
@@ -28,12 +27,6 @@ script = ExtResource("5_ychvb")
closed_pose = ExtResource("7_rl64h")
metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[sub_resource type="Resource" id="Resource_wi1yl"]
script = ExtResource("11_rjayc")
ingredient_id = &"burger_buns"
result = ExtResource("11_ut7mg")
metadata/_custom_type_script = "uid://coidnv8b2yvxr"
[node name="CookedBurger" unique_id=1675596942 instance=ExtResource("1_ut7mg")]
[node name="CollisionShape3D" parent="." index="0"]
@@ -54,7 +47,10 @@ hand_pose = SubResource("Resource_lc22d")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06531982, 0.042291984, -0.08604182)
hand_pose = SubResource("Resource_qyiot")
[node name="CombinableItem" parent="." index="4" unique_id=434304805 instance=ExtResource("10_ut7mg")]
recipes = Array[ExtResource("11_rjayc")]([SubResource("Resource_wi1yl")])
[node name="FoodItem" parent="." index="4" unique_id=234567891 instance=ExtResource("10_zz42p")]
id = "cooked_burger"
type = 2
[node name="CookableItem" parent="." index="5" unique_id=280820828 instance=ExtResource("11_5ch2b")]
[node name="CombinableItem" parent="." index="5" unique_id=996936271 instance=ExtResource("10_ut7mg")]
[node name="DespawningItem" parent="." index="7" unique_id=303090111 instance=ExtResource("10_6p8pj")]
+5
View File
@@ -7,6 +7,7 @@
[ext_resource type="PackedScene" uid="uid://ctw7nbntd5pcj" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_right.tscn" id="5_dunns"]
[ext_resource type="Animation" uid="uid://d1xnpyc08njjx" path="res://addons/godot-xr-tools/hands/animations/right/Grip 4.res" id="6_fh0f6"]
[ext_resource type="PackedScene" uid="uid://bfj80jh13t6e5" path="res://Prefabs/food_item.tscn" id="7_yy3y8"]
[ext_resource type="PackedScene" uid="uid://b5ukku8i0hilb" path="res://Prefabs/despawning_item.tscn" id="9_ej8jm"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_fco8w"]
height = 0.10392761
@@ -78,4 +79,8 @@ 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
[node name="DespawningItem" parent="." index="7" unique_id=303090111 instance=ExtResource("9_ej8jm")]
+136
View File
@@ -0,0 +1,136 @@
extends Node
## The whole interaction layer: two RPCs, for every object in the game.
##
## Registered as the "NetGrab" autoload so its RPCs resolve to the same node path
## on every peer.
##
## A hand picks something up locally the instant the player grabs it — no round
## trip, no waiting — and tells the server. The server answers by moving the
## object's NetXform to that peer, which is what actually makes the prediction
## work: a MultiplayerSynchronizer never applies inbound state on the peer that
## owns it, so from that moment the holder's own hand drives the object and the
## server's copy follows instead of fighting it. Releasing hands NetXform back,
## and the server decides where the object really ends up.
##
## Note what is NOT here. There is no per-object networking component, no
## replicated "who is holding this" field to keep in step with the authority, and
## no grant/reject/force-release negotiation. Authority is the single source of
## truth for who simulates an object, and NetWorld.apply_physics_role reads it.
## Starts watching a pickable. Called by NetWorld for every replicated object, so
## no scene has to include a networking node to take part.
func watch(item: XRToolsPickable) -> void:
if item.picked_up.is_connected(_on_picked_up):
return
item.picked_up.connect(_on_picked_up)
item.dropped.connect(_on_dropped)
func _on_picked_up(item: Node3D) -> void:
if not NetworkManager.is_online():
return
# A station snap zone grabbing something is the server placing it, not a
# player taking it, so it must not move authority anywhere.
if not (item.get_picked_up_by() is XRToolsFunctionPickup):
return
NetworkManager.log_line("%s grabbed by hand, claiming it" % item.name)
if NetworkManager.is_server():
_claim(item.get_path(), 1)
else:
# rpc_id() to ourselves is rejected by Godot, which is why the server
# branch calls straight through instead.
_request_grab.rpc_id(1, item.get_path())
func _on_dropped(item: Node3D) -> void:
if not NetworkManager.is_online():
return
# Only the peer that was actually driving the object reports a release. A drop
# caused by losing authority (see NetWorld.apply_physics_role) must not be
# echoed back as if the player had let go.
var xform := item.get_node_or_null(NetReplication.XFORM_NAME)
if not xform or not xform.is_multiplayer_authority():
return
# Our own final transform travels with the release. We were driving the object
# right up to this moment and our position updates ride the synchronizer's
# separate, unordered channel, which this reliable message routinely
# overtakes — so the server's copy can still be back where the object was
# before we carried it away. Deciding the snap from that stale position
# teleports the object straight back into the station it was just taken from.
if NetworkManager.is_server():
_settle(item.get_path(), item.global_transform, item.linear_velocity, item.angular_velocity)
else:
_request_release.rpc_id(
1, item.get_path(), item.global_transform,
item.linear_velocity, item.angular_velocity
)
# --- server side -----------------------------------------------------------
@rpc("any_peer", "reliable")
func _request_grab(item_path: NodePath) -> void:
if not NetworkManager.is_server():
return
_claim(item_path, multiplayer.get_remote_sender_id())
@rpc("any_peer", "reliable")
func _request_release(item_path: NodePath, xform: Transform3D, lin: Vector3, ang: Vector3) -> void:
if not NetworkManager.is_server():
return
_settle(item_path, xform, lin, ang)
func _claim(item_path: NodePath, peer: int) -> void:
var item := get_node_or_null(item_path)
if not item:
return
NetworkManager.log_line("grant %s to peer %d" % [item.name, peer])
# Order matters: hand the object over first, so the station's zone has already
# stopped owning it by the time it is told to let go.
_set_xform_authority.rpc(item_path, peer)
NetStations.release_from_zones(self, item)
func _settle(item_path: NodePath, xform: Transform3D, lin: Vector3, ang: Vector3) -> void:
var item := get_node_or_null(item_path)
if not item:
return
NetworkManager.log_line("release %s" % item.name)
if item is Node3D:
item.global_transform = xform
_set_xform_authority.rpc(item_path, 1)
if item is RigidBody3D:
item.linear_velocity = lin
item.angular_velocity = ang
NetStations.try_snap.call_deferred(self, item)
## set_multiplayer_authority is a local call, so every peer has to run it for
## them to agree on who is driving the object.
@rpc("authority", "call_local", "reliable")
func _set_xform_authority(item_path: NodePath, peer: int) -> void:
var item := get_node_or_null(item_path)
if not item:
return
var xform := item.get_node_or_null(NetReplication.XFORM_NAME)
if not xform:
return
xform.set_multiplayer_authority(peer)
NetworkManager.apply_physics_role(item)
## Hands everything a departing peer was holding back to the server. Without
## this, anything still in their hand when they dropped out would be frozen
## forever on every remaining peer, waiting on an authority that has gone.
func reclaim_from(peer: int) -> void:
if not NetworkManager.is_server():
return
for item in NetworkManager.replicated_objects():
var xform := item.get_node_or_null(NetReplication.XFORM_NAME)
if xform and xform.get_multiplayer_authority() == peer:
NetworkManager.log_line("reclaiming %s from departed peer %d" % [item.name, peer])
_settle(item.get_path(), item.global_transform, Vector3.ZERO, Vector3.ZERO)
+1
View File
@@ -0,0 +1 @@
uid://bv82nioivbmnx
+188
View File
@@ -0,0 +1,188 @@
extends Node
class_name NetReplication
## Builds MultiplayerSynchronizers for any node by convention, so no scene needs
## a hand-authored replication config.
##
## Every replicated node gets TWO synchronizers, both generated here:
##
## NetSync script state (is_dirty, contained_ids, time_cooked, ...).
## Always owned by the server. Gameplay outcomes are the server's to
## decide, so this never changes hands.
## NetXform position + quaternion. Owned by the server while the object is
## loose, and handed to a peer for as long as that peer holds it.
##
## Splitting them is what makes client-side grab prediction work. A
## MultiplayerSynchronizer never applies inbound state on the peer that owns it,
## so giving the holder NetXform means their own hand drives the object with no
## round trip and no fight with the server's copy — while is_dirty and friends
## keep flowing one way, server to client, exactly as before.
##
## The obvious alternative, per-peer visibility (set_visibility_for), does NOT
## work: MultiplayerSpawner also uses synchronizer visibility to decide whether
## a node should exist on a peer, so hiding an object from its holder despawns
## it in their hand. Verified in test/spike/.
##
## The convention for what gets replicated:
## * a Node3D replicates `position` and `quaternion` (never `scale` — nothing
## in this game animates scale as gameplay state)
## * every script variable, on the node and on any scripted descendant, whose
## name does not start with "_" and whose declared type is serialisable
##
## Underscore-prefixed vars are the opt-out, and they already mark exactly the
## state that must not be replicated: @onready node references, cached lookups,
## per-frame bookkeeping.
## SceneReplicationConfig's replication modes. The enum is not exposed under a
## friendly name in GDScript, so they are spelled out here.
const MODE_ALWAYS := 1
const MODE_ON_CHANGE := 2
const SYNC_NAME := "NetSync"
const XFORM_NAME := "NetXform"
## Types that survive a network round trip. Object/Callable/Signal/RID cannot be
## serialised, and are exactly what @onready and cached references hold.
const SYNCABLE_TYPES := [
TYPE_BOOL, TYPE_INT, TYPE_FLOAT, TYPE_STRING, TYPE_STRING_NAME,
TYPE_VECTOR2, TYPE_VECTOR3, TYPE_QUATERNION, TYPE_TRANSFORM3D,
TYPE_COLOR, TYPE_PACKED_STRING_ARRAY, TYPE_ARRAY,
]
## Adds both synchronizers to `node`, unless they are already there. Idempotent.
##
## Must run on EVERY peer, not just the authority: the client's copy is built by
## MultiplayerSpawner straight from the .tscn, so it only has synchronizers if
## something puts them there. NetWorld calls this from the content root's
## child_entered_tree on both sides — early enough that they enter the tree
## inside the spawner's own add_child(), which is what lets them pick up the
## spawn payload (verified in test/spike/: a late joiner receives position and
## script state from a synchronizer that exists only at runtime).
static func attach(node: Node) -> void:
if node is Node3D and not node.has_node(XFORM_NAME):
_add_sync(node, XFORM_NAME, _transform_config())
if not node.has_node(SYNC_NAME):
_add_sync(node, SYNC_NAME, state_config(node))
static func _add_sync(node: Node, sync_name: String, config: SceneReplicationConfig) -> void:
var sync := MultiplayerSynchronizer.new()
sync.name = sync_name
sync.replication_config = config
# Sync every network tick. ON_CHANGE properties are only sent when they
# actually change regardless of this interval.
sync.replication_interval = 0.0
# Inherit the node's authority rather than defaulting to the server. Items are
# server-owned and this changes nothing for them, but a player avatar sets its
# authority to the peer it belongs to in _enter_tree — which has already run by
# the time we get here — and its synchronizer has to agree, or the owning peer
# would be receiving its own head and hands back from the server.
sync.set_multiplayer_authority(node.get_multiplayer_authority())
node.add_child(sync)
## Transform-only config. ALWAYS rather than ON_CHANGE: a carried or simulated
## object changes every tick anyway, so ON_CHANGE would only add a comparison
## per property per tick. spawn = true so a replicated object arrives already in
## the right place instead of sitting at the origin for a frame.
static func _transform_config() -> SceneReplicationConfig:
var config := SceneReplicationConfig.new()
_add(config, ".:position", true, MODE_ALWAYS)
_add(config, ".:quaternion", true, MODE_ALWAYS)
return config
## Script-state config for `node` and its scripted descendants. Public so the
## tests can inspect what the convention picked up without spinning up a session.
##
## ON_CHANGE, not ALWAYS: the value is then only sent — and, crucially, only
## ASSIGNED on the receiving peer — when it actually changes. Under ALWAYS every
## replicated setter becomes a per-tick hot path, which is how this project
## previously ended up rebuilding every plate's visuals 60 times a second.
static func state_config(node: Node) -> SceneReplicationConfig:
var config := SceneReplicationConfig.new()
for path in _script_var_paths(node, node):
_add(config, path, true, MODE_ON_CHANGE)
return config
static func _add(config: SceneReplicationConfig, path: String, spawn: bool, mode: int) -> void:
var np := NodePath(path)
config.add_property(np)
config.property_set_spawn(np, spawn)
config.property_set_replication_mode(np, mode)
## Whether a script comes from a third-party addon rather than this game.
##
## Addon components are local plumbing, and replicating their configuration is
## not merely wasteful — it is actively wrong. godot-xr-tools' snap zones and
## pickables both expose a public `enabled`, which is precisely the flag each
## peer has to set for ITSELF: a client disables its stations' snap zones because
## placement is the server's decision, and disables a pickable another player is
## holding. Replicating those meant the server helpfully sent `enabled = true`
## straight back over every client's gate, so stations on clients went on
## grabbing objects out of the local player's hands.
##
## Their values are authored in the scene file and therefore already identical on
## every peer, so nothing is lost by leaving them alone.
static func _is_addon(script: Script) -> bool:
return script.resource_path.begins_with("res://addons/")
## Whether a typed array holds something that can cross the wire.
##
## An array of nodes cannot, and this game has several: ItemContainer's
## meal_positions/side_positions are Array[Node3D], and contained_items is
## Array[FoodItem]. Replicating one would try to serialise live node references.
##
## GDScript reports the element type three different ways, so all three are
## handled here (verified against the real scripts):
## Array[String] hint 23, hint_string "4:" -> element type 4
## Array[Node3D] hint 23, hint_string "24/34:Node3D" -> element type 24
## Array[FoodItem] hint 31, hint_string "FoodItem" -> a class name
## An untyped Array reports an empty hint_string and is excluded too: it can hold
## anything, including nodes, so there is no safe answer.
static func _is_syncable_array(prop: Dictionary) -> bool:
var hint_string := str(prop["hint_string"])
if hint_string.is_empty():
return false
var head := hint_string.split(":")[0].split("/")[0]
if not head.is_valid_int():
# A bare class name, e.g. "FoodItem".
return false
return SYNCABLE_TYPES.has(head.to_int()) and head.to_int() != TYPE_ARRAY
## Every "<relative path>:<var>" on `node` and its scripted descendants.
## Descends through children but stops at anything carrying its own synchronizer
## — that subtree replicates itself and must not be replicated twice.
static func _script_var_paths(root: Node, node: Node) -> Array[String]:
var paths: Array[String] = []
var prefix: String = "." if node == root else str(root.get_path_to(node))
var script: Script = node.get_script() as Script
# Note the descent below still happens for an addon-scripted node — only its
# own properties are skipped. plate.tscn's root is godot-xr-tools' pickable.gd
# and its PlateController child is where the game state actually lives.
if script and _is_addon(script):
script = null
if script:
for prop in script.get_script_property_list():
var prop_name := str(prop["name"])
if prop_name.begins_with("_"):
continue
if not (prop["usage"] & PROPERTY_USAGE_SCRIPT_VARIABLE):
continue
if not SYNCABLE_TYPES.has(prop["type"]):
continue
if prop["type"] == TYPE_ARRAY and not _is_syncable_array(prop):
continue
paths.append("%s:%s" % [prefix, prop_name])
for child in node.get_children():
if child is MultiplayerSynchronizer or child is MultiplayerSpawner:
continue
if child.has_node(SYNC_NAME) or child.has_node(XFORM_NAME):
continue
paths.append_array(_script_var_paths(root, child))
return paths
+1
View File
@@ -0,0 +1 @@
uid://bmuqb0yywjfyw
+64
View File
@@ -0,0 +1,64 @@
extends Node
class_name NetStations
## Server-side placement rules for stations. Generic over the "station" group —
## there is nothing per-station here, and nothing any individual station scene
## has to opt into.
##
## Placement is a server decision for the same reason cooking is: every peer runs
## its own copy of a snap zone, so letting each decide independently means the
## same object gets grabbed in two places at once.
## Every snap zone belonging to a station. Some stations (Table) have more than
## one, so this is not a one-per-station lookup.
static func zones(context: Node) -> Array:
var found := []
for station in context.get_tree().get_nodes_in_group("station"):
for child in station.get_children():
if child is XRToolsSnapZone:
found.append(child)
return found
## Frees an object from whatever station is currently holding it, because
## someone has just taken it by hand.
static func release_from_zones(context: Node, item: Node) -> void:
for zone in zones(context):
if zone.picked_up_object == item:
zone.drop_object()
# Make the zone forget it as well. These zones are snap_mode=RANGE, so
# every frame they re-grab anything still listed in their grab area — and
# Jolt does NOT emit body_exited when let_go() switches the object's
# collision layer back out of the zone's mask, so the entry never clears
# on its own. The station then snatches the object straight back off the
# player who just took it and teleports it home. Bringing it near again
# re-adds it properly, and releasing next to a station is handled
# explicitly by try_snap below.
if zone._object_in_grab_area.has(item):
zone._object_in_grab_area.erase(item)
## Snaps a just-released object into the nearest empty station zone in range.
##
## Call this DEFERRED. XRToolsFunctionPickup's own "grab an object out of a snap
## zone" path calls zone.drop_object() before it calls pick_up() on the hand's
## behalf, and drop_object() synchronously fires the `dropped` signal that lands
## here. Running inline would immediately re-snap the object into the very zone
## it is still physically inside, stealing it before the hand's own pick_up()
## later in the same call stack ever runs — leaving the hand pointing at an
## object whose grab driver belongs to the zone, which crashes on the next
## controller press. The is_picked_up() check below is the second guard, for the
## case where something grabs it for real before this runs.
static func try_snap(context: Node, item: Node) -> void:
if not (item is Node3D) or not is_instance_valid(item):
return
if item.has_method("is_picked_up") and item.is_picked_up():
return
for zone in zones(context):
if is_instance_valid(zone.picked_up_object):
continue
if zone.global_position.distance_to(item.global_position) <= zone.grab_distance:
NetworkManager.log_line("snapped %s into %s" % [item.name, zone.get_parent().name])
zone.pick_up_object(item)
return
+1
View File
@@ -0,0 +1 @@
uid://cgp15pxa7ui1r
+251
View File
@@ -0,0 +1,251 @@
extends Node
class_name NetWorld
## Owns the replicated contents of the world: what exists, where it lives, and
## which peer is allowed to simulate it.
##
## Everything here runs on Godot's stock MultiplayerSpawner in its DEFAULT mode.
## There is no spawn_function and no payload dictionary: the server instantiates
## a scene, sets it up, and adds it under the spawn path — the spawner replicates
## the creation (and later the deletion) to every peer, including late joiners,
## and the synchronizers NetReplication attaches carry the state.
##
## The two hooks that make this generic, rather than something each object opts
## into:
##
## * content_root.child_entered_tree -> NetReplication.attach, on EVERY peer.
## The client's copy is built by the spawner straight from the .tscn, so this
## is what gives it synchronizers at all. It also runs early enough for them
## to pick up the spawn payload.
## * the same hook, on clients only -> _gate. One rule decides what a client is
## not allowed to simulate, for any object, whatever it happens to be.
## Directories scanned for spawnable scenes. Anything in them can be spawned
## over the network without being registered by hand anywhere.
const SPAWNABLE_DIRS := [
"res://Items/",
"res://Containers/",
"res://Stations/",
"res://Prefabs/",
]
var _spawner: MultiplayerSpawner
var _content_root: Node
## Wires this up to the world scene's spawner and content root. Must run on every
## peer BEFORE it connects, so the spawnable list is identical by the time any
## spawn packet can arrive.
func setup(spawner: MultiplayerSpawner, content_root: Node) -> void:
_spawner = spawner
_content_root = content_root
_register_spawnables()
_content_root.child_entered_tree.connect(_on_content_child_entered)
## Registers every scene under SPAWNABLE_DIRS, sorted.
##
## The sort is not cosmetic. Auto-spawn puts an INDEX into this list on the wire,
## not a path, so a peer whose list is ordered differently instantiates the wrong
## scene entirely. Directory listing order is not guaranteed to match across
## machines, so it is pinned here.
func _register_spawnables() -> void:
var scenes: Array[String] = []
for dir in SPAWNABLE_DIRS:
for file in ResourceLoader.list_directory(dir):
if file.ends_with(".tscn"):
scenes.append(dir + file)
scenes.sort()
for scene in scenes:
_spawner.add_spawnable_scene(scene)
NetworkManager.log_line("Registered %d spawnable scenes" % scenes.size())
func _on_content_child_entered(node: Node) -> void:
# Our own synchronizers re-enter here as children of the node, not of the
# content root, so this only ever sees spawned roots — but the guard is cheap
# and makes the intent explicit.
if node is MultiplayerSynchronizer:
return
NetReplication.attach(node)
# Grab handling is wired up centrally, so no scene has to carry a networking
# component to be pickable over the network.
if node is XRToolsPickable:
NetGrab.watch(node)
if not NetworkManager.owns_world():
_gate(node)
# Deferred, in this order, because both depend on the node being fully
# constructed: XRToolsPickable captures original_collision_mask in an @onready,
# which has not run yet at child_entered_tree time. Reading it now would
# record 0 as the object's authored collision mask and it would never collide
# with anything again.
_remember_authored.call_deferred(node)
apply_physics_role.call_deferred(node)
# --- spawning --------------------------------------------------------------
## Creates a networked object. Server-only when online (the spawner replicates
## it from there); works directly when offline.
##
## `props` are applied BEFORE the node enters the tree, so they ride the spawn
## packet as the synchronizer's spawn properties and every peer builds the object
## already configured. Note that this means their setters run before the node is
## in the tree, where @onready references are still null — any setter reachable
## this way has to be null-guarded.
func spawn(scene_path: String, xform: Transform3D, node_name: String = "", props: Dictionary = {}) -> Node:
if not NetworkManager.owns_world():
return null
var scene: PackedScene = load(scene_path)
if not scene:
push_error("NetWorld.spawn: could not load scene %s" % scene_path)
return null
var inst := scene.instantiate()
if node_name != "":
inst.name = node_name
for key in props:
inst.set(key, props[key])
if inst is Node3D:
inst.transform = xform
_content_root.add_child(inst)
# global_transform can only be honoured once the node has a parent to be
# global relative to. Content roots are normally at the origin, but a debug
# scene is free to move one.
if inst is Node3D:
inst.global_transform = xform
NetworkManager.log_line("spawn: %s as %s" % [scene_path.get_file(), inst.name])
return inst
## Destroys a networked object everywhere. The spawner broadcasts the despawn
## when a tracked node leaves the tree on the authority, so freeing it here is
## the whole implementation — there is no despawn RPC any more.
##
## Callers reach this holding all sorts of nodes (a component such as
## DespawningItem, or a visual deep inside a plate), so it walks up to the object
## the spawner actually knows about. Getting that wrong used to leave a ghost
## copy on every client, which then blocked the station it was sitting in.
func despawn(node: Node) -> void:
if not NetworkManager.owns_world() or not is_instance_valid(node):
return
var root := _spawned_root(node)
if not root:
# Not part of the replicated world at all (a cosmetic copy parented under
# a plate, say). Freeing it locally is all that was ever meant.
node.queue_free()
return
NetworkManager.log_line("despawn: %s" % root.name)
root.queue_free()
# The ancestor that is a direct child of the content root — i.e. the node the
# spawner tracks — or null if this node is not part of the replicated world.
func _spawned_root(node: Node) -> Node:
var current := node
while current:
if current.get_parent() == _content_root:
return current
current = current.get_parent()
return null
## Every replicated object currently in the world.
func objects() -> Array[Node]:
var found: Array[Node] = []
if _content_root:
for child in _content_root.get_children():
found.append(child)
return found
# --- what a client is not allowed to simulate ------------------------------
## The one gating rule, applied to every replicated object on peers that do not
## own world logic.
##
## Stations decide things (what has cooked, what is clean, what snaps where) and
## those decisions are the server's, so a client neither runs their logic nor
## lets their snap zones grab anything. Without this each peer independently
## grabs and simulates the same shared object, and the copies drift apart.
##
## Note what is NOT here: display code. A client still has to show a lit hob and
## a dirty plate, so anything visual must be driven from a replicated value's
## setter rather than from _process — which is where it belongs anyway, since
## that is the only version that also works for a late joiner.
func _gate(node: Node) -> void:
if node.is_in_group("station"):
node.set_process(false)
var zones := _snap_zones_of(node)
for zone in zones:
zone.enabled = false
zone.set_process(false)
NetworkManager.log_line("gated %s (%d snap zones)" % [node.name, zones.size()])
func _snap_zones_of(node: Node) -> Array:
var zones := []
for child in node.get_children():
if child is XRToolsSnapZone:
zones.append(child)
return zones
## Puts a body into the right physics state for whether this peer is currently
## driving it, which is exactly "do we own its NetXform".
##
## The authority IS the state here. The old implementation carried a replicated
## `net_held_by` peer id alongside the authority and reconciled the two by hand,
## which is what made held items get stuck frozen, or disabled forever, when the
## two disagreed. There is only one source of truth now.
##
## Called when an object is created and again whenever its NetXform changes
## hands, which is the complete set of moments the answer can change.
func apply_physics_role(node: Node) -> void:
if not (node is RigidBody3D):
return
var xform := node.get_node_or_null(NetReplication.XFORM_NAME)
if not xform:
return
var body: RigidBody3D = node
if xform.is_multiplayer_authority():
# We simulate it: restore whatever the scene authored. XRToolsPickable
# manages freeze and collision itself while an object is actually in a
# hand, so a held object is left alone.
if body is XRToolsPickable and body.is_picked_up():
return
body.freeze = false
body.freeze_mode = body.get_meta("net_freeze_mode", body.freeze_mode)
if body is XRToolsPickable:
body.collision_mask = body.original_collision_mask
# `enabled` has to be restored explicitly. Nothing else ever writes it
# back: the non-authority branch below clears it, so once any peer had
# held this object every other peer left it disabled forever. On the
# server that quietly broke everything downstream — hands could no
# longer pick the object up, while a snap zone still reported having
# grabbed it.
body.enabled = body.get_meta("net_enabled", body.enabled)
return
# Someone else drives it: stop simulating and just follow the sync. Kinematic
# rather than static so the incoming transform can still move it.
if body is XRToolsPickable and body.is_picked_up():
body.drop()
body.freeze = true
body.freeze_mode = RigidBody3D.FREEZE_MODE_KINEMATIC
body.collision_mask = 0
if body is XRToolsPickable:
# Still grabbable if the SERVER owns it, because that just means the object
# is lying around loose — being able to pick those up is the entire point.
# Only an object held by another player is off limits, and that is exactly
# when NetXform belongs to a peer other than 1.
body.enabled = xform.get_multiplayer_authority() == 1
# Records the state the scene authored, before gating has a chance to overwrite
# it, so reclaiming an object restores what it was built with rather than
# whatever the frozen-follower state last forced on it.
func _remember_authored(node: Node) -> void:
if not (node is RigidBody3D) or node.has_meta("net_freeze_mode"):
return
node.set_meta("net_freeze_mode", node.freeze_mode)
if node is XRToolsPickable:
node.set_meta("net_enabled", node.enabled)
+1
View File
@@ -0,0 +1 @@
uid://bgo0xq4uupuhi
+264
View File
@@ -0,0 +1,264 @@
extends Node
## Session manager for VRyHungry (listen-server model: the host is peer 1 and
## also plays).
##
## Registered as the "NetworkManager" autoload. This owns the transport and the
## session lifecycle, and nothing else — what exists in the world and who is
## allowed to simulate it belongs to NetWorld, and interaction belongs to
## NetGrab. The spawn_item/despawn_item pair below are deliberately thin
## forwards, so game code keeps one obvious place to call.
const DEFAULT_PORT := 24565
const MAX_CLIENTS := 7
## Emitted on every peer (including the server for its own local player) when a
## player peer joins. On the server this fires for each remote peer; the server
## uses it to spawn that peer's avatar.
signal player_joined(peer_id: int)
signal player_left(peer_id: int)
signal session_started(is_server: bool)
signal session_ended()
signal connection_failed()
var _world: Node = null
var _net_world: NetWorld = null
var _log_file: FileAccess
## Reason the session ended, shown by the menu on its next _ready() (see
## take_status). Avoids depending on a live signal connection to a panel that
## does not exist yet at the moment the session actually ends.
var last_status := ""
func _ready() -> void:
_open_log()
multiplayer.peer_connected.connect(_on_peer_connected)
multiplayer.peer_disconnected.connect(_on_peer_disconnected)
multiplayer.connected_to_server.connect(_on_connected_to_server)
multiplayer.connection_failed.connect(_on_connection_failed)
multiplayer.server_disconnected.connect(_on_server_disconnected)
# --- session ---------------------------------------------------------------
## Start hosting. The host is peer 1 and also plays.
func host(port: int = DEFAULT_PORT) -> Error:
var peer := ENetMultiplayerPeer.new()
var err := peer.create_server(port, MAX_CLIENTS)
if err != OK:
log_line("HOST failed to create_server on port %d: %s" % [port, error_string(err)])
return err
multiplayer.multiplayer_peer = peer
log_line("HOST started on port %d (peer id %d)" % [port, multiplayer.get_unique_id()])
session_started.emit(true)
player_joined.emit(multiplayer.get_unique_id())
return OK
## Join an existing host.
func join(address: String = "127.0.0.1", port: int = DEFAULT_PORT) -> Error:
var peer := ENetMultiplayerPeer.new()
var err := peer.create_client(address, port)
if err != OK:
log_line("JOIN failed to create_client %s:%d: %s" % [address, port, error_string(err)])
return err
multiplayer.multiplayer_peer = peer
log_line("JOIN connecting to %s:%d ..." % [address, port])
return OK
## Leave the session and tear down transport.
func leave() -> void:
_go_offline()
log_line("Session ended")
session_ended.emit()
# Restore Godot's default OfflineMultiplayerPeer rather than leaving the peer
# null: is_multiplayer_authority() and get_unique_id() both throw on a null peer,
# and plenty of code keeps calling them while we are back in menu state.
func _go_offline() -> void:
if multiplayer.multiplayer_peer:
multiplayer.multiplayer_peer.close()
multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new()
unregister_world()
func is_server() -> bool:
return is_online() and multiplayer.is_server()
## True only when a real ENet session is active. Godot installs a default
## OfflineMultiplayerPeer, so a non-null peer alone does not mean "online".
func is_online() -> bool:
var p := multiplayer.multiplayer_peer
return p != null and not (p is OfflineMultiplayerPeer)
## True on the machine that owns authoritative world logic: the server when
## online, or the single player when offline. Station logic and spawning only run
## where this is true, so state has one source of truth.
func owns_world() -> bool:
return not is_online() or is_server()
# --- world -----------------------------------------------------------------
## Called by the world scene once its tree exists. Must run before
## world_ready()/host()/join() on every peer, so the spawnable scene list is
## registered before any spawn packet can arrive.
func register_world(world: Node, net_world: NetWorld) -> void:
_world = world
_net_world = net_world
log_line("World registered")
## Called when the world scene goes away (disconnect, leaving the session) so the
## autoload does not hold freed references across a scene reload.
func unregister_world() -> void:
_world = null
_net_world = null
## Creates a networked object. See NetWorld.spawn.
func spawn_item(scene_path: String, xform: Transform3D, node_name: String = "", props: Dictionary = {}) -> Node:
if not _net_world:
push_error("spawn_item called with no world registered: %s" % scene_path)
return null
return _net_world.spawn(scene_path, xform, node_name, props)
## Destroys a networked object everywhere. See NetWorld.despawn.
func despawn_item(node: Node) -> void:
if _net_world:
_net_world.despawn(node)
## Puts an object into the right physics state for whether this peer drives it.
func apply_physics_role(node: Node) -> void:
if _net_world:
_net_world.apply_physics_role(node)
## Every replicated object currently in the world.
func replicated_objects() -> Array[Node]:
if not _net_world:
return []
return _net_world.objects()
## Called by the world scene after it has registered itself and connected its
## listeners. Kicks off any menu- or command-line-driven session, so session
## signals never fire before the world is listening for them.
func world_ready() -> void:
consume_pending_session()
# --- menu-driven session request -------------------------------------------
# Set by the main menu's Host/Join buttons before switching to the multiplayer
# scene; consumed once that scene is ready to listen for session signals (avoids
# a race between change_scene_to_file and the connection callbacks).
var pending_action := ""
var pending_ip := ""
func request_host() -> void:
pending_action = "host"
func request_join(ip: String) -> void:
pending_action = "join"
pending_ip = ip
func consume_pending_session() -> void:
if pending_action == "host":
pending_action = ""
host()
elif pending_action == "join":
pending_action = ""
join(pending_ip)
else:
_handle_cmdline()
## Returns the reason the last session ended (if any) and clears it. The menu
## pulls this on its own _ready() rather than depending on a live signal
## connection to a panel that does not exist yet when the session ends.
func take_status() -> String:
var s := last_status
last_status = ""
return s
# --- session signal handlers ----------------------------------------------
func _on_peer_connected(peer_id: int) -> void:
log_line("peer_connected: %d" % peer_id)
if is_server():
player_joined.emit(peer_id)
func _on_peer_disconnected(peer_id: int) -> void:
log_line("peer_disconnected: %d" % peer_id)
if is_server():
# Anything still in their hand would otherwise stay frozen on every
# remaining peer, waiting on an authority that has gone.
NetGrab.reclaim_from(peer_id)
player_left.emit(peer_id)
func _on_connected_to_server() -> void:
log_line("connected_to_server (my id=%d)" % multiplayer.get_unique_id())
session_started.emit(false)
func _on_connection_failed() -> void:
log_line("connection_failed")
_go_offline()
last_status = "Could not connect"
connection_failed.emit()
func _on_server_disconnected() -> void:
log_line("server_disconnected")
_go_offline()
last_status = "Host disconnected"
session_ended.emit()
# --- command-line driven test bootstrap -----------------------------------
func _handle_cmdline() -> void:
var args := OS.get_cmdline_user_args()
if args.has("--server"):
log_line("cmdline: --server")
host()
elif args.has("--join"):
var idx := args.find("--join")
var addr := "127.0.0.1"
if idx + 1 < args.size():
addr = args[idx + 1]
log_line("cmdline: --join %s" % addr)
join(addr)
# --- logging ---------------------------------------------------------------
func _open_log() -> void:
var dir := OS.get_environment("TEMP")
if dir.is_empty():
dir = OS.get_environment("TMPDIR")
if dir.is_empty():
dir = "user://"
var path := dir.path_join("vryhungry_net_%d.log" % OS.get_process_id())
_log_file = FileAccess.open(path, FileAccess.WRITE)
log_line("=== NetworkManager log (pid %d) ===" % OS.get_process_id())
func log_line(s: String) -> void:
var id := 0
var p := multiplayer.multiplayer_peer
if p != null and p.get_connection_status() == MultiplayerPeer.CONNECTION_CONNECTED:
id = multiplayer.get_unique_id()
var line := "[NET %d] %s" % [id, s]
print(line)
if _log_file:
_log_file.store_line(line)
_log_file.flush()
+1
View File
@@ -0,0 +1 @@
uid://deefoory0vqmm
+79
View File
@@ -0,0 +1,79 @@
extends Node
class_name WorldLayout
## Reads the kitchen a scene file authored and describes it as data, so the
## server can respawn it as replicated objects.
##
## The authored nodes are a template, not the live world. Baking them into the
## scene would mean each peer ran its own unsynced copy; spawning them means the
## client receives the server's, through the same path as a mid-session join.
## Directories whose scenes count as world content, and the base type to look for
## in each. Anything instanced from these is picked up automatically — adding a
## new station or item needs no change here.
const SOURCES := [
{"dir": "res://Stations/", "type": "StaticBody3D"},
{"dir": "res://Items/", "type": "XRToolsPickable"},
{"dir": "res://Containers/", "type": "XRToolsPickable"},
]
## Every authored node in the current scene, stations first.
##
## Order matters: stations have to exist before items, so an item spawning on top
## of one lands in a snap zone that is already there.
func get_authored_nodes() -> Array[Node]:
var found: Array[Node] = []
for source in SOURCES:
for node in _instances_of(source["dir"], source["type"]):
if not found.has(node):
found.append(node)
return found
func _instances_of(dir: String, type: String) -> Array[Node]:
var scenes := []
for file in ResourceLoader.list_directory(dir):
scenes.append(dir + file)
var found: Array[Node] = []
for node in get_tree().root.find_children("*", type, true, false):
if node.scene_file_path in scenes:
found.append(node)
return found
## Turns authored nodes into spawn descriptions.
func describe(nodes: Array[Node]) -> Array[Dictionary]:
var data: Array[Dictionary] = []
for node in nodes:
data.append(_describe_one(node))
return data
func _describe_one(node: Node) -> Dictionary:
return {
"scene": node.scene_file_path,
"name": node.name,
# Global, not local: the copies are respawned under one content root, so
# an authored node nested inside another (JonScene parents Counter5 under
# Counter3) would otherwise land in the wrong place.
"xform": node.global_transform,
"props": _authored_props(node),
}
# Only authored configuration — @export vars, the ones the editor exposes. Plain
# script variables are live runtime state, and replaying those into a fresh
# instance re-runs their setters before the node is in the tree, where any setter
# touching an @onready reference blows up.
func _authored_props(node: Node) -> Dictionary:
var props := {}
var script: Script = node.get_script() as Script
if not script:
return props
for prop in script.get_script_property_list():
var prop_name := str(prop["name"])
if not (prop["usage"] & PROPERTY_USAGE_EDITOR) or prop_name.begins_with("_"):
continue
props[prop_name] = node.get(prop_name)
return props
+1
View File
@@ -0,0 +1 @@
uid://donvkica3drtx
+106
View File
@@ -0,0 +1,106 @@
extends Node3D
## Networked representation of one connected player.
##
## The owning peer's local XR rig drives the three transforms below every frame;
## the generated NetSync replicates them, and every other peer applies them to
## the avatar's head and hands. They are ordinary script variables rather than an
## authored replication config, so the avatar goes through exactly the same
## convention as every other replicated object.
@onready var _head: Node3D = $Head
@onready var _left_hand: Node3D = $LeftHand
@onready var _right_hand: Node3D = $RightHand
## Replicated pose. Underscore-free by design — that is what marks a variable as
## replicated (see NetReplication). Written by the owning peer, applied by
## everyone else through the setters.
var head_xform: Transform3D = Transform3D.IDENTITY: set = _set_head_xform
var left_xform: Transform3D = Transform3D.IDENTITY: set = _set_left_xform
var right_xform: Transform3D = Transform3D.IDENTITY: set = _set_right_xform
var _local_camera: Node3D
var _local_left_hand: Node3D
var _local_right_hand: Node3D
func _enter_tree() -> void:
# The avatar's name is the peer id it belongs to. Authority has to be claimed
# here rather than in _ready(): NetReplication reads it when it attaches the
# synchronizers, which happens as this node enters the tree.
set_multiplayer_authority(str(name).to_int())
func _ready() -> void:
# LeftHand/RightHand are the full godot-xr-tools glove scenes, whose root
# carries hand.gd. That script sets top_level = true and every physics frame
# repositions itself to track a live XRController3D parent. Here the parent is
# just this avatar, not a controller, so leaving it running fights both the
# local copy below and the replicated values on other peers — and mostly wins,
# since it runs every physics tick regardless of our _process. That was the
# "hands stuck near the origin, only occasionally correct" symptom. Nothing
# else in that script matters here; _controller is always null without a real
# controller ancestor, so the grip animation already no-ops.
_left_hand.set_physics_process(false)
_right_hand.set_physics_process(false)
if not is_multiplayer_authority():
set_process(false)
# State that arrived in the spawn packet was applied before these @onready
# references existed, so render it now.
_apply_pose()
return
var origin := get_tree().get_first_node_in_group("local_xr_origin")
if origin:
_local_camera = origin.get_node_or_null("XRCamera3D")
_local_left_hand = origin.get_node_or_null("XRControllerLeftHand")
_local_right_hand = origin.get_node_or_null("XRControllerRightHand")
# Every peer's rig is baked at the same spot, so spread joiners along X
# rather than starting them stacked on top of each other. ENet peer ids
# are large effectively-random 32-bit numbers, so this has to be bounded
# AND kept well inside the floor's footprint — an earlier version used up
# to 12 units and could drop a joining player off the edge.
var peer_id := str(name).to_int()
if peer_id != 1:
var slot := absi(peer_id) % 4
origin.position += Vector3((slot - 1.5) * 1.2, 0, 0)
# Don't render your own floating head and hands from the inside.
_head.visible = false
_left_hand.visible = false
_right_hand.visible = false
func _process(_delta: float) -> void:
if _local_camera:
head_xform = _local_camera.global_transform
if _local_left_hand:
left_xform = _local_left_hand.global_transform
if _local_right_hand:
right_xform = _local_right_hand.global_transform
# The setters are null-guarded because a spawn-replicated property fires its
# setter BEFORE the node is in the tree, when @onready references are still null.
func _set_head_xform(value: Transform3D) -> void:
head_xform = value
if _head:
_head.global_transform = value
func _set_left_xform(value: Transform3D) -> void:
left_xform = value
if _left_hand:
_left_hand.global_transform = value
func _set_right_xform(value: Transform3D) -> void:
right_xform = value
if _right_hand:
_right_hand.global_transform = value
func _apply_pose() -> void:
_head.global_transform = head_xform
_left_hand.global_transform = left_xform
_right_hand.global_transform = right_xform
+1
View File
@@ -0,0 +1 @@
uid://bncuxh7j7ix5q
+19
View File
@@ -0,0 +1,19 @@
[gd_scene load_steps=4 format=3]
[ext_resource type="Script" path="res://Player/net_player.gd" id="1_np001"]
[ext_resource type="PackedScene" uid="uid://bq86r4yll8po" path="res://addons/godot-xr-tools/hands/scenes/lowpoly/left_fullglove_low.tscn" id="2_np002"]
[ext_resource type="PackedScene" uid="uid://xqimcf20s2jp" path="res://addons/godot-xr-tools/hands/scenes/lowpoly/right_fullglove_low.tscn" id="3_np003"]
[sub_resource type="CapsuleMesh" id="CapsuleMesh_np004"]
radius = 0.09
height = 0.22
[node name="NetPlayer" type="Node3D"]
script = ExtResource("1_np001")
[node name="Head" type="MeshInstance3D" parent="."]
mesh = SubResource("CapsuleMesh_np004")
[node name="LeftHand" parent="." instance=ExtResource("2_np002")]
[node name="RightHand" parent="." instance=ExtResource("3_np003")]
+93 -14
View File
@@ -1,24 +1,103 @@
class_name CombinableItem
extends Node
## Identity of this item, referenced by other items' recipes.
@export var id: StringName
const RECIPE_MANAGER = preload("res://RecipeManager.gd")
## Recipes describing what the item holding this component turns into when
## another item is combined into it while snapped. Recipes are directional:
## only the snapped (base) item's recipes are consulted.
@export var recipes: Array[CombineRecipe] = []
@onready var combine_area_3d: Area3D = $Area3d
@onready var _pickable: XRToolsPickable = get_parent() as XRToolsPickable
# Guard so a combine only fires once.
var _combining: bool = false
var _food_item: FoodItem
func _ready() -> void:
if id.is_empty():
push_error("CombinableItem on ", get_parent().name, " has no 'id' set.")
print("CombinableItem _ready(): ", _pickable.name)
_food_item = get_parent().get_node_or_null("FoodItem") as FoodItem
if not _food_item:
push_error("CombinableItem is missing FoodItem reference. must be a sibling of a FoodItem on ", get_parent().name, ".")
if not _pickable:
push_error("CombineZone must be a grand child of an XRToolsPickable.")
return
if not _food_item:
push_error("CombineZone requires a FoodItem sibling on ", _pickable.name, ".")
return
# Detect items whether held (layer 17 "Held Objects") or loose
# (layer 3 "Pickable Objects"). Don't advertise a layer of our own.
combine_area_3d.collision_mask = 0b0000_0000_0000_0001_0000_0000_0000_0100
combine_area_3d.collision_layer = 0
# Deferred: _ready can run during a physics signal flush (when a combine
# spawns the result), where toggling monitoring directly is forbidden.
set_deferred("monitoring", false)
set_deferred("monitorable", false)
# Signals
_pickable.picked_up.connect(_on_item_picked_up)
_pickable.dropped.connect(_on_item_dropped)
combine_area_3d.body_entered.connect(_on_body_entered)
## Returns the scene this item becomes when combined with [param other_id],
## or null if there is no matching recipe.
func get_result_for(other_id: StringName) -> PackedScene:
for recipe in recipes:
if recipe and recipe.ingredient_id == other_id:
return recipe.result
# Enable the trigger only while snapped into a snap zone (not hand-held).
func _on_item_picked_up(_item: Node3D) -> void:
var by := _pickable.get_picked_up_by()
var snapped: bool = by != null and by.has_method("is_xr_class") and by.is_xr_class("XRToolsSnapZone")
set_deferred("monitoring", snapped)
func _on_item_dropped(_item: Node3D) -> void:
set_deferred("monitoring", false)
# If the other body is a FoodItem, check for a recipe and combine if one exists.
# Combining is a server decision (the base item is server-snapped into a zone).
func _on_body_entered(body: Node3D) -> void:
if not NetworkManager.owns_world():
return
if _combining or body == _pickable:
print("CombinableItem _on_body_entered: other is our own pickable")
return
var other := _find_food_item(body)
if not other:
print("CombinableItem _on_body_entered: other is not a foodItem")
return
var result: PackedScene = RECIPE_MANAGER.get_combination_result(_food_item.id, other.id)
if not result:
print("CombinableItem _on_body_entered: There is no recipe for %s + %s" % [_food_item.id, other.id])
return
_combine(body, result)
# Instantiate the result of combination and free the two ingredient items
func _combine(other_body: Node3D, result: PackedScene) -> void:
print("CombinableItem _combine: combining %s + %s into %s" % [_food_item.id, _find_food_item(other_body).id, result.resource_path])
# Get Snapzone
var snap_zone := _pickable.get_picked_up_by()
if not snap_zone or not snap_zone.has_method("pick_up_object"):
return
# Spawn the result through the server (so it replicates to every peer,
# including late joiners) at the base item's location, in world space.
var base_transform := _pickable.global_transform
var result_instance: Node3D = NetworkManager.spawn_item(result.resource_path, base_transform)
# Free the pickable / root of this item and consume the incoming item.
snap_zone.drop_object()
NetworkManager.despawn_item(_pickable)
other_body.drop()
NetworkManager.despawn_item(other_body)
# Snap the result into the now-empty zone.
snap_zone.pick_up_object(result_instance)
# Find a FoodItem among the direct children of [param node].
func _find_food_item(node: Node) -> FoodItem:
if not node:
return null
for child in node.get_children():
if child is FoodItem:
return child
return null
+5 -10
View File
@@ -1,19 +1,14 @@
[gd_scene format=3 uid="uid://3lr2dhy62rhk"]
[ext_resource type="Script" uid="uid://dounic663dn5q" path="res://Prefabs/combinable_item.gd" id="1_q21ti"]
[ext_resource type="Script" uid="uid://coidnv8b2yvxr" path="res://Prefabs/combine_recipe.gd" id="2_anbu7"]
[ext_resource type="Script" uid="uid://e3im02nq5cye" path="res://Prefabs/combine_zone.gd" id="4_0om48"]
[sub_resource type="BoxShape3D" id="BoxShape3D_combine"]
size = Vector3(0.16, 0.16, 0.16)
[sub_resource type="SphereShape3D" id="SphereShape3D_o1b3t"]
radius = 0.2
[node name="CombinableItem" type="Node3D" unique_id=996936271]
script = ExtResource("1_q21ti")
id = &"some_food_item"
recipes = Array[ExtResource("2_anbu7")]([null])
[node name="CombineZone" type="Area3D" parent="." unique_id=1514178016]
script = ExtResource("4_0om48")
[node name="Area3d" type="Area3D" parent="." unique_id=1514178016]
[node name="CollisionShape3D" type="CollisionShape3D" parent="CombineZone" unique_id=706892516]
shape = SubResource("BoxShape3D_combine")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Area3d" unique_id=706892516]
shape = SubResource("SphereShape3D_o1b3t")
-103
View File
@@ -1,103 +0,0 @@
class_name CombineZone
extends Area3D
## Trigger area that lets a snapped item combine with another item pushed into
## it. The zone only monitors while its owning item is held by an
## [XRToolsSnapZone]; when an item carrying a matching [CombinableItem.id]
## enters, the snapped (base) item transforms into the recipe result and the
## incoming item is consumed.
# The pickable this zone belongs to (its parent).
@onready var _item: XRToolsPickable = get_parent().get_parent() as XRToolsPickable
# The base item's recipe data.
@onready var _combinable: CombinableItem = _find_combinable(_item)
# Guard so a combine only fires once.
var _combining: bool = false
func _ready() -> void:
# Detect items whether held (layer 17 "Held Objects") or loose
# (layer 3 "Pickable Objects"). Don't advertise a layer of our own.
collision_mask = 0b0000_0000_0000_0001_0000_0000_0000_0100
collision_layer = 0
# Deferred: _ready can run during a physics signal flush (when a combine
# spawns the result), where toggling monitoring directly is forbidden.
set_deferred("monitoring", false)
set_deferred("monitorable", false)
if not _item:
push_error("CombineZone must be a grand child of an XRToolsPickable.")
return
if not _combinable:
push_error("CombineZone requires a CombinableItem sibling on ", _item.name, ".")
return
_item.picked_up.connect(_on_item_picked_up)
_item.dropped.connect(_on_item_dropped)
body_entered.connect(_on_body_entered)
# Enable the trigger only while snapped into a snap zone (not hand-held).
func _on_item_picked_up(_pickable: Node3D) -> void:
var by := _item.get_picked_up_by()
var snapped: bool = by != null and by.has_method("is_xr_class") and by.is_xr_class("XRToolsSnapZone")
set_deferred("monitoring", snapped)
func _on_item_dropped(_pickable: Node3D) -> void:
set_deferred("monitoring", false)
func _on_body_entered(body: Node3D) -> void:
if _combining or body == _item:
return
var other := _find_combinable(body)
if not other:
return
var result: PackedScene = _combinable.get_result_for(other.id)
if not result:
return
_combine(body, result)
# Transform the base item into [param result], consuming the incoming item.
func _combine(other_body: Node3D, result: PackedScene) -> void:
_combining = true
var snap_zone := _item.get_picked_up_by()
if not snap_zone or not snap_zone.has_method("pick_up_object"):
push_warning("CombineZone: base item is not held by a snap zone; cannot combine.")
_combining = false
return
# Spawn the result at the base item's location, in world space.
var base_transform := _item.global_transform
var result_instance: Node3D = result.instantiate()
_item.get_tree().current_scene.add_child(result_instance)
result_instance.global_transform = base_transform
# Free the base item and consume the incoming item.
snap_zone.drop_object()
_item.queue_free()
if other_body.has_method("drop_and_free"):
other_body.drop_and_free()
else:
other_body.queue_free()
# Snap the result into the now-empty zone.
snap_zone.pick_up_object(result_instance)
# Find a CombinableItem among the direct children of [param node].
func _find_combinable(node: Node) -> CombinableItem:
if not node:
return null
for child in node.get_children():
if child is CombinableItem:
return child
return null
-1
View File
@@ -1 +0,0 @@
uid://e3im02nq5cye
+63
View File
@@ -0,0 +1,63 @@
extends Node
class_name DespawningItem
@export var time_to_despawn: float = 8
# The minimum speed required to reset despawn timer.
@export var minimum_speed_square: float = 0.1
@onready var _pickable: XRToolsPickable = get_parent() as XRToolsPickable
@onready var _rigid: RigidBody3D = get_parent() as RigidBody3D
var _time_left: float = time_to_despawn
func _ready() -> void:
if not _pickable:
push_error("DespawningItem must be a grand child of an XRToolsPickable.")
return
if not _rigid:
push_error("DespawningItem must be a grand child of an RigidBody3D.")
return
func _process(delta: float) -> void:
# Despawning is a world decision, so only the owner of world logic runs the
# clock. Every peer used to run its own copy: the countdown drifted between
# them and the blink below toggled `visible` locally, so the same item was
# shown on one peer and hidden on the other. Non-owners just follow the
# server, which removes the item for everyone when its time is up.
if not NetworkManager.owns_world():
return
# if we're held or moving, reset timer and return
if _pickable.get_picked_up_by() or _rigid.linear_velocity.length_squared() > pow(minimum_speed_square,2):
_time_left = time_to_despawn
_set_visible(true)
return
# Count down to zero and despawn
_time_left -= delta
if _time_left <= 0:
print("DespawningItem despawning!" , get_parent())
NetworkManager.despawn_item(get_parent())
# Stop counting: despawn_item() only queues the free, so without this we
# keep re-reporting the same item every frame until it actually goes.
set_process(false)
return
# Make item blink in and out before despawning
if _time_left < time_to_despawn / 2:
_set_visible(int(_time_left * 5.0) % 2 == 0)
# `visible` is not a replicated property, so a blink driven only here would make
# the item flicker on the host and stay solid on clients. Until it is synced,
# only warn when there is nobody else to disagree with.
func _set_visible(value: bool) -> void:
if NetworkManager.is_online():
get_parent().visible = true
return
get_parent().visible = value
+1
View File
@@ -0,0 +1 @@
uid://deyna316ka4xs
+6
View File
@@ -0,0 +1,6 @@
[gd_scene format=3 uid="uid://b5ukku8i0hilb"]
[ext_resource type="Script" uid="uid://deyna316ka4xs" path="res://Prefabs/despawning_item.gd" id="1_ayqk8"]
[node name="DespawningItem" type="Node" unique_id=303090111]
script = ExtResource("1_ayqk8")
+1
View File
@@ -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
+1 -2
View File
@@ -4,5 +4,4 @@
[node name="FoodItem" type="Node" unique_id=63948206]
script = ExtResource("1_0na5k")
id = "hamburger"
item_type = "Meal"
id = "some_food_id"
+16
View File
@@ -0,0 +1,16 @@
[gd_scene format=3 uid="uid://mpapt5mkbuao"]
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_4m60m"]
friction = 0.0
bounce = 1.0
[sub_resource type="SphereShape3D" id="SphereShape3D_nn8tr"]
radius = 0.2752769
[node name="SlideOffDome" type="StaticBody3D" unique_id=1427609426]
collision_layer = 7
physics_material_override = SubResource("PhysicsMaterial_4m60m")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="." unique_id=513124640]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.99165964, 0)
shape = SubResource("SphereShape3D_nn8tr")
+341
View File
@@ -0,0 +1,341 @@
class_name RecipeManager
extends Node
static var _recipes: Dictionary
static var _combining_map: Dictionary
static var _cooking_map: Dictionary
static var _chopping_map: Dictionary
static var _rolling_map: Dictionary
static var _augmenting_map: Dictionary
static var _scene_paths: Dictionary
static var _loaded: bool = false
static func load_recipes() -> void:
if _loaded:
return
var recipe_path := "res://recipes.yaml"
if not FileAccess.file_exists(recipe_path):
push_error("RecipeManager: recipes.yaml was not found at %s" % recipe_path)
return
var yaml_available := ClassDB.class_exists("YAML")
if yaml_available:
var result = ClassDB.class_call_static("YAML", "load_file", recipe_path)
if result != null and not result.has_error():
var data = result.get_data()
if typeof(data) != TYPE_DICTIONARY:
push_warning("RecipeManager: YAML addon parsed recipes.yaml but returned an unsupported structure")
_recipes = data
_build_scene_paths()
_build_combining_map()
_build_cooking_map()
_build_chopping_map()
_build_rolling_map()
_build_augmenting_map()
_loaded = true
static func get_combination_result(first_id: StringName, second_id: StringName) -> PackedScene:
load_recipes()
var result_id = _combining_map.get(_make_pair_key(first_id, second_id))
if result_id == null:
return null
return get_item_scene(result_id)
static func get_cooking_result(ingredient_id: StringName) -> String:
load_recipes()
for cooked_id in _cooking_map.keys():
var cook_defs = _cooking_map[cooked_id]
# cook_defs may be an Array of recipe dicts (new) or a single dict (backwards compat)
if typeof(cook_defs) == TYPE_ARRAY:
for cook_def in cook_defs:
if cook_def["ingredient"] == ingredient_id:
return cooked_id
else:
var cook_def = cook_defs
if cook_def["ingredient"] == ingredient_id:
return cooked_id
return ""
static func get_cooking_time(ingredient_id: StringName) -> float:
load_recipes()
for cooked_id in _cooking_map.keys():
var cook_defs = _cooking_map[cooked_id]
if typeof(cook_defs) == TYPE_ARRAY:
for cook_def in cook_defs:
if cook_def["ingredient"] == ingredient_id:
return cook_def["time"]
else:
var cook_def = cook_defs
if cook_def["ingredient"] == ingredient_id:
return cook_def["time"]
return 0.0
static func get_item_scene(item_id: StringName) -> PackedScene:
load_recipes()
var scene_path = _scene_paths.get(str(item_id), "")
if typeof(scene_path) != TYPE_STRING or scene_path.is_empty():
push_error("RecipeManager: no scene mapping found for item id '%s'" % item_id)
return null
var scene = ResourceLoader.load(scene_path)
if not scene:
push_error("RecipeManager: failed to load scene '%s' for item '%s'" % [scene_path, item_id])
return null
return scene as PackedScene
static func print_all_recipes() -> void:
load_recipes()
if not _loaded:
print("RecipeManager: could not load recipes.yaml; no recipes printed.")
return
if _combining_map.is_empty():
print("RecipeManager: no combining recipes found")
return
print("#### RecipeManager: Loaded recipes ####")
_print_combining_recipes()
print("")
_print_cooking_recipes()
print("")
_print_chopping_recipes()
print("")
_print_rolling_recipes()
print("")
_print_augmenting_recipes()
static func _print_combining_recipes() -> void:
for pair_key in _combining_map.keys():
var result_id = _combining_map[pair_key]
var key_str = str(pair_key)
var separator_index = key_str.find("|")
if separator_index == -1:
print("RecipeManager: invalid combining map key '%s'" % key_str)
continue
var first = key_str.substr(0, separator_index)
var second = key_str.substr(separator_index + 1, key_str.length() - separator_index - 1)
print(" %s <-combine-- %s + %s" % [result_id, first, second])
static func _print_cooking_recipes() -> void:
for cooked_id in _cooking_map.keys():
var cook_defs = _cooking_map[cooked_id]
if typeof(cook_defs) == TYPE_ARRAY:
for cook_def in cook_defs:
print(" %s <-cook-- %s - time: %.1f" % [cooked_id, cook_def["ingredient"], cook_def["time"]])
else:
var cook_def = cook_defs
print(" %s <-cook-- %s - time: %.1f" % [cooked_id, cook_def["ingredient"], cook_def["time"]])
static func _print_chopping_recipes() -> void:
for chopped_id in _chopping_map.keys():
var chop_def = _chopping_map[chopped_id]
print(" %s <-chop-- %s - work: %.1f" % [chopped_id, chop_def["ingredient"], chop_def["work"]])
static func _print_rolling_recipes() -> void:
for rolled_id in _rolling_map.keys():
var roll_def = _rolling_map[rolled_id]
print(" %s <-roll-- %s - work: %.1f" % [rolled_id, roll_def["ingredient"], roll_def["work"]])
static func _print_augmenting_recipes() -> void:
for target_id in _augmenting_map.keys():
var augment_def = _augmenting_map[target_id]
for ingredient_id in augment_def.keys():
var attr_key = augment_def[ingredient_id]
print(" %s <-augment-- %s adds attribute '%s'" % [target_id, ingredient_id, attr_key])
static func _build_scene_paths() -> void:
_scene_paths.clear()
var items = _recipes.get("items", {})
if typeof(items) != TYPE_DICTIONARY:
return
for item_id in items.keys():
var item_def = items[item_id]
if typeof(item_def) != TYPE_DICTIONARY:
continue
var scene_path = item_def.get("scene", "")
if typeof(scene_path) == TYPE_STRING and not scene_path.is_empty():
_scene_paths[str(item_id)] = scene_path
# Reads strucure into _combining_map:
# combining:
# hamburger:
# - [cooked_burger, burger_buns]
static func _build_combining_map() -> void:
_combining_map.clear()
var combining = _recipes.get("combining", {})
for result_id in combining.keys():
var recipe_entries = _get_recipe_entries(combining[result_id])
if recipe_entries.is_empty():
push_error("RecipeManager: combining recipe '%s' must contain at least one valid recipe" % result_id)
continue
for recipe in recipe_entries:
var first = StringName(recipe[0])
var second = StringName(recipe[1])
var key = _make_pair_key(first, second)
_combining_map[key] = result_id
static func _get_recipe_entries(recipe_value: Variant) -> Array:
var recipes: Array = []
if typeof(recipe_value) != TYPE_ARRAY:
return recipes
if recipe_value.is_empty():
return recipes
if typeof(recipe_value[0]) == TYPE_ARRAY:
for recipe in recipe_value:
if typeof(recipe) == TYPE_ARRAY and recipe.size() == 2:
recipes.append(recipe)
else:
if recipe_value.size() == 2:
recipes.append(recipe_value)
return recipes
static func _make_pair_key(first_id: StringName, second_id: StringName) -> StringName:
if str(first_id) <= str(second_id):
return StringName(str(first_id) + "|" + str(second_id))
return StringName(str(second_id) + "|" + str(first_id))
# Reads structure into _cooking_map:
# cooking:
# cooked_burger:
# ingredient: raw_burger
# time: 3
# or allowing multiple recipes for the same cooked item:
# charcoal:
# - ingredient: cube
# time: 1
# - ingredient: some_other
# time: 2
static func _build_cooking_map() -> void:
_cooking_map.clear()
var cooking = _recipes.get("cooking", {})
if typeof(cooking) != TYPE_DICTIONARY:
return
for cooked_id in cooking.keys():
var cook_val = cooking[cooked_id]
var entries: Array = []
if typeof(cook_val) == TYPE_ARRAY:
for entry in cook_val:
if typeof(entry) != TYPE_DICTIONARY:
push_error("RecipeManager: cooking recipe for '%s' contains a non-dictionary entry" % cooked_id)
continue
entries.append(entry)
elif typeof(cook_val) == TYPE_DICTIONARY:
entries.append(cook_val)
else:
push_error("RecipeManager: cooking recipe for '%s' must be a dictionary or array of dictionaries" % cooked_id)
continue
var parsed_entries: Array = []
for cook_def in entries:
var ingredient = cook_def.get("ingredient", "")
if typeof(ingredient) != TYPE_STRING or str(ingredient).is_empty():
push_error("RecipeManager: cooking recipe '%s' missing a valid 'ingredient' field" % cooked_id)
continue
var time_val = cook_def.get("time", null)
if typeof(time_val) != TYPE_INT and typeof(time_val) != TYPE_FLOAT:
push_error("RecipeManager: cooking recipe '%s' missing a valid 'time' field" % cooked_id)
continue
parsed_entries.append({"ingredient": StringName(str(ingredient)), "time": float(time_val)})
if not parsed_entries.is_empty():
_cooking_map[StringName(cooked_id)] = parsed_entries
# Reads structure into _chopping_map:
# chopping:
# chopped_onion:
# ingredient: onion
# work: 2
static func _build_chopping_map() -> void:
_chopping_map.clear()
var chopping = _recipes.get("chopping", {})
if typeof(chopping) != TYPE_DICTIONARY:
return
for chopped_id in chopping.keys():
var chop_def = chopping[chopped_id]
if typeof(chop_def) != TYPE_DICTIONARY:
push_error("RecipeManager: chopping recipe for '%s' must be a dictionary" % chopped_id)
continue
var ingredient = chop_def.get("ingredient", "")
if typeof(ingredient) != TYPE_STRING or str(ingredient).is_empty():
push_error("RecipeManager: chopping recipe '%s' missing a valid 'ingredient' field" % chopped_id)
continue
var work_val = chop_def.get("work", null)
if typeof(work_val) != TYPE_INT and typeof(work_val) != TYPE_FLOAT:
push_error("RecipeManager: chopping recipe '%s' missing a valid 'work' field" % chopped_id)
continue
# store chopped item -> { ingredient: StringName, work: float }
_chopping_map[StringName(chopped_id)] = {"ingredient": StringName(str(ingredient)), "work": float(work_val)}
# Reads structure into _rolling_map:
# rolling:
# pie_base:
# ingredient: dough
# work: 80
static func _build_rolling_map() -> void:
_rolling_map.clear()
var rolling = _recipes.get("rolling", {})
if typeof(rolling) != TYPE_DICTIONARY:
return
for rolled_id in rolling.keys():
var roll_def = rolling[rolled_id]
if typeof(roll_def) != TYPE_DICTIONARY:
push_error("RecipeManager: rolling recipe for '%s' must be a dictionary" % rolled_id)
continue
var ingredient = roll_def.get("ingredient", "")
if typeof(ingredient) != TYPE_STRING or str(ingredient).is_empty():
push_error("RecipeManager: rolling recipe '%s' missing a valid 'ingredient' field" % rolled_id)
continue
var work_val = roll_def.get("work", null)
if typeof(work_val) != TYPE_INT and typeof(work_val) != TYPE_FLOAT:
push_error("RecipeManager: rolling recipe '%s' missing a valid 'work' field" % rolled_id)
continue
# store rolled item -> { ingredient: StringName, work: float }
_rolling_map[StringName(rolled_id)] = {"ingredient": StringName(str(ingredient)), "work": float(work_val)}
# Reads structure into _augmenting_map:
# augmenting: # Process of adding an item onto another without changing it's type, but toggling attributes.
# cooked_burger:
# has_tomato: sliced_tomato
# has_cheese: cheese
static func _build_augmenting_map() -> void:
_augmenting_map.clear()
var augmenting = _recipes.get("augmenting", {})
if typeof(augmenting) != TYPE_DICTIONARY:
return
for target_id in augmenting.keys():
var augment_def = augmenting[target_id]
if typeof(augment_def) != TYPE_DICTIONARY:
push_error("RecipeManager: augmenting recipe for '%s' must be a dictionary" % target_id)
continue
var map: Dictionary = {}
for attr_key in augment_def.keys():
var ingredient = augment_def[attr_key]
if typeof(ingredient) != TYPE_STRING or str(ingredient).is_empty():
push_error("RecipeManager: augmenting recipe '%s' has invalid ingredient for '%s'" % [target_id, attr_key])
continue
# store ingredient -> attribute_key (e.g. sliced_tomato -> has_tomato)
map[StringName(str(ingredient))] = StringName(str(attr_key))
if not map.is_empty():
_augmenting_map[StringName(target_id)] = map
+1
View File
@@ -0,0 +1 @@
uid://cuo88u56uqwuy
+68
View File
@@ -0,0 +1,68 @@
# RecipeManager
## Overview
`RecipeManager` is a static Godot class that centralizes recipe data for food item combinations and allows runtime lookup of result scenes.
The manager loads a single YAML file at startup: `res://recipes.yaml`, using the installed `addons/yaml` addon.
## Responsibilities
- Load recipe definitions from `recipes.yaml`.
- Provide symmetric lookups for two-item combining recipes so `A + B` and `B + A` map to the same result.
- Resolve item IDs to their corresponding scene resources.
- Print all loaded combining recipes when the application starts.
## Data structure in `recipes.yaml`
The recipe YAML file contains two top-level sections:
- `items`: maps item IDs to their scene path and optional metadata.
- `combining`: maps result item IDs to one or more recipe pairs.
Example structure:
```yaml
items:
hamburger:
scene: res://Items/hamburger.tscn
type: meal
burger_buns:
scene: res://Items/BurgerBuns.tscn
type: ingredient
combining:
hamburger:
- [cooked_burger, burger_buns]
- [charcoal, charcoal]
charcoal:
- [cube, cube]
```
### `items`
Each entry under `items` uses the item ID as the key.
The manager reads the `scene` field for each item and uses it to resolve the packed scene for recipe results.
### `combining`
Each entry under `combining` represents a result item ID, and its value is a list of recipe pairs.
Each recipe pair is a two-item array of ingredient IDs.
This allows a single result item to have multiple valid recipes.
The manager normalizes each ingredient pair using a sorted key string internally, so lookups are symmetric.
## Runtime behavior
- `FoodItem.id` is used when combining items to look up the recipe result.
- `RecipeManager.get_combination(first_id, second_id)` computes a canonical key for the pair and returns the resulting item's scene.
- On startup, `main.gd` calls `RecipeManager.print_all_recipes()`, which logs each combining recipe in the form:
`ingredient_a + ingredient_b -> result_id`
## Notes
- `RecipeManager` prefers the installed YAML addon to parse `recipes.yaml` when it is available.
- If the addon is unavailable in the current runtime, the manager falls back to a lightweight built-in parser for the simple `items`/`combining` file format.
- Scene paths now live in the YAML data instead of being hardcoded in the manager.
- Because `RecipeManager` is static, it can be used from any script without creating an instance.
+145
View File
@@ -0,0 +1,145 @@
[gd_scene format=3 uid="uid://22shbqdvnwgo"]
[ext_resource type="Script" uid="uid://b4ldkd3ngs0vp" path="res://main.gd" id="1_m3h4l"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://XROrigin.tscn" id="2_8pfaf"]
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://Textures/dev_material_3d.tres" id="3_gatbn"]
[ext_resource type="PackedScene" uid="uid://j7caslh27nor" path="res://Stations/Hob.tscn" id="4_3lufs"]
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://Textures/sky/NightSkyHDRI009_16K.tres" id="5_kh26v"]
[ext_resource type="PackedScene" uid="uid://c6rift56ql3f8" path="res://Stations/BurgerBunsDispenser.tscn" id="7_tejmp"]
[ext_resource type="PackedScene" uid="uid://dpot5qie20vf6" path="res://Items/burger.tscn" id="9_rwx83"]
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://Stations/sink.tscn" id="12_ah4xa"]
[ext_resource type="PackedScene" uid="uid://cnjwtnhwh0i8q" path="res://Stations/dirt_station.tscn" id="13_46xi2"]
[ext_resource type="PackedScene" uid="uid://ck5tuftqmyiue" path="res://Stations/plate_dispenser.tscn" id="14_h88sx"]
[ext_resource type="PackedScene" uid="uid://cwnwo4i28upap" path="res://Stations/raw_burger_dispenser.tscn" id="15_m3h4l"]
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://Stations/Counter.tscn" id="15_tpcje"]
[ext_resource type="PackedScene" uid="uid://caf0xanmxbshy" path="res://Stations/table.tscn" id="16_g2k6a"]
[ext_resource type="Script" uid="uid://k8ywnvlhcic4" path="res://Scenes/testworldLoad.gd" id="16_m3h4l"]
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="17_gatbn"]
[ext_resource type="PackedScene" uid="uid://xtcei2uvd5li" path="res://UI/game_over_panel.tscn" id="18_3lufs"]
[ext_resource type="Script" uid="uid://cwijoksyou1ey" path="res://Scenes/GameOvercontroler.gd" id="19_3lufs"]
[sub_resource type="BoxShape3D" id="BoxShape3D_vlqg6"]
size = Vector3(16, 0.1, 16)
[sub_resource type="BoxMesh" id="BoxMesh_24d3s"]
material = ExtResource("3_gatbn")
size = Vector3(16, 0.1, 16)
[sub_resource type="Environment" id="Environment_bvwq1"]
background_mode = 2
sky = ExtResource("5_kh26v")
reflected_light_source = 2
ssr_enabled = true
ssao_enabled = true
ssil_enabled = true
sdfgi_enabled = true
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
size = Vector3(16, 10, 0.1)
[node name="Main" type="Node3D" unique_id=1312265607]
script = ExtResource("1_m3h4l")
[node name="XROrigin3D" parent="." unique_id=2055526621 instance=ExtResource("2_8pfaf")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0)
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1376644384]
transform = Transform3D(-0.8660254, -0.43301278, 0.24999999, 0.3022632, -0.05510214, 0.9516306, -0.39829266, 0.8997021, 0.17860365, 0, 0, 0)
[node name="Table" parent="." unique_id=1863572470 instance=ExtResource("16_g2k6a")]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 2.739665, 0.47583598, -1.1895752)
primary_duration = 35.0
[node name="Floor" type="StaticBody3D" parent="." unique_id=122279514]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.05, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor" unique_id=958841648]
shape = SubResource("BoxShape3D_vlqg6")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floor/CollisionShape3D" unique_id=1939997056]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0002836883, 0.0006355047, -0.0054528117)
mesh = SubResource("BoxMesh_24d3s")
[node name="Hob" parent="." unique_id=1687971542 instance=ExtResource("4_3lufs")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, -1.2)
[node name="Hob2" parent="." unique_id=496572049 instance=ExtResource("4_3lufs")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.6, 0.5, -1.2)
[node name="Hob3" parent="." unique_id=421567982 instance=ExtResource("4_3lufs")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.2, 0.5, -1.2)
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="BurgerBunsDispenser" parent="." unique_id=1720683779 instance=ExtResource("7_tejmp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8, 0.015, -1.2)
[node name="Sink" parent="." unique_id=2055277359 instance=ExtResource("12_ah4xa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5997182, 0.5, -1.2)
[node name="Sink2" parent="." unique_id=1692612192 instance=ExtResource("12_ah4xa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.1997182, 0.5, -1.2)
[node name="DirtStation" parent="." unique_id=160842153 instance=ExtResource("13_46xi2")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.8000001, 0.5, -1.2)
[node name="Counter2" parent="." unique_id=368890752 instance=ExtResource("15_tpcje")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.8, 0.5, -0.6)
[node name="Counter3" parent="." unique_id=1498817646 instance=ExtResource("15_tpcje")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.8, 0.5, 0)
[node name="Counter4" parent="." unique_id=906748771 instance=ExtResource("15_tpcje")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.8, 0.5, 0.6)
[node name="Counter5" parent="." unique_id=1487893288 instance=ExtResource("15_tpcje")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, -0.6, 0.5, 1.2)
[node name="Counter6" parent="." unique_id=1154936647 instance=ExtResource("15_tpcje")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 0.5, 1.2)
[node name="Counter7" parent="." unique_id=990260272 instance=ExtResource("15_tpcje")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0.6, 0.5, 1.2)
[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=315740174]
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" unique_id=33059670]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.689, 8)
shape = SubResource("BoxShape3D_24d3s")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D" unique_id=2018792171]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.689, -8)
shape = SubResource("BoxShape3D_24d3s")
[node name="CollisionShape3D3" type="CollisionShape3D" parent="StaticBody3D" unique_id=757662929]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -8, 4.689, 0)
shape = SubResource("BoxShape3D_24d3s")
[node name="CollisionShape3D4" type="CollisionShape3D" parent="StaticBody3D" unique_id=1468386997]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 8, 4.689, 0)
shape = SubResource("BoxShape3D_24d3s")
[node name="GameOverPanel" parent="." unique_id=221361954 instance=ExtResource("17_gatbn")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.46454135, 3.4496074, -1.832967)
visible = false
scene = ExtResource("18_3lufs")
viewport_size = Vector2(900, 600)
transparent = 0
filter = false
scene_properties_keys = PackedStringArray("game_over_panel.gd")
[node name="controler" type="Node" parent="GameOverPanel" unique_id=1302491889]
script = ExtResource("19_3lufs")
[node name="PlateDispenser" parent="." unique_id=710538846 instance=ExtResource("14_h88sx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8, 0, 1.2)
[node name="RawBurgerDispenser" parent="." unique_id=235630131 instance=ExtResource("15_m3h4l")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.2, 0, 1.2)
[node name="Node" type="Node" parent="." unique_id=1224933801]
script = ExtResource("16_m3h4l")
[node name="raw_burger" parent="." unique_id=1675596942 instance=ExtResource("9_rwx83")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.6, 1.2, -0.6)
+140
View File
@@ -0,0 +1,140 @@
[gd_scene format=3 uid="uid://22shbqdvnwgo"]
[ext_resource type="Script" uid="uid://b4ldkd3ngs0vp" path="res://main.gd" id="1_m3h4l"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://XROrigin.tscn" id="2_8pfaf"]
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://Textures/dev_material_3d.tres" id="3_gatbn"]
[ext_resource type="PackedScene" uid="uid://j7caslh27nor" path="res://Stations/Hob.tscn" id="4_3lufs"]
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://Textures/sky/NightSkyHDRI009_16K.tres" id="5_kh26v"]
[ext_resource type="PackedScene" uid="uid://c6rift56ql3f8" path="res://Stations/BurgerBunsDispenser.tscn" id="7_tejmp"]
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://Stations/sink.tscn" id="12_ah4xa"]
[ext_resource type="PackedScene" uid="uid://cnjwtnhwh0i8q" path="res://Stations/dirt_station.tscn" id="13_46xi2"]
[ext_resource type="PackedScene" uid="uid://ck5tuftqmyiue" path="res://Stations/plate_dispenser.tscn" id="14_h88sx"]
[ext_resource type="PackedScene" uid="uid://cwnwo4i28upap" path="res://Stations/raw_burger_dispenser.tscn" id="15_m3h4l"]
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://Stations/Counter.tscn" id="15_tpcje"]
[ext_resource type="PackedScene" uid="uid://caf0xanmxbshy" path="res://Stations/table.tscn" id="16_g2k6a"]
[ext_resource type="Script" uid="uid://k8ywnvlhcic4" path="res://Scenes/testworldLoad.gd" id="16_m3h4l"]
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="17_gatbn"]
[ext_resource type="PackedScene" uid="uid://xtcei2uvd5li" path="res://UI/game_over_panel.tscn" id="18_3lufs"]
[ext_resource type="Script" uid="uid://cwijoksyou1ey" path="res://Scenes/GameOvercontroler.gd" id="19_3lufs"]
[sub_resource type="BoxShape3D" id="BoxShape3D_vlqg6"]
size = Vector3(16, 0.1, 16)
[sub_resource type="BoxMesh" id="BoxMesh_24d3s"]
material = ExtResource("3_gatbn")
size = Vector3(16, 0.1, 16)
[sub_resource type="Environment" id="Environment_bvwq1"]
background_mode = 2
sky = ExtResource("5_kh26v")
reflected_light_source = 2
ssr_enabled = true
ssao_enabled = true
ssil_enabled = true
sdfgi_enabled = true
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
size = Vector3(16, 10, 0.1)
[node name="Main" type="Node3D" unique_id=1312265607]
script = ExtResource("1_m3h4l")
[node name="XROrigin3D" parent="." unique_id=2055526621 instance=ExtResource("2_8pfaf")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0)
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1376644384]
transform = Transform3D(-0.8660254, -0.43301278, 0.24999999, 0.3022632, -0.05510214, 0.9516306, -0.39829266, 0.8997021, 0.17860365, 0, 0, 0)
[node name="Floor" type="StaticBody3D" parent="." unique_id=122279514]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.05, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor" unique_id=958841648]
shape = SubResource("BoxShape3D_vlqg6")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floor/CollisionShape3D" unique_id=1939997056]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0002836883, 0.0006355047, -0.0054528117)
mesh = SubResource("BoxMesh_24d3s")
[node name="Hob" parent="." unique_id=1687971542 instance=ExtResource("4_3lufs")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, -1.2)
[node name="Hob2" parent="." unique_id=496572049 instance=ExtResource("4_3lufs")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.6, 0.5, -1.2)
[node name="Hob3" parent="." unique_id=421567982 instance=ExtResource("4_3lufs")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.2, 0.5, -1.2)
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="BurgerBunsDispenser" parent="." unique_id=1720683779 instance=ExtResource("7_tejmp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8, 0.015, -1.2)
[node name="Sink" parent="." unique_id=2055277359 instance=ExtResource("12_ah4xa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5997182, 0.5, -1.2)
[node name="Sink2" parent="." unique_id=1692612192 instance=ExtResource("12_ah4xa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.1997182, 0.5, -1.2)
[node name="DirtStation" parent="." unique_id=160842153 instance=ExtResource("13_46xi2")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.8000001, 0.5, -1.2)
[node name="Counter2" parent="." unique_id=368890752 instance=ExtResource("15_tpcje")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.8, 0.5, -0.6)
[node name="Counter3" parent="." unique_id=1498817646 instance=ExtResource("15_tpcje")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.8, 0.5, 0)
[node name="Counter4" parent="." unique_id=906748771 instance=ExtResource("15_tpcje")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.8, 0.5, 0.6)
[node name="Counter5" parent="." unique_id=1487893288 instance=ExtResource("15_tpcje")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, -0.6, 0.5, 1.2)
[node name="Counter6" parent="." unique_id=1154936647 instance=ExtResource("15_tpcje")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 0.5, 1.2)
[node name="Counter7" parent="." unique_id=990260272 instance=ExtResource("15_tpcje")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0.6, 0.5, 1.2)
[node name="Table" parent="." unique_id=1863572470 instance=ExtResource("16_g2k6a")]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 2.739665, 0.47583598, -1.1895752)
[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=315740174]
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" unique_id=33059670]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.689, 8)
shape = SubResource("BoxShape3D_24d3s")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D" unique_id=2018792171]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.689, -8)
shape = SubResource("BoxShape3D_24d3s")
[node name="CollisionShape3D3" type="CollisionShape3D" parent="StaticBody3D" unique_id=757662929]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -8, 4.689, 0)
shape = SubResource("BoxShape3D_24d3s")
[node name="CollisionShape3D4" type="CollisionShape3D" parent="StaticBody3D" unique_id=1468386997]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 8, 4.689, 0)
shape = SubResource("BoxShape3D_24d3s")
[node name="GameOverPanel" parent="." unique_id=221361954 instance=ExtResource("17_gatbn")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.46454135, 3.4496074, -1.832967)
visible = false
scene = ExtResource("18_3lufs")
viewport_size = Vector2(900, 600)
transparent = 0
filter = false
scene_properties_keys = PackedStringArray("game_over_panel.gd")
[node name="controler" type="Node" parent="GameOverPanel" unique_id=1302491889]
script = ExtResource("19_3lufs")
[node name="PlateDispenser" parent="." unique_id=710538846 instance=ExtResource("14_h88sx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8, 0, 1.2)
[node name="RawBurgerDispenser" parent="." unique_id=235630131 instance=ExtResource("15_m3h4l")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.2, 0, 1.2)
[node name="Node" type="Node" parent="." unique_id=1224933801]
script = ExtResource("16_m3h4l")
+140
View File
@@ -0,0 +1,140 @@
[gd_scene format=3 uid="uid://22shbqdvnwgo"]
[ext_resource type="Script" uid="uid://b4ldkd3ngs0vp" path="res://main.gd" id="1_m3h4l"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://XROrigin.tscn" id="2_8pfaf"]
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://Textures/dev_material_3d.tres" id="3_gatbn"]
[ext_resource type="PackedScene" uid="uid://j7caslh27nor" path="res://Stations/Hob.tscn" id="4_3lufs"]
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://Textures/sky/NightSkyHDRI009_16K.tres" id="5_kh26v"]
[ext_resource type="PackedScene" uid="uid://c6rift56ql3f8" path="res://Stations/BurgerBunsDispenser.tscn" id="7_tejmp"]
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://Stations/sink.tscn" id="12_ah4xa"]
[ext_resource type="PackedScene" uid="uid://cnjwtnhwh0i8q" path="res://Stations/dirt_station.tscn" id="13_46xi2"]
[ext_resource type="PackedScene" uid="uid://ck5tuftqmyiue" path="res://Stations/plate_dispenser.tscn" id="14_h88sx"]
[ext_resource type="PackedScene" uid="uid://cwnwo4i28upap" path="res://Stations/raw_burger_dispenser.tscn" id="15_m3h4l"]
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://Stations/Counter.tscn" id="15_tpcje"]
[ext_resource type="PackedScene" uid="uid://caf0xanmxbshy" path="res://Stations/table.tscn" id="16_g2k6a"]
[ext_resource type="Script" uid="uid://k8ywnvlhcic4" path="res://Scenes/testworldLoad.gd" id="16_m3h4l"]
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="17_gatbn"]
[ext_resource type="PackedScene" uid="uid://xtcei2uvd5li" path="res://UI/game_over_panel.tscn" id="18_3lufs"]
[ext_resource type="Script" uid="uid://cwijoksyou1ey" path="res://Scenes/GameOvercontroler.gd" id="19_3lufs"]
[sub_resource type="BoxShape3D" id="BoxShape3D_vlqg6"]
size = Vector3(16, 0.1, 16)
[sub_resource type="BoxMesh" id="BoxMesh_24d3s"]
material = ExtResource("3_gatbn")
size = Vector3(16, 0.1, 16)
[sub_resource type="Environment" id="Environment_bvwq1"]
background_mode = 2
sky = ExtResource("5_kh26v")
reflected_light_source = 2
ssr_enabled = true
ssao_enabled = true
ssil_enabled = true
sdfgi_enabled = true
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
size = Vector3(16, 10, 0.1)
[node name="Main" type="Node3D" unique_id=1312265607]
script = ExtResource("1_m3h4l")
[node name="XROrigin3D" parent="." unique_id=2055526621 instance=ExtResource("2_8pfaf")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.6, 0)
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1376644384]
transform = Transform3D(-0.8660254, -0.43301278, 0.24999999, 0.3022632, -0.05510214, 0.9516306, -0.39829266, 0.8997021, 0.17860365, 0, 0, 0)
[node name="Floor" type="StaticBody3D" parent="." unique_id=122279514]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.05, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor" unique_id=958841648]
shape = SubResource("BoxShape3D_vlqg6")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floor/CollisionShape3D" unique_id=1939997056]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.0002836883, 0.0006355047, -0.0054528117)
mesh = SubResource("BoxMesh_24d3s")
[node name="Hob" parent="." unique_id=1687971542 instance=ExtResource("4_3lufs")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, -1.2)
[node name="Hob2" parent="." unique_id=496572049 instance=ExtResource("4_3lufs")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.6, 0.5, -1.2)
[node name="Hob3" parent="." unique_id=421567982 instance=ExtResource("4_3lufs")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.2, 0.5, -1.2)
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="BurgerBunsDispenser" parent="." unique_id=1720683779 instance=ExtResource("7_tejmp")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8, 0.015, -1.2)
[node name="Sink" parent="." unique_id=2055277359 instance=ExtResource("12_ah4xa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.5997182, 0.5, -1.2)
[node name="Sink2" parent="." unique_id=1692612192 instance=ExtResource("12_ah4xa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.1997182, 0.5, -1.2)
[node name="DirtStation" parent="." unique_id=160842153 instance=ExtResource("13_46xi2")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.8000001, 0.5, -1.2)
[node name="Counter2" parent="." unique_id=368890752 instance=ExtResource("15_tpcje")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.8, 0.5, -0.6)
[node name="Counter3" parent="." unique_id=1498817646 instance=ExtResource("15_tpcje")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.8, 0.5, 0)
[node name="Counter4" parent="." unique_id=906748771 instance=ExtResource("15_tpcje")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.8, 0.5, 0.6)
[node name="Counter5" parent="." unique_id=1487893288 instance=ExtResource("15_tpcje")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, -0.6, 0.5, 1.2)
[node name="Counter6" parent="." unique_id=1154936647 instance=ExtResource("15_tpcje")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0, 0.5, 1.2)
[node name="Counter7" parent="." unique_id=990260272 instance=ExtResource("15_tpcje")]
transform = Transform3D(-1, 0, -8.742278e-08, 0, 1, 0, 8.742278e-08, 0, -1, 0.6, 0.5, 1.2)
[node name="Table" parent="." unique_id=1863572470 instance=ExtResource("16_g2k6a")]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 2.739665, 0.47583598, -1.1895752)
[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=315740174]
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" unique_id=33059670]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.689, 8)
shape = SubResource("BoxShape3D_24d3s")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D" unique_id=2018792171]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.689, -8)
shape = SubResource("BoxShape3D_24d3s")
[node name="CollisionShape3D3" type="CollisionShape3D" parent="StaticBody3D" unique_id=757662929]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -8, 4.689, 0)
shape = SubResource("BoxShape3D_24d3s")
[node name="CollisionShape3D4" type="CollisionShape3D" parent="StaticBody3D" unique_id=1468386997]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 8, 4.689, 0)
shape = SubResource("BoxShape3D_24d3s")
[node name="GameOverPanel" parent="." unique_id=221361954 instance=ExtResource("17_gatbn")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.46454135, 3.4496074, -1.832967)
visible = false
scene = ExtResource("18_3lufs")
viewport_size = Vector2(900, 600)
transparent = 0
filter = false
scene_properties_keys = PackedStringArray("game_over_panel.gd")
[node name="controler" type="Node" parent="GameOverPanel" unique_id=1302491889]
script = ExtResource("19_3lufs")
[node name="PlateDispenser" parent="." unique_id=710538846 instance=ExtResource("14_h88sx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8, 0, 1.2)
[node name="RawBurgerDispenser" parent="." unique_id=235630131 instance=ExtResource("15_m3h4l")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.2, 0, 1.2)
[node name="Node" type="Node" parent="." unique_id=1224933801]
script = ExtResource("16_m3h4l")
+11
View File
@@ -0,0 +1,11 @@
extends Node
func _ready() -> void:
$"..".visible = false
# Listen for the game over signal from GameManager
Signals.game_over.connect(_on_game_over)
func _on_game_over() -> void:
$"..".visible = true
+1
View File
@@ -0,0 +1 @@
uid://cwijoksyou1ey
+92 -83
View File
@@ -1,45 +1,62 @@
[gd_scene format=3 uid="uid://do6mrslyqe5qe"]
[ext_resource type="Script" uid="uid://b4ldkd3ngs0vp" path="res://main.gd" id="1_57ppd"]
[ext_resource type="Script" uid="uid://d1cefhe3yyyds" path="res://Scenes/multiplayer_world.gd" id="1_57ppd"]
[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="PackedScene" uid="uid://j7caslh27nor" path="res://Stations/Hob.tscn" id="4_ctden"]
[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="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://c6rift56ql3f8" path="res://Stations/BurgerBunsDispenser.tscn" id="9_sq0s2"]
[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"]
[sub_resource type="BoxShape3D" id="BoxShape3D_vlqg6"]
size = Vector3(5, 0.1, 5)
[sub_resource type="BoxMesh" id="BoxMesh_24d3s"]
material = ExtResource("3_irf4n")
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
[ext_resource type="PackedScene" uid="uid://cwnwo4i28upap" path="res://Stations/raw_burger_dispenser.tscn" id="11_ctden"]
[ext_resource type="PackedScene" uid="uid://bbg7dwsbxxh1t" path="res://Scenes/cube_side_dispense.tscn" id="12_57ppd"]
[ext_resource type="PackedScene" uid="uid://ck5tuftqmyiue" path="res://Stations/plate_dispenser.tscn" id="13_irf4n"]
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://Stations/sink.tscn" id="13_o1b3t"]
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="14_di04w"]
[ext_resource type="PackedScene" uid="uid://cnjwtnhwh0i8q" path="res://Stations/dirt_station.tscn" id="14_irf4n"]
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://Stations/Counter.tscn" id="15_di04w"]
[ext_resource type="PackedScene" uid="uid://xtcei2uvd5li" path="res://UI/game_over_panel.tscn" id="15_eoxxy"]
[ext_resource type="PackedScene" uid="uid://caf0xanmxbshy" path="res://Stations/table.tscn" id="16_di04w"]
[ext_resource type="Script" uid="uid://cwijoksyou1ey" path="res://Scenes/GameOvercontroler.gd" id="16_n8fyw"]
[sub_resource type="Environment" id="Environment_bvwq1"]
background_mode = 2
sky = ExtResource("7_n8fyw")
ambient_light_source = 3
ambient_light_color = Color(1, 1, 1, 1)
ambient_light_sky_contribution = 0.9
reflected_light_source = 2
ssr_enabled = true
ssao_enabled = true
ssil_enabled = true
sdfgi_enabled = true
[sub_resource type="BoxShape3D" id="BoxShape3D_vlqg6"]
size = Vector3(20, 0.1, 20)
[sub_resource type="BoxMesh" id="BoxMesh_24d3s"]
material = ExtResource("3_irf4n")
size = Vector3(20, 0.1, 20)
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
size = Vector3(20, 10, 0.1)
[node name="Main" type="Node3D" unique_id=1312265607]
script = ExtResource("1_57ppd")
[node name="XROrigin3D" parent="." unique_id=2055526621 instance=ExtResource("2_o1b3t")]
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="XROrigin3D" parent="." unique_id=2055526621 groups=["local_xr_origin"] instance=ExtResource("2_o1b3t")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9667189, 0)
[node name="WorldContent" type="Node3D" parent="." unique_id=262398468]
[node name="Players" type="Node3D" parent="." unique_id=1772076868]
[node name="ItemsSpawner" type="MultiplayerSpawner" parent="." unique_id=2051771581]
spawn_path = NodePath("../WorldContent")
[node name="PlayersSpawner" type="MultiplayerSpawner" parent="." unique_id=619815427]
spawn_path = NodePath("../Players")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1376644384]
transform = Transform3D(-0.8660254, -0.43301278, 0.24999999, 0.3022632, -0.05510214, 0.9516306, -0.39829266, 0.8997021, 0.17860365, 0, 0, 0)
@@ -54,79 +71,71 @@ shape = SubResource("BoxShape3D_vlqg6")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00018164515, 0.0006352663, -0.002532661)
mesh = SubResource("BoxMesh_24d3s")
[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)
[node name="InvisibleWalls" type="StaticBody3D" parent="." unique_id=315740174]
[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)
[node name="CollisionShape3D" type="CollisionShape3D" parent="Counter" unique_id=692568688]
[node name="CollisionShape3D" type="CollisionShape3D" parent="InvisibleWalls" unique_id=33059670]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.688614, 8.838269)
shape = SubResource("BoxShape3D_24d3s")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Counter/CollisionShape3D" unique_id=127773521]
mesh = SubResource("BoxMesh_i5j2u")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="InvisibleWalls" unique_id=2018792171]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.688614, -10.243342)
shape = SubResource("BoxShape3D_24d3s")
[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="CollisionShape3D3" type="CollisionShape3D" parent="InvisibleWalls" unique_id=757662929]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -9.807113, 4.688614, -0.018813243)
shape = SubResource("BoxShape3D_24d3s")
[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="CollisionShape3D4" type="CollisionShape3D" parent="InvisibleWalls" unique_id=1468386997]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 9.934778, 4.297072, -0.018813023)
shape = SubResource("BoxShape3D_24d3s")
[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="Table" parent="." unique_id=1863572470 instance=ExtResource("16_di04w")]
transform = Transform3D(-1, 0, 8.742277e-08, 0, 1, 0, -8.742277e-08, 0, -1, 3.6294794, 0.54177135, 0.0973109)
primary_duration = 35.0
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="Hob" parent="." unique_id=1687971542 instance=ExtResource("4_ctden")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.35077858, 0.50655985, -1.2833805)
[node name="BurgerBuns" parent="." unique_id=1088240294 instance=ExtResource("8_rraok")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8162017, 1.6081157, -1.4714175)
[node name="Sink" parent="." unique_id=2055277359 instance=ExtResource("13_o1b3t")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.24685252, 0.51461196, -1.2828919)
[node name="DirtStation" parent="." unique_id=160842153 instance=ExtResource("14_irf4n")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.7978771, 0.50655985, -1.2598276)
[node name="Counter" parent="." unique_id=1487893288 instance=ExtResource("15_di04w")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.94890714, 0.5115015, -1.3041471)
[node name="Counter2" parent="." unique_id=368890752 instance=ExtResource("15_di04w")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.5477214, 0.5115016, -0.1103079)
[node name="Counter4" parent="." unique_id=1748373996 instance=ExtResource("15_di04w")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.5477214, 0.5115016, -0.70863545)
[node name="Counter3" parent="." unique_id=1498817646 instance=ExtResource("15_di04w")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.5477214, 0.5115016, 0.49258912)
[node name="Counter5" parent="Counter3" unique_id=200341072 instance=ExtResource("15_di04w")]
transform = Transform3D(-1, 0, 4.371139e-08, 0, 1, 0, -4.371139e-08, 0, -1, -0.12681937, 2.3841858e-07, 3.538899)
[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.5242664, 0.008738995, 1.1073059)
[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)
[node name="RawBurgerDispenser" parent="." unique_id=235630131 instance=ExtResource("11_ctden")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.8896122, 0.008738995, 1.0872328)
[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)
[node name="PlateDispenser" parent="." unique_id=710538846 instance=ExtResource("13_irf4n")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.26631236, 0.008738995, 1.087036)
[node name="burger2" parent="." unique_id=1584460510 instance=ExtResource("11_qn1ku")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.1396115, 1.5300478, -1.2016745)
[node name="GameOverPanel" parent="." unique_id=1234658657 instance=ExtResource("14_di04w")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -2.0281777, 2.8122003, 0)
scene = ExtResource("15_eoxxy")
viewport_size = Vector2(900, 600)
transparent = 0
filter = false
scene_properties_keys = PackedStringArray("game_over_panel.gd")
[node name="burger3" parent="." unique_id=1884095916 instance=ExtResource("11_qn1ku")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.1424646, 1.4969791, -1.210453)
[node name="controler" type="Node" parent="GameOverPanel" unique_id=803158176]
script = ExtResource("16_n8fyw")
[node name="burger4" parent="." unique_id=1844818864 instance=ExtResource("11_qn1ku")]
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)
[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)
[node name="CubeSideDispenser2" parent="." unique_id=200950572 instance=ExtResource("12_57ppd")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.35154933, 0, 1.1119425)
+72
View File
@@ -0,0 +1,72 @@
[gd_scene format=3 uid="uid://bbg7dwsbxxh1t"]
[ext_resource type="Script" uid="uid://0y6wnjcsum6" path="res://Stations/item_dispenser.gd" id="1_4m60m"]
[ext_resource type="PackedScene" uid="uid://e4i6o5oriecx" path="res://Items/PickupCube.tscn" id="2_nn8tr"]
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="3_ahn1e"]
[ext_resource type="PackedScene" uid="uid://mpapt5mkbuao" path="res://Prefabs/slide_off_dome.tscn" id="4_nn8tr"]
[sub_resource type="SphereShape3D" id="SphereShape3D_xmbo2"]
radius = 0.3
[sub_resource type="CylinderShape3D" id="CylinderShape3D_24d3s"]
radius = 0.29541016
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_24d3s"]
albedo_color = Color(0.1764706, 1, 1, 1)
[sub_resource type="BoxMesh" id="BoxMesh_irf4n"]
material = SubResource("StandardMaterial3D_24d3s")
size = Vector3(0.1, 0.1, 0.1)
[node name="CubeSideDispenser2" type="StaticBody3D" unique_id=200950572]
script = ExtResource("1_4m60m")
item_scene = ExtResource("2_nn8tr")
[node name="XRToolsSnapZone" type="Area3D" parent="." unique_id=1018021004]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00070536137, 1.0440714, -0.002165556)
collision_layer = 65536
collision_mask = 65536
script = ExtResource("3_ahn1e")
snap_mode = 1
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
[node name="CollisionShape3D" type="CollisionShape3D" parent="XRToolsSnapZone" unique_id=182042233]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.15291119, 0)
shape = SubResource("SphereShape3D_xmbo2")
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1974757539]
shape = SubResource("CylinderShape3D_24d3s")
[node name="SlideOffDome" parent="." unique_id=1427609426 instance=ExtResource("4_nn8tr")]
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="." unique_id=1172420592]
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=1073546772]
radius = 0.3
sides = 32
[node name="Cubes" type="Node3D" parent="." unique_id=100532970]
[node name="MeshInstance3D" type="MeshInstance3D" parent="Cubes" unique_id=2040729886]
transform = Transform3D(0.9709369, 0, 0.23933554, 0, 1, 0, -0.23933554, 0, 0.9709369, -0.0038359165, 1.0421022, -0.1349423)
mesh = SubResource("BoxMesh_irf4n")
[node name="MeshInstance3D2" type="MeshInstance3D" parent="Cubes" unique_id=2119335322]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.1336323, 1.0421022, 0.049409628)
mesh = SubResource("BoxMesh_irf4n")
[node name="MeshInstance3D3" type="MeshInstance3D" parent="Cubes" unique_id=896999260]
transform = Transform3D(0.94914126, 0, -0.31485054, 0, 1, 0, 0.31485054, 0, 0.94914126, 0.021345377, 1.0421022, 0.13508391)
mesh = SubResource("BoxMesh_irf4n")
[node name="MeshInstance3D4" type="MeshInstance3D" parent="Cubes" unique_id=1055210121]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.14830339, 1.0421022, 0.054090023)
mesh = SubResource("BoxMesh_irf4n")
[node name="MeshInstance3D5" type="MeshInstance3D" parent="Cubes" unique_id=1800524097]
transform = Transform3D(0.966823, 0, -0.2554472, 0, 1, 0, 0.2554472, 0, 0.966823, 0.12695658, 1.0421022, -0.07926583)
mesh = SubResource("BoxMesh_irf4n")
[node name="MeshInstance3D6" type="MeshInstance3D" parent="Cubes" unique_id=192094054]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.11111963, 1.0421022, -0.094003916)
mesh = SubResource("BoxMesh_irf4n")
+166
View File
@@ -0,0 +1,166 @@
[gd_scene format=3 uid="uid://c1nv4w33fedj6"]
[ext_resource type="Script" uid="uid://b4ldkd3ngs0vp" path="res://main.gd" id="1_72gy5"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://XROrigin.tscn" id="2_8wkh3"]
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://Textures/dev_material_3d.tres" id="3_m56cs"]
[ext_resource type="PackedScene" uid="uid://j7caslh27nor" path="res://Stations/Hob.tscn" id="4_5kvh0"]
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://Textures/sky/NightSkyHDRI009_16K.tres" id="5_l1qm6"]
[ext_resource type="PackedScene" uid="uid://c0lknik4noobs" path="res://Items/BurgerBuns.tscn" id="6_bktvt"]
[ext_resource type="PackedScene" uid="uid://c6rift56ql3f8" path="res://Stations/BurgerBunsDispenser.tscn" id="7_1nkd0"]
[ext_resource type="PackedScene" uid="uid://bp3v1jl8pctro" path="res://Containers/plate.tscn" id="8_l1owj"]
[ext_resource type="PackedScene" uid="uid://dpot5qie20vf6" path="res://Items/burger.tscn" id="9_220hi"]
[ext_resource type="PackedScene" uid="uid://b3m2ag8g5rj4r" path="res://Items/hamburger.tscn" id="10_qacki"]
[ext_resource type="PackedScene" uid="uid://e4i6o5oriecx" path="res://Items/PickupCube.tscn" id="11_npf8s"]
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://Stations/sink.tscn" id="12_8apyq"]
[ext_resource type="PackedScene" uid="uid://cnjwtnhwh0i8q" path="res://Stations/dirt_station.tscn" id="13_jnwcx"]
[ext_resource type="PackedScene" uid="uid://cfc4ho67u4r5e" path="res://Items/cooked_burger.tscn" id="14_1lg2m"]
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://Stations/Counter.tscn" id="15_yy81s"]
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="16_vp"]
[ext_resource type="PackedScene" path="res://UI/main_menu_panel.tscn" id="17_panel"]
[sub_resource type="BoxShape3D" id="BoxShape3D_vlqg6"]
size = Vector3(115, 0.1, 15)
[sub_resource type="BoxMesh" id="BoxMesh_24d3s"]
material = ExtResource("3_m56cs")
size = Vector3(15, 0.1, 15)
[sub_resource type="Environment" id="Environment_bvwq1"]
background_mode = 2
sky = ExtResource("5_l1qm6")
reflected_light_source = 2
ssr_enabled = true
ssao_enabled = true
ssil_enabled = true
sdfgi_enabled = true
[node name="Main" type="Node3D" unique_id=1312265607]
script = ExtResource("1_72gy5")
[node name="XROrigin3D" parent="." unique_id=2055526621 instance=ExtResource("2_8wkh3")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.36171648, 0, 0.81835127)
[node name="MainMenuPanel3D" parent="." unique_id=1448860532 instance=ExtResource("16_vp")]
transform = Transform3D(5, 0, 0, 0, 5, 0, 0, 0, 5, 0.36171648, 2.0238447, -1.9758987)
screen_size = Vector2(0.6, 0.4)
scene = ExtResource("17_panel")
viewport_size = Vector2(600, 400)
transparent = 1
scene_properties_keys = PackedStringArray("main_menu_panel.gd")
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1376644384]
transform = Transform3D(-0.8660254, -0.43301278, 0.24999999, 0.3022632, -0.05510214, 0.9516306, -0.39829266, 0.8997021, 0.17860365, 0, 0, 0)
[node name="Floor" type="StaticBody3D" parent="." unique_id=122279514]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.05, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor" unique_id=958841648]
shape = SubResource("BoxShape3D_vlqg6")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floor/CollisionShape3D" unique_id=1939997056]
mesh = SubResource("BoxMesh_24d3s")
[node name="Hob" parent="." unique_id=1687971542 instance=ExtResource("4_5kvh0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.29336345, 0.5, -1.484)
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="BurgerBuns" parent="." unique_id=1088240294 instance=ExtResource("6_bktvt")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5530176, 1.0505146, -1.3074328)
[node name="BurgerBunsDispenser" parent="." unique_id=1720683779 instance=ExtResource("7_1nkd0")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.568947, -0.018512607, -1.317366)
[node name="Plate" parent="." unique_id=190487773 instance=ExtResource("8_l1owj")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5717233, 1.1548845, 1.5373346)
[node name="burger" parent="." unique_id=1417604760 instance=ExtResource("9_220hi")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.6888188, 1.0325116, -1.7110313)
[node name="burger2" parent="." unique_id=1584460510 instance=ExtResource("9_220hi")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.6931299, 1.1429771, -1.71225)
[node name="burger3" parent="." unique_id=1884095916 instance=ExtResource("9_220hi")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.69027674, 1.1099085, -1.7210286)
[node name="burger4" parent="." unique_id=1844818864 instance=ExtResource("9_220hi")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.69134104, 1.0672915, -1.7210286)
[node name="Hamburger" parent="." unique_id=761091445 instance=ExtResource("10_qacki")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.9352558, 1.2334514, 1.2447833)
[node name="PickableObject" parent="." unique_id=1675596942 instance=ExtResource("11_npf8s")]
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, 0.6225724, 1.0654817, -1.0473135)
[node name="PickableObject2" parent="." unique_id=713087634 instance=ExtResource("11_npf8s")]
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, -5.293956e-23, -2.6077032e-08, 1.4901161e-08, 1, 0.6359743, 1.0501236, -1.1673055)
[node name="PickableObject3" parent="." unique_id=879935619 instance=ExtResource("11_npf8s")]
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, 0.5142721, 1.0654817, -1.0473135)
[node name="PickableObject4" parent="." unique_id=198541902 instance=ExtResource("11_npf8s")]
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.0501236, -1.1673055)
[node name="Hamburger2" parent="." unique_id=1349934579 instance=ExtResource("10_qacki")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.9857153, 1.1424131, 0.9472374)
[node name="PickableObject5" parent="." unique_id=1021333509 instance=ExtResource("11_npf8s")]
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, 0.73287535, 1.0922265, -1.0473135)
[node name="PickableObject6" parent="." unique_id=1268843669 instance=ExtResource("11_npf8s")]
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, -5.293956e-23, -2.6077032e-08, 1.4901161e-08, 1, 0.7462772, 1.0768684, -1.1673055)
[node name="Sink" parent="." unique_id=2055277359 instance=ExtResource("12_8apyq")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.3147688, 0.5, -1.4940417)
[node name="DirtStation" parent="." unique_id=160842153 instance=ExtResource("13_jnwcx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.0864775, 0.5, -1.244947)
[node name="Plate2" parent="." unique_id=356790445 instance=ExtResource("8_l1owj")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5730225, 1.1085004, 0.59790254)
[node name="CookedBurger" parent="." unique_id=1127807542 instance=ExtResource("14_1lg2m")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.30782473, 1.1446649, -1.0928738)
[node name="CookedBurger2" parent="." unique_id=160088590 instance=ExtResource("14_1lg2m")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.30671906, 1.0522771, -1.0928738)
[node name="CookedBurger3" parent="." unique_id=992183367 instance=ExtResource("14_1lg2m")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.3344773, 1.0492828, -0.7096845)
[node name="CookedBurger4" parent="." unique_id=1837607086 instance=ExtResource("14_1lg2m")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.30671906, 1.098119, -1.0928738)
[node name="BurgerBuns2" parent="." unique_id=1210358958 instance=ExtResource("6_bktvt")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.3596323, 1.0205106, -0.22482127)
[node name="PickableObject7" parent="." unique_id=641653545 instance=ExtResource("11_npf8s")]
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, -1.3556751, 1.0887735, 0.28881657)
[node name="PickableObject8" parent="." unique_id=1733819363 instance=ExtResource("11_npf8s")]
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, -5.293956e-23, -2.6077032e-08, 1.4901161e-08, 1, -1.3422732, 1.0734154, 0.16882455)
[node name="PickableObject9" parent="." unique_id=12419746 instance=ExtResource("11_npf8s")]
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, -1.4639754, 1.0887735, 0.28881657)
[node name="PickableObject10" parent="." unique_id=313160217 instance=ExtResource("11_npf8s")]
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, -5.293956e-23, -2.6077032e-08, 1.4901161e-08, 1, -1.4505737, 1.0734154, 0.16882455)
[node name="Counter" parent="." unique_id=1487893288 instance=ExtResource("15_yy81s")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.7124918, 0.5, -1.4886917)
[node name="Counter2" parent="." unique_id=368890752 instance=ExtResource("15_yy81s")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.7648025, 0.5, -0.4458799)
[node name="Counter3" parent="." unique_id=1498817646 instance=ExtResource("15_yy81s")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.7648025, 0.5, 0.55367994)
[node name="Counter4" parent="." unique_id=906748771 instance=ExtResource("15_yy81s")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.7648025, 0.5, 1.5539298)
[node name="Hamburger3" parent="." unique_id=369573848 instance=ExtResource("10_qacki")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.7201865, 1.142413, 0.14773655)
[node name="Plate3" parent="." unique_id=2004250522 instance=ExtResource("8_l1owj")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5818124, 1.1085004, -0.4634577)
+79
View File
@@ -0,0 +1,79 @@
[gd_scene format=3 uid="uid://c30i6h32w8p47"]
[ext_resource type="Script" uid="uid://d1cefhe3yyyds" path="res://Scenes/multiplayer_world.gd" id="1_kdan8"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://XROrigin.tscn" id="2_g30gi"]
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://Textures/dev_material_3d.tres" id="3_75ecy"]
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://Textures/sky/NightSkyHDRI009_16K.tres" id="5_c3xgf"]
[ext_resource type="Script" uid="uid://biu4qr3nr1eny" path="res://test/mp_test_driver.gd" id="99_mptst"]
[sub_resource type="BoxShape3D" id="BoxShape3D_vlqg6"]
size = Vector3(15, 0.1, 15)
[sub_resource type="BoxMesh" id="BoxMesh_24d3s"]
material = ExtResource("3_75ecy")
size = Vector3(15, 0.1, 15)
[sub_resource type="Environment" id="Environment_bvwq1"]
background_mode = 2
sky = ExtResource("5_c3xgf")
reflected_light_source = 2
ssr_enabled = true
ssao_enabled = true
ssil_enabled = true
sdfgi_enabled = true
[sub_resource type="BoxShape3D" id="BoxShape3D_arao0"]
size = Vector3(15, 20, 0.1)
[node name="Main" type="Node3D" unique_id=1312265607]
script = ExtResource("1_kdan8")
[node name="XROrigin3D" parent="." unique_id=2055526621 groups=["local_xr_origin"] instance=ExtResource("2_g30gi")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.36171648, 0, 0.81835127)
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1376644384]
transform = Transform3D(-0.8660254, -0.43301278, 0.24999999, 0.3022632, -0.05510214, 0.9516306, -0.39829266, 0.8997021, 0.17860365, 0, 0, 0)
[node name="Floor" type="StaticBody3D" parent="." unique_id=122279514]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.05, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor" unique_id=958841648]
shape = SubResource("BoxShape3D_vlqg6")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floor/CollisionShape3D" unique_id=1939997056]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00018164515, 0.0006352663, -0.002532661)
mesh = SubResource("BoxMesh_24d3s")
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="WorldContent" type="Node3D" parent="." unique_id=291550153]
[node name="Players" type="Node3D" parent="." unique_id=1595463693]
[node name="ItemsSpawner" type="MultiplayerSpawner" parent="." unique_id=627119248]
spawn_path = NodePath("../WorldContent")
[node name="PlayersSpawner" type="MultiplayerSpawner" parent="." unique_id=106645565]
spawn_path = NodePath("../Players")
[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=4404969]
[node name="CollisionShape3D" type="CollisionShape3D" parent="StaticBody3D" unique_id=998476672]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.197384, 7.589958)
shape = SubResource("BoxShape3D_arao0")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="StaticBody3D" unique_id=340303902]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 9.197384, -7.509142)
shape = SubResource("BoxShape3D_arao0")
[node name="CollisionShape3D3" type="CollisionShape3D" parent="StaticBody3D" unique_id=1193703037]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -7.438612, 9.197384, -0.018813243)
shape = SubResource("BoxShape3D_arao0")
[node name="CollisionShape3D4" type="CollisionShape3D" parent="StaticBody3D" unique_id=1431367494]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 7.502467, 9.197384, -0.018813023)
shape = SubResource("BoxShape3D_arao0")
[node name="TestDriver" type="Node" parent="."]
script = ExtResource("99_mptst")
+145
View File
@@ -0,0 +1,145 @@
extends Node3D
## World script for the multiplayer scene. Starts the host/join the menu asked
## for, turns the authored kitchen into replicated objects, gives every connected
## peer an avatar, and returns to the menu when the session ends.
##
## The world's contents are NOT left baked into the scene file. Whatever the
## scene authors is treated as a template: the server spawns real copies of it
## through NetWorld and every peer drops its own authored originals. A client
## therefore shows the server's world rather than assuming its local copy of the
## scene matches — which is also exactly the path a player joining mid-session
## takes.
const PLAYER_SCENE := "res://Player/net_player.tscn"
## Whether to build the full kitchen on the machine that owns the world. The real
## game scene wants this; focused debug scenes bake their own handful of objects
## and turn it off, so the thing under test is not sharing the world with a
## second copy of the whole kitchen.
@export var populate_from_layout: bool = true
var xr_interface: XRInterface
var _net_world: NetWorld
var _populated := false
func _ready() -> void:
xr_interface = XRServer.find_interface("OpenXR")
if xr_interface and xr_interface.is_initialized():
DisplayServer.window_set_vsync_mode(DisplayServer.VSYNC_DISABLED)
get_viewport().use_xr = true
# Both roots go through the same generic replication hook, so a player avatar
# is just another replicated object — nothing about it is special-cased.
_net_world = NetWorld.new()
_net_world.name = "NetWorld"
add_child(_net_world)
_net_world.setup($ItemsSpawner, $WorldContent)
$PlayersSpawner.add_spawnable_scene(PLAYER_SCENE)
$Players.child_entered_tree.connect(_on_player_entered)
NetworkManager.register_world(self, _net_world)
NetworkManager.player_joined.connect(_on_player_joined)
NetworkManager.player_left.connect(_on_player_left)
NetworkManager.session_started.connect(_on_session_started)
NetworkManager.session_ended.connect(_on_session_ended)
NetworkManager.connection_failed.connect(_on_connection_failed)
# world_ready() is what actually calls host()/join() (or the command-line
# equivalent). Populating before this point would be wrong for every case, not
# just offline: is_online() is still false until host()/join() runs, so
# owns_world() reads true for a joining client too and it would build its own
# copy instead of receiving the server's. host() emits session_started
# synchronously, which populates via _on_session_started; the call after
# world_ready() only covers the case where neither ran — this scene opened
# directly, offline.
NetworkManager.world_ready()
_populate_world_if_owner()
func _on_player_entered(node: Node) -> void:
if node is MultiplayerSynchronizer:
return
NetReplication.attach(node)
func _exit_tree() -> void:
NetworkManager.unregister_world()
func _on_session_started(_is_server: bool) -> void:
_populate_world_if_owner()
## Turns the authored template into replicated objects, exactly once, on the
## machine that owns world logic. Safe to call from several entry points.
func _populate_world_if_owner() -> void:
if _populated or not populate_from_layout:
return
# WorldLayout reads the live scene tree to find what to replicate, so it has
# to be an instance sitting in that tree.
var layout := WorldLayout.new()
add_child(layout)
var authored := layout.get_authored_nodes()
# Every peer drops its authored copies. The client would otherwise show its
# local originals on top of the server's replicated ones, and the two sets
# would drift apart because only the server's are synced.
if not NetworkManager.owns_world():
NetworkManager.log_line("Clearing %d authored nodes; the server's copies replace them" % authored.size())
_remove_authored(authored)
layout.queue_free()
return
_populated = true
GameManager.meals_in_play = ["hamburger"]
var objects := layout.describe(authored)
layout.queue_free()
_remove_authored(authored)
NetworkManager.log_line("Populating world: %d objects" % objects.size())
for d in objects:
NetworkManager.spawn_item(d["scene"], d["xform"], d["name"], d["props"])
NetworkManager.log_line("World populated")
# Freed immediately rather than queue_free()d, so the names are released before
# the replicated copies are spawned under the same ones.
func _remove_authored(nodes: Array[Node]) -> void:
for node in nodes:
if is_instance_valid(node):
node.get_parent().remove_child(node)
node.free()
## Only the server (or the single offline machine) creates avatars;
## MultiplayerSpawner replicates the result to everyone else, late joiners
## included.
func _on_player_joined(peer_id: int) -> void:
if not NetworkManager.owns_world() or $Players.has_node(str(peer_id)):
return
var p: Node = load(PLAYER_SCENE).instantiate()
# The name is the peer id, which is how net_player.gd knows whose avatar it
# is on every peer — MultiplayerSpawner replicates the name.
p.name = str(peer_id)
$Players.add_child(p)
NetworkManager.log_line("Spawned avatar for peer %d" % peer_id)
func _on_player_left(peer_id: int) -> void:
if not NetworkManager.owns_world():
return
var p := $Players.get_node_or_null(str(peer_id))
if p:
p.queue_free()
NetworkManager.log_line("Despawned avatar for peer %d" % peer_id)
func _on_session_ended() -> void:
NetworkManager.log_line("Session ended, returning to main menu")
get_tree().change_scene_to_file("res://Scenes/mainMenu.tscn")
func _on_connection_failed() -> void:
NetworkManager.log_line("Connection failed, returning to main menu")
get_tree().change_scene_to_file("res://Scenes/mainMenu.tscn")
+1
View File
@@ -0,0 +1 @@
uid://d1cefhe3yyyds
+84
View File
@@ -0,0 +1,84 @@
[gd_scene format=3 uid="uid://dbgu4r127ke5v"]
[ext_resource type="Script" uid="uid://b4ldkd3ngs0vp" path="res://main.gd" id="1_1ymas"]
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://Textures/sky/NightSkyHDRI009_16K.tres" id="2_1jq86"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://XROrigin.tscn" id="3_bryd6"]
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://Textures/dev_material_3d.tres" id="4_kpgm6"]
[ext_resource type="PackedScene" uid="uid://j7caslh27nor" path="res://Stations/Hob.tscn" id="5_gfdi7"]
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://Stations/sink.tscn" id="6_fmmg3"]
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://Stations/Counter.tscn" id="7_jnxsa"]
[ext_resource type="PackedScene" uid="uid://e4i6o5oriecx" path="res://Items/PickupCube.tscn" id="8_xl5nn"]
[sub_resource type="Environment" id="Environment_bvwq1"]
background_mode = 2
sky = ExtResource("2_1jq86")
ambient_light_source = 3
ambient_light_color = Color(1, 1, 1, 1)
ambient_light_sky_contribution = 0.9
reflected_light_source = 2
ssr_enabled = true
ssao_enabled = true
ssil_enabled = true
sdfgi_enabled = true
[sub_resource type="BoxShape3D" id="BoxShape3D_vlqg6"]
size = Vector3(20, 0.1, 20)
[sub_resource type="BoxMesh" id="BoxMesh_24d3s"]
material = ExtResource("4_kpgm6")
size = Vector3(20, 0.1, 20)
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
size = Vector3(20, 10, 0.1)
[node name="Main" type="Node3D" unique_id=1312265607]
script = ExtResource("1_1ymas")
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="XROrigin3D" parent="." unique_id=2055526621 instance=ExtResource("3_bryd6")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.9667189, 0)
[node name="DirectionalLight3D" type="DirectionalLight3D" parent="." unique_id=1376644384]
transform = Transform3D(-0.8660254, -0.43301278, 0.24999999, 0.3022632, -0.05510214, 0.9516306, -0.39829266, 0.8997021, 0.17860365, 0, 0, 0)
[node name="Floor" type="StaticBody3D" parent="." unique_id=122279514]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.05, 0)
[node name="CollisionShape3D" type="CollisionShape3D" parent="Floor" unique_id=958841648]
shape = SubResource("BoxShape3D_vlqg6")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Floor/CollisionShape3D" unique_id=1939997056]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00018164515, 0.0006352663, -0.002532661)
mesh = SubResource("BoxMesh_24d3s")
[node name="InvisibleWalls" type="StaticBody3D" parent="." unique_id=315740174]
[node name="CollisionShape3D" type="CollisionShape3D" parent="InvisibleWalls" unique_id=33059670]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.688614, 8.838269)
shape = SubResource("BoxShape3D_24d3s")
[node name="CollisionShape3D2" type="CollisionShape3D" parent="InvisibleWalls" unique_id=2018792171]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 4.688614, -10.243342)
shape = SubResource("BoxShape3D_24d3s")
[node name="CollisionShape3D3" type="CollisionShape3D" parent="InvisibleWalls" unique_id=757662929]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, -9.807113, 4.688614, -0.018813243)
shape = SubResource("BoxShape3D_24d3s")
[node name="CollisionShape3D4" type="CollisionShape3D" parent="InvisibleWalls" unique_id=1468386997]
transform = Transform3D(-4.371139e-08, 0, -1, 0, 1, 0, 1, 0, -4.371139e-08, 9.934778, 4.297072, -0.018813023)
shape = SubResource("BoxShape3D_24d3s")
[node name="Hob" parent="." unique_id=1687971542 instance=ExtResource("5_gfdi7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.35077858, 0.50655985, -1.2833805)
[node name="Sink" parent="." unique_id=2055277359 instance=ExtResource("6_fmmg3")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.24685252, 0.51461196, -1.2828919)
[node name="Counter" parent="." unique_id=1487893288 instance=ExtResource("7_jnxsa")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.94890714, 0.5115015, -1.3041471)
[node name="PickableObject" parent="." unique_id=1675596942 instance=ExtResource("8_xl5nn")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.87560004, 1.5534955, -1.2869046)
+62
View File
@@ -0,0 +1,62 @@
extends Node
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
print(get_stations())
print(get_items())
func get_node_data(node):
# {"scene": "res://Stations/Hob.tscn", "name": "Hob",
# "xform": Transform3D(Basis(), Vector3(0.29336345, 0.8981018, -1.484)), "props": {}},
var data = {}
data["scene"] = node.scene_file_path
data["name"] = node.name
data["xform"] = node.transform
data["props"] = {}
var scrip = node.get_script()
if scrip:
for i in scrip.get_script_property_list():
if i.usage & PROPERTY_USAGE_STORAGE:
data["props"][i["name"]] = node.get(i["name"])
return data
func get_stations() -> Array[Dictionary]:
var Stations = ResourceLoader.list_directory("res://Stations/")
var Stations2 = []
for i in Stations:
Stations2.append("res://Stations/" + i)
Stations = Stations2
var Stations_nodes = []
for i in get_tree().root.find_children("*", "StaticBody3D", true, false):
if i.scene_file_path in Stations:
Stations_nodes.append(i)
var data: Array[Dictionary] = []
for i in Stations_nodes:
data.append(get_node_data(i))
return data
func get_items() -> Array[Dictionary]:
var Items = ResourceLoader.list_directory("res://Items/")
var Items2 = []
for i in Items:
Items2.append("res://Items/" + i)
Items = Items2
var Items_nodes = []
for i in get_tree().root.find_children("*", "XRToolsPickable", true, false):
if i.scene_file_path in Items:
Items_nodes.append(i)
var data: Array[Dictionary] = []
for i in Items_nodes:
data.append(get_node_data(i))
return data
+1
View File
@@ -0,0 +1 @@
uid://k8ywnvlhcic4
+4
View File
@@ -0,0 +1,4 @@
extends Node
signal game_over
signal restart_game
+1
View File
@@ -0,0 +1 @@
uid://fuux6cxfjwdc
Binary file not shown.
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://mmasxwqyqmib"
path="res://.godot/imported/220175__gameaudio__pop-click.wav-1330523e09eacb15d341a14b80e4481e.sample"
[deps]
source_file="res://Sounds/220175__gameaudio__pop-click.wav"
dest_files=["res://.godot/imported/220175__gameaudio__pop-click.wav-1330523e09eacb15d341a14b80e4481e.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://ecva70pect61"
path="res://.godot/imported/220178__gameaudio__click.wav-ca46bf33c1c48e1e526f04c43ca7d450.sample"
[deps]
source_file="res://Sounds/220178__gameaudio__click.wav"
dest_files=["res://.godot/imported/220178__gameaudio__click.wav-ca46bf33c1c48e1e526f04c43ca7d450.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://b3wxawyrvuc6s"
path="res://.godot/imported/220179__gameaudio__click-metal-ting.wav-b01c457287fe42298a36c3de7c536c68.sample"
[deps]
source_file="res://Sounds/220179__gameaudio__click-metal-ting.wav"
dest_files=["res://.godot/imported/220179__gameaudio__click-metal-ting.wav-b01c457287fe42298a36c3de7c536c68.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://b7sr2sb1ks5en"
path="res://.godot/imported/220180__gameaudio__click-pop.wav-9e467150046193d705dd830885c89cd1.sample"
[deps]
source_file="res://Sounds/220180__gameaudio__click-pop.wav"
dest_files=["res://.godot/imported/220180__gameaudio__click-pop.wav-9e467150046193d705dd830885c89cd1.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://1ccsqbju32ey"
path="res://.godot/imported/220187__gameaudio__loosedeny-casual-1.wav-cb0e560d42c6026ded2d2e240e614433.sample"
[deps]
source_file="res://Sounds/220187__gameaudio__loosedeny-casual-1.wav"
dest_files=["res://.godot/imported/220187__gameaudio__loosedeny-casual-1.wav-cb0e560d42c6026ded2d2e240e614433.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bdnsgt7xt3261"
path="res://.godot/imported/220194__gameaudio__click-heavy.wav-aca40ed286d93eb365d527a162fd3129.sample"
[deps]
source_file="res://Sounds/220194__gameaudio__click-heavy.wav"
dest_files=["res://.godot/imported/220194__gameaudio__click-heavy.wav-aca40ed286d93eb365d527a162fd3129.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://daiv8ubwdbidf"
path="res://.godot/imported/220195__gameaudio__click-wooden-1.wav-9368ef861eabf2cf1d5bd0db33c616c8.sample"
[deps]
source_file="res://Sounds/220195__gameaudio__click-wooden-1.wav"
dest_files=["res://.godot/imported/220195__gameaudio__click-wooden-1.wav-9368ef861eabf2cf1d5bd0db33c616c8.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://qed775b4j1gg"
path="res://.godot/imported/220196__gameaudio__click-wooden-2.wav-45bb63efefaf817b60155beec9343d74.sample"
[deps]
source_file="res://Sounds/220196__gameaudio__click-wooden-2.wav"
dest_files=["res://.godot/imported/220196__gameaudio__click-wooden-2.wav-45bb63efefaf817b60155beec9343d74.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://bqtk1adk8umbx"
path="res://.godot/imported/220197__gameaudio__click-basic.wav-9f173e2b7206278e95710ab077d62c32.sample"
[deps]
source_file="res://Sounds/220197__gameaudio__click-basic.wav"
dest_files=["res://.godot/imported/220197__gameaudio__click-basic.wav-9f173e2b7206278e95710ab077d62c32.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://ysgfx76jkx2q"
path="res://.godot/imported/220198__gameaudio__click-with-two-parts.wav-089977567529b37b0fd9cd019eb7b3c2.sample"
[deps]
source_file="res://Sounds/220198__gameaudio__click-with-two-parts.wav"
dest_files=["res://.godot/imported/220198__gameaudio__click-with-two-parts.wav-089977567529b37b0fd9cd019eb7b3c2.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://dtyh22ccebiv5"
path="res://.godot/imported/220199__gameaudio__click-higher.wav-d1c1550d99a0cc873012c4010877005b.sample"
[deps]
source_file="res://Sounds/220199__gameaudio__click-higher.wav"
dest_files=["res://.godot/imported/220199__gameaudio__click-higher.wav-d1c1550d99a0cc873012c4010877005b.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://cywjbbeintjew"
path="res://.godot/imported/220208__gameaudio__click-pop-two-part.wav-04cb5eb3e0b3459771dbab42bbd24be9.sample"
[deps]
source_file="res://Sounds/220208__gameaudio__click-pop-two-part.wav"
dest_files=["res://.godot/imported/220208__gameaudio__click-pop-two-part.wav-04cb5eb3e0b3459771dbab42bbd24be9.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
Binary file not shown.
@@ -0,0 +1,24 @@
[remap]
importer="wav"
type="AudioStreamWAV"
uid="uid://claw3d2wnyr6a"
path="res://.godot/imported/220212__gameaudio__ping-bing.wav-2a1049829e71a0034c7e8d18745663f1.sample"
[deps]
source_file="res://Sounds/220212__gameaudio__ping-bing.wav"
dest_files=["res://.godot/imported/220212__gameaudio__ping-bing.wav-2a1049829e71a0034c7e8d18745663f1.sample"]
[params]
force/8_bit=false
force/mono=false
force/max_rate=false
force/max_rate_hz=44100
edit/trim=false
edit/normalize=false
edit/loop_mode=0
edit/loop_begin=0
edit/loop_end=-1
compress/mode=2
BIN
View File
Binary file not shown.
+19
View File
@@ -0,0 +1,19 @@
[remap]
importer="mp3"
type="AudioStreamMP3"
uid="uid://clkjwcawdqvta"
path="res://.godot/imported/money.mp3-95c717b8402507d80974f4f4287b0b63.mp3str"
[deps]
source_file="res://Sounds/money.mp3"
dest_files=["res://.godot/imported/money.mp3-95c717b8402507d80974f4f4287b0b63.mp3str"]
[params]
loop=false
loop_offset=0.0
bpm=0.0
beat_count=0
bar_beats=4
+8 -5
View File
@@ -3,11 +3,13 @@
[ext_resource type="Script" uid="uid://0y6wnjcsum6" path="res://Stations/item_dispenser.gd" id="1_myl3s"]
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="1_p30r1"]
[ext_resource type="PackedScene" uid="uid://c0lknik4noobs" path="res://Items/BurgerBuns.tscn" id="2_1q74o"]
[ext_resource type="PackedScene" uid="uid://mpapt5mkbuao" path="res://Prefabs/slide_off_dome.tscn" id="4_rf1b2"]
[sub_resource type="SphereShape3D" id="SphereShape3D_xmbo2"]
radius = 0.3
[sub_resource type="CylinderShape3D" id="CylinderShape3D_24d3s"]
radius = 0.3
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_vlqg6"]
albedo_color = Color(0.6784191, 0.54546416, 0.016760282, 1)
@@ -22,7 +24,6 @@ collision_layer = 65536
collision_mask = 65536
script = ExtResource("1_p30r1")
snap_mode = 1
initial_object = NodePath("../../BurgerBuns")
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
[node name="CollisionShape3D" type="CollisionShape3D" parent="XRToolsSnapZone" unique_id=1104626493]
@@ -31,14 +32,16 @@ shape = SubResource("SphereShape3D_xmbo2")
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1470079357]
shape = SubResource("CylinderShape3D_24d3s")
[node name="SlideOffDome" parent="." unique_id=1427609426 instance=ExtResource("4_rf1b2")]
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="." unique_id=1746426494]
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=858311379]
radius = 0.4
radius = 0.3
sides = 32
[node name="CSGCombiner3DBuns" type="CSGCombiner3D" parent="CSGCombiner3D" unique_id=1459017790]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.108142376, 1.0341886, -0.19146484)
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.16038476, 1.0341886, -0.09012994)
autosmooth = true
smoothing_angle = 138.9
@@ -119,7 +122,7 @@ cone = true
material = SubResource("StandardMaterial3D_vlqg6")
[node name="CSGCombiner3DBuns4" type="CSGCombiner3D" parent="CSGCombiner3D" unique_id=2055085730]
transform = Transform3D(0.95670986, 0, 0.29104328, 0, 1, 0, -0.29104328, 0, 0.95670986, -0.14758292, 1.0341886, -0.1304872)
transform = Transform3D(0.95670986, 0, 0.29104328, 0, 1, 0, -0.29104328, 0, 0.95670986, -0.08665481, 1.0341886, -0.10344604)
autosmooth = true
smoothing_angle = 138.9
@@ -146,7 +149,7 @@ cone = true
material = SubResource("StandardMaterial3D_vlqg6")
[node name="CSGCombiner3DBuns5" type="CSGCombiner3D" parent="CSGCombiner3D" unique_id=546748728]
transform = Transform3D(0.20608562, 0, -0.978534, 0, 1, 0, 0.978534, 0, 0.20608562, -0.082762055, 1.0341886, 0.2722176)
transform = Transform3D(0.20608562, 0, -0.978534, 0, 1, 0, 0.978534, 0, 0.20608562, -0.047733016, 1.0341886, 0.19433105)
autosmooth = true
smoothing_angle = 138.9
+71 -15
View File
@@ -1,34 +1,90 @@
[gd_scene format=3 uid="uid://efaec6ymgabo"]
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="1_dlkho"]
[ext_resource type="AudioStream" uid="uid://bqtk1adk8umbx" path="res://Sounds/220197__gameaudio__click-basic.wav" id="2_0aadn"]
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
size = Vector3(0.6, 1, 0.6)
[sub_resource type="BoxMesh" id="BoxMesh_i5j2u"]
[sub_resource type="BoxShape3D" id="BoxShape3D_1ntq7"]
size = Vector3(0.6, 0.12802735, 0.6)
[sub_resource type="SphereShape3D" id="SphereShape3D_dlkho"]
radius = 0.3
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_24d3s"]
albedo_color = Color(0.49, 0.3854667, 0.29400003, 1)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_pt8vn"]
albedo_color = Color(0.66595805, 0.53976387, 0.4331022, 1)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_vlqg6"]
albedo_color = Color(1.1759251, 0.741115, 0.5692133, 1)
[node name="Counter" type="StaticBody3D" unique_id=1487893288 groups=["station"]]
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=692568688]
[node name="CollisionShape3DCuttingBoard" type="CollisionShape3D" parent="." unique_id=706340473]
shape = SubResource("BoxShape3D_24d3s")
[node name="MeshInstance3D" type="MeshInstance3D" parent="CollisionShape3D" unique_id=127773521]
mesh = SubResource("BoxMesh_i5j2u")
[node name="Label3D" type="Label3D" parent="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="." unique_id=1647380272 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, 0.5608841, 0)
collision_layer = 65536
collision_mask = 65536
collision_mask = 65540
script = ExtResource("1_dlkho")
stash_sound = ExtResource("2_0aadn")
snap_mode = 1
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
[node name="CollisionShape3D2" type="CollisionShape3D" parent="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")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.002, 0)
shape = SubResource("BoxShape3D_1ntq7")
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="XRToolsSnapZone" unique_id=1786831079]
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="." unique_id=451757283]
use_collision = true
[node name="CSGBox3D" type="CSGBox3D" parent="CSGCombiner3D" unique_id=305755330]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.046, -0.025)
size = Vector3(0.6, 0.908, 0.55)
material = SubResource("StandardMaterial3D_24d3s")
[node name="CSGBox3D7" type="CSGBox3D" parent="CSGCombiner3D" unique_id=1086568272]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.39999902, 0.22965088)
operation = 2
size = Vector3(0.6, 0.22992969, 0.14069825)
material = SubResource("StandardMaterial3D_24d3s")
[node name="CSGBox3D2" type="CSGBox3D" parent="CSGCombiner3D" unique_id=43663195]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5, 0)
size = Vector3(0.6, 0.202, 0.6)
[node name="CSGBox3D3" type="CSGBox3D" parent="CSGCombiner3D" unique_id=1210567516]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5617909, 0.060281754)
operation = 2
size = Vector3(0.6, 0.12051563, 0.6402156)
[node name="CSGBox3D4" type="CSGBox3D" parent="CSGCombiner3D" unique_id=1533996708]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.15, 0.08, 0.26034504)
size = Vector3(0.25, 0.6, 0.024)
material = SubResource("StandardMaterial3D_pt8vn")
[node name="CSGBox3D5" type="CSGBox3D" parent="CSGCombiner3D" unique_id=1983709234]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.15, 0.08, 0.26034504)
size = Vector3(0.25, 0.6, 0.024)
material = SubResource("StandardMaterial3D_pt8vn")
[node name="CSGSphere3D" type="CSGSphere3D" parent="CSGCombiner3D" unique_id=1785057925]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.057649717, 0.12459713, 0.29140875)
radius = 0.025492515
[node name="CSGSphere3D2" type="CSGSphere3D" parent="CSGCombiner3D" unique_id=1224446005]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.060837455, 0.12459713, 0.29140875)
radius = 0.025492515
[node name="CSGBox3D6" type="CSGBox3D" parent="CSGCombiner3D" unique_id=187377667]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.514, 0)
size = Vector3(0.48251343, 0.037231445, 0.42160034)
material = SubResource("StandardMaterial3D_vlqg6")
[node name="CSGBox3D6" type="CSGBox3D" parent="CSGCombiner3D/CSGBox3D6" unique_id=1146824846]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.1899699, 0.01924485, -0.0039587095)
operation = 2
size = Vector3(0.037109375, 0.092285156, 0.26757813)
+243 -21
View File
@@ -1,42 +1,264 @@
[gd_scene format=3 uid="uid://j7caslh27nor"]
[ext_resource type="Script" uid="uid://bsn8vhv5adxdo" path="res://Stations/hob.gd" id="1_7jc4g"]
[ext_resource type="Texture2D" uid="uid://b7n8d4krwbcvl" path="res://Textures/5.png" id="2_0sasq"]
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="2_er1dp"]
[ext_resource type="AudioStream" uid="uid://bqtk1adk8umbx" path="res://Sounds/220197__gameaudio__click-basic.wav" id="3_6oyg1"]
[ext_resource type="PackedScene" uid="uid://bxbocxdaayvwx" path="res://UI/progress_bar.tscn" id="3_7uuqv"]
[ext_resource type="Material" uid="uid://d1djvskv4n4m3" path="res://Textures/hob_off.tres" id="4_8qpxk"]
[ext_resource type="Material" uid="uid://db7c7w4apwti7" path="res://Textures/hob_on.tres" id="6_m7l4u"]
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
[sub_resource type="BoxShape3D" id="BoxShape3D_kdxnr"]
size = Vector3(0.6, 1, 0.6)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_m5xe2"]
albedo_texture = ExtResource("2_0sasq")
uv1_triplanar = true
[sub_resource type="BoxShape3D" id="BoxShape3D_7uuqv"]
size = Vector3(0.6, 0.12802735, 0.6)
[sub_resource type="BoxMesh" id="BoxMesh_i5j2u"]
material = SubResource("StandardMaterial3D_m5xe2")
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_gkb3v"]
[sub_resource type="SphereShape3D" id="SphereShape3D_vlqg6"]
radius = 0.3
[sub_resource type="Animation" id="Animation_7uuqv"]
length = 0.001
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("CSGCombiner3D/CSGTorus3D3:material")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("4_8qpxk")]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("CSGCombiner3D/CSGTorus3D2:material")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("4_8qpxk")]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("CSGCombiner3D/CSGTorus3D:material")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("4_8qpxk")]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("CSGCombiner3D/CSGTorus3D3:material:emission_energy_multiplier")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("OmniLight3D:light_energy")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 0,
"values": [0.0]
}
[sub_resource type="Animation" id="Animation_6oyg1"]
resource_name = "hob"
loop_mode = 1
tracks/0/type = "value"
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/path = NodePath("CSGCombiner3D/CSGTorus3D3:material")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("6_m7l4u")]
}
tracks/1/type = "value"
tracks/1/imported = false
tracks/1/enabled = true
tracks/1/path = NodePath("CSGCombiner3D/CSGTorus3D2:material")
tracks/1/interp = 1
tracks/1/loop_wrap = true
tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("6_m7l4u")]
}
tracks/2/type = "value"
tracks/2/imported = false
tracks/2/enabled = true
tracks/2/path = NodePath("CSGCombiner3D/CSGTorus3D:material")
tracks/2/interp = 1
tracks/2/loop_wrap = true
tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("6_m7l4u")]
}
tracks/3/type = "value"
tracks/3/imported = false
tracks/3/enabled = true
tracks/3/path = NodePath("CSGCombiner3D/CSGTorus3D3:material:emission_energy_multiplier")
tracks/3/interp = 1
tracks/3/loop_wrap = true
tracks/3/keys = {
"times": PackedFloat32Array(0, 0.5, 1),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [1.0, 0.0, 1.0]
}
tracks/4/type = "value"
tracks/4/imported = false
tracks/4/enabled = true
tracks/4/path = NodePath("OmniLight3D:light_energy")
tracks/4/interp = 1
tracks/4/loop_wrap = true
tracks/4/keys = {
"times": PackedFloat32Array(0, 0.5, 1),
"transitions": PackedFloat32Array(1, 1, 1),
"update": 0,
"values": [1.0, 0.0, 1.0]
}
[sub_resource type="AnimationLibrary" id="AnimationLibrary_ac5f3"]
_data = {
&"RESET": SubResource("Animation_7uuqv"),
&"hob": SubResource("Animation_6oyg1")
}
[node name="Hob" type="StaticBody3D" unique_id=1687971542 groups=["station"]]
script = ExtResource("1_7jc4g")
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1283846023]
shape = SubResource("BoxShape3D_24d3s")
shape = SubResource("BoxShape3D_kdxnr")
[node name="MeshInstance3D" type="MeshInstance3D" parent="CollisionShape3D" unique_id=1454284058]
mesh = SubResource("BoxMesh_i5j2u")
[node name="Label3D" type="Label3D" parent="CollisionShape3D" unique_id=757148654]
transform = Transform3D(0.9999992, 0, 0, 0, 0.99999946, 0, 0, 0, 0.9999992, 0.002797456, 0.6309581, -0.2812457)
text = "Hob"
[node name="XRToolsSnapZone" type="Area3D" parent="." unique_id=538157739]
[node name="XRToolsSnapZone" type="Area3D" parent="." unique_id=538157739 groups=["station"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5270121, 0)
collision_layer = 65536
collision_mask = 65536
collision_mask = 65540
script = ExtResource("2_er1dp")
stash_sound = ExtResource("3_6oyg1")
snap_mode = 1
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
[node name="CollisionShape3D2" type="CollisionShape3D" parent="XRToolsSnapZone" unique_id=370920392]
transform = Transform3D(0.5, 0, 0, 0, 0.5, 0, 0, 0, 0.5, 0, -0.000975132, 0)
shape = SubResource("SphereShape3D_vlqg6")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.000975132, 0)
shape = SubResource("BoxShape3D_7uuqv")
[node name="AudioStreamPlayer3D" type="AudioStreamPlayer3D" parent="XRToolsSnapZone" unique_id=1991627595]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.022546828, -0.5270121, 0.36528283)
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="." unique_id=70901698]
[node name="CSGBox3D" type="CSGBox3D" parent="CSGCombiner3D" unique_id=1111505172]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -0.00894776)
size = Vector3(0.6, 1, 0.5821045)
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="CSGCombiner3D/CSGBox3D" unique_id=1338463939]
transform = Transform3D(0.8943019, 0, 0, 0, 0.8943019, 0, 0, 0, 0.8943019, 0, 0.5103538, -7.827557e-05)
operation = 2
radius = 0.25976563
height = 0.08898926
sides = 32
[node name="CSGTorus3D3" type="CSGTorus3D" parent="CSGCombiner3D" unique_id=666891341]
transform = Transform3D(0.8943019, 0, 0, 0, 0.8943019, 0, 0, 0, 0.8943019, 0, 0.5003869, -7.827557e-05)
inner_radius = 0.09153879
outer_radius = 0.120084204
sides = 32
material = ExtResource("4_8qpxk")
[node name="CSGTorus3D2" type="CSGTorus3D" parent="CSGCombiner3D" unique_id=24541894]
transform = Transform3D(0.8943019, 0, 0, 0, 0.8943019, 0, 0, 0, 0.8943019, 0, 0.5003869, -7.827557e-05)
inner_radius = 0.15036294
outer_radius = 0.17592031
sides = 32
material = ExtResource("4_8qpxk")
[node name="CSGTorus3D" type="CSGTorus3D" parent="CSGCombiner3D" unique_id=1901978664]
transform = Transform3D(0.8943019, 0, 0, 0, 0.8943019, 0, 0, 0, 0.8943019, 0, 0.5003869, -7.827557e-05)
inner_radius = 0.20426142
outer_radius = 0.2321898
sides = 32
material = ExtResource("4_8qpxk")
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=1107239311]
transform = Transform3D(0.8943019, 0, 0, 0, 0.8943019, 0, 0, 0, 0.8943019, 0, 0.4498226, -7.827557e-05)
radius = 0.071777344
height = 0.09637451
sides = 32
[node name="CSGCylinder3D2" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=435540815]
transform = Transform3D(0.8943019, 0, 0, 0, -3.9091177e-08, 0.8943019, 0, -0.8943019, -3.9091177e-08, 0, 0.48668858, -0.0020651226)
radius = 0.008
height = 0.44487303
[node name="CSGCylinder3D3" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=878171801]
transform = Transform3D(-3.9091177e-08, -0.8943019, -3.9091177e-08, 0, -3.9091177e-08, 0.8943019, -0.8943019, 3.9091177e-08, 1.7087296e-15, 0, 0.48668858, -0.0020651226)
radius = 0.008
height = 0.44487303
[node name="CSGCylinder3D4" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=1619646436]
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, -0.20412213, 0.42728558, 0.26171687)
radius = 0.044433594
height = 0.10932617
material = SubResource("StandardMaterial3D_gkb3v")
[node name="CSGCylinder3D5" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=548846612]
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0.12531614, 0.42728558, 0.26171687)
radius = 0.044433594
height = 0.10932617
material = SubResource("StandardMaterial3D_gkb3v")
[node name="CSGCylinder3D6" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=1208989647]
transform = Transform3D(1, 0, 0, 0, -4.371139e-08, 1, 0, -1, -4.371139e-08, 0.22979808, 0.42728558, 0.26171687)
radius = 0.044433594
height = 0.10932617
material = SubResource("StandardMaterial3D_gkb3v")
[node name="CSGBox3D2" type="CSGBox3D" parent="CSGCombiner3D" unique_id=465340362]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.039733887, -0.07685089, 0.29250562)
operation = 2
size = Vector3(1.0999756, 0.8462982, 0.072387695)
[node name="CSGBox3D3" type="CSGBox3D" parent="CSGCombiner3D" unique_id=1813079759]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.003479004, -0.08253479, 0.2656765)
size = Vector3(0.55, 0.835, 0.072)
[node name="CSGBox3D4" type="CSGBox3D" parent="CSGCombiner3D" unique_id=1978186019]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.003479004, -0.45215607, 0.24655426)
size = Vector3(0.55, 0.096, 0.14)
[node name="ProgressBar3D" parent="." unique_id=654673176 instance=ExtResource("3_7uuqv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.74736404, -0.09216304)
[node name="AnimationPlayer" type="AnimationPlayer" parent="." unique_id=1525460719]
libraries/ = SubResource("AnimationLibrary_ac5f3")
[node name="OmniLight3D" type="OmniLight3D" parent="." unique_id=1618457623]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5053487, 0)
light_color = Color(1, 0.13725491, 0, 1)
light_energy = 0.0
omni_range = 0.5
+4
View File
@@ -0,0 +1,4 @@
[gd_scene format=3 uid="uid://cwwnbx5uat3fw"]
[node name="CSGBox3D" type="CSGBox3D" unique_id=725518829]
+19
View File
@@ -0,0 +1,19 @@
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:
if not NetworkManager.owns_world():
return
var plate: PlateController = item.get_node_or_null("PlateController") as PlateController
if not plate:
print("Dirt Station: held object is not a Plate")
return
if not plate.is_dirty:
plate.is_dirty = true
+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://Stations/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="BoxShape3D" id="BoxShape3D_mep2a"]
size = Vector3(0.81640625, 0.5635376, 0.79351807)
[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 = 65540
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.008666992, -0.11009073, -0.009353638)
shape = SubResource("BoxShape3D_mep2a")
+105 -36
View File
@@ -1,59 +1,128 @@
extends StaticBody3D
const RECIPE_MANAGER = preload("res://RecipeManager.gd")
@export var cook_speed = 1
@onready var snap_zone: XRToolsSnapZone = $XRToolsSnapZone
@onready var progress_bar: ProgressBar3D = $ProgressBar3D
## Cooking state. All three are replicated (see Hob.tscn's Sync node) and each
## refreshes the display when it changes, which is what makes the hob look alive
## on a client: only the world owner runs the station's _process and its snap
## zone, so a client never reaches the code below by itself and would otherwise
## show a hob that never lights up.
var time_cooked: float = 0.0: set = _set_time_cooked
var cooking_result: String = "": set = _set_cooking_result
var cooking_result_time: float = 0.0: set = _set_cooking_result_time
func _set_time_cooked(value: float) -> void:
if is_equal_approx(time_cooked, value):
return
time_cooked = value
_refresh_display()
func _set_cooking_result(value: String) -> void:
if cooking_result == value:
return
cooking_result = value
_refresh_display()
# The flames follow whether we're cooking, on every peer.
_play_animation("hob" if not cooking_result.is_empty() else "RESET")
func _set_cooking_result_time(value: float) -> void:
if is_equal_approx(cooking_result_time, value):
return
cooking_result_time = value
_refresh_display()
var item = null
var progress = 0
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
if snap_zone.initial_object:
item = snap_zone.initial_object
print("Hob has item: ", item)
else:
print("Hob is empty")
if not progress_bar or progress_bar is not ProgressBar3D:
push_error("Hob missing reference to progressbar, or wrong type:", progress_bar)
snap_zone.has_picked_up.connect(_on_object_picked_up)
snap_zone.has_dropped.connect(_on_object_dropped)
_refresh_display()
func convert_item(cookable: CookableItem) -> void:
print("Hob converting ", cookable)
func _play_animation(name: String) -> void:
# Replicated setters can fire before the node is in the tree (spawn payload),
# when the @onready children don't exist yet.
var player := get_node_or_null("AnimationPlayer") as AnimationPlayer
if player:
player.play(name)
func _refresh_display() -> void:
# Guarded for the same reason as _play_animation.
if not progress_bar:
return
var progress := 0.0
if cooking_result and cooking_result_time > 0:
progress = clampf(float(time_cooked) / cooking_result_time, 0.0, 1.0)
progress_bar.set_progress(progress)
progress_bar.set_bar_visible(not cooking_result.is_empty())
progress_bar.override_fill_color(Color.RED if cooking_result == "charcoal" else Color.GREEN)
func _on_object_picked_up(_item) -> void:
print("Hob: object picked up: ", _item)
# Find the CookableItem in held object
var _food_item = _item.get_node_or_null("FoodItem") as FoodItem
if not _food_item:
print("Hob: held object is not a FoodItem")
return
var result = RECIPE_MANAGER.get_cooking_result(_food_item.id)
if not result:
print("Hob: held a FoodItem that is not cookable, id: %s result: %s" % [_food_item.id, result])
return
cooking_result = result
cooking_result_time = RECIPE_MANAGER.get_cooking_time(_food_item.id)
print("Hob: set cooking_result ", cooking_result)
# The setters above already refresh the display and start the flames.
func _on_object_dropped() -> void:
print("Hob: object drop ")
time_cooked = 0
cooking_result = ""
cooking_result_time = 0
func convert_held_to_item(_item: String) -> void:
if not NetworkManager.owns_world():
return
print("Hob converting ", _item)
var old_pickable = snap_zone.picked_up_object
if not old_pickable:
push_warning("Hob finished cooking item, but snap zone is missing its reference")
push_warning("Hob finished cooking _item, but snap zone is missing its reference")
return
print("picked_up_object ", snap_zone.picked_up_object)
# Spawn the new item through the server so it replicates to every peer
# (including late joiners), in the old item's position.
var original_transform = old_pickable.global_transform
var new_scene_instance = cookable.turns_into.instantiate()
# Add the new item to the hob's parent (so it lives in the main world space)
get_parent().add_child(new_scene_instance)
new_scene_instance.global_transform = original_transform
var new_scene_instance = NetworkManager.spawn_item(RECIPE_MANAGER.get_item_scene(_item).resource_path, original_transform)
# Drop and free the old item and pick up the new one
print("Hob freeing old_pickable ", old_pickable)
snap_zone.drop_object()
print("old_pickable ", old_pickable)
old_pickable.queue_free()
NetworkManager.despawn_item(old_pickable)
snap_zone.pick_up_object(new_scene_instance)
# Called every frame. 'delta' is the elapsed time since the previous frame.
# If cooking something, progress cooking, when done, convert item
func _process(delta: float) -> void:
# Find the CookableItem in held object
var cookable = null
if snap_zone.picked_up_object:
var matches = snap_zone.picked_up_object.get_children().filter(func(c): return c is CookableItem)
if matches.size() > 0:
cookable = matches[0]
if cooking_result:
#print("Hob cooking_result: ", cooking_result)
time_cooked += cook_speed * delta
_refresh_display()
if time_cooked >= cooking_result_time:
time_cooked = 0
convert_held_to_item(cooking_result)
# Cook it if exists, then convert item after cooking
if cookable:
progress += cook_speed * delta
print("Cooking ", progress)
if progress >= cookable.cooking_time:
progress = 0
convert_item(cookable)
else:
progress = 0
+3 -5
View File
@@ -13,10 +13,8 @@ func _ready() -> void:
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
if not NetworkManager.owns_world():
return
if not snap_zone.picked_up_object:
var new_item = item_scene.instantiate()
# Add the new item to the hob's parent (so it lives in the main world space)
get_parent().add_child(new_item)
new_item.global_transform = snap_zone.transform
var new_item = NetworkManager.spawn_item(item_scene.resource_path, snap_zone.global_transform)
snap_zone.pick_up_object(new_item)
+107
View File
@@ -0,0 +1,107 @@
[gd_scene format=3 uid="uid://ck5tuftqmyiue"]
[ext_resource type="Script" uid="uid://0y6wnjcsum6" path="res://Stations/item_dispenser.gd" id="1_jm0ik"]
[ext_resource type="PackedScene" uid="uid://bp3v1jl8pctro" path="res://Containers/plate.tscn" id="2_tfo2i"]
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="3_lr065"]
[ext_resource type="PackedScene" uid="uid://mpapt5mkbuao" path="res://Prefabs/slide_off_dome.tscn" id="4_tfo2i"]
[sub_resource type="SphereShape3D" id="SphereShape3D_xmbo2"]
radius = 0.3
[sub_resource type="CylinderShape3D" id="CylinderShape3D_24d3s"]
radius = 0.3
[node name="PlateDispenser" type="StaticBody3D" unique_id=710538846]
script = ExtResource("1_jm0ik")
item_scene = ExtResource("2_tfo2i")
[node name="XRToolsSnapZone" type="Area3D" parent="." unique_id=238176038]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00070536137, 1.1603245, -0.002165556)
collision_layer = 65536
collision_mask = 65536
script = ExtResource("3_lr065")
snap_mode = 1
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
[node name="CollisionShape3D" type="CollisionShape3D" parent="XRToolsSnapZone" unique_id=1942470044]
shape = SubResource("SphereShape3D_xmbo2")
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=831688237]
shape = SubResource("CylinderShape3D_24d3s")
[node name="SlideOffDome" parent="." unique_id=1427609426 instance=ExtResource("4_tfo2i")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.061363697, 0)
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="." unique_id=696108271]
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=1339763385]
radius = 0.3
sides = 32
[node name="Plates" type="Node3D" parent="." unique_id=1364909922]
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="Plates" unique_id=2128650644]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.0289642, 0)
autosmooth = true
smoothing_angle = 103.9
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="Plates/CSGCombiner3D" unique_id=472067854]
radius = 0.2
height = 0.03
sides = 16
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="Plates/CSGCombiner3D/CSGCylinder3D" unique_id=7092994]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.010312311, 0)
operation = 2
radius = 0.15
height = 0.03
sides = 16
[node name="CSGCylinder3D2" type="CSGCylinder3D" parent="Plates/CSGCombiner3D" unique_id=23957958]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.027119078, 0)
radius = 0.15
height = 0.02
[node name="CSGCombiner3D2" type="CSGCombiner3D" parent="Plates" unique_id=404631280]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.0762081, 0)
autosmooth = true
smoothing_angle = 103.9
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="Plates/CSGCombiner3D2" unique_id=943162425]
radius = 0.2
height = 0.03
sides = 16
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="Plates/CSGCombiner3D2/CSGCylinder3D" unique_id=218364524]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.010312311, 0)
operation = 2
radius = 0.15
height = 0.03
sides = 16
[node name="CSGCylinder3D2" type="CSGCylinder3D" parent="Plates/CSGCombiner3D2" unique_id=1548327331]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.027119078, 0)
radius = 0.15
height = 0.02
[node name="CSGCombiner3D3" type="CSGCombiner3D" parent="Plates" unique_id=1506211353]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.1214186, 0)
autosmooth = true
smoothing_angle = 103.9
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="Plates/CSGCombiner3D3" unique_id=739830577]
radius = 0.2
height = 0.03
sides = 16
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="Plates/CSGCombiner3D3/CSGCylinder3D" unique_id=1882120753]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.010312311, 0)
operation = 2
radius = 0.15
height = 0.03
sides = 16
[node name="CSGCylinder3D2" type="CSGCylinder3D" parent="Plates/CSGCombiner3D3" unique_id=1904629745]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.027119078, 0)
radius = 0.15
height = 0.02
+98
View File
@@ -0,0 +1,98 @@
[gd_scene format=3 uid="uid://cwnwo4i28upap"]
[ext_resource type="Script" uid="uid://0y6wnjcsum6" path="res://Stations/item_dispenser.gd" id="1_gkb3v"]
[ext_resource type="PackedScene" uid="uid://dpot5qie20vf6" path="res://Items/burger.tscn" id="2_mep2a"]
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="3_3xuvi"]
[ext_resource type="Texture2D" uid="uid://cexxfyw03hr81" path="res://Textures/1.png" id="4_1f5le"]
[ext_resource type="PackedScene" uid="uid://mpapt5mkbuao" path="res://Prefabs/slide_off_dome.tscn" id="5_mep2a"]
[sub_resource type="SphereShape3D" id="SphereShape3D_xmbo2"]
radius = 0.3
[sub_resource type="CylinderShape3D" id="CylinderShape3D_24d3s"]
radius = 0.3
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_di04w"]
albedo_texture = ExtResource("4_1f5le")
[node name="RawBurgerDispenser" type="StaticBody3D" unique_id=235630131]
script = ExtResource("1_gkb3v")
item_scene = ExtResource("2_mep2a")
[node name="XRToolsSnapZone" type="Area3D" parent="." unique_id=1523586273]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00070536137, 1.0645258, -0.002165556)
collision_layer = 65536
collision_mask = 65536
script = ExtResource("3_3xuvi")
snap_mode = 1
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
[node name="CollisionShape3D" type="CollisionShape3D" parent="XRToolsSnapZone" unique_id=2105824734]
shape = SubResource("SphereShape3D_xmbo2")
[node name="SlideOffDome" parent="." unique_id=1427609426 instance=ExtResource("5_mep2a")]
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=378049928]
shape = SubResource("CylinderShape3D_24d3s")
[node name="CSGCombiner3D" type="CSGCombiner3D" parent="." unique_id=1275577257]
[node name="CSGCylinder3D" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=1973748218]
radius = 0.3
sides = 32
[node name="CSGCylinder3D2" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=590219609]
transform = Transform3D(1, 0, 0, 0, 0.9532462, 0.30219492, 0, -0.30219492, 0.9532462, -0.1276815, 1.0521446, -0.052202225)
radius = 0.08300781
height = 0.028435059
sides = 16
material = SubResource("StandardMaterial3D_di04w")
[node name="CSGCylinder3D3" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=177377476]
transform = Transform3D(1, 0, 0, 0, 0.9694763, 0.245185, 0, -0.245185, 0.9694763, 0.08106685, 1.0391599, -0.119440794)
radius = 0.08300781
height = 0.03
sides = 16
material = SubResource("StandardMaterial3D_di04w")
[node name="CSGCylinder3D4" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=622291452]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.19005477, 1.0198405, 0.049397707)
radius = 0.08300781
height = 0.03
sides = 16
material = SubResource("StandardMaterial3D_di04w")
[node name="CSGCylinder3D5" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=703594207]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.026051283, 1.0175319, 0.0042250156)
radius = 0.08300781
height = 0.03
sides = 16
material = SubResource("StandardMaterial3D_di04w")
[node name="CSGCylinder3D6" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=955808722]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.05739355, 1.0197641, 0.13219571)
radius = 0.08300781
height = 0.03
sides = 16
material = SubResource("StandardMaterial3D_di04w")
[node name="CSGCylinder3D7" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=1066788957]
transform = Transform3D(0.9111114, 0.40515354, 0.075673, -0.41123694, 0.8813372, 0.2326565, 0.027568169, -0.24309555, 0.9696106, 0.14799988, 1.0345665, 0.11710405)
radius = 0.08300781
height = 0.03
sides = 16
material = SubResource("StandardMaterial3D_di04w")
[node name="CSGCylinder3D8" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=553053058]
transform = Transform3D(0.9541017, 0.29948288, 0, -0.29948288, 0.9541017, 0, 0, 0, 1, 0.041060925, 1.0337045, 0.18304396)
radius = 0.08300781
height = 0.03
sides = 16
material = SubResource("StandardMaterial3D_di04w")
[node name="CSGCylinder3D9" type="CSGCylinder3D" parent="CSGCombiner3D" unique_id=980376661]
transform = Transform3D(0.8510151, 0.22759955, 0.47325662, -0.16729629, 0.97174567, -0.16649997, -0.49778044, 0.06251989, 0.8650468, 0.2036674, 1.0335208, -0.024382353)
radius = 0.08300781
height = 0.03
sides = 16
material = SubResource("StandardMaterial3D_di04w")
+94
View File
@@ -0,0 +1,94 @@
extends StaticBody3D
const plate_wash_time: float = 3.0
@export_range(0.0, 10.0, 0.1) var wash_speed: float = 1.0
@onready var snap_zone: XRToolsSnapZone = $XRToolsSnapZone
@onready var progress_bar: ProgressBar3D = $ProgressBar3D
## Washing state. Both are replicated (see sink.tscn's Sync node) and refresh the
## display when they change. Only the world owner runs this station's _process
## and snap zone, so without this a client never updates its bar — it stayed
## frozen on screen long after the plate came out clean.
var time_washed: float = 0.0: set = _set_time_washed
var is_washing: bool = false: set = _set_is_washing
var plate: PlateController = null
func _set_time_washed(value: float) -> void:
if is_equal_approx(time_washed, value):
return
time_washed = value
_refresh_progress_bar()
func _set_is_washing(value: bool) -> void:
if is_washing == value:
return
is_washing = value
_refresh_progress_bar()
_set_effects_playing(is_washing)
# Water, bubbles and the animation follow the washing state on every peer, not
# just the one running the logic.
func _set_effects_playing(playing: bool) -> void:
var player := get_node_or_null("AnimationPlayer") as AnimationPlayer
if player:
player.play("working" if playing else "RESET")
for effect in ["water", "bubbles", "GPUParticles3D"]:
var node := get_node_or_null(effect) as Node3D
if node:
node.visible = playing
func _ready() -> void:
if not progress_bar or progress_bar is not ProgressBar3D:
push_error("Sink missing reference to progressbar, or wrong type:", progress_bar)
snap_zone.has_picked_up.connect(_on_object_picked_up)
snap_zone.has_dropped.connect(_on_object_dropped)
progress_bar.override_fill_color(Color.DODGER_BLUE)
_refresh_progress_bar()
func _refresh_progress_bar() -> void:
if not progress_bar:
return
progress_bar.set_progress(clampf(float(time_washed) / plate_wash_time, 0.0, 1.0))
progress_bar.set_bar_visible(is_washing)
func _on_object_picked_up(_item) -> void:
print("Sink: object picked up: ", _item)
plate = _item.get_node_or_null("PlateController") as PlateController
if plate:
# The setter starts the effects and shows the bar, here and on clients.
is_washing = plate.is_dirty
func _on_object_dropped() -> void:
print("Sink: object drop ")
_reset_sink()
func _reset_sink():
time_washed = 0
is_washing = false
plate = null
func complete_washing():
if not plate:
return
plate.is_dirty = false
_reset_sink()
print("Sink washing complete!")
func _process(delta: float) -> void:
if is_washing:
time_washed += wash_speed * delta
_refresh_progress_bar()
print("Sink washing plate: ", time_washed)
if time_washed >= plate_wash_time:
complete_washing()
+1
View File
@@ -0,0 +1 @@
uid://byh5j25mwt3oc

Some files were not shown because too many files have changed in this diff Show More