3 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
139 changed files with 3434 additions and 3282 deletions
+18 -20
View File
@@ -1,8 +1,6 @@
class_name ItemContainer
extends Node3D
const RECIPE_MANAGER = preload("res://scripts/recipe_Manager.gd")
@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] = []
@@ -29,8 +27,8 @@ func _ready() -> void:
# 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
if not NetworkManager.owns_world():
return
print("Container enabled: ", enabled)
if not enabled:
print("Container disabled in _on_body_entered body")
@@ -92,7 +90,7 @@ func _add_item(item: Node3D) -> void:
updated.append(food_node.id)
plate_controller.contained_ids = updated
item.queue_free()
NetworkManager.despawn_item(item)
func erase_item(item: FoodItem) -> void:
@@ -124,7 +122,7 @@ func refresh_visuals(ids: Array[String]) -> void:
var meal_idx := 0
var side_idx := 0
for id in ids:
var scene := RECIPE_MANAGER.get_item_scene(id)
var scene := RecipeManager.get_item_scene(id)
if not scene:
continue
var visual := scene.instantiate()
@@ -156,19 +154,22 @@ func refresh_visuals(ids: Array[String]) -> void:
visual.rotation = positions[idx].rotation
# Strip interactivity/networking from a display-only copy: it's not spawned
# through NetworkManager, so it must never try to sync (its NetPickable child,
# if any, would have no corresponding replicated identity on other peers) or
# be grabbable/collidable.
# 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 net_pickable := visual.get_node_or_null("NetPickable")
if net_pickable:
# Detach and free it outright rather than queue_free(): this runs before
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 _ready() (which starts syncing and logging)
# before the queued deletion lands at the end of the frame.
visual.remove_child(net_pickable)
net_pickable.free()
# 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
@@ -195,9 +196,6 @@ func _make_cosmetic(visual: Node3D) -> void:
func _remove_from_physics(visual: Node3D) -> void:
if visual is RigidBody3D:
PhysicsServer3D.body_set_space((visual as RigidBody3D).get_rid(), RID())
var despawning_item = visual.get_node_or_null("DespawningItem")
if despawning_item:
despawning_item.queue_free()
#plate (Pickalbe)
+1 -1
View File
@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://du31pqeytu8as"]
[ext_resource type="Script" uid="uid://6lyhyial1fh5" path="res://containers/container.gd" id="1_r4cle"]
[ext_resource type="Script" uid="uid://6lyhyial1fh5" path="res://Containers/container.gd" id="1_r4cle"]
[sub_resource type="SphereShape3D" id="SphereShape3D_vlqg6"]
radius = 0.3
+2 -23
View File
@@ -1,14 +1,13 @@
[gd_scene format=3 uid="uid://bp3v1jl8pctro"]
[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://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"]
[ext_resource type="PackedScene" uid="uid://ctw7nbntd5pcj" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_right.tscn" id="5_vlcpl"]
[ext_resource type="Animation" uid="uid://d1xnpyc08njjx" path="res://addons/godot-xr-tools/hands/animations/right/Grip 4.res" id="6_el51w"]
[ext_resource type="Script" uid="uid://bwd0pe2udb5xo" path="res://Net/net_pickable.gd" id="20_netpk"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_kek77"]
height = 0.0635376
@@ -27,23 +26,6 @@ metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_vlqg6"]
albedo_color = Color(0.36656043, 0.16690676, 0.12531222, 1)
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_np_plate"]
properties/0/path = NodePath(".:position")
properties/0/spawn = false
properties/0/replication_mode = 1
properties/1/path = NodePath(".:quaternion")
properties/1/spawn = false
properties/1/replication_mode = 1
properties/2/path = NodePath("NetPickable:net_held_by")
properties/2/spawn = true
properties/2/replication_mode = 1
properties/3/path = NodePath("PlateController:contained_ids")
properties/3/spawn = true
properties/3/replication_mode = 1
properties/4/path = NodePath("PlateController:is_dirty")
properties/4/spawn = true
properties/4/replication_mode = 1
[node name="Plate" type="RigidBody3D" unique_id=190487773]
collision_layer = 4
collision_mask = 196615
@@ -153,6 +135,3 @@ polygon = PackedVector2Array(-0.053057775, 0.2586278, 0.09469998, 0.40791017, 0.
depth = 0.02
material = SubResource("StandardMaterial3D_vlqg6")
[node name="NetPickable" type="MultiplayerSynchronizer" parent="." unique_id=1770751620]
replication_config = SubResource("SceneReplicationConfig_np_plate")
script = ExtResource("20_netpk")
+5 -5
View File
@@ -30,11 +30,11 @@ func _process(_delta: float) -> void:
func _set_contained_ids(value: Array[String]) -> void:
# Only rebuild when the contents actually changed. This property is
# replicated in ALWAYS mode, so the synchronizer assigns it every network
# tick on every peer that doesn't own the plate — and refresh_visuals()
# frees and re-instantiates a scene per item each time. That was thousands
# of throwaway nodes per run (and a log line from each one's NetPickable).
# 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
@@ -6,10 +6,9 @@
[ext_resource type="Script" uid="uid://dvobm6vcfnqe8" path="res://addons/godot-xr-tools/hands/poses/hand_pose_settings.gd" id="4_wb51u"]
[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="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"]
[ext_resource type="Script" uid="uid://bwd0pe2udb5xo" path="res://Net/net_pickable.gd" id="20_netpk"]
[ext_resource type="PackedScene" uid="uid://3lr2dhy62rhk" path="res://Prefabs/combinable_item.tscn" id="7_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
@@ -28,17 +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="SceneReplicationConfig" id="SceneReplicationConfig_np_buns"]
properties/0/path = NodePath(".:position")
properties/0/spawn = false
properties/0/replication_mode = 1
properties/1/path = NodePath(".:quaternion")
properties/1/spawn = false
properties/1/replication_mode = 1
properties/2/path = NodePath("NetPickable:net_held_by")
properties/2/spawn = true
properties/2/replication_mode = 1
[node name="BurgerBuns" unique_id=1088240294 instance=ExtResource("1_g1t48")]
[node name="CollisionShape3D" parent="." index="0"]
@@ -86,8 +74,4 @@ type = 2
[node name="CombinableItem" parent="." index="5" unique_id=996936271 instance=ExtResource("7_wb51u")]
[node name="NetPickable" type="MultiplayerSynchronizer" parent="." index="6" unique_id=2086885420]
replication_config = SubResource("SceneReplicationConfig_np_buns")
script = ExtResource("20_netpk")
[node name="DespawningItem" parent="." index="7" unique_id=303090111 instance=ExtResource("10_46e7r")]
+3 -19
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="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"]
[ext_resource type="Script" uid="uid://bwd0pe2udb5xo" path="res://Net/net_pickable.gd" id="20_netpk"]
[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"]
height = 0.1
@@ -34,17 +33,6 @@ script = ExtResource("4_mgacb")
closed_pose = ExtResource("6_cp3eg")
metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_np_charcoal"]
properties/0/path = NodePath(".:position")
properties/0/spawn = false
properties/0/replication_mode = 1
properties/1/path = NodePath(".:quaternion")
properties/1/spawn = false
properties/1/replication_mode = 1
properties/2/path = NodePath("NetPickable:net_held_by")
properties/2/spawn = true
properties/2/replication_mode = 1
[node name="PickableObject" unique_id=1675596942 instance=ExtResource("1_r73y2")]
[node name="CollisionShape3D" parent="." index="0"]
@@ -67,8 +55,4 @@ type = 2
[node name="CombinableItem" parent="." index="5" unique_id=996936271 instance=ExtResource("8_wmrff")]
[node name="NetPickable" type="MultiplayerSynchronizer" parent="." index="6" unique_id=1070495412]
replication_config = SubResource("SceneReplicationConfig_np_charcoal")
script = ExtResource("20_netpk")
[node name="DespawningItem" parent="." index="7" unique_id=303090111 instance=ExtResource("10_6ypk4")]
+3 -19
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="4_hc3f7"]
[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://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"]
[ext_resource type="Script" uid="uid://bwd0pe2udb5xo" path="res://Net/net_pickable.gd" id="20_netpk"]
[ext_resource type="PackedScene" uid="uid://3lr2dhy62rhk" path="res://Prefabs/combinable_item.tscn" id="7_bdp75"]
[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"]
size = Vector3(0.1, 0.1, 0.1)
@@ -31,17 +30,6 @@ script = ExtResource("4_hc3f7")
closed_pose = ExtResource("6_bdp75")
metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_np_cube"]
properties/0/path = NodePath(".:position")
properties/0/spawn = false
properties/0/replication_mode = 1
properties/1/path = NodePath(".:quaternion")
properties/1/spawn = false
properties/1/replication_mode = 1
properties/2/path = NodePath("NetPickable:net_held_by")
properties/2/spawn = true
properties/2/replication_mode = 1
[node name="PickableObject" unique_id=1675596942 groups=["platalbe_item"] instance=ExtResource("1_dbtw8")]
[node name="CollisionShape3D" parent="." index="0"]
@@ -64,8 +52,4 @@ type = 1
[node name="CombinableItem" parent="." index="5" unique_id=996936271 instance=ExtResource("7_bdp75")]
[node name="NetPickable" type="MultiplayerSynchronizer" parent="." index="6" unique_id=1858332513]
replication_config = SubResource("SceneReplicationConfig_np_cube")
script = ExtResource("20_netpk")
[node name="DespawningItem" parent="." index="7" unique_id=303090111 instance=ExtResource("10_uygc5")]
+3 -19
View File
@@ -1,15 +1,14 @@
[gd_scene format=3 uid="uid://dpot5qie20vf6"]
[ext_resource type="PackedScene" uid="uid://c8l60rnugru40" path="res://addons/godot-xr-tools/objects/pickable.tscn" id="1_fco8w"]
[ext_resource type="Texture2D" uid="uid://cexxfyw03hr81" path="res://textures/1.png" id="2_r8jvx"]
[ext_resource type="Texture2D" uid="uid://cexxfyw03hr81" path="res://Textures/1.png" id="2_r8jvx"]
[ext_resource type="PackedScene" uid="uid://c25yxb0vt53vc" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_left.tscn" id="3_qixic"]
[ext_resource type="Animation" uid="uid://db62hs5s4n2b3" path="res://addons/godot-xr-tools/hands/animations/left/Grip 4.res" id="4_bw8vh"]
[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://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"]
[ext_resource type="Script" uid="uid://bwd0pe2udb5xo" path="res://Net/net_pickable.gd" id="20_netpk"]
[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
@@ -28,17 +27,6 @@ script = ExtResource("5_w8sii")
closed_pose = ExtResource("7_wqxjj")
metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_np_burger"]
properties/0/path = NodePath(".:position")
properties/0/spawn = false
properties/0/replication_mode = 1
properties/1/path = NodePath(".:quaternion")
properties/1/spawn = false
properties/1/replication_mode = 1
properties/2/path = NodePath("NetPickable:net_held_by")
properties/2/spawn = true
properties/2/replication_mode = 1
[node name="raw_burger" unique_id=1675596942 instance=ExtResource("1_fco8w")]
[node name="CollisionShape3D" parent="." index="0"]
@@ -63,8 +51,4 @@ hand_pose = SubResource("Resource_qyiot")
id = "raw_burger"
type = 2
[node name="NetPickable" type="MultiplayerSynchronizer" parent="." index="5" unique_id=1382968688]
replication_config = SubResource("SceneReplicationConfig_np_burger")
script = ExtResource("20_netpk")
[node name="DespawningItem" parent="." index="6" unique_id=303090111 instance=ExtResource("10_l4hsd")]
+3 -19
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://bfj80jh13t6e5" path="res://prefabs/food_item.tscn" id="10_zz42p"]
[ext_resource type="Script" uid="uid://bwd0pe2udb5xo" path="res://Net/net_pickable.gd" id="20_netpk"]
[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://bfj80jh13t6e5" path="res://Prefabs/food_item.tscn" id="10_zz42p"]
[sub_resource type="CylinderShape3D" id="CylinderShape3D_fco8w"]
height = 0.04777527
@@ -28,17 +27,6 @@ script = ExtResource("5_ychvb")
closed_pose = ExtResource("7_rl64h")
metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_np_cookedburger"]
properties/0/path = NodePath(".:position")
properties/0/spawn = false
properties/0/replication_mode = 1
properties/1/path = NodePath(".:quaternion")
properties/1/spawn = false
properties/1/replication_mode = 1
properties/2/path = NodePath("NetPickable:net_held_by")
properties/2/spawn = true
properties/2/replication_mode = 1
[node name="CookedBurger" unique_id=1675596942 instance=ExtResource("1_ut7mg")]
[node name="CollisionShape3D" parent="." index="0"]
@@ -65,8 +53,4 @@ type = 2
[node name="CombinableItem" parent="." index="5" unique_id=996936271 instance=ExtResource("10_ut7mg")]
[node name="NetPickable" type="MultiplayerSynchronizer" parent="." index="6" unique_id=925955029]
replication_config = SubResource("SceneReplicationConfig_np_cookedburger")
script = ExtResource("20_netpk")
[node name="DespawningItem" parent="." index="7" unique_id=303090111 instance=ExtResource("10_6p8pj")]
+17 -33
View File
@@ -1,27 +1,26 @@
[gd_scene format=3 uid="uid://b3m2ag8g5rj4r"]
[ext_resource type="PackedScene" uid="uid://c8l60rnugru40" path="res://addons/godot-xr-tools/objects/pickable.tscn" id="1_gu23e"]
[ext_resource type="PackedScene" uid="uid://c25yxb0vt53vc" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_left.tscn" id="2_l78s7"]
[ext_resource type="Animation" uid="uid://db62hs5s4n2b3" path="res://addons/godot-xr-tools/hands/animations/left/Grip 4.res" id="3_d4y38"]
[ext_resource type="Script" uid="uid://dvobm6vcfnqe8" path="res://addons/godot-xr-tools/hands/poses/hand_pose_settings.gd" id="4_bejy7"]
[ext_resource type="PackedScene" uid="uid://ctw7nbntd5pcj" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_right.tscn" id="5_cu6ps"]
[ext_resource type="Animation" uid="uid://d1xnpyc08njjx" path="res://addons/godot-xr-tools/hands/animations/right/Grip 4.res" id="6_jq7iw"]
[ext_resource type="PackedScene" uid="uid://bfj80jh13t6e5" path="res://prefabs/food_item.tscn" id="7_fn8yh"]
[ext_resource type="Script" uid="uid://bwd0pe2udb5xo" path="res://Net/net_pickable.gd" id="8_f6bya"]
[ext_resource type="PackedScene" uid="uid://b5ukku8i0hilb" path="res://prefabs/despawning_item.tscn" id="9_4uadj"]
[ext_resource type="PackedScene" uid="uid://c8l60rnugru40" path="res://addons/godot-xr-tools/objects/pickable.tscn" id="1_3gf3l"]
[ext_resource type="PackedScene" uid="uid://c25yxb0vt53vc" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_left.tscn" id="2_0mkco"]
[ext_resource type="Animation" uid="uid://db62hs5s4n2b3" path="res://addons/godot-xr-tools/hands/animations/left/Grip 4.res" id="3_6tnvi"]
[ext_resource type="Script" uid="uid://dvobm6vcfnqe8" path="res://addons/godot-xr-tools/hands/poses/hand_pose_settings.gd" id="4_cljtj"]
[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
radius = 0.096191406
[sub_resource type="Resource" id="Resource_lc22d"]
script = ExtResource("4_bejy7")
closed_pose = ExtResource("3_d4y38")
script = ExtResource("4_cljtj")
closed_pose = ExtResource("3_6tnvi")
metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[sub_resource type="Resource" id="Resource_qyiot"]
script = ExtResource("4_bejy7")
closed_pose = ExtResource("6_jq7iw")
script = ExtResource("4_cljtj")
closed_pose = ExtResource("6_fh0f6")
metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_3gf3l"]
@@ -30,29 +29,18 @@ albedo_color = Color(0.6784191, 0.54546416, 0.016760282, 1)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_6l01i"]
albedo_color = Color(0.29, 0.101500005, 0, 1)
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_np_hamburger"]
properties/0/path = NodePath(".:position")
properties/0/spawn = false
properties/0/replication_mode = 1
properties/1/path = NodePath(".:quaternion")
properties/1/spawn = false
properties/1/replication_mode = 1
properties/2/path = NodePath("NetPickable:net_held_by")
properties/2/spawn = true
properties/2/replication_mode = 1
[node name="Hamburger" unique_id=1675596942 groups=["platalbe_item"] instance=ExtResource("1_gu23e")]
[node name="Hamburger" unique_id=1675596942 groups=["platalbe_item"] instance=ExtResource("1_3gf3l")]
gravity_scale = 0.04
[node name="CollisionShape3D" parent="." index="0"]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.02, 0.02, 0)
shape = SubResource("CylinderShape3D_fco8w")
[node name="GrabPointHandLeft" parent="." index="1" unique_id=1571481674 instance=ExtResource("2_l78s7")]
[node name="GrabPointHandLeft" parent="." index="1" unique_id=1571481674 instance=ExtResource("2_0mkco")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.067650706, 0.04601878, -0.08606844)
hand_pose = SubResource("Resource_lc22d")
[node name="GrabPointHandRight" parent="." index="2" unique_id=514404634 instance=ExtResource("5_cu6ps")]
[node name="GrabPointHandRight" parent="." index="2" unique_id=514404634 instance=ExtResource("5_dunns")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06531982, 0.042291984, -0.08604182)
hand_pose = SubResource("Resource_qyiot")
@@ -90,13 +78,9 @@ height = 0.03
sides = 16
material = SubResource("StandardMaterial3D_6l01i")
[node name="FoodItem" parent="." index="5" unique_id=63948206 instance=ExtResource("7_fn8yh")]
[node name="FoodItem" parent="." index="5" unique_id=63948206 instance=ExtResource("7_yy3y8")]
id = "hamburger"
type = 0
sell_value = 4
[node name="NetPickable" type="MultiplayerSynchronizer" parent="." index="6" unique_id=56164120]
replication_config = SubResource("SceneReplicationConfig_np_hamburger")
script = ExtResource("8_f6bya")
[node name="DespawningItem" parent="." index="7" unique_id=303090111 instance=ExtResource("9_4uadj")]
[node name="DespawningItem" parent="." index="7" unique_id=303090111 instance=ExtResource("9_ej8jm")]
-149
View File
@@ -1,149 +0,0 @@
extends Node3D
## World script for the multiplayer scene. Consumes the host/join request set
## by the main menu, spawns the world's stations/items on whichever machine
## owns the world (server, or the local player when offline), spawns/despawns
## a player avatar per connected peer, and returns to the menu if the session
## ends.
##
## The world's actual content (stations, items) is NOT baked into this scene —
## it's spawned at runtime from Net/world_layout.gd via NetworkManager, so a
## joining client receives it from the server (MultiplayerSpawner replays
## existing spawns to late joiners) instead of relying on its own local copy
## matching.
const PLAYER_SCENE := preload("res://Player/net_player.tscn")
## Whether to spawn the full WorldLayout on the machine that owns the world.
## The real game scene wants this; focused debug scenes (test/) bake their own
## handful of stations and items instead and turn it off, so the thing under
## test isn't sharing the world with a second copy of the whole kitchen.
@export var populate_from_layout: bool = true
var xr_interface: XRInterface
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
NetworkManager.register_world(self, $PlayersSpawner, $ItemsSpawner)
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 cmdline
# equivalent). Populating before this point is wrong for EVERY case, not
# just offline: is_online() is still false until host()/join() runs, so
# owns_world() would read true for a joining client too, and it would
# build its own local copy instead of receiving the server's via the
# spawner. host() emits session_started synchronously, which populates
# via _on_session_started below; the explicit call after world_ready()
# only matters for the case where neither host() nor join() ran (no
# pending session, no cmdline args) — running this scene directly offline.
NetworkManager.world_ready()
_populate_world_if_owner()
get_tree().create_timer(3.0).timeout.connect(_log_world_state)
# Temporary-ish sanity check: confirms WorldContent actually ended up
# populated on this peer (whether by spawning it or by receiving it via
# replication), so a silent replication failure shows up in the net log
# instead of just an empty-looking world.
func _log_world_state() -> void:
NetworkManager.log_line("World state: WorldContent=%d children, Players=%d children" % [$WorldContent.get_child_count(), $Players.get_child_count()])
func _exit_tree() -> void:
NetworkManager.unregister_world()
func _on_session_started(_is_server: bool) -> void:
NetworkManager.gate_existing_stations()
_populate_world_if_owner()
## Spawns the world's stations/items exactly once, on the machine that owns
## world logic (server or offline). Safe to call multiple times/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
# needs to be an instance sitting in that tree — its methods can't be called
# on the class itself.
var layout := WorldLayout.new()
add_child(layout)
var authored := layout.get_station_nodes()
authored.append_array(layout.get_item_nodes())
# The stations and items authored into the scene file are a *template*, not
# the live world. Only the server turns them into real objects, spawned
# through NetworkManager so they replicate. Every peer therefore drops its
# own 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 stations := layout.get_stations()
var items := layout.get_items()
layout.queue_free()
_remove_authored(authored)
NetworkManager.log_line("Populating world: %d stations, %d items" % [stations.size(), items.size()])
for d in stations:
NetworkManager.spawn_item(d["scene"], d["xform"], d["name"], d["props"])
for d in items:
NetworkManager.spawn_item(d["scene"], d["xform"], d["name"], d["props"])
NetworkManager.log_line("World populated")
# Free the authored template nodes. Done immediately rather than with
# queue_free() 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) materialises player
## avatars; MultiplayerSpawner replicates the result to everyone else,
## including late joiners.
func _on_player_joined(peer_id: int) -> void:
if not NetworkManager.owns_world() or $Players.has_node(str(peer_id)):
return
var p := PLAYER_SCENE.instantiate()
p.name = str(peer_id)
$Players.add_child(p, true)
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")
-559
View File
@@ -1,559 +0,0 @@
extends Node
## Client-server session manager for VRyHungry (listen-server model).
##
## Registered as the "NetworkManager" autoload. Owns transport (ENet), tracks
## the session, and is the single place that reassigns multiplayer authority
## (only the server does so). The world scene (main.gd) registers its spawners
## here via [method register_world]; higher layers (players, items, stations)
## build on top of this in later phases.
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 player.
signal player_joined(peer_id: int)
signal player_left(peer_id: int)
signal session_started(is_server: bool)
signal session_ended()
signal connection_failed()
# World hooks, registered by main.gd once the scene tree exists.
var _world: Node = null
var _players_spawner: MultiplayerSpawner = null
var _items_spawner: MultiplayerSpawner = null
var _content_root: Node = null
var _log_file: FileAccess
## Reason the session ended, shown by the menu on the next _ready() (see
## take_status). Avoids depending on a live signal connection to a panel that
## doesn't 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)
# --- Public API ------------------------------------------------------------
## Start hosting. The host is peer 1 and also plays (listen server).
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)
# The host's own local player joins immediately.
_on_player_present(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), so is_multiplayer_authority()/get_unique_id() keep working while we are
# back in single-player / menu state.
func _go_offline() -> void:
if multiplayer.multiplayer_peer:
multiplayer.multiplayer_peer.close()
multiplayer.multiplayer_peer = OfflineMultiplayerPeer.new()
unregister_world()
# --- Item spawning ---------------------------------------------------------
## Spawn a networked item. Server-only when online (replicates to all peers via
## the ItemsSpawner, including late joiners); works directly when offline.
## node_name gives the spawned node a deterministic, identical name on every
## peer (needed for NodePath-based RPCs to resolve it); props are applied to
## the instance before it enters the tree, so exported vars land correctly.
## Returns the new node on the machine that owns spawning, else null.
func spawn_item(scene_path: String, xform: Transform3D, node_name: String = "", props: Dictionary = {}) -> Node:
if is_online() and not is_server():
return null
var data := {"scene": scene_path, "xform": xform, "name": node_name, "props": props}
var via := "spawner" if (is_online() and _items_spawner) else "offline"
log_line("spawn_item: %s (name=%s, via=%s)" % [scene_path.get_file(), node_name, via])
if is_online() and _items_spawner:
return _items_spawner.spawn(data)
# Offline: instantiate directly under the registered content root, or (for
# scenes that never call register_world, e.g. the offline menu/dev scenes)
# the current scene, so this keeps working without every offline scene
# needing to opt in.
var inst := _spawn_item_from_data(data)
if inst:
var parent: Node = _content_root if _content_root else get_tree().current_scene
if parent:
parent.add_child(inst)
return inst
## Despawn a server-spawned item. MultiplayerSpawner broadcasts a despawn to
## every peer when a tracked node exits the tree on the authority, so this is
## the single seam for destroying spawned items (works offline too).
func despawn_item(node: Node) -> void:
if not owns_world() or not is_instance_valid(node):
return
log_line("despawn_item: %s" % node.name)
# Items that came from the ItemsSpawner are despawned on every peer
# automatically when they leave the tree here. Items baked into a scene file
# are unknown to the spawner, so their removal has to be broadcast
# explicitly — otherwise every client keeps a ghost copy of an item the
# server has consumed, which then blocks the station it was sitting in and
# gets grabbed instead of the real item that replaced it.
if is_online() and not _is_spawner_tracked(node):
_despawn_static_item.rpc(node.get_path())
node.queue_free()
# Items the ItemsSpawner replicates live under its spawn path; anything else was
# baked into the scene file and the spawner knows nothing about it.
func _is_spawner_tracked(node: Node) -> bool:
return _content_root != null and _content_root.is_ancestor_of(node)
@rpc("authority", "call_remote", "reliable")
func _despawn_static_item(path: NodePath) -> void:
var node := get_node_or_null(path)
if node:
log_line("despawn_static_item: freeing %s (the server consumed it)" % node.name)
node.queue_free()
# MultiplayerSpawner custom spawn function: runs on every peer to build the node
# from the replicated payload.
func _spawn_item_from_data(data: Variant) -> Node:
var scene: PackedScene = load(data["scene"])
if not scene:
push_error("spawn_item: could not load scene %s" % str(data.get("scene")))
return null
var inst := scene.instantiate()
if inst is Node3D:
inst.transform = data["xform"]
if data.get("name", "") != "":
inst.name = data["name"]
for key in data.get("props", {}):
inst.set(key, data["props"][key])
if not owns_world():
_gate_station(inst)
return inst
# Stations run their own logic and auto-grab (XRToolsSnapZone with
# snap_mode=RANGE) identically on every peer by default, which would let each
# peer independently grab/simulate the same shared object. Disable both on
# every peer except the one that owns world logic; the server-authoritative
# item-authority RPCs are what let clients still grab a server-held item by
# hand. Runs before the node enters the tree, so its own _ready() sees the
# final (disabled) state.
func _gate_station(node: Node) -> void:
if not (node is StaticBody3D):
return
for child in node.get_children():
if child is XRToolsSnapZone:
child.enabled = false
child.set_process(false)
node.set_process(false)
log_line("gated station (non-owner peer): %s" % node.name)
## Gate every station already sitting in the scene tree, for peers that don't
## own world logic. Stations that arrive through spawn_item() are gated as they
## are built (see _spawn_item_from_data), but ones baked into a scene file never
## pass through there — leaving a client running its own snap zones, which then
## grab items straight out of the local hand and fight the server's
## authoritative placement. Idempotent, so it's safe on every session start.
func gate_existing_stations() -> void:
if owns_world():
return
for station in get_tree().get_nodes_in_group("station"):
_gate_station(station)
# --- Item grab-authority transfer -----------------------------------------
## Called by NetPickable when this peer grabs an item by hand. Godot rejects
## rpc_id() targeting your own peer id ("RPC on yourself is not allowed"), so
## when we ARE the server this runs the logic directly instead of round-
## tripping an RPC to ourselves — otherwise every host-side grab/drop was
## silently failing to run its server-side half (no denial checks, and
## crucially no auto-snap-into-station on release).
func request_item_authority_from(item_path: NodePath) -> void:
if is_server():
_grant_or_reject_item_authority(item_path, multiplayer.get_unique_id())
else:
_request_item_authority_rpc.rpc_id(1, item_path)
@rpc("any_peer", "reliable")
func _request_item_authority_rpc(item_path: NodePath) -> void:
if not is_server():
return
_grant_or_reject_item_authority(item_path, multiplayer.get_remote_sender_id())
## Runs on the server (called directly if the requester IS the server, or via
## the RPC above otherwise). If the item was snapped into a station, the
## station releases it so the grabber cleanly takes ownership.
func _grant_or_reject_item_authority(item_path: NodePath, sender: int) -> void:
var item := get_node_or_null(item_path)
if item:
var np := item.get_node_or_null("NetPickable")
if np and np.net_held_by != 0 and np.net_held_by != sender:
# Already legitimately held by a different live peer: reject the
# requester's optimistic client-side grab instead of stealing it.
log_line("request_item_authority: DENIED %s to peer %d (already held by %d)" % [item.name, sender, np.net_held_by])
_force_release_item_to(sender, item_path)
return
log_line("request_item_authority: granting %s to peer %d" % [str(item.name) if item else str(item_path), sender])
# Assign authority + held state first (disables the item on the server so its
# snap zone won't re-grab it), then release it from any station.
_set_item_authority.rpc(item_path, sender)
if item:
_release_from_snap_zones(item)
## Called by NetPickable when this peer releases an item, forwarding its throw
## velocity so the server can resume simulating it. Same self-RPC issue as
## above: runs directly if we're the server.
func release_item_authority_from(item_path: NodePath, lin: Vector3, ang: Vector3, xform: Transform3D) -> void:
if is_server():
_do_release_item_authority(item_path, lin, ang, xform, multiplayer.get_unique_id())
else:
_release_item_authority_rpc.rpc_id(1, item_path, lin, ang, xform)
@rpc("any_peer", "reliable")
func _release_item_authority_rpc(item_path: NodePath, lin: Vector3, ang: Vector3, xform: Transform3D) -> void:
if not is_server():
return
_do_release_item_authority(item_path, lin, ang, xform, multiplayer.get_remote_sender_id())
## Runs on the server. If released next to a station, the server snaps it in
## (server-authoritative placement).
func _do_release_item_authority(item_path: NodePath, lin: Vector3, ang: Vector3, xform: Transform3D, sender: int) -> void:
log_line("release_item_authority: %s released by peer %d" % [str(item_path), sender])
_set_item_authority.rpc(item_path, 1)
var item := get_node_or_null(item_path)
if item is RigidBody3D:
# Adopt the releasing peer's own final transform rather than trusting our
# copy's. That peer was the item's authority right up to this moment, and
# its position updates travel on the synchronizer's separate, unordered
# channel — this reliable RPC routinely overtakes them, leaving our copy
# still sitting where the item was BEFORE the peer carried it away. The
# snap decision below then reads that stale position and teleports the
# item straight back into the station it was just picked up from.
item.global_transform = xform
item.freeze = false
item.linear_velocity = lin
item.angular_velocity = ang
_try_snap_into_station.call_deferred(item)
# All station snap zones in the world (every XRToolsSnapZone child of a node in
# the "station" group — some stations, e.g. Table, have more than one).
func _station_snap_zones() -> Array:
var zones := []
for station in get_tree().get_nodes_in_group("station"):
for child in station.get_children():
if child is XRToolsSnapZone:
zones.append(child)
return zones
# If the item is snapped into any station, drop it from that station.
func _release_from_snap_zones(item: Node) -> void:
for zone in _station_snap_zones():
if zone.picked_up_object == item:
log_line("releasing %s from %s's snap zone (authority just granted elsewhere)" % [item.name, zone.get_parent().name])
zone.drop_object()
# Make the zone forget the item as well. These zones are snap_mode=RANGE,
# so every frame they re-grab anything still listed in their grab area
# that can be picked up — and Jolt does not emit body_exited when let_go()
# switches the item's collision layer back out of the zone's mask, so the
# entry goes stale and never clears. The station then snatches the item
# straight back off the player who just took it, teleporting it home.
# Bringing it near again re-adds it properly (a held item is on the layer
# the zone watches), and releasing next to a station is handled
# explicitly by _try_snap_into_station.
if zone._object_in_grab_area.has(item):
zone._object_in_grab_area.erase(item)
# Snap the item into the nearest empty station snap zone within grab range.
#
# Called deferred from _do_release_item_authority: XRToolsFunctionPickup's own
# "grab an item out of a snap zone" path calls zone.drop_object() BEFORE it
# calls pick_up() on the hand's behalf. drop_object()'s let_go() synchronously
# fires the pickable's `dropped` signal, which (via NetPickable) lands here —
# if this ran synchronously it would immediately re-snap the item into the
# very same zone it's still physically inside, stealing it away before the
# hand's own pick_up() call (later in the same call stack) ever runs. That
# leaves XRToolsFunctionPickup.picked_up_object pointing at an item whose
# _grab_driver actually belongs to the zone — a stale reference that crashes
# (null _grab_driver) the next time a controller button is pressed. Deferring
# lets the hand's pick_up() go first; the is_picked_up() check below is a
# second guard in case the item gets grabbed for real before this runs.
func _try_snap_into_station(item: Node) -> void:
if not (item is Node3D):
return
if item.has_method("is_picked_up") and item.is_picked_up():
var by: Node = null
if item.has_method("get_picked_up_by"):
by = item.get_picked_up_by()
log_line("skipped snapping %s: already held by %s (grab-race guard)" % [item.name, by.get_path() if by else "?"])
return
for zone in _station_snap_zones():
if is_instance_valid(zone.picked_up_object):
continue
if zone.global_position.distance_to(item.global_position) <= zone.grab_distance:
log_line("snapped %s into %s" % [item.name, zone.get_parent().name])
zone.pick_up_object(item)
return
log_line("no station in range to snap %s into (or none empty)" % item.name)
# Server broadcasts an authority assignment so every peer agrees on who owns the
# item (set_multiplayer_authority is a local call and must run everywhere).
@rpc("authority", "call_local", "reliable")
func _set_item_authority(item_path: NodePath, peer: int) -> void:
var item := get_node_or_null(item_path)
if not item:
return
log_line("_set_item_authority: %s -> peer %d" % [item.name, peer])
item.set_multiplayer_authority(peer) # recursive: item + synchronizer + NetPickable
var np := item.get_node_or_null("NetPickable")
if np:
np.net_held_by = 0 if peer == 1 else peer
np.apply_held_state()
## Rejects peer's optimistic grab (the item was already legitimately held by
## someone else). Same self-RPC concern: if the rejected peer is the server
## itself, apply it directly rather than rpc_id-ing ourselves.
func _force_release_item_to(peer: int, item_path: NodePath) -> void:
if peer == 1:
_do_force_release(item_path)
else:
force_release_item.rpc_id(peer, item_path)
@rpc("authority", "reliable")
func force_release_item(item_path: NodePath) -> void:
_do_force_release(item_path)
func _do_force_release(item_path: NodePath) -> void:
log_line("force_release_item: dropping %s (server rejected our grab)" % str(item_path))
var item := get_node_or_null(item_path)
if item and item.has_method("drop"):
item.drop()
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 should
## only run where this is true, so state has one source of truth.
func owns_world() -> bool:
return not is_online() or is_server()
# --- Station work-progress seam -------------------------------------------
## Reusable entry point for a client to contribute work to a station (e.g. a
## future chopping/gesture station). The client detects the gesture locally and
## calls this; the server validates and accumulates. Timer-driven stations like
## the Hob don't need it, but it is the drop-in seam for input-driven ones.
@rpc("any_peer", "reliable")
func submit_work(station_path: NodePath, amount: float) -> void:
if not is_server():
return
var station := get_node_or_null(station_path)
if station and station.has_method("add_work"):
log_line("submit_work: peer %d contributed %.2f to %s" % [multiplayer.get_remote_sender_id(), amount, station.name])
station.add_work(multiplayer.get_remote_sender_id(), amount)
## Called by the world scene once it's ready, passing its spawners. Must run
## before world_ready()/host()/join() on every peer so the custom spawn
## function is installed before any spawn packet can arrive.
func register_world(world: Node, players_spawner: MultiplayerSpawner, items_spawner: MultiplayerSpawner) -> void:
_world = world
_players_spawner = players_spawner
_items_spawner = items_spawner
_content_root = items_spawner.get_node(items_spawner.spawn_path) if items_spawner else world
if _items_spawner:
_items_spawner.spawn_function = _spawn_item_from_data
log_line("World registered (players_spawner=%s items_spawner=%s)" % [str(players_spawner != null), str(items_spawner != null)])
## Called when the world scene goes away (disconnect, leaving the session) so
## the autoload doesn't hold stale/freed references across a scene reload.
func unregister_world() -> void:
_world = null
_content_root = null
_players_spawner = null
_items_spawner = null
## 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 doesn't exist yet when the session ends.
func take_status() -> String:
var s := last_status
last_status = ""
return s
## Called by main.gd after it has registered the world and connected its
## player_joined/left listeners. Kicks off any menu- or command-line-driven
## session so that session signals never fire before the world is listening.
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's world is ready to listen for session
# signals (avoids a race between change_scene_to_file and 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()
# --- Session signal handlers ----------------------------------------------
func _on_peer_connected(peer_id: int) -> void:
log_line("peer_connected: %d" % peer_id)
# Only the server reacts by materialising that peer's player.
if is_server():
_on_player_present(peer_id)
func _on_peer_disconnected(peer_id: int) -> void:
log_line("peer_disconnected: %d" % peer_id)
if is_server():
_on_player_absent(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()
# Player materialise/dematerialise. Phase 2 wires these to the PlayersSpawner;
# for now they announce presence so the transport layer is independently testable.
func _on_player_present(peer_id: int) -> void:
log_line("player_present: %d" % peer_id)
player_joined.emit(peer_id)
func _on_player_absent(peer_id: int) -> void:
log_line("player_absent: %d" % peer_id)
player_left.emit(peer_id)
# --- 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()
+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
-209
View File
@@ -1,209 +0,0 @@
extends MultiplayerSynchronizer
#
### Networked sync component for a pickable item. Added as a child literally
### named "NetPickable" (network_manager.gd's authority RPCs already expect
### this) of every net-synced pickable, replicating its transform and held
### state. Only the current multiplayer authority (the server while loose, or
### whichever peer is holding it) actually simulates physics for the item;
### every other peer freezes their local copy and just follows the synced
### transform.
#
### 0 = loose/server-simulated; otherwise the peer id currently holding it.
### Replicated at spawn and on change so a late joiner sees the current holder.
#var net_held_by: int = 0: set = _set_net_held_by
#
#var _pickable: XRToolsPickable
#
## This item's own baked freeze_mode (e.g. plate.tscn bakes KINEMATIC, not the
## RigidBody3D default of STATIC) — captured once so it can be restored when
## this peer regains ownership, instead of getting stuck on whatever
## apply_held_state() last forced it to while non-authority.
#var _original_freeze_mode: int
#
## Same idea for the pickable's authored `enabled` flag, which the non-authority
## branch of apply_held_state() clears while someone else is holding the item.
#var _original_enabled: bool
#
## Whether the "our own hand still holds this" guard has already been logged for
## the current grab. apply_held_state() runs every network tick, so without this
## the guard message repeats for as long as you hold the item.
#var _grab_race_logged := false
#
#
#func _ready() -> void:
#_pickable = get_parent() as XRToolsPickable
#if not _pickable:
#push_error("NetPickable must be a child of an XRToolsPickable")
#return
#_original_freeze_mode = _pickable.freeze_mode
#_original_enabled = _pickable.enabled
#_pickable.picked_up.connect(_on_picked_up)
#_pickable.dropped.connect(_on_dropped)
## Deferred: the pickable root captures its own original_collision_mask/
## original_collision_layer via @onready, which runs AFTER this child's
## _ready() but BEFORE the root's _ready() body. Calling apply_held_state
## synchronously here would freeze/mask the item before that capture runs,
## permanently corrupting the "restore on drop" values.
#apply_held_state.call_deferred()
#
#
#func _set_net_held_by(value: int) -> void:
#var old := net_held_by
#net_held_by = value
#if old != value and NetworkManager.is_online():
#print("%s net_held_by: %d -> %d (local state: %s, authority=%d)" % [
#_pickable.name, old, value, _holder_desc(), get_multiplayer_authority()
#])
#apply_held_state()
#
#
### Puts the item in the right physics state for whether this peer currently
### owns it. Called locally after net_held_by changes, and directly by
### NetworkManager._set_item_authority right after an authority handoff.
###
### IMPORTANT: this runs on every network tick, not just on a real change.
### net_held_by is replicated in ALWAYS mode, so the synchronizer assigns it every
### tick on non-authority peers — unchanged value included — and that assignment
### lands in _set_net_held_by(), which calls this. So every branch here has to be
### idempotent and silent when there is nothing to do: otherwise each item logs a
### line and rewrites four physics properties every tick on every peer that
### doesn't own it.
#func apply_held_state() -> void:
#if not _pickable:
#return
#if not NetworkManager.is_online() or is_multiplayer_authority():
#_grab_race_logged = false
## We own this item's simulation (offline, loose+server, or currently
## holding it). If it's not actively in our own hand right now, make
## sure it isn't still left frozen/collision-less from a previous
## non-authority period (e.g. right after regaining authority when a
## client released it) — while actually held, XRToolsPickable's own
## pick_up()/let_go() already manage these fields, so leave those be.
#if not _pickable.is_picked_up():
#var changed := _pickable.freeze_mode != _original_freeze_mode \
#or _pickable.collision_mask != _pickable.original_collision_mask
#if changed:
#if NetworkManager.is_online():
#print(
#"%s: reclaiming ownership, restoring freeze_mode %d->%d collision_mask %d->%d" % [
#_pickable.name, _pickable.freeze_mode, _original_freeze_mode,
#_pickable.collision_mask, _pickable.original_collision_mask
#]
#)
#_pickable.freeze_mode = _original_freeze_mode
#_pickable.collision_mask = _pickable.original_collision_mask
## Unlike freeze/collision (which XRToolsPickable manages itself while
## held), `enabled` is only ever written by the non-authority branch
## below, so it must be restored here or it stays false forever: once a
## client grabbed this item, every other peer set enabled=false, and
## regaining authority left it that way. On the server that silently
## broke everything downstream — hands couldn't pick the item up again,
## and a station snap zone would "snap" it (emitting has_picked_up, so
## e.g. 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 that then fell out of the station.
#if _pickable.enabled != _original_enabled:
#if NetworkManager.is_online():
#print("%s: reclaiming ownership, restoring enabled %s->%s" % [
#_pickable.name, _pickable.enabled, _original_enabled
#])
#_pickable.enabled = _original_enabled
#return
## A net_held_by/position sync update can race ahead of the
## authority-handoff RPC that's about to confirm a grab we just made
## optimistically (they travel on different channels with no ordering
## guarantee). Don't let a stale sync value yank an item out of our own
## hand mid-grab — only an explicit force_release_item rejection, or
## actually losing authority for real, should end a grab we initiated.
#if _pickable.is_picked_up() and _pickable.get_picked_up_by() is XRToolsFunctionPickup:
## Log once per grab, not once per tick.
#if NetworkManager.is_online() and not _grab_race_logged:
#_grab_race_logged = true
#print(
#"%s: ignoring non-authority sync (net_held_by=%d) — still actively held by our own hand (grab-race guard)" % [
#_pickable.name, net_held_by
#]
#)
#return
#_grab_race_logged = false
## Someone else owns it: stop simulating locally, just follow the sync.
#if _pickable.is_picked_up():
#if NetworkManager.is_online():
#print(
#"%s: was held by %s on this peer, but authority now says peer %d owns it — force-dropping" % [
#_pickable.name, _holder_desc(), net_held_by
#]
#)
#_pickable.drop()
## Bail out when we're already in the follow-the-sync state. Without this the
## writes below (and the line logged with them) repeated every tick for every
## item on every non-authority peer — 90% of the log, plus four redundant
## physics-property writes per item per tick. The comparison also means we
## still re-apply if something else perturbs the state (e.g. let_go()
## restoring the collision mask after a force-drop).
#var want_enabled := (net_held_by == 0)
#if _pickable.freeze \
#and _pickable.freeze_mode == RigidBody3D.FREEZE_MODE_KINEMATIC \
#and _pickable.collision_mask == 0 \
#and _pickable.enabled == want_enabled:
#return
#if NetworkManager.is_online():
#print("%s: freezing (non-authority, owner=peer %d)" % [_pickable.name, net_held_by])
#_pickable.freeze = true
#_pickable.freeze_mode = RigidBody3D.FREEZE_MODE_KINEMATIC
#_pickable.collision_mask = 0
#_pickable.enabled = want_enabled
#
#
### Local hand grab (not a station snap zone, which is server-only): request
### authority immediately so the throw/drop can be reconciled, but let the grab
### happen instantly here rather than waiting on the round trip.
#func _on_picked_up(_p) -> void:
#var by := _pickable.get_picked_up_by()
#if not (by is XRToolsFunctionPickup):
## e.g. a station snap zone grabbed it (server-side auto-snap, or the
## addon's own "grab out of a snap zone" shortcut mid-cascade) — not a
## player-initiated hand grab, so no authority request from here.
#if NetworkManager.is_online():
#print("%s picked up by %s (not a hand) — no authority request" % [_pickable.name, _holder_desc()])
#return
#if NetworkManager.is_online():
#print("%s grabbed by hand (authority was peer %d), requesting authority" % [_pickable.name, net_held_by])
#NetworkManager.request_item_authority_from(_pickable.get_path())
#
#
#func _on_dropped(_p) -> void:
## Only forward if we're actually still the authority — a drop caused by
## apply_held_state() losing authority (see above) must not re-report.
#if not is_multiplayer_authority():
#if NetworkManager.is_online():
#print("%s dropped locally, but we aren't its authority (peer %d is) — not reporting" % [_pickable.name, net_held_by])
#return
#if NetworkManager.is_online():
#print("%s dropped, reporting release to server (lin=%s ang=%s)" % [
#_pickable.name, _pickable.linear_velocity, _pickable.angular_velocity
#])
## Send our own final transform too: we were the authority until now, and the
## server's copy may not have received our last position sync yet.
#NetworkManager.release_item_authority_from(
#_pickable.get_path(), _pickable.linear_velocity, _pickable.angular_velocity,
#_pickable.global_transform
#)
#
#
### Human-readable description of what's currently holding this item on THIS
### peer, for diagnosing desyncs between a hand's own "what am I holding"
### bookkeeping and the item's actual grab state (see the snap-zone-grab race
### in NetworkManager._try_snap_into_station for a real example).
#func _holder_desc() -> String:
#if not _pickable or not _pickable.is_picked_up():
#return "loose"
#var by := _pickable.get_picked_up_by()
#if not by:
#return "held(no grabber?)"
#if by is XRToolsFunctionPickup:
#return "hand(%s)" % by.get_path()
#if by is XRToolsSnapZone:
#var station := by.get_parent()
#return "zone(%s)" % (station.name if station else str(by.get_path()))
#return "other(%s: %s)" % [by.get_class(), by.get_path()]
-1
View File
@@ -1 +0,0 @@
uid://bwd0pe2udb5xo
+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()
+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
+78 -43
View File
@@ -1,71 +1,106 @@
extends Node3D
## Networked representation of one connected player. The owning peer's local
## XR rig (found via the "local_xr_origin" group) drives Head/LeftHand/
## RightHand each frame; the MultiplayerSynchronizer replicates those
## transforms so every other peer sees a matching avatar.
## 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:
# MultiplayerSynchronizer resolves authority when this node enters the
# tree, so authority must be set here rather than in _ready(), or the
# first synced frames go the wrong direction.
# 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
# node carries hand.gd (XRToolsHand). That script sets top_level = true
# and every physics frame does global_transform = get_parent().
# global_transform * offset — i.e. it actively repositions itself to
# track a live XRController3D parent. Here the parent is just this
# NetPlayer node, not a controller, so left running it fights (and mostly
# wins, since it runs every physics tick regardless of our own _process)
# against both the local authority's transform copy below and the
# replicated values on other peers — the exact "hands stuck near origin,
# only occasionally correct" symptom. Disable it everywhere; nothing else
# in that script matters here since _controller is always null without a
# real controller ancestor (grip/trigger animation already no-ops).
# 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 is_multiplayer_authority():
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 in the scene; spread
# joiners out along X so they don't start stacked on top of each
# other. Peer ids from ENet are large effectively-random 32-bit
# numbers, so this must be bounded, AND kept well within the
# floor's actual footprint (15x15, so ~7.5 units from center) —
# a previous version used up to 12 units and could place a
# joining player off the edge of the floor.
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/hands from the inside.
_head.visible = false
_left_hand.visible = false
_right_hand.visible = false
else:
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.global_transform = _local_camera.global_transform
head_xform = _local_camera.global_transform
if _local_left_hand:
_left_hand.global_transform = _local_left_hand.global_transform
left_xform = _local_left_hand.global_transform
if _local_right_hand:
_right_hand.global_transform = _local_right_hand.global_transform
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
+2 -27
View File
@@ -1,6 +1,6 @@
[gd_scene format=3]
[gd_scene load_steps=4 format=3]
[ext_resource type="Script" uid="uid://bncuxh7j7ix5q" path="res://player/net_player.gd" id="1_np001"]
[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"]
@@ -8,26 +8,6 @@
radius = 0.09
height = 0.22
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_np005"]
properties/0/path = NodePath("Head:position")
properties/0/spawn = false
properties/0/replication_mode = 1
properties/1/path = NodePath("Head:quaternion")
properties/1/spawn = false
properties/1/replication_mode = 1
properties/2/path = NodePath("LeftHand:position")
properties/2/spawn = false
properties/2/replication_mode = 1
properties/3/path = NodePath("LeftHand:quaternion")
properties/3/spawn = false
properties/3/replication_mode = 1
properties/4/path = NodePath("RightHand:position")
properties/4/spawn = false
properties/4/replication_mode = 1
properties/5/path = NodePath("RightHand:quaternion")
properties/5/spawn = false
properties/5/replication_mode = 1
[node name="NetPlayer" type="Node3D"]
script = ExtResource("1_np001")
@@ -37,8 +17,3 @@ mesh = SubResource("CapsuleMesh_np004")
[node name="LeftHand" parent="." instance=ExtResource("2_np002")]
[node name="RightHand" parent="." instance=ExtResource("3_np003")]
[node name="Sync" type="MultiplayerSynchronizer" parent="."]
root_path = NodePath("..")
replication_config = SubResource("SceneReplicationConfig_np005")
replication_interval = 0.033
+7 -10
View File
@@ -1,7 +1,7 @@
class_name CombinableItem
extends Node
const RECIPE_MANAGER = preload("res://scripts/recipe_Manager.gd")
const RECIPE_MANAGER = preload("res://RecipeManager.gd")
@onready var combine_area_3d: Area3D = $Area3d
@onready var _pickable: XRToolsPickable = get_parent() as XRToolsPickable
@@ -51,8 +51,8 @@ func _on_item_dropped(_item: Node3D) -> void:
# 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 not NetworkManager.owns_world():
return
if _combining or body == _pickable:
print("CombinableItem _on_body_entered: other is our own pickable")
return
@@ -81,16 +81,13 @@ func _combine(other_body: Node3D, result: PackedScene) -> void:
# 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)
var result_instance: Node3D = result.instantiate()
get_tree().root.add_child(result_instance)
result_instance.transform = base_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()
_pickable.queue_free()
NetworkManager.despawn_item(_pickable)
other_body.drop()
other_body.queue_free()
NetworkManager.despawn_item(other_body)
# Snap the result into the now-empty zone.
snap_zone.pick_up_object(result_instance)
+1 -1
View File
@@ -1,6 +1,6 @@
[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://dounic663dn5q" path="res://Prefabs/combinable_item.gd" id="1_q21ti"]
[sub_resource type="SphereShape3D" id="SphereShape3D_o1b3t"]
radius = 0.2
+8
View File
@@ -0,0 +1,8 @@
class_name CombineRecipe
extends Resource
## The [CombinableItem.id] of the item that must be combined into the base item.
@export var ingredient_id: StringName
## The scene the base item turns into when [member ingredient_id] is combined in.
@export var result: PackedScene
+1
View File
@@ -0,0 +1 @@
uid://coidnv8b2yvxr
+9
View File
@@ -0,0 +1,9 @@
class_name CookableItem
extends Node
@export_range(0.0, 30.0, 0.5, "or_greater", "suffix:s") var cooking_time: float = 4.0
@export var turns_into: PackedScene
func _ready() -> void:
if not turns_into:
push_error("Cooking Error: 'turns_into' PackedScene is missing on ", name, ". Please assign a scene in the Inspector.")
+1
View File
@@ -0,0 +1 @@
uid://bs7cxydoxk1cx
+9
View File
@@ -0,0 +1,9 @@
[gd_scene format=3 uid="uid://7earnjgdmwgx"]
[ext_resource type="Script" uid="uid://bs7cxydoxk1cx" path="res://Prefabs/cookable_item.gd" id="1_6hwx6"]
[ext_resource type="PackedScene" uid="uid://cucc3gaqu2nab" path="res://Items/Charcoal.tscn" id="2_rpt7j"]
[node name="CookableItem" type="Node" unique_id=280820828]
script = ExtResource("1_6hwx6")
cooking_time = 2.0
turns_into = ExtResource("2_rpt7j")
+5 -5
View File
@@ -28,8 +28,8 @@ func _process(delta: float) -> void:
# 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 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):
@@ -42,7 +42,7 @@ func _process(delta: float) -> void:
_time_left -= delta
if _time_left <= 0:
print("DespawningItem despawning!" , get_parent())
get_parent().queue_free()
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)
@@ -56,8 +56,8 @@ func _process(delta: float) -> void:
# `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: # TODO: Fix blinking
if true:# NetworkManager.is_online():
func _set_visible(value: bool) -> void:
if NetworkManager.is_online():
get_parent().visible = true
return
get_parent().visible = value
+1 -1
View File
@@ -1,6 +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"]
[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 -1
View File
@@ -1,6 +1,6 @@
[gd_scene format=3 uid="uid://bfj80jh13t6e5"]
[ext_resource type="Script" uid="uid://5tpoohkopryv" path="res://prefabs/food_item.gd" id="1_0na5k"]
[ext_resource type="Script" uid="uid://5tpoohkopryv" path="res://Prefabs/food_item.gd" id="1_0na5k"]
[node name="FoodItem" type="Node" unique_id=63948206]
script = ExtResource("1_0na5k")
@@ -1,3 +1,4 @@
class_name RecipeManager
extends Node
static var _recipes: Dictionary
+1
View File
@@ -0,0 +1 @@
uid://cuo88u56uqwuy
+7 -7
View File
@@ -25,18 +25,18 @@ Example structure:
```yaml
items:
hamburger:
scene: res://Items/hamburger.tscn
type: meal
scene: res://Items/hamburger.tscn
type: meal
burger_buns:
scene: res://Items/BurgerBuns.tscn
type: ingredient
scene: res://Items/BurgerBuns.tscn
type: ingredient
combining:
hamburger:
- [cooked_burger, burger_buns]
- [charcoal, charcoal]
- [cooked_burger, burger_buns]
- [charcoal, charcoal]
charcoal:
- [cube, cube]
- [cube, cube]
```
### `items`
@@ -1,22 +1,22 @@
[gd_scene format=3 uid="uid://22shbqdvnwgo"]
[ext_resource type="Script" uid="uid://b4ldkd3ngs0vp" path="res://scripts/main.gd" id="1_m3h4l"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://prefabs/xr_origin.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://test/testworld_load.gd" id="16_m3h4l"]
[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://prefabs/game_over_controler.gd" id="19_3lufs"]
[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)
@@ -1,24 +1,25 @@
[gd_scene format=3 uid="uid://do6mrslyqe5qe"]
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://textures/sky/NightSkyHDRI009_16K.tres" id="2_6gspb"]
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="3_8n1fs"]
[ext_resource type="PackedScene" uid="uid://xtcei2uvd5li" path="res://ui/game_over_panel.tscn" id="4_6gspb"]
[ext_resource type="Script" uid="uid://cwijoksyou1ey" path="res://prefabs/GameOvercontroler.gd" id="5_qmys3"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://prefabs/xr_origin.tscn" id="6_b4aof"]
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://textures/dev_material_3d.tres" id="7_mdqee"]
[ext_resource type="PackedScene" uid="uid://caf0xanmxbshy" path="res://stations/table.tscn" id="8_wl1ox"]
[ext_resource type="PackedScene" uid="uid://j7caslh27nor" path="res://stations/Hob.tscn" id="9_wrlv7"]
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://stations/sink.tscn" id="10_dwulx"]
[ext_resource type="PackedScene" uid="uid://cnjwtnhwh0i8q" path="res://stations/dirt_station.tscn" id="11_e8c1b"]
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://stations/Counter.tscn" id="12_cm8ly"]
[ext_resource type="PackedScene" uid="uid://c6rift56ql3f8" path="res://stations/BurgerBunsDispenser.tscn" id="13_0sfn4"]
[ext_resource type="PackedScene" uid="uid://cwnwo4i28upap" path="res://stations/raw_burger_dispenser.tscn" id="14_d0yvd"]
[ext_resource type="PackedScene" uid="uid://ck5tuftqmyiue" path="res://stations/plate_dispenser.tscn" id="15_evyxv"]
[ext_resource type="PackedScene" uid="uid://bbg7dwsbxxh1t" path="res://stations/cube_side_dispense.tscn" id="16_kktuy"]
[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="Sky" uid="uid://c1abtpwhdm2d5" path="res://Textures/sky/NightSkyHDRI009_16K.tres" id="7_n8fyw"]
[ext_resource type="PackedScene" uid="uid://c6rift56ql3f8" path="res://Stations/BurgerBunsDispenser.tscn" id="9_sq0s2"]
[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("2_6gspb")
sky = ExtResource("7_n8fyw")
ambient_light_source = 3
ambient_light_color = Color(1, 1, 1, 1)
ambient_light_sky_contribution = 0.9
@@ -32,33 +33,31 @@ sdfgi_enabled = true
size = Vector3(20, 0.1, 20)
[sub_resource type="BoxMesh" id="BoxMesh_24d3s"]
material = ExtResource("7_mdqee")
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="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="GameOverPanel" parent="." unique_id=1234658657 instance=ExtResource("3_8n1fs")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -2.0281777, 2.8122003, 0)
scene = ExtResource("4_6gspb")
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=803158176]
script = ExtResource("5_qmys3")
[node name="XROrigin3D" parent="." unique_id=2055526621 groups=["local_xr_origin"] instance=ExtResource("6_b4aof")]
[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)
@@ -90,47 +89,53 @@ shape = SubResource("BoxShape3D_24d3s")
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="Stations" type="Node3D" parent="." unique_id=1237237441]
[node name="Table" parent="Stations" unique_id=1863572470 instance=ExtResource("8_wl1ox")]
[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="Hob" parent="Stations" unique_id=1687971542 instance=ExtResource("9_wrlv7")]
[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="Hob2" parent="Stations" unique_id=717907738 instance=ExtResource("9_wrlv7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.26079375, 0.50655985, -1.2833805)
[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="Sink" parent="Stations" unique_id=2055277359 instance=ExtResource("10_dwulx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.9064429, 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="DirtStation" parent="Stations" unique_id=160842153 instance=ExtResource("11_e8c1b")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.4574674, 0.50655985, -1.2598276)
[node name="Counter" parent="Stations" unique_id=1487893288 instance=ExtResource("12_cm8ly")]
[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="Stations" unique_id=368890752 instance=ExtResource("12_cm8ly")]
[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="Stations" unique_id=1748373996 instance=ExtResource("12_cm8ly")]
[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="Stations" unique_id=1498817646 instance=ExtResource("12_cm8ly")]
[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="Stations" unique_id=200341072 instance=ExtResource("12_cm8ly")]
transform = Transform3D(0, 0, -1, 0, 1, 0, 1, 0, 0, 1.9911776, 0.51150185, 0.61940837)
[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="Stations" unique_id=1720683779 instance=ExtResource("13_0sfn4")]
[node name="BurgerBunsDispenser" parent="." unique_id=1720683779 instance=ExtResource("9_sq0s2")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5242664, 0.008738995, 1.1073059)
[node name="RawBurgerDispenser" parent="Stations" unique_id=235630131 instance=ExtResource("14_d0yvd")]
[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="PlateDispenser" parent="Stations" unique_id=710538846 instance=ExtResource("15_evyxv")]
[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="CubeSideDispenser2" parent="Stations" unique_id=200950572 instance=ExtResource("16_kktuy")]
[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="controler" type="Node" parent="GameOverPanel" unique_id=803158176]
script = ExtResource("16_n8fyw")
[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)
@@ -1,9 +1,9 @@
[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://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"]
[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
-138
View File
@@ -1,138 +0,0 @@
[gd_scene format=3 uid="uid://do6mrslyqe5qe"]
[ext_resource type="Script" uid="uid://b4ldkd3ngs0vp" path="res://scripts/main.gd" id="1_6gspb"]
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://textures/sky/NightSkyHDRI009_16K.tres" id="2_6gspb"]
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="3_8n1fs"]
[ext_resource type="PackedScene" uid="uid://xtcei2uvd5li" path="res://ui/game_over_panel.tscn" id="4_6gspb"]
[ext_resource type="Script" uid="uid://cwijoksyou1ey" path="res://prefabs/game_over_controler.gd" id="5_qmys3"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://prefabs/xr_origin.tscn" id="6_b4aof"]
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://textures/dev_material_3d.tres" id="7_mdqee"]
[ext_resource type="PackedScene" uid="uid://caf0xanmxbshy" path="res://stations/table.tscn" id="8_wl1ox"]
[ext_resource type="PackedScene" uid="uid://j7caslh27nor" path="res://stations/Hob.tscn" id="9_wrlv7"]
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://stations/sink.tscn" id="10_dwulx"]
[ext_resource type="PackedScene" uid="uid://cnjwtnhwh0i8q" path="res://stations/dirt_station.tscn" id="11_e8c1b"]
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://stations/Counter.tscn" id="12_cm8ly"]
[ext_resource type="PackedScene" uid="uid://c6rift56ql3f8" path="res://stations/BurgerBunsDispenser.tscn" id="13_0sfn4"]
[ext_resource type="PackedScene" uid="uid://cwnwo4i28upap" path="res://stations/raw_burger_dispenser.tscn" id="14_d0yvd"]
[ext_resource type="PackedScene" uid="uid://ck5tuftqmyiue" path="res://stations/plate_dispenser.tscn" id="15_evyxv"]
[ext_resource type="PackedScene" uid="uid://bbg7dwsbxxh1t" path="res://stations/cube_side_dispense.tscn" id="16_kktuy"]
[sub_resource type="Environment" id="Environment_bvwq1"]
background_mode = 2
sky = ExtResource("2_6gspb")
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("7_mdqee")
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_6gspb")
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="GameOverPanel" parent="." unique_id=1234658657 instance=ExtResource("3_8n1fs")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -2.0281777, 2.8122003, 0)
scene = ExtResource("4_6gspb")
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=803158176]
script = ExtResource("5_qmys3")
[node name="XROrigin3D" parent="." unique_id=2055526621 groups=["local_xr_origin"] instance=ExtResource("6_b4aof")]
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="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="Stations" type="Node3D" parent="." unique_id=1237237441]
[node name="Table" parent="Stations" unique_id=1863572470 instance=ExtResource("8_wl1ox")]
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="Hob" parent="Stations" unique_id=1687971542 instance=ExtResource("9_wrlv7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.35077858, 0.50655985, -1.2833805)
[node name="Hob2" parent="Stations" unique_id=717907738 instance=ExtResource("9_wrlv7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.26079375, 0.50655985, -1.2833805)
[node name="Sink" parent="Stations" unique_id=2055277359 instance=ExtResource("10_dwulx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.9064429, 0.51461196, -1.2828919)
[node name="DirtStation" parent="Stations" unique_id=160842153 instance=ExtResource("11_e8c1b")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.4574674, 0.50655985, -1.2598276)
[node name="Counter" parent="Stations" unique_id=1487893288 instance=ExtResource("12_cm8ly")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.94890714, 0.5115015, -1.3041471)
[node name="Counter2" parent="Stations" unique_id=368890752 instance=ExtResource("12_cm8ly")]
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="Stations" unique_id=1748373996 instance=ExtResource("12_cm8ly")]
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="Stations" unique_id=1498817646 instance=ExtResource("12_cm8ly")]
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="Stations" unique_id=200341072 instance=ExtResource("12_cm8ly")]
transform = Transform3D(0, 0, -1, 0, 1, 0, 1, 0, 0, 1.9911776, 0.51150185, 0.61940837)
[node name="BurgerBunsDispenser" parent="Stations" unique_id=1720683779 instance=ExtResource("13_0sfn4")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5242664, 0.008738995, 1.1073059)
[node name="RawBurgerDispenser" parent="Stations" unique_id=235630131 instance=ExtResource("14_d0yvd")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.8896122, 0.008738995, 1.0872328)
[node name="PlateDispenser" parent="Stations" unique_id=710538846 instance=ExtResource("15_evyxv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.26631236, 0.008738995, 1.087036)
[node name="CubeSideDispenser2" parent="Stations" unique_id=200950572 instance=ExtResource("16_kktuy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.35154933, 0, 1.1119425)
-136
View File
@@ -1,136 +0,0 @@
[gd_scene format=3 uid="uid://do6mrslyqe5qe"]
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://textures/sky/NightSkyHDRI009_16K.tres" id="2_6gspb"]
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="3_8n1fs"]
[ext_resource type="PackedScene" uid="uid://xtcei2uvd5li" path="res://ui/game_over_panel.tscn" id="4_6gspb"]
[ext_resource type="Script" uid="uid://cwijoksyou1ey" path="res://prefabs/GameOvercontroler.gd" id="5_qmys3"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://prefabs/xr_origin.tscn" id="6_b4aof"]
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://textures/dev_material_3d.tres" id="7_mdqee"]
[ext_resource type="PackedScene" uid="uid://caf0xanmxbshy" path="res://stations/table.tscn" id="8_wl1ox"]
[ext_resource type="PackedScene" uid="uid://j7caslh27nor" path="res://stations/Hob.tscn" id="9_wrlv7"]
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://stations/sink.tscn" id="10_dwulx"]
[ext_resource type="PackedScene" uid="uid://cnjwtnhwh0i8q" path="res://stations/dirt_station.tscn" id="11_e8c1b"]
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://stations/Counter.tscn" id="12_cm8ly"]
[ext_resource type="PackedScene" uid="uid://c6rift56ql3f8" path="res://stations/BurgerBunsDispenser.tscn" id="13_0sfn4"]
[ext_resource type="PackedScene" uid="uid://cwnwo4i28upap" path="res://stations/raw_burger_dispenser.tscn" id="14_d0yvd"]
[ext_resource type="PackedScene" uid="uid://ck5tuftqmyiue" path="res://stations/plate_dispenser.tscn" id="15_evyxv"]
[ext_resource type="PackedScene" uid="uid://bbg7dwsbxxh1t" path="res://stations/cube_side_dispense.tscn" id="16_kktuy"]
[sub_resource type="Environment" id="Environment_bvwq1"]
background_mode = 2
sky = ExtResource("2_6gspb")
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("7_mdqee")
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]
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="GameOverPanel" parent="." unique_id=1234658657 instance=ExtResource("3_8n1fs")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -2.0281777, 2.8122003, 0)
scene = ExtResource("4_6gspb")
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=803158176]
script = ExtResource("5_qmys3")
[node name="XROrigin3D" parent="." unique_id=2055526621 groups=["local_xr_origin"] instance=ExtResource("6_b4aof")]
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="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="Stations" type="Node3D" parent="." unique_id=1237237441]
[node name="Table" parent="Stations" unique_id=1863572470 instance=ExtResource("8_wl1ox")]
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="Hob" parent="Stations" unique_id=1687971542 instance=ExtResource("9_wrlv7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.35077858, 0.50655985, -1.2833805)
[node name="Hob2" parent="Stations" unique_id=717907738 instance=ExtResource("9_wrlv7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.26079375, 0.50655985, -1.2833805)
[node name="Sink" parent="Stations" unique_id=2055277359 instance=ExtResource("10_dwulx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.9064429, 0.51461196, -1.2828919)
[node name="DirtStation" parent="Stations" unique_id=160842153 instance=ExtResource("11_e8c1b")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.4574674, 0.50655985, -1.2598276)
[node name="Counter" parent="Stations" unique_id=1487893288 instance=ExtResource("12_cm8ly")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.94890714, 0.5115015, -1.3041471)
[node name="Counter2" parent="Stations" unique_id=368890752 instance=ExtResource("12_cm8ly")]
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="Stations" unique_id=1748373996 instance=ExtResource("12_cm8ly")]
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="Stations" unique_id=1498817646 instance=ExtResource("12_cm8ly")]
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="Stations" unique_id=200341072 instance=ExtResource("12_cm8ly")]
transform = Transform3D(0, 0, -1, 0, 1, 0, 1, 0, 0, 1.9911776, 0.51150185, 0.61940837)
[node name="BurgerBunsDispenser" parent="Stations" unique_id=1720683779 instance=ExtResource("13_0sfn4")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5242664, 0.008738995, 1.1073059)
[node name="RawBurgerDispenser" parent="Stations" unique_id=235630131 instance=ExtResource("14_d0yvd")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.8896122, 0.008738995, 1.0872328)
[node name="PlateDispenser" parent="Stations" unique_id=710538846 instance=ExtResource("15_evyxv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.26631236, 0.008738995, 1.087036)
[node name="CubeSideDispenser2" parent="Stations" unique_id=200950572 instance=ExtResource("16_kktuy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.35154933, 0, 1.1119425)
-136
View File
@@ -1,136 +0,0 @@
[gd_scene format=3 uid="uid://do6mrslyqe5qe"]
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://textures/sky/NightSkyHDRI009_16K.tres" id="2_6gspb"]
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="3_8n1fs"]
[ext_resource type="PackedScene" uid="uid://xtcei2uvd5li" path="res://ui/game_over_panel.tscn" id="4_6gspb"]
[ext_resource type="Script" uid="uid://cwijoksyou1ey" path="res://prefabs/GameOvercontroler.gd" id="5_qmys3"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://prefabs/xr_origin.tscn" id="6_b4aof"]
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://textures/dev_material_3d.tres" id="7_mdqee"]
[ext_resource type="PackedScene" uid="uid://caf0xanmxbshy" path="res://stations/table.tscn" id="8_wl1ox"]
[ext_resource type="PackedScene" uid="uid://j7caslh27nor" path="res://stations/Hob.tscn" id="9_wrlv7"]
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://stations/sink.tscn" id="10_dwulx"]
[ext_resource type="PackedScene" uid="uid://cnjwtnhwh0i8q" path="res://stations/dirt_station.tscn" id="11_e8c1b"]
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://stations/Counter.tscn" id="12_cm8ly"]
[ext_resource type="PackedScene" uid="uid://c6rift56ql3f8" path="res://stations/BurgerBunsDispenser.tscn" id="13_0sfn4"]
[ext_resource type="PackedScene" uid="uid://cwnwo4i28upap" path="res://stations/raw_burger_dispenser.tscn" id="14_d0yvd"]
[ext_resource type="PackedScene" uid="uid://ck5tuftqmyiue" path="res://stations/plate_dispenser.tscn" id="15_evyxv"]
[ext_resource type="PackedScene" uid="uid://bbg7dwsbxxh1t" path="res://stations/cube_side_dispense.tscn" id="16_kktuy"]
[sub_resource type="Environment" id="Environment_bvwq1"]
background_mode = 2
sky = ExtResource("2_6gspb")
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("7_mdqee")
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]
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="GameOverPanel" parent="." unique_id=1234658657 instance=ExtResource("3_8n1fs")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -2.0281777, 2.8122003, 0)
scene = ExtResource("4_6gspb")
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=803158176]
script = ExtResource("5_qmys3")
[node name="XROrigin3D" parent="." unique_id=2055526621 groups=["local_xr_origin"] instance=ExtResource("6_b4aof")]
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="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="Stations" type="Node3D" parent="." unique_id=1237237441]
[node name="Table" parent="Stations" unique_id=1863572470 instance=ExtResource("8_wl1ox")]
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="Hob" parent="Stations" unique_id=1687971542 instance=ExtResource("9_wrlv7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.35077858, 0.50655985, -1.2833805)
[node name="Hob2" parent="Stations" unique_id=717907738 instance=ExtResource("9_wrlv7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.26079375, 0.50655985, -1.2833805)
[node name="Sink" parent="Stations" unique_id=2055277359 instance=ExtResource("10_dwulx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.9064429, 0.51461196, -1.2828919)
[node name="DirtStation" parent="Stations" unique_id=160842153 instance=ExtResource("11_e8c1b")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.4574674, 0.50655985, -1.2598276)
[node name="Counter" parent="Stations" unique_id=1487893288 instance=ExtResource("12_cm8ly")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.94890714, 0.5115015, -1.3041471)
[node name="Counter2" parent="Stations" unique_id=368890752 instance=ExtResource("12_cm8ly")]
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="Stations" unique_id=1748373996 instance=ExtResource("12_cm8ly")]
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="Stations" unique_id=1498817646 instance=ExtResource("12_cm8ly")]
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="Stations" unique_id=200341072 instance=ExtResource("12_cm8ly")]
transform = Transform3D(0, 0, -1, 0, 1, 0, 1, 0, 0, 1.9911776, 0.51150185, 0.61940837)
[node name="BurgerBunsDispenser" parent="Stations" unique_id=1720683779 instance=ExtResource("13_0sfn4")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5242664, 0.008738995, 1.1073059)
[node name="RawBurgerDispenser" parent="Stations" unique_id=235630131 instance=ExtResource("14_d0yvd")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.8896122, 0.008738995, 1.0872328)
[node name="PlateDispenser" parent="Stations" unique_id=710538846 instance=ExtResource("15_evyxv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.26631236, 0.008738995, 1.087036)
[node name="CubeSideDispenser2" parent="Stations" unique_id=200950572 instance=ExtResource("16_kktuy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.35154933, 0, 1.1119425)
-136
View File
@@ -1,136 +0,0 @@
[gd_scene format=3 uid="uid://do6mrslyqe5qe"]
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://textures/sky/NightSkyHDRI009_16K.tres" id="2_6gspb"]
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="3_8n1fs"]
[ext_resource type="PackedScene" uid="uid://xtcei2uvd5li" path="res://ui/game_over_panel.tscn" id="4_6gspb"]
[ext_resource type="Script" uid="uid://cwijoksyou1ey" path="res://prefabs/game_over_controler.gd" id="5_qmys3"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://prefabs/xr_origin.tscn" id="6_b4aof"]
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://textures/dev_material_3d.tres" id="7_mdqee"]
[ext_resource type="PackedScene" uid="uid://caf0xanmxbshy" path="res://stations/table.tscn" id="8_wl1ox"]
[ext_resource type="PackedScene" uid="uid://j7caslh27nor" path="res://stations/Hob.tscn" id="9_wrlv7"]
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://stations/sink.tscn" id="10_dwulx"]
[ext_resource type="PackedScene" uid="uid://cnjwtnhwh0i8q" path="res://stations/dirt_station.tscn" id="11_e8c1b"]
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://stations/Counter.tscn" id="12_cm8ly"]
[ext_resource type="PackedScene" uid="uid://c6rift56ql3f8" path="res://stations/BurgerBunsDispenser.tscn" id="13_0sfn4"]
[ext_resource type="PackedScene" uid="uid://cwnwo4i28upap" path="res://stations/raw_burger_dispenser.tscn" id="14_d0yvd"]
[ext_resource type="PackedScene" uid="uid://ck5tuftqmyiue" path="res://stations/plate_dispenser.tscn" id="15_evyxv"]
[ext_resource type="PackedScene" uid="uid://bbg7dwsbxxh1t" path="res://stations/cube_side_dispense.tscn" id="16_kktuy"]
[sub_resource type="Environment" id="Environment_bvwq1"]
background_mode = 2
sky = ExtResource("2_6gspb")
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("7_mdqee")
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]
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="GameOverPanel" parent="." unique_id=1234658657 instance=ExtResource("3_8n1fs")]
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -2.0281777, 2.8122003, 0)
scene = ExtResource("4_6gspb")
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=803158176]
script = ExtResource("5_qmys3")
[node name="XROrigin3D" parent="." unique_id=2055526621 groups=["local_xr_origin"] instance=ExtResource("6_b4aof")]
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="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="Stations" type="Node3D" parent="." unique_id=1237237441]
[node name="Table" parent="Stations" unique_id=1863572470 instance=ExtResource("8_wl1ox")]
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="Hob" parent="Stations" unique_id=1687971542 instance=ExtResource("9_wrlv7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.35077858, 0.50655985, -1.2833805)
[node name="Hob2" parent="Stations" unique_id=717907738 instance=ExtResource("9_wrlv7")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.26079375, 0.50655985, -1.2833805)
[node name="Sink" parent="Stations" unique_id=2055277359 instance=ExtResource("10_dwulx")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.9064429, 0.51461196, -1.2828919)
[node name="DirtStation" parent="Stations" unique_id=160842153 instance=ExtResource("11_e8c1b")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.4574674, 0.50655985, -1.2598276)
[node name="Counter" parent="Stations" unique_id=1487893288 instance=ExtResource("12_cm8ly")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.94890714, 0.5115015, -1.3041471)
[node name="Counter2" parent="Stations" unique_id=368890752 instance=ExtResource("12_cm8ly")]
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="Stations" unique_id=1748373996 instance=ExtResource("12_cm8ly")]
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="Stations" unique_id=1498817646 instance=ExtResource("12_cm8ly")]
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="Stations" unique_id=200341072 instance=ExtResource("12_cm8ly")]
transform = Transform3D(0, 0, -1, 0, 1, 0, 1, 0, 0, 1.9911776, 0.51150185, 0.61940837)
[node name="BurgerBunsDispenser" parent="Stations" unique_id=1720683779 instance=ExtResource("13_0sfn4")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5242664, 0.008738995, 1.1073059)
[node name="RawBurgerDispenser" parent="Stations" unique_id=235630131 instance=ExtResource("14_d0yvd")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.8896122, 0.008738995, 1.0872328)
[node name="PlateDispenser" parent="Stations" unique_id=710538846 instance=ExtResource("15_evyxv")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.26631236, 0.008738995, 1.087036)
[node name="CubeSideDispenser2" parent="Stations" unique_id=200950572 instance=ExtResource("16_kktuy")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.35154933, 0, 1.1119425)
+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)
-53
View File
@@ -1,53 +0,0 @@
[gd_scene format=3 uid="uid://c1nv4w33fedj6"]
[ext_resource type="Script" uid="uid://b4ldkd3ngs0vp" path="res://scripts/main.gd" id="1_rtw2f"]
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://textures/sky/NightSkyHDRI009_16K.tres" id="2_rtw2f"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://prefabs/xr_origin.tscn" id="3_tbmy8"]
[ext_resource type="PackedScene" uid="uid://clujaf3u776a3" path="res://addons/godot-xr-tools/objects/viewport_2d_in_3d.tscn" id="4_jk1qb"]
[ext_resource type="PackedScene" path="res://ui/main_menu_panel.tscn" id="5_rtw2f"]
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://textures/dev_material_3d.tres" id="6_oa1go"]
[sub_resource type="Environment" id="Environment_bvwq1"]
background_mode = 2
sky = ExtResource("2_rtw2f")
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(115, 0.1, 15)
[sub_resource type="BoxMesh" id="BoxMesh_24d3s"]
material = ExtResource("6_oa1go")
size = Vector3(15, 0.1, 15)
[node name="Main" type="Node3D" unique_id=1312265607]
script = ExtResource("1_rtw2f")
[node name="WorldEnvironment" type="WorldEnvironment" parent="." unique_id=1177077250]
environment = SubResource("Environment_bvwq1")
[node name="XROrigin3D" parent="." unique_id=2055526621 instance=ExtResource("3_tbmy8")]
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("4_jk1qb")]
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("5_rtw2f")
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")
+12 -7
View File
@@ -1,19 +1,21 @@
[gd_scene format=3 uid="uid://c30i6h32w8p47"]
[ext_resource type="PackedScene" uid="uid://j5s5wus7tuhb" path="res://prefabs/xr_origin.tscn" id="1_pjkx2"]
[ext_resource type="Material" uid="uid://cmia50cfqxxo4" path="res://textures/dev_material_3d.tres" id="2_pjkx2"]
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://textures/sky/NightSkyHDRI009_16K.tres" id="3_4vwpp"]
[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("2_pjkx2")
material = ExtResource("3_75ecy")
size = Vector3(15, 0.1, 15)
[sub_resource type="Environment" id="Environment_bvwq1"]
background_mode = 2
sky = ExtResource("3_4vwpp")
sky = ExtResource("5_c3xgf")
reflected_light_source = 2
ssr_enabled = true
ssao_enabled = true
@@ -24,8 +26,9 @@ sdfgi_enabled = true
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("1_pjkx2")]
[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]
@@ -52,7 +55,6 @@ environment = SubResource("Environment_bvwq1")
spawn_path = NodePath("../WorldContent")
[node name="PlayersSpawner" type="MultiplayerSpawner" parent="." unique_id=106645565]
_spawnable_scenes = PackedStringArray("res://Player/net_player.tscn")
spawn_path = NodePath("../Players")
[node name="StaticBody3D" type="StaticBody3D" parent="." unique_id=4404969]
@@ -72,3 +74,6 @@ 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")
+8 -8
View File
@@ -1,13 +1,13 @@
[gd_scene format=3 uid="uid://dbgu4r127ke5v"]
[ext_resource type="Script" uid="uid://b4ldkd3ngs0vp" path="res://scripts/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://prefabs/xr_origin.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"]
[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
View File
@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://mmasxwqyqmib"
path="res://.godot/imported/220175__gameaudio__pop-click.wav-6ef2d3317a82c347b715936ede79653a.sample"
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-6ef2d3317a82c347b715936ede79653a.sample"]
source_file="res://Sounds/220175__gameaudio__pop-click.wav"
dest_files=["res://.godot/imported/220175__gameaudio__pop-click.wav-1330523e09eacb15d341a14b80e4481e.sample"]
[params]
+3 -3
View File
@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://ecva70pect61"
path="res://.godot/imported/220178__gameaudio__click.wav-566ebf31c82573e187ff8a1db97a7861.sample"
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-566ebf31c82573e187ff8a1db97a7861.sample"]
source_file="res://Sounds/220178__gameaudio__click.wav"
dest_files=["res://.godot/imported/220178__gameaudio__click.wav-ca46bf33c1c48e1e526f04c43ca7d450.sample"]
[params]
@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://b3wxawyrvuc6s"
path="res://.godot/imported/220179__gameaudio__click-metal-ting.wav-82be282871110eef8fea8249619832d7.sample"
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-82be282871110eef8fea8249619832d7.sample"]
source_file="res://Sounds/220179__gameaudio__click-metal-ting.wav"
dest_files=["res://.godot/imported/220179__gameaudio__click-metal-ting.wav-b01c457287fe42298a36c3de7c536c68.sample"]
[params]
@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://b7sr2sb1ks5en"
path="res://.godot/imported/220180__gameaudio__click-pop.wav-32216325683d314fa3adc66d13e633f4.sample"
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-32216325683d314fa3adc66d13e633f4.sample"]
source_file="res://Sounds/220180__gameaudio__click-pop.wav"
dest_files=["res://.godot/imported/220180__gameaudio__click-pop.wav-9e467150046193d705dd830885c89cd1.sample"]
[params]
@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://1ccsqbju32ey"
path="res://.godot/imported/220187__gameaudio__loosedeny-casual-1.wav-2e7c1356ffec0a1e5b732b21f42e21a0.sample"
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-2e7c1356ffec0a1e5b732b21f42e21a0.sample"]
source_file="res://Sounds/220187__gameaudio__loosedeny-casual-1.wav"
dest_files=["res://.godot/imported/220187__gameaudio__loosedeny-casual-1.wav-cb0e560d42c6026ded2d2e240e614433.sample"]
[params]
@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://bdnsgt7xt3261"
path="res://.godot/imported/220194__gameaudio__click-heavy.wav-43269bff3c60e2451b470f929c6b6bb8.sample"
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-43269bff3c60e2451b470f929c6b6bb8.sample"]
source_file="res://Sounds/220194__gameaudio__click-heavy.wav"
dest_files=["res://.godot/imported/220194__gameaudio__click-heavy.wav-aca40ed286d93eb365d527a162fd3129.sample"]
[params]
@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://daiv8ubwdbidf"
path="res://.godot/imported/220195__gameaudio__click-wooden-1.wav-f161e2c5a53d686c65d143b45f33acb1.sample"
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-f161e2c5a53d686c65d143b45f33acb1.sample"]
source_file="res://Sounds/220195__gameaudio__click-wooden-1.wav"
dest_files=["res://.godot/imported/220195__gameaudio__click-wooden-1.wav-9368ef861eabf2cf1d5bd0db33c616c8.sample"]
[params]
@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://qed775b4j1gg"
path="res://.godot/imported/220196__gameaudio__click-wooden-2.wav-372f3d1af9c561baf2360e14b5b7050b.sample"
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-372f3d1af9c561baf2360e14b5b7050b.sample"]
source_file="res://Sounds/220196__gameaudio__click-wooden-2.wav"
dest_files=["res://.godot/imported/220196__gameaudio__click-wooden-2.wav-45bb63efefaf817b60155beec9343d74.sample"]
[params]
@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://bqtk1adk8umbx"
path="res://.godot/imported/220197__gameaudio__click-basic.wav-61aa24994882b9ab5848ecead3d7aba9.sample"
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-61aa24994882b9ab5848ecead3d7aba9.sample"]
source_file="res://Sounds/220197__gameaudio__click-basic.wav"
dest_files=["res://.godot/imported/220197__gameaudio__click-basic.wav-9f173e2b7206278e95710ab077d62c32.sample"]
[params]
@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://ysgfx76jkx2q"
path="res://.godot/imported/220198__gameaudio__click-with-two-parts.wav-23adbbdcc4d995994bf9700f6b6e244d.sample"
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-23adbbdcc4d995994bf9700f6b6e244d.sample"]
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]
@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://dtyh22ccebiv5"
path="res://.godot/imported/220199__gameaudio__click-higher.wav-0ea6f7a1d32e528aace111f0ce8b9631.sample"
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-0ea6f7a1d32e528aace111f0ce8b9631.sample"]
source_file="res://Sounds/220199__gameaudio__click-higher.wav"
dest_files=["res://.godot/imported/220199__gameaudio__click-higher.wav-d1c1550d99a0cc873012c4010877005b.sample"]
[params]
@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://cywjbbeintjew"
path="res://.godot/imported/220208__gameaudio__click-pop-two-part.wav-9e40de3d9bebd124d0fe54a4f4cc4db9.sample"
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-9e40de3d9bebd124d0fe54a4f4cc4db9.sample"]
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]
@@ -3,12 +3,12 @@
importer="wav"
type="AudioStreamWAV"
uid="uid://claw3d2wnyr6a"
path="res://.godot/imported/220212__gameaudio__ping-bing.wav-04a5460471fa8fe82fe5d9bc5d946bb0.sample"
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-04a5460471fa8fe82fe5d9bc5d946bb0.sample"]
source_file="res://Sounds/220212__gameaudio__ping-bing.wav"
dest_files=["res://.godot/imported/220212__gameaudio__ping-bing.wav-2a1049829e71a0034c7e8d18745663f1.sample"]
[params]
+3 -3
View File
@@ -3,12 +3,12 @@
importer="mp3"
type="AudioStreamMP3"
uid="uid://clkjwcawdqvta"
path="res://.godot/imported/money.mp3-e3eae11b0c1923c268268b900bde9157.mp3str"
path="res://.godot/imported/money.mp3-95c717b8402507d80974f4f4287b0b63.mp3str"
[deps]
source_file="res://sounds/money.mp3"
dest_files=["res://.godot/imported/money.mp3-e3eae11b0c1923c268268b900bde9157.mp3str"]
source_file="res://Sounds/money.mp3"
dest_files=["res://.godot/imported/money.mp3-95c717b8402507d80974f4f4287b0b63.mp3str"]
[params]
+3 -3
View File
@@ -1,9 +1,9 @@
[gd_scene format=3 uid="uid://c6rift56ql3f8"]
[ext_resource type="Script" uid="uid://0y6wnjcsum6" path="res://stations/item_dispenser.gd" id="1_myl3s"]
[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/burger_buns.tscn" id="2_1q74o"]
[ext_resource type="PackedScene" uid="uid://mpapt5mkbuao" path="res://prefabs/slide_off_dome.tscn" id="4_rf1b2"]
[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
+1 -1
View File
@@ -1,7 +1,7 @@
[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"]
[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)
+19 -111
View File
@@ -1,19 +1,11 @@
[gd_scene format=3 uid="uid://j7caslh27nor"]
[ext_resource type="Script" uid="uid://bsn8vhv5adxdo" path="res://stations/hob.gd" id="1_34vy5"]
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="2_xy5oe"]
[ext_resource type="AudioStream" uid="uid://bqtk1adk8umbx" path="res://sounds/220197__gameaudio__click-basic.wav" id="3_aqrs6"]
[ext_resource type="Material" uid="uid://d1djvskv4n4m3" path="res://textures/hob_off.tres" id="4_34vy5"]
[ext_resource type="PackedScene" uid="uid://bxbocxdaayvwx" path="res://ui/progress_bar.tscn" id="5_m4alr"]
[ext_resource type="Material" uid="uid://db7c7w4apwti7" path="res://textures/hob_on.tres" id="6_xy5oe"]
[ext_resource type="Script" uid="uid://bu0g23cfrqy0m" path="res://stations/station_movement.gd" id="7_tjce5"]
[ext_resource type="Script" uid="uid://bfrlpbsqg5lqr" path="res://addons/godot-xr-tools/objects/pickable.gd" id="8_f2m64"]
[ext_resource type="PackedScene" uid="uid://c25yxb0vt53vc" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_left.tscn" id="9_7mmlt"]
[ext_resource type="Animation" uid="uid://db62hs5s4n2b3" path="res://addons/godot-xr-tools/hands/animations/left/Grip 4.res" id="10_jnfpx"]
[ext_resource type="Script" uid="uid://dvobm6vcfnqe8" path="res://addons/godot-xr-tools/hands/poses/hand_pose_settings.gd" id="11_4me6o"]
[ext_resource type="PackedScene" uid="uid://ctw7nbntd5pcj" path="res://addons/godot-xr-tools/objects/grab_points/grab_point_hand_right.tscn" id="12_tlp5u"]
[ext_resource type="Animation" uid="uid://d1xnpyc08njjx" path="res://addons/godot-xr-tools/hands/animations/right/Grip 4.res" id="13_vttml"]
[ext_resource type="Script" uid="uid://bwd0pe2udb5xo" path="res://Net/net_pickable.gd" id="14_glc7b"]
[ext_resource type="Script" uid="uid://bsn8vhv5adxdo" path="res://Stations/hob.gd" id="1_7jc4g"]
[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_kdxnr"]
size = Vector3(0.6, 1, 0.6)
@@ -23,23 +15,6 @@ size = Vector3(0.6, 0.12802735, 0.6)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_gkb3v"]
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_np_hob"]
properties/0/path = NodePath(".:time_cooked")
properties/0/spawn = true
properties/0/replication_mode = 1
properties/1/path = NodePath(".:cooking_result_time")
properties/1/spawn = true
properties/1/replication_mode = 1
properties/2/path = NodePath(".:cooking_result")
properties/2/spawn = true
properties/2/replication_mode = 1
properties/3/path = NodePath(".:position")
properties/3/spawn = true
properties/3/replication_mode = 1
properties/4/path = NodePath(".:rotation")
properties/4/spawn = true
properties/4/replication_mode = 1
[sub_resource type="Animation" id="Animation_7uuqv"]
length = 0.001
tracks/0/type = "value"
@@ -52,7 +27,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("4_34vy5")]
"values": [ExtResource("4_8qpxk")]
}
tracks/1/type = "value"
tracks/1/imported = false
@@ -64,7 +39,7 @@ tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("4_34vy5")]
"values": [ExtResource("4_8qpxk")]
}
tracks/2/type = "value"
tracks/2/imported = false
@@ -76,7 +51,7 @@ tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("4_34vy5")]
"values": [ExtResource("4_8qpxk")]
}
tracks/3/type = "value"
tracks/3/imported = false
@@ -116,7 +91,7 @@ tracks/0/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("6_xy5oe")]
"values": [ExtResource("6_m7l4u")]
}
tracks/1/type = "value"
tracks/1/imported = false
@@ -128,7 +103,7 @@ tracks/1/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("6_xy5oe")]
"values": [ExtResource("6_m7l4u")]
}
tracks/2/type = "value"
tracks/2/imported = false
@@ -140,7 +115,7 @@ tracks/2/keys = {
"times": PackedFloat32Array(0),
"transitions": PackedFloat32Array(1),
"update": 1,
"values": [ExtResource("6_xy5oe")]
"values": [ExtResource("6_m7l4u")]
}
tracks/3/type = "value"
tracks/3/imported = false
@@ -173,39 +148,8 @@ _data = {
&"hob": SubResource("Animation_6oyg1")
}
[sub_resource type="BoxShape3D" id="BoxShape3D_m1xbq"]
size = Vector3(0.1, 0.1, 0.1)
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_24d3s"]
albedo_color = Color(0.1764706, 1, 1, 1)
[sub_resource type="BoxMesh" id="BoxMesh_vlqg6"]
material = SubResource("StandardMaterial3D_24d3s")
size = Vector3(0.1, 0.1, 0.1)
[sub_resource type="Resource" id="Resource_lc22d"]
script = ExtResource("11_4me6o")
closed_pose = ExtResource("10_jnfpx")
metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[sub_resource type="Resource" id="Resource_qyiot"]
script = ExtResource("11_4me6o")
closed_pose = ExtResource("13_vttml")
metadata/_custom_type_script = "uid://dvobm6vcfnqe8"
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_np_cube"]
properties/0/path = NodePath(".:position")
properties/0/spawn = false
properties/0/replication_mode = 1
properties/1/path = NodePath(".:quaternion")
properties/1/spawn = false
properties/1/replication_mode = 1
properties/2/path = NodePath("NetPickable:net_held_by")
properties/2/spawn = true
properties/2/replication_mode = 1
[node name="Hob" type="StaticBody3D" unique_id=1687971542 groups=["station"]]
script = ExtResource("1_34vy5")
script = ExtResource("1_7jc4g")
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1283846023]
shape = SubResource("BoxShape3D_kdxnr")
@@ -214,8 +158,8 @@ shape = SubResource("BoxShape3D_kdxnr")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.5270121, 0)
collision_layer = 65536
collision_mask = 65540
script = ExtResource("2_xy5oe")
stash_sound = ExtResource("3_aqrs6")
script = ExtResource("2_er1dp")
stash_sound = ExtResource("3_6oyg1")
snap_mode = 1
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
@@ -244,21 +188,21 @@ transform = Transform3D(0.8943019, 0, 0, 0, 0.8943019, 0, 0, 0, 0.8943019, 0, 0.
inner_radius = 0.09153879
outer_radius = 0.120084204
sides = 32
material = ExtResource("4_34vy5")
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_34vy5")
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_34vy5")
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)
@@ -307,10 +251,7 @@ size = Vector3(0.55, 0.835, 0.072)
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="Sync" type="MultiplayerSynchronizer" parent="." unique_id=768992259]
replication_config = SubResource("SceneReplicationConfig_np_hob")
[node name="ProgressBar3D" parent="." unique_id=654673176 instance=ExtResource("5_m4alr")]
[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]
@@ -321,36 +262,3 @@ 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
[node name="Movement" type="Node3D" parent="." unique_id=1818087979]
script = ExtResource("7_tjce5")
[node name="MoveHandle" type="RigidBody3D" parent="Movement" unique_id=1675596942 groups=["platalbe_item"]]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.92786825, 0)
collision_layer = 4
collision_mask = 196615
axis_lock_linear_y = true
axis_lock_angular_x = true
axis_lock_angular_z = true
mass = 0.004
gravity_scale = 0.0
linear_damp = 100.0
script = ExtResource("8_f2m64")
[node name="CollisionShape3D" type="CollisionShape3D" parent="Movement/MoveHandle" unique_id=1023455695]
shape = SubResource("BoxShape3D_m1xbq")
[node name="MeshInstance3D" type="MeshInstance3D" parent="Movement/MoveHandle" unique_id=1223689787]
mesh = SubResource("BoxMesh_vlqg6")
[node name="GrabPointHandLeft" parent="Movement/MoveHandle" unique_id=1571481674 instance=ExtResource("9_7mmlt")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.067650706, 0.04601878, -0.08606844)
hand_pose = SubResource("Resource_lc22d")
[node name="GrabPointHandRight" parent="Movement/MoveHandle" unique_id=514404634 instance=ExtResource("12_tlp5u")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.06531982, 0.042291984, -0.08604182)
hand_pose = SubResource("Resource_qyiot")
[node name="NetPickable" type="MultiplayerSynchronizer" parent="Movement/MoveHandle" unique_id=1858332513]
replication_config = SubResource("SceneReplicationConfig_np_cube")
script = ExtResource("14_glc7b")
+1
View File
@@ -1,3 +1,4 @@
[gd_scene format=3 uid="uid://cwwnbx5uat3fw"]
[node name="CSGBox3D" type="CSGBox3D" unique_id=725518829]
+2 -2
View File
@@ -7,8 +7,8 @@ func _ready() -> void:
snap_zone.has_picked_up.connect(_makeDirty)
func _makeDirty(item) -> void:
#if not NetworkManager.owns_world():
#return
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")
+1 -1
View File
@@ -1,6 +1,6 @@
[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://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"]
+7 -10
View File
@@ -1,6 +1,6 @@
extends StaticBody3D
const RECIPE_MANAGER = preload("res://scripts/recipe_Manager.gd")
const RECIPE_MANAGER = preload("res://RecipeManager.gd")
@export var cook_speed = 1
@onready var snap_zone: XRToolsSnapZone = $XRToolsSnapZone
@@ -70,7 +70,7 @@ func _refresh_display() -> void:
func _on_object_picked_up(_item) -> void:
print("Hob: object picked up: ", _item)
# Find the FoodItem in held object
# 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")
@@ -94,8 +94,8 @@ func _on_object_dropped() -> void:
func convert_held_to_item(_item: String) -> void:
#if not NetworkManager.owns_world():
#return
if not NetworkManager.owns_world():
return
print("Hob converting ", _item)
var old_pickable = snap_zone.picked_up_object
@@ -106,15 +106,12 @@ func convert_held_to_item(_item: String) -> void:
# 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 = NetworkManager.spawn_item(RECIPE_MANAGER.get_item_scene(_item).resource_path, original_transform)
var new_scene_instance = RECIPE_MANAGER.get_item_scene(_item).instantiate()
get_tree().root.add_child(new_scene_instance)
new_scene_instance.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()
old_pickable.queue_free()
NetworkManager.despawn_item(old_pickable)
snap_zone.pick_up_object(new_scene_instance)
+3 -6
View File
@@ -13,11 +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 NetworkManager.owns_world():
return
if not snap_zone.picked_up_object:
#var new_item = NetworkManager.spawn_item(item_scene.resource_path, snap_zone.global_transform)
var new_item = item_scene.instantiate()
get_tree().root.add_child(new_item)
new_item.transform = snap_zone.global_transform
var new_item = NetworkManager.spawn_item(item_scene.resource_path, snap_zone.global_transform)
snap_zone.pick_up_object(new_item)
+3 -3
View File
@@ -1,9 +1,9 @@
[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://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"]
[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
+4 -4
View File
@@ -1,10 +1,10 @@
[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://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"]
[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
+2 -13
View File
@@ -1,8 +1,8 @@
[gd_scene format=4 uid="uid://dvrk268s7gkxh"]
[ext_resource type="Script" uid="uid://byh5j25mwt3oc" path="res://stations/sink.gd" id="1_7hh4b"]
[ext_resource type="Script" uid="uid://byh5j25mwt3oc" path="res://Stations/sink.gd" id="1_7hh4b"]
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="2_3ocod"]
[ext_resource type="PackedScene" uid="uid://bxbocxdaayvwx" path="res://ui/progress_bar.tscn" id="4_1pinr"]
[ext_resource type="PackedScene" uid="uid://bxbocxdaayvwx" path="res://UI/progress_bar.tscn" id="4_1pinr"]
[sub_resource type="BoxShape3D" id="BoxShape3D_l02yb"]
size = Vector3(0.6, 0.9610596, 0.6)
@@ -15,14 +15,6 @@ stereo = true
[sub_resource type="BoxShape3D" id="BoxShape3D_ai6d4"]
size = Vector3(0.5, 0.128, 0.5)
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_np_sink"]
properties/0/path = NodePath(".:time_washed")
properties/0/spawn = true
properties/0/replication_mode = 1
properties/1/path = NodePath(".:is_washing")
properties/1/spawn = true
properties/1/replication_mode = 1
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_0gbf8"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_bvwq1"]
@@ -234,9 +226,6 @@ transform = Transform3D(1, 0, 0, 0, 0.9367828, -0.34991136, 0, 0.34991136, 0.936
operation = 2
size = Vector3(1, 1.2053223, 0.352417)
[node name="Sync" type="MultiplayerSynchronizer" parent="." unique_id=1601242574]
replication_config = SubResource("SceneReplicationConfig_np_sink")
[node name="ProgressBar3D" parent="." unique_id=654673176 instance=ExtResource("4_1pinr")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0.8164611, -0.035980098)
-18
View File
@@ -1,18 +0,0 @@
extends Node3D
@onready var move_handle: XRToolsPickable = $MoveHandle
@onready var move_handle_rigid: RigidBody3D = $MoveHandle
@onready var hob: StaticBody3D = $".."
# Called when the node enters the scene tree for the first time.
func _ready() -> void:
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta: float) -> void:
move_handle_rigid.linear_velocity = Vector3.ZERO
move_handle_rigid.angular_velocity = Vector3.ZERO
hob.global_position.x = move_handle.global_position.x
hob.global_position.z = move_handle.global_position.z
-1
View File
@@ -1 +0,0 @@
uid://bu0g23cfrqy0m
+60 -46
View File
@@ -1,8 +1,7 @@
class_name Table
extends StaticBody3D
const GAME_MANAGER = preload("res://scripts/game_manager.gd")
const GAME_MANAGER = preload("res://GameManager.gd")
@export var thinking_duration: float = 3.0
@export var primary_duration: float = 60.0
@@ -30,16 +29,21 @@ enum TableState {
EATING
}
## State is server-authoritative and synced (see table.tscn's Sync node);
## state transitions only ever run where NetworkManager.owns_world() is true
## (the whole station's _process is gated off elsewhere for non-owners, see
## NetworkManager._gate_station). The setters below just refresh the display,
## so both the server (via _setState) and clients (via incoming sync) show
## the same text. Use _setState(), never assign _state directly.
var _state: TableState = TableState.EMPTY: set = _set_state
var _state_time: float = 0.0: set = _set_state_time
var _state_duration: float = 0.0 # set in _set_state_time
var _unsatisfied_orders: Array[String] = []: set = _set_unsatisfied_orders
## State is server-authoritative and replicated. Transitions only ever run where
## NetworkManager.owns_world() is true — the whole station's _process is gated
## off for non-owners (NetWorld._gate) — and the setters below just refresh the
## display, so the server (via _setState) and clients (via incoming sync) show
## the same thing. Use _setState(), never assign `state` directly.
##
## These are deliberately not underscore-prefixed: that prefix is what marks a
## variable as private and unreplicated (see NetReplication), and this is exactly
## the state that has to reach every peer. state_duration is replicated for the
## same reason — the progress bar divides by it, and on a client that never ran a
## transition it would otherwise still be zero.
var state: TableState = TableState.EMPTY: set = _set_state
var state_time: float = 0.0: set = _set_state_time
var state_duration: float = 0.0 # set in _setState alongside state_time
var unsatisfied_orders: Array[String] = []: set = _set_unsatisfied_orders
func _ready() -> void:
@@ -75,7 +79,7 @@ func _ready() -> void:
func _on_object_picked_up(_item) -> void:
print("Table: object picked up: ", _item)
if _state == TableState.EATING:
if state == TableState.EATING:
return
_absorb_item_if_correct(_item)
@@ -99,14 +103,21 @@ func _absorb_item_if_correct(_item: Node) -> void:
# Absorm items from the plate we want
for food_item in plate.container.contained_items:
print("Table: held a plate with FoodItem: ", food_item.id)
if food_item.id in _unsatisfied_orders:
if food_item.id in unsatisfied_orders:
print("Table: held FoodItem is in unsatisfied orders, removing it")
_unsatisfied_orders.erase(food_item.id)
if _unsatisfied_orders.size() > 0 and _state != TableState.EATING:
# Reassign rather than mutate in place. This property has a setter that
# refreshes the label, and mutating an array never fires it — so the
# peer that actually served the food would be the one peer whose table
# still showed the order outstanding. duplicate() also preserves the
# Array[String] typing the property requires.
var remaining := unsatisfied_orders.duplicate()
remaining.erase(food_item.id)
unsatisfied_orders = remaining
if unsatisfied_orders.size() > 0 and state != TableState.EATING:
_setState(TableState.WAITING_FRIEND)
# Table has everything it wants. Start eating
elif _unsatisfied_orders.is_empty() and _state != TableState.EATING:
elif unsatisfied_orders.is_empty() and state != TableState.EATING:
GAME_MANAGER.money += food_item.sell_value
audio_player.stream = money_sound
audio_player.play()
@@ -115,7 +126,7 @@ func _absorb_item_if_correct(_item: Node) -> void:
func place_order() -> void:
print("Table: place_order()")
var new_orders = _unsatisfied_orders.duplicate()
var new_orders = unsatisfied_orders.duplicate()
new_orders.append(GAME_MANAGER.get_random_meal())
new_orders.append(GAME_MANAGER.get_random_meal())
_set_unsatisfied_orders(new_orders)
@@ -123,7 +134,9 @@ func place_order() -> void:
func satisfyAllOrders() -> void:
print("Table: satisfyAllOrders()")
_unsatisfied_orders.clear()
# Assigned, not cleared in place, for the same reason as in
# _absorb_item_if_correct: clear() would not fire the setter.
unsatisfied_orders = []
clearAllPlates()
_setState(TableState.EMPTY)
@@ -147,42 +160,42 @@ func _set_snap_zones_enabled(value: bool) -> void:
## Server-only state transition: sets the new state's timer and assigns
## _state (whose setter refreshes the display on every peer).
## state (whose setter refreshes the display on every peer).
func _setState(newState: TableState) -> void:
print("Table set _state: ", TableState.keys()[newState])
print("Table set state: ", TableState.keys()[newState])
match newState:
TableState.EMPTY:
_state_time = 5.0
_state_duration = 5.0
state_time = 5.0
state_duration = 5.0
TableState.THINKING:
_state_time = thinking_duration
_state_duration = thinking_duration # Can't be done in _set_state(), will set duration inside timer
state_time = thinking_duration
state_duration = thinking_duration # Can't be done in _set_state(), will set duration inside timer
TableState.WAITING_PRIMARY:
_state_time = primary_duration
_state_duration = primary_duration
state_time = primary_duration
state_duration = primary_duration
TableState.WAITING_FRIEND:
_state_time = friend_duration
_state_duration = friend_duration
state_time = friend_duration
state_duration = friend_duration
TableState.EATING:
_state_time = eating_duration
_state_duration = eating_duration
state_time = eating_duration
state_duration = eating_duration
_set_snap_zones_enabled(false)
_state = newState
state = newState
## Pure presentation, driven off the current (locally authoritative or
## synced-from-server) state. Runs on every peer.
func _refresh_display() -> void:
# _state, _state_time and _unsatisfied_orders are replicated with spawn=true,
# state, state_time and unsatisfied_orders are replicated with spawn=true,
# and MultiplayerSpawner applies a spawn payload BEFORE the node enters the
# tree — so these setters fire while the @onready children below are still
# null. Bail out until _ready() has resolved them; _ready() calls back in
# once it has, so nothing that arrived early is lost.
if not progress_bar or not label_3d or not label_3d_time:
return
match _state:
match state:
TableState.EMPTY:
progress_bar.set_bar_visible(false)
label_3d.text = "empty"
@@ -190,47 +203,48 @@ func _refresh_display() -> void:
progress_bar.set_bar_visible(false)
label_3d.text = lbl_thinking
TableState.WAITING_PRIMARY:
label_3d.text = "%s\n%s" % [TableState.keys()[_state], "\n".join(_unsatisfied_orders)]
label_3d.text = "%s\n%s" % [TableState.keys()[state], "\n".join(unsatisfied_orders)]
progress_bar.set_bar_visible(true)
progress_bar.override_fill_color(Color.RED if _state_time < 10 else Color.YELLOW)
progress_bar.override_fill_color(Color.RED if state_time < 10 else Color.YELLOW)
TableState.WAITING_FRIEND:
label_3d.text = "%s\n%s" % [TableState.keys()[_state], "\n".join(_unsatisfied_orders)]
label_3d.text = "%s\n%s" % [TableState.keys()[state], "\n".join(unsatisfied_orders)]
progress_bar.set_bar_visible(true)
progress_bar.override_fill_color(Color.RED if _state_time < 5 else Color.YELLOW)
progress_bar.override_fill_color(Color.RED if state_time < 5 else Color.YELLOW)
TableState.EATING:
label_3d.text = lbl_eating
progress_bar.set_bar_visible(false)
label_3d_time.text = "%.1f" % _state_time
progress_bar.set_progress(clampf(float(_state_time) / _state_duration, 0.0, 1.0))
label_3d_time.text = "%.1f" % state_time
var progress := state_time / state_duration if state_duration > 0.0 else 0.0
progress_bar.set_progress(clampf(progress, 0.0, 1.0))
func _set_state(value: TableState) -> void:
_state = value
state = value
_refresh_display()
func _set_state_time(value: float) -> void:
_state_time = value
state_time = value
_refresh_display()
func _set_unsatisfied_orders(value: Array[String]) -> void:
_unsatisfied_orders = value
unsatisfied_orders = value
_refresh_display()
func _process(delta: float) -> void:
# Wait for state to finish
if _state_time > 0.0:
_state_time = max(0.0, _state_time - delta)
if state_time > 0.0:
state_time = max(0.0, state_time - delta)
return
if GAME_MANAGER.game_state == GAME_MANAGER.GameState.GAME_OVER:
return
# When state timer is finished, do this stuff before moving to next state
match _state:
match state:
TableState.EMPTY:
print("Table State EMPTY finish")
_setState(TableState.THINKING)
+16 -30
View File
@@ -1,10 +1,10 @@
[gd_scene format=3 uid="uid://caf0xanmxbshy"]
[ext_resource type="Script" uid="uid://caeikc7e3igkd" path="res://stations/table.gd" id="1_aecp7"]
[ext_resource type="AudioStream" uid="uid://clkjwcawdqvta" path="res://sounds/money.mp3" id="2_5mi7y"]
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="3_03yai"]
[ext_resource type="AudioStream" uid="uid://daiv8ubwdbidf" path="res://sounds/220195__gameaudio__click-wooden-1.wav" id="4_grjry"]
[ext_resource type="PackedScene" uid="uid://bxbocxdaayvwx" path="res://ui/progress_bar.tscn" id="5_sldpd"]
[ext_resource type="Script" uid="uid://caeikc7e3igkd" path="res://Stations/table.gd" id="1_2vcpj"]
[ext_resource type="Script" uid="uid://cquqe4f1m1sw6" path="res://addons/godot-xr-tools/objects/snap_zone.gd" id="1_8j1nt"]
[ext_resource type="AudioStream" uid="uid://clkjwcawdqvta" path="res://Sounds/money.mp3" id="2_jslhm"]
[ext_resource type="AudioStream" uid="uid://daiv8ubwdbidf" path="res://Sounds/220195__gameaudio__click-wooden-1.wav" id="3_0s6ir"]
[ext_resource type="PackedScene" uid="uid://bxbocxdaayvwx" path="res://UI/progress_bar.tscn" id="3_kjf1i"]
[sub_resource type="BoxShape3D" id="BoxShape3D_24d3s"]
size = Vector3(0.6, 1, 0.6)
@@ -15,20 +15,9 @@ radius = 0.6
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_24d3s"]
albedo_color = Color(0.31, 0.21576, 0.1333, 1)
[sub_resource type="SceneReplicationConfig" id="SceneReplicationConfig_np_table"]
properties/0/path = NodePath(".:_state")
properties/0/spawn = true
properties/0/replication_mode = 1
properties/1/path = NodePath(".:_state_time")
properties/1/spawn = true
properties/1/replication_mode = 1
properties/2/path = NodePath(".:_unsatisfied_orders")
properties/2/spawn = true
properties/2/replication_mode = 1
[node name="Table" type="StaticBody3D" unique_id=1863572470 groups=["station"]]
script = ExtResource("1_aecp7")
money_sound = ExtResource("2_5mi7y")
script = ExtResource("1_2vcpj")
money_sound = ExtResource("2_jslhm")
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=228053941]
shape = SubResource("BoxShape3D_24d3s")
@@ -37,8 +26,8 @@ shape = SubResource("BoxShape3D_24d3s")
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.31874347, 0.5270121, 0)
collision_layer = 65536
collision_mask = 65540
script = ExtResource("3_03yai")
stash_sound = ExtResource("4_grjry")
script = ExtResource("1_8j1nt")
stash_sound = ExtResource("3_0s6ir")
snap_mode = 1
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
@@ -53,8 +42,8 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.013531357, -0.015141487, 0
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.34755045, 0.5270121, 0)
collision_layer = 65536
collision_mask = 65540
script = ExtResource("3_03yai")
stash_sound = ExtResource("4_grjry")
script = ExtResource("1_8j1nt")
stash_sound = ExtResource("3_0s6ir")
snap_mode = 1
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
@@ -69,8 +58,8 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.013531357, -0.015141487, 0
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.012355864, 0.5270121, 0.33038777)
collision_layer = 65536
collision_mask = 65540
script = ExtResource("3_03yai")
stash_sound = ExtResource("4_grjry")
script = ExtResource("1_8j1nt")
stash_sound = ExtResource("3_0s6ir")
snap_mode = 1
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
@@ -85,8 +74,8 @@ transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.013531357, -0.015141487, 0
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.022546828, 0.5270121, -0.36528283)
collision_layer = 65536
collision_mask = 65540
script = ExtResource("3_03yai")
stash_sound = ExtResource("4_grjry")
script = ExtResource("1_8j1nt")
stash_sound = ExtResource("3_0s6ir")
snap_mode = 1
metadata/_custom_type_script = "uid://cquqe4f1m1sw6"
@@ -189,10 +178,7 @@ pixel_size = 0.003
billboard = 2
text = "20.1s"
[node name="Sync" type="MultiplayerSynchronizer" parent="." unique_id=2000411505]
replication_config = SubResource("SceneReplicationConfig_np_table")
[node name="ProgressBar3D" parent="." unique_id=654673176 instance=ExtResource("5_sldpd")]
[node name="ProgressBar3D" parent="." unique_id=654673176 instance=ExtResource("3_kjf1i")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 1.3676775, 0)
y_billboard = true
+59
View File
@@ -0,0 +1,59 @@
- Move recipes into a Yaml file that is read, and handles symetry through a Static manager class?
A `FoodItem` has an ID.
Example:
```yaml
combining: # The combinging of two items, entries always have a list of exactly two items
cooked_burger:
- cooked_burger
- burger_buns
dough:
- flour
- water
cooking:
cooked_burger:
ingredient: raw_burger
time: 3
charcoal:
ingredient: cooked_burger
time: 4
charcoal:
ingredient: toast
time: 2
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
salad:
has_tomato: sliced_tomato
has_olives: olives
chopping:
salad:
ingredient: lettuce
work: 50 # Wave arms faster makes work go faster
rolling:
pie_base:
ingredient: dough
work: 80
```
```py
on_area_enter(other):
var result = RecipeManager.getCombination(my_id, other_id)
if result:
convertInto(result)
```
- Counters are stations like hobs that convert items by chopping, rolling ect depending on `RecipeManager`,
and only converts items after hand gestures are done enough?
- Plates are lists of `FoodItems`?
Plate[`Hamburger`] accepts `Chips` => Plate[`Hamburger`, `Chips`]
Plate[`Hamburger`, `Chips`] accepts `Cheese` => Plate[`Hamburger(Cheese=true)`, `Chips`]
The logic for combining has to be expanded for plates.
- Plates have a property `is_dirty` they get after a customer clears the plate, and is disabled after being processed in `Sink`
+3 -3
View File
@@ -3,7 +3,7 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://cexxfyw03hr81"
path.s3tc="res://.godot/imported/1.png-28d6e3d31e46c95f0dea1abf906c0f74.s3tc.ctex"
path.s3tc="res://.godot/imported/1.png-1282cd758f0d245fa29065df8c6fe28d.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
@@ -11,8 +11,8 @@ metadata={
[deps]
source_file="res://textures/1.png"
dest_files=["res://.godot/imported/1.png-28d6e3d31e46c95f0dea1abf906c0f74.s3tc.ctex"]
source_file="res://Textures/1.png"
dest_files=["res://.godot/imported/1.png-1282cd758f0d245fa29065df8c6fe28d.s3tc.ctex"]
[params]
+3 -3
View File
@@ -3,7 +3,7 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://cxsy4fi0iv1dx"
path.s3tc="res://.godot/imported/2.png-3b4d648e04c4a84e8b8f6c622069553c.s3tc.ctex"
path.s3tc="res://.godot/imported/2.png-58b544529b3c8efe890c8b21f147e810.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
@@ -11,8 +11,8 @@ metadata={
[deps]
source_file="res://textures/2.png"
dest_files=["res://.godot/imported/2.png-3b4d648e04c4a84e8b8f6c622069553c.s3tc.ctex"]
source_file="res://Textures/2.png"
dest_files=["res://.godot/imported/2.png-58b544529b3c8efe890c8b21f147e810.s3tc.ctex"]
[params]
+3 -3
View File
@@ -3,7 +3,7 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://cxeeadx0c2ygg"
path.s3tc="res://.godot/imported/3.png-ff3babb0d8b4fdc49e4a4961a679d180.s3tc.ctex"
path.s3tc="res://.godot/imported/3.png-ea971c9bd22bfef88dcd66b7417b5707.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
@@ -11,8 +11,8 @@ metadata={
[deps]
source_file="res://textures/3.png"
dest_files=["res://.godot/imported/3.png-ff3babb0d8b4fdc49e4a4961a679d180.s3tc.ctex"]
source_file="res://Textures/3.png"
dest_files=["res://.godot/imported/3.png-ea971c9bd22bfef88dcd66b7417b5707.s3tc.ctex"]
[params]
+3 -3
View File
@@ -3,7 +3,7 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://xpf60mxi3cf"
path.s3tc="res://.godot/imported/4.png-7c86e7f37dd6d943dc49fdd7899e8cb6.s3tc.ctex"
path.s3tc="res://.godot/imported/4.png-352134ccf44954619410b58ec193bd16.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
@@ -11,8 +11,8 @@ metadata={
[deps]
source_file="res://textures/4.png"
dest_files=["res://.godot/imported/4.png-7c86e7f37dd6d943dc49fdd7899e8cb6.s3tc.ctex"]
source_file="res://Textures/4.png"
dest_files=["res://.godot/imported/4.png-352134ccf44954619410b58ec193bd16.s3tc.ctex"]
[params]
+3 -3
View File
@@ -3,7 +3,7 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://b7n8d4krwbcvl"
path.s3tc="res://.godot/imported/5.png-b386ff019a5e522d985ab44e8f6c88d9.s3tc.ctex"
path.s3tc="res://.godot/imported/5.png-be0d39347a68c1d063c92edeb31b0a20.s3tc.ctex"
metadata={
"imported_formats": ["s3tc_bptc"],
"vram_texture": true
@@ -11,8 +11,8 @@ metadata={
[deps]
source_file="res://textures/5.png"
dest_files=["res://.godot/imported/5.png-b386ff019a5e522d985ab44e8f6c88d9.s3tc.ctex"]
source_file="res://Textures/5.png"
dest_files=["res://.godot/imported/5.png-be0d39347a68c1d063c92edeb31b0a20.s3tc.ctex"]
[params]
+3 -3
View File
@@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://eqp04wybmg"
path="res://.godot/imported/devTex.svg-246e77b8f216572aac74f8f3d27707b4.ctex"
path="res://.godot/imported/devTex.svg-7096dfe1fce7d6bfeb43d4ba1bd108ed.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/devTex.svg"
dest_files=["res://.godot/imported/devTex.svg-246e77b8f216572aac74f8f3d27707b4.ctex"]
source_file="res://Textures/devTex.svg"
dest_files=["res://.godot/imported/devTex.svg-7096dfe1fce7d6bfeb43d4ba1bd108ed.ctex"]
[params]
+1 -1
View File
@@ -1,6 +1,6 @@
[gd_resource type="StandardMaterial3D" format=3 uid="uid://cmia50cfqxxo4"]
[ext_resource type="Texture2D" uid="uid://eqp04wybmg" path="res://textures/devTex.svg" id="1_3jxsn"]
[ext_resource type="Texture2D" uid="uid://eqp04wybmg" path="res://Textures/devTex.svg" id="1_3jxsn"]
[sub_resource type="StandardMaterial3D" id="StandardMaterial3D_0gbf8"]
transparency = 1
+3 -3
View File
@@ -3,15 +3,15 @@
importer="texture"
type="CompressedTexture2D"
uid="uid://hfkxs3ncjc4m"
path="res://.godot/imported/NightSkyHDRI009.png-30c624de99c676c23642a0e7a463453d.ctex"
path="res://.godot/imported/NightSkyHDRI009.png-5fecb5274d03e5767c649d4bae381a39.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://textures/sky/NightSkyHDRI009.png"
dest_files=["res://.godot/imported/NightSkyHDRI009.png-30c624de99c676c23642a0e7a463453d.ctex"]
source_file="res://Textures/sky/NightSkyHDRI009.png"
dest_files=["res://.godot/imported/NightSkyHDRI009.png-5fecb5274d03e5767c649d4bae381a39.ctex"]
[params]

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