From 60b63b58ddc3fa2fa3bcee61f31329db494dc471 Mon Sep 17 00:00:00 2001 From: Stalen <33173619+stalengd@users.noreply.github.com> Date: Fri, 9 Aug 2024 09:17:51 +0300 Subject: [PATCH] Head bandana ingestion blocking fix (#28910) --- Content.Shared/Clothing/Components/MaskComponent.cs | 12 ++++++++++++ Content.Shared/Clothing/EntitySystems/MaskSystem.cs | 6 ++++-- .../Prototypes/Entities/Clothing/Head/bandanas.yml | 2 ++ .../Prototypes/Entities/Clothing/Masks/bandanas.yml | 1 + 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Clothing/Components/MaskComponent.cs b/Content.Shared/Clothing/Components/MaskComponent.cs index 5430417a8c..41b2b797f5 100644 --- a/Content.Shared/Clothing/Components/MaskComponent.cs +++ b/Content.Shared/Clothing/Components/MaskComponent.cs @@ -22,4 +22,16 @@ public sealed partial class MaskComponent : Component [DataField, AutoNetworkedField] public string EquippedPrefix = "toggled"; + + /// + /// When will function normally, otherwise will not react to events + /// + [DataField("enabled"), AutoNetworkedField] + public bool IsEnabled = true; + + /// + /// When will disable when folded + /// + [DataField, AutoNetworkedField] + public bool DisableOnFolded; } diff --git a/Content.Shared/Clothing/EntitySystems/MaskSystem.cs b/Content.Shared/Clothing/EntitySystems/MaskSystem.cs index 2a4383279a..fd0b7e782b 100644 --- a/Content.Shared/Clothing/EntitySystems/MaskSystem.cs +++ b/Content.Shared/Clothing/EntitySystems/MaskSystem.cs @@ -35,7 +35,7 @@ public sealed class MaskSystem : EntitySystem private void OnToggleMask(Entity ent, ref ToggleMaskEvent args) { var (uid, mask) = ent; - if (mask.ToggleActionEntity == null || !_timing.IsFirstTimePredicted) + if (mask.ToggleActionEntity == null || !_timing.IsFirstTimePredicted || !mask.IsEnabled) return; if (!_inventorySystem.TryGetSlotEntity(args.Performer, "mask", out var existing) || !uid.Equals(existing)) @@ -53,7 +53,7 @@ public sealed class MaskSystem : EntitySystem // set to untoggled when unequipped, so it isn't left in a 'pulled down' state private void OnGotUnequipped(EntityUid uid, MaskComponent mask, GotUnequippedEvent args) { - if (!mask.IsToggled) + if (!mask.IsToggled || !mask.IsEnabled) return; mask.IsToggled = false; @@ -78,6 +78,8 @@ public sealed class MaskSystem : EntitySystem private void OnFolded(Entity ent, ref FoldedEvent args) { + if (ent.Comp.DisableOnFolded) + ent.Comp.IsEnabled = !args.IsFolded; ent.Comp.IsToggled = args.IsFolded; ToggleMaskComponents(ent.Owner, ent.Comp, ent.Owner); diff --git a/Resources/Prototypes/Entities/Clothing/Head/bandanas.yml b/Resources/Prototypes/Entities/Clothing/Head/bandanas.yml index da56194f71..007cba3f22 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/bandanas.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/bandanas.yml @@ -7,6 +7,8 @@ folded: true - type: Mask isToggled: true + enabled: false + disableOnFolded: true - type: IngestionBlocker enabled: false - type: IdentityBlocker diff --git a/Resources/Prototypes/Entities/Clothing/Masks/bandanas.yml b/Resources/Prototypes/Entities/Clothing/Masks/bandanas.yml index 8021030095..bb5d6f2d2f 100644 --- a/Resources/Prototypes/Entities/Clothing/Masks/bandanas.yml +++ b/Resources/Prototypes/Entities/Clothing/Masks/bandanas.yml @@ -15,6 +15,7 @@ unfoldedHideLayers: - Snout - type: Mask + disableOnFolded: true - type: IngestionBlocker - type: IdentityBlocker coverage: MOUTH -- 2.52.0