Fix Plates not disable/lock on clients in multiplayer

This commit is contained in:
JonShard
2026-08-21 15:46:01 +02:00
parent 5c4baa272a
commit e965cddde7
6 changed files with 63 additions and 95 deletions
+7 -1
View File
@@ -43,6 +43,9 @@ properties/3/replication_mode = 2
properties/4/path = NodePath("PlateController:is_dirty")
properties/4/spawn = false
properties/4/replication_mode = 1
properties/5/path = NodePath("NetPickable:grabbable")
properties/5/spawn = false
properties/5/replication_mode = 1
[node name="Plate" type="RigidBody3D" unique_id=190487773]
collision_layer = 4
@@ -51,8 +54,11 @@ freeze_mode = 1
script = ExtResource("1_nq5sa")
second_hand_grab = 1
[node name="PlateController" type="Node" parent="." unique_id=1503264193]
[node name="PlateController" type="Node" parent="." unique_id=1503264193 node_paths=PackedStringArray("net_pickable", "dirty_node", "container")]
script = ExtResource("1_vjsmi")
net_pickable = NodePath("../NetPickable")
dirty_node = NodePath("../Dirty")
container = NodePath("../Container")
[node name="CollisionShape3D" type="CollisionShape3D" parent="." unique_id=1365637864]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, -0.007171631, 0)
+22 -3
View File
@@ -1,14 +1,31 @@
class_name PlateController
extends Node
@onready var dirty_node: Node3D = $"../Dirty"
@onready var container: ItemContainer = $"../Container"
@export var net_pickable: NetPickable
@export var dirty_node: Node3D
@export var container: ItemContainer
## Synced summary of the plate's contents (item ids). The contents themselves
## are the real item nodes ItemContainer reparents under the plate; this is only
## what other systems read to ask "what is on this plate" without walking them.
@export var contained_ids: Array[String] = []
@export var enabled = true:
get:
return enabled
set(value):
if NetworkManager.owns_world():
clients_set_enabled.rpc(value)
enabled = value
container.enabled = not is_dirty
net_pickable.grabbable = value
SweetLogger.info("Set plate enabled: {0}", [value])
@rpc("authority", "call_remote", "reliable")
func clients_set_enabled(value: bool) -> void:
enabled = value
@export var is_dirty: bool = false:
get:
return is_dirty
@@ -29,4 +46,6 @@ func get_food_items() -> Array[FoodItem]:
return container.contained_items
func _ready() -> void:
Helper.check_reference(self, dirty_node, Node3D)
Helper.check_reference(self, dirty_node, Node3D)
Helper.check_reference(self, net_pickable, NetPickable)
Helper.check_reference(self, container, ItemContainer)