Skip to content

Commit

Permalink
Fix item cabinet's visual state desyncing when toggled by a different…
Browse files Browse the repository at this point in the history
… client in view (space-wizards#22759)

Fix item cabinet's visual state desyncing when opened by a different client in view
  • Loading branch information
DrSmugleaf authored Dec 20, 2023
1 parent f43ff90 commit edceb55
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Content.Shared/Cabinet/ItemCabinetComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
6 changes: 6 additions & 0 deletions Content.Shared/Cabinet/SharedItemCabinetSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public override void Initialize()
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);
Expand All @@ -48,6 +49,11 @@ private void OnComponentStartup(EntityUid uid, ItemCabinetComponent cabinet, Com
_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
Expand Down

0 comments on commit edceb55

Please sign in to comment.