]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix toggleable helmets (#22195)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Wed, 6 Dec 2023 21:56:03 +0000 (08:56 +1100)
committerGitHub <noreply@github.com>
Wed, 6 Dec 2023 21:56:03 +0000 (17:56 -0400)
Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs

index fa8c1af20854d1aee4e674050cf811297a658f70..e3110eca356c3f7508bbca56e5630ff52b281b69 100644 (file)
@@ -42,6 +42,7 @@ public sealed class ToggleableClothingSystem : EntitySystem
         SubscribeLocalEvent<AttachedClothingComponent, InteractHandEvent>(OnInteractHand);
         SubscribeLocalEvent<AttachedClothingComponent, GotUnequippedEvent>(OnAttachedUnequip);
         SubscribeLocalEvent<AttachedClothingComponent, ComponentRemove>(OnRemoveAttached);
+        SubscribeLocalEvent<AttachedClothingComponent, BeingUnequippedAttemptEvent>(OnAttachedUnequipAttempt);
 
         SubscribeLocalEvent<ToggleableClothingComponent, InventoryRelayedEvent<GetVerbsEvent<EquipmentVerb>>>(GetRelayedVerbs);
         SubscribeLocalEvent<ToggleableClothingComponent, GetVerbsEvent<EquipmentVerb>>(OnGetVerbs);
@@ -176,6 +177,11 @@ public sealed class ToggleableClothingSystem : EntitySystem
             QueueDel(component.ClothingUid.Value);
     }
 
+    private void OnAttachedUnequipAttempt(EntityUid uid, AttachedClothingComponent component, BeingUnequippedAttemptEvent args)
+    {
+        args.Cancel();
+    }
+
     private void OnRemoveAttached(EntityUid uid, AttachedClothingComponent component, ComponentRemove args)
     {
         // if the attached component is being removed (maybe entity is being deleted?) we will just remove the
@@ -242,7 +248,7 @@ public sealed class ToggleableClothingSystem : EntitySystem
 
         var parent = Transform(target).ParentUid;
         if (component.Container.ContainedEntity == null)
-            _inventorySystem.TryUnequip(user, parent, component.Slot);
+            _inventorySystem.TryUnequip(user, parent, component.Slot, force: true);
         else if (_inventorySystem.TryGetSlotEntity(parent, component.Slot, out var existing))
         {
             _popupSystem.PopupClient(Loc.GetString("toggleable-clothing-remove-first", ("entity", existing)),