Fix toggleable helmets (#22195)

This commit is contained in:
metalgearsloth
2023-12-07 08:56:03 +11:00
committed by GitHub
parent abce2dd1ee
commit 3252a2b8bb

View 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)),