Fix item cabinet's visual state desyncing when toggled by a different client in view (#22759)
Fix item cabinet's visual state desyncing when opened by a different client in view
This commit is contained in:
@@ -7,7 +7,7 @@ namespace Content.Shared.Cabinet;
|
||||
/// <summary>
|
||||
/// Used for entities that can be opened, closed, and can hold one item. E.g., fire extinguisher cabinets.
|
||||
/// </summary>
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
|
||||
public sealed partial class ItemCabinetComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
|
||||
@@ -22,6 +22,7 @@ public abstract class SharedItemCabinetSystem : EntitySystem
|
||||
SubscribeLocalEvent<ItemCabinetComponent, ComponentInit>(OnComponentInit);
|
||||
SubscribeLocalEvent<ItemCabinetComponent, ComponentRemove>(OnComponentRemove);
|
||||
SubscribeLocalEvent<ItemCabinetComponent, ComponentStartup>(OnComponentStartup);
|
||||
SubscribeLocalEvent<ItemCabinetComponent, AfterAutoHandleStateEvent>(OnComponentHandleState);
|
||||
|
||||
SubscribeLocalEvent<ItemCabinetComponent, ActivateInWorldEvent>(OnActivateInWorld);
|
||||
SubscribeLocalEvent<ItemCabinetComponent, GetVerbsEvent<AlternativeVerb>>(AddToggleOpenVerb);
|
||||
@@ -48,6 +49,11 @@ public abstract class SharedItemCabinetSystem : EntitySystem
|
||||
_itemSlots.SetLock(uid, cabinet.CabinetSlot, !cabinet.Opened);
|
||||
}
|
||||
|
||||
private void OnComponentHandleState(Entity<ItemCabinetComponent> ent, ref AfterAutoHandleStateEvent args)
|
||||
{
|
||||
UpdateAppearance(ent, ent);
|
||||
}
|
||||
|
||||
protected virtual void UpdateAppearance(EntityUid uid, ItemCabinetComponent? cabinet = null)
|
||||
{
|
||||
// we don't fuck with appearance data, and instead just manually update the sprite on the client
|
||||
|
||||
Reference in New Issue
Block a user