Fix plates not syncing dirty
This commit is contained in:
@@ -4,26 +4,30 @@ extends Node
|
|||||||
@onready var dirty_node: Node3D = $"../Dirty"
|
@onready var dirty_node: Node3D = $"../Dirty"
|
||||||
@onready var container: ItemContainer = $"../Container"
|
@onready var container: ItemContainer = $"../Container"
|
||||||
|
|
||||||
@export var is_dirty: bool = false
|
|
||||||
|
|
||||||
## Synced summary of the plate's contents (item ids). The contents themselves
|
## 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
|
## 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.
|
## what other systems read to ask "what is on this plate" without walking them.
|
||||||
@export var contained_ids: Array[String] = []
|
@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]:
|
func get_food_items() -> Array[FoodItem]:
|
||||||
return container.contained_items
|
return container.contained_items
|
||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
if not dirty_node:
|
if not dirty_node:
|
||||||
SweetLogger.warning("{0} missing dirty_node reference", [name])
|
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
|
|
||||||
|
|||||||
@@ -179,8 +179,6 @@ func apply_held_state() -> void:
|
|||||||
and _pickable.collision_mask == 0 \
|
and _pickable.collision_mask == 0 \
|
||||||
and _pickable.enabled == want_enabled:
|
and _pickable.enabled == want_enabled:
|
||||||
return
|
return
|
||||||
if NetworkManager.is_online(): # This was spamming that Knife was frozen every frame.
|
|
||||||
SweetLogger.debug("{0}: freezing (non-authority, owner=peer {1})", [_pickable.name, net_held_by])
|
|
||||||
_pickable.freeze = true
|
_pickable.freeze = true
|
||||||
_pickable.freeze_mode = RigidBody3D.FREEZE_MODE_KINEMATIC
|
_pickable.freeze_mode = RigidBody3D.FREEZE_MODE_KINEMATIC
|
||||||
_pickable.collision_mask = 0
|
_pickable.collision_mask = 0
|
||||||
|
|||||||
Binary file not shown.
@@ -1 +0,0 @@
|
|||||||
uid://be8o8m6xpp3kc
|
|
||||||
Reference in New Issue
Block a user