Fix plates not syncing dirty

This commit is contained in:
JonShard
2026-08-20 09:23:25 +02:00
parent 62ea4a1540
commit 06dde91468
4 changed files with 17 additions and 16 deletions
+17 -13
View File
@@ -4,26 +4,30 @@ extends Node
@onready var dirty_node: Node3D = $"../Dirty"
@onready var container: ItemContainer = $"../Container"
@export var is_dirty: bool = false
## 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 is_dirty: bool = false:
get:
return is_dirty
set(value):
if NetworkManager.owns_world():
clients_set_dirty.rpc(value)
is_dirty = value
container.enabled = not value
dirty_node.visible = value
SweetLogger.info("Set plate dirty: {0}", [value])
@rpc("authority", "call_remote", "reliable")
func clients_set_dirty(value: bool) -> void:
is_dirty = value
func get_food_items() -> Array[FoodItem]:
return container.contained_items
func _ready() -> void:
if not dirty_node:
SweetLogger.warning("{0} missing dirty_node reference", [name])
dirty_node.visible = is_dirty
func _process(_delta: float) -> void:
if is_dirty:
container.enabled = false
dirty_node.visible = true
else:
container.enabled = true
dirty_node.visible = false
SweetLogger.warning("{0} missing dirty_node reference", [name])