]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix item cabinet's visual state desyncing when toggled by a different client in view...
authorDrSmugleaf <DrSmugleaf@users.noreply.github.com>
Wed, 20 Dec 2023 00:38:03 +0000 (16:38 -0800)
committerGitHub <noreply@github.com>
Wed, 20 Dec 2023 00:38:03 +0000 (11:38 +1100)
Fix item cabinet's visual state desyncing when opened by a different client in view

Content.Shared/Cabinet/ItemCabinetComponent.cs
Content.Shared/Cabinet/SharedItemCabinetSystem.cs

index 71367e8de686611f68998c133a185d9822bf6cf9..dcc276e5651b4421787c56f0a16fd64f9a64e093 100644 (file)
@@ -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>
index 92af6a4f8a3f8ed09fb0dbeb8c3f18142925802c..ca496814c71fb489b885eb66ffc1102f4fd75486 100644 (file)
@@ -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