asd
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
[ext_resource type="PackedScene" path="res://UI/main_menu_panel.tscn" id="17_panel"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_vlqg6"]
|
||||
size = Vector3(5, 0.1, 5)
|
||||
size = Vector3(115, 0.1, 15)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_24d3s"]
|
||||
material = ExtResource("3_m56cs")
|
||||
|
||||
+9
-119
@@ -3,22 +3,10 @@
|
||||
[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="PackedScene" uid="uid://j7caslh27nor" path="res://Stations/Hob.tscn" id="4_y6cjq"]
|
||||
[ext_resource type="Sky" uid="uid://c1abtpwhdm2d5" path="res://Textures/sky/NightSkyHDRI009_16K.tres" id="5_c3xgf"]
|
||||
[ext_resource type="PackedScene" uid="uid://c0lknik4noobs" path="res://Items/BurgerBuns.tscn" id="6_urxur"]
|
||||
[ext_resource type="PackedScene" uid="uid://c6rift56ql3f8" path="res://Stations/BurgerBunsDispenser.tscn" id="7_3a3tq"]
|
||||
[ext_resource type="PackedScene" uid="uid://bp3v1jl8pctro" path="res://Containers/plate.tscn" id="8_8xmyt"]
|
||||
[ext_resource type="PackedScene" uid="uid://dpot5qie20vf6" path="res://Items/burger.tscn" id="9_6lx3u"]
|
||||
[ext_resource type="PackedScene" uid="uid://b3m2ag8g5rj4r" path="res://Items/hamburger.tscn" id="10_p5bqy"]
|
||||
[ext_resource type="PackedScene" uid="uid://e4i6o5oriecx" path="res://Items/PickupCube.tscn" id="11_jl027"]
|
||||
[ext_resource type="PackedScene" uid="uid://dvrk268s7gkxh" path="res://Stations/sink.tscn" id="12_j3sw5"]
|
||||
[ext_resource type="PackedScene" uid="uid://cnjwtnhwh0i8q" path="res://Stations/dirt_station.tscn" id="13_sbg0f"]
|
||||
[ext_resource type="PackedScene" uid="uid://cfc4ho67u4r5e" path="res://Items/cooked_burger.tscn" id="14_lt5wx"]
|
||||
[ext_resource type="PackedScene" uid="uid://efaec6ymgabo" path="res://Stations/Counter.tscn" id="15_7pgth"]
|
||||
[ext_resource type="PackedScene" uid="uid://caf0xanmxbshy" path="res://Stations/table.tscn" id="16_8yyag"]
|
||||
|
||||
[sub_resource type="BoxShape3D" id="BoxShape3D_vlqg6"]
|
||||
size = Vector3(5, 0.1, 5)
|
||||
size = Vector3(15, 0.1, 15)
|
||||
|
||||
[sub_resource type="BoxMesh" id="BoxMesh_24d3s"]
|
||||
material = ExtResource("3_75ecy")
|
||||
@@ -36,7 +24,7 @@ sdfgi_enabled = true
|
||||
[node name="Main" type="Node3D" unique_id=1312265607]
|
||||
script = ExtResource("1_kdan8")
|
||||
|
||||
[node name="XROrigin3D" parent="." unique_id=2055526621 instance=ExtResource("2_g30gi")]
|
||||
[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,114 +40,16 @@ shape = SubResource("BoxShape3D_vlqg6")
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.00018164515, 0.0006352663, -0.002532661)
|
||||
mesh = SubResource("BoxMesh_24d3s")
|
||||
|
||||
[node name="Hob" parent="." unique_id=1687971542 instance=ExtResource("4_y6cjq")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.29336345, 0.8981018, -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_urxur")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.8162017, 1.6081157, -1.4714175)
|
||||
[node name="WorldContent" type="Node3D" parent="."]
|
||||
|
||||
[node name="BurgerBunsDispenser" parent="." unique_id=1720683779 instance=ExtResource("7_3a3tq")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.832131, 0.40028095, -1.4813508)
|
||||
[node name="Players" type="Node3D" parent="."]
|
||||
|
||||
[node name="Plate" parent="." unique_id=190487773 instance=ExtResource("8_8xmyt")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5717233, 1.5454081, 1.5373346)
|
||||
[node name="ItemsSpawner" type="MultiplayerSpawner" parent="."]
|
||||
spawn_path = NodePath("../WorldContent")
|
||||
|
||||
[node name="burger" parent="." unique_id=1417604760 instance=ExtResource("9_6lx3u")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.6888188, 1.4195822, -1.7110313)
|
||||
|
||||
[node name="burger2" parent="." unique_id=1584460510 instance=ExtResource("9_6lx3u")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.6931299, 1.5300478, -1.71225)
|
||||
|
||||
[node name="burger3" parent="." unique_id=1884095916 instance=ExtResource("9_6lx3u")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.69027674, 1.4969791, -1.7210286)
|
||||
|
||||
[node name="burger4" parent="." unique_id=1844818864 instance=ExtResource("9_6lx3u")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0.69134104, 1.4543622, -1.7210286)
|
||||
|
||||
[node name="Hamburger" parent="." unique_id=761091445 instance=ExtResource("10_p5bqy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.9352558, 1.623975, 1.2447833)
|
||||
|
||||
[node name="PickableObject" parent="." unique_id=1675596942 instance=ExtResource("11_jl027")]
|
||||
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, 0.6225724, 1.4792972, -1.0473135)
|
||||
|
||||
[node name="PickableObject2" parent="." unique_id=713087634 instance=ExtResource("11_jl027")]
|
||||
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.4639391, -1.1673055)
|
||||
|
||||
[node name="PickableObject3" parent="." unique_id=879935619 instance=ExtResource("11_jl027")]
|
||||
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, 0.5142721, 1.4792972, -1.0473135)
|
||||
|
||||
[node name="PickableObject4" parent="." unique_id=198541902 instance=ExtResource("11_jl027")]
|
||||
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, -5.293956e-23, -2.6077032e-08, 1.4901161e-08, 1, 0.5276739, 1.4639391, -1.1673055)
|
||||
|
||||
[node name="Hamburger2" parent="." unique_id=1349934579 instance=ExtResource("10_p5bqy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.9857153, 1.5329368, 0.9472374)
|
||||
|
||||
[node name="PickableObject5" parent="." unique_id=1021333509 instance=ExtResource("11_jl027")]
|
||||
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, 0.73287535, 1.4792972, -1.0473135)
|
||||
|
||||
[node name="PickableObject6" parent="." unique_id=1268843669 instance=ExtResource("11_jl027")]
|
||||
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.4639391, -1.1673055)
|
||||
|
||||
[node name="Sink" parent="." unique_id=2055277359 instance=ExtResource("12_j3sw5")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.3140475, 0.9061539, -1.4941733)
|
||||
|
||||
[node name="DirtStation" parent="." unique_id=160842153 instance=ExtResource("13_sbg0f")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2.0864775, 0.8981018, -1.244947)
|
||||
|
||||
[node name="Plate2" parent="." unique_id=356790445 instance=ExtResource("8_8xmyt")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5730225, 1.499024, 0.59790254)
|
||||
|
||||
[node name="CookedBurger" parent="." unique_id=1127807542 instance=ExtResource("14_lt5wx")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.30671906, 1.4131018, -1.0928738)
|
||||
|
||||
[node name="CookedBurger2" parent="." unique_id=160088590 instance=ExtResource("14_lt5wx")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.30671906, 1.4496142, -1.0928738)
|
||||
|
||||
[node name="CookedBurger3" parent="." unique_id=992183367 instance=ExtResource("14_lt5wx")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.3344773, 1.4398065, -0.7096845)
|
||||
|
||||
[node name="CookedBurger4" parent="." unique_id=1837607086 instance=ExtResource("14_lt5wx")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.30671906, 1.525444, -1.0928738)
|
||||
|
||||
[node name="BurgerBuns2" parent="." unique_id=1210358958 instance=ExtResource("6_urxur")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.3596323, 1.4110342, -0.22482127)
|
||||
|
||||
[node name="PickableObject7" parent="." unique_id=641653545 instance=ExtResource("11_jl027")]
|
||||
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, -1.3556751, 1.4792972, 0.28881657)
|
||||
|
||||
[node name="PickableObject8" parent="." unique_id=1733819363 instance=ExtResource("11_jl027")]
|
||||
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.4639391, 0.16882455)
|
||||
|
||||
[node name="PickableObject9" parent="." unique_id=12419746 instance=ExtResource("11_jl027")]
|
||||
transform = Transform3D(1, 0, -2.2351742e-08, -2.9802322e-08, 1.0000001, 0, -2.6077032e-08, 1.4901161e-08, 1, -1.4639754, 1.4792972, 0.28881657)
|
||||
|
||||
[node name="PickableObject10" parent="." unique_id=313160217 instance=ExtResource("11_jl027")]
|
||||
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.4639391, 0.16882455)
|
||||
|
||||
[node name="Counter" parent="." unique_id=1487893288 instance=ExtResource("15_7pgth")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -0.7124918, 0.90304357, -1.4886917)
|
||||
|
||||
[node name="Counter2" parent="." unique_id=368890752 instance=ExtResource("15_7pgth")]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.7648025, 0.90304357, -0.4458799)
|
||||
|
||||
[node name="Counter3" parent="." unique_id=1498817646 instance=ExtResource("15_7pgth")]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.7648025, 0.90304357, 0.55367994)
|
||||
|
||||
[node name="Counter4" parent="." unique_id=906748771 instance=ExtResource("15_7pgth")]
|
||||
transform = Transform3D(-4.371139e-08, 0, 1, 0, 1, 0, -1, 0, -4.371139e-08, -1.7648025, 0.90304357, 1.5539298)
|
||||
|
||||
[node name="Table" parent="." unique_id=1863572470 instance=ExtResource("16_8yyag")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 1.633146, 0.9030438, 1.1343781)
|
||||
initial_thinking_time = 8.0
|
||||
initial_primary_time = 40.0
|
||||
initial_friend_time = 3.0
|
||||
initial_eating_time = 3.0
|
||||
|
||||
[node name="Hamburger3" parent="." unique_id=369573848 instance=ExtResource("10_p5bqy")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.7201865, 1.5329367, 0.14773655)
|
||||
|
||||
[node name="Plate3" parent="." unique_id=2004250522 instance=ExtResource("8_8xmyt")]
|
||||
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -1.5818124, 1.499024, -0.4634577)
|
||||
[node name="PlayersSpawner" type="MultiplayerSpawner" parent="."]
|
||||
_spawnable_scenes = PackedStringArray("res://Player/net_player.tscn")
|
||||
spawn_path = NodePath("../Players")
|
||||
|
||||
@@ -1,13 +1,21 @@
|
||||
extends Node3D
|
||||
|
||||
## World script for the multiplayer scene. Consumes the host/join request set
|
||||
## by the main menu, and returns to the menu if the session ends.
|
||||
## 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.
|
||||
##
|
||||
## Connection-level only for now: no PlayersSpawner/ItemsSpawner here since the
|
||||
## networked Player/NetPickable scenes aren't ported yet (out of scope for this
|
||||
## change) — peers connect, but avatars/items don't sync.
|
||||
## 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")
|
||||
|
||||
var xr_interface: XRInterface
|
||||
var _populated := false
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
@@ -16,11 +24,60 @@ func _ready() -> void:
|
||||
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)
|
||||
|
||||
# Offline (single player / dev run): owns_world() is already true, so
|
||||
# populate immediately. Online host case is handled by session_started.
|
||||
_populate_world_if_owner()
|
||||
|
||||
NetworkManager.world_ready()
|
||||
|
||||
|
||||
func _exit_tree() -> void:
|
||||
NetworkManager.unregister_world()
|
||||
|
||||
|
||||
func _on_session_started(_is_server: bool) -> void:
|
||||
_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 not NetworkManager.owns_world() or _populated:
|
||||
return
|
||||
_populated = true
|
||||
GameManager.meals_in_play = ["hamburger"]
|
||||
for d in WorldLayout.get_stations():
|
||||
NetworkManager.spawn_item(d["scene"], d["xform"], d["name"], d["props"])
|
||||
for d in WorldLayout.get_items():
|
||||
NetworkManager.spawn_item(d["scene"], d["xform"], d["name"], d["props"])
|
||||
|
||||
|
||||
## 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)
|
||||
|
||||
|
||||
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()
|
||||
|
||||
|
||||
func _on_session_ended() -> void:
|
||||
get_tree().change_scene_to_file("res://Scenes/mainMenu.tscn")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user