From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Fri, 19 Apr 2024 05:40:23 +0000 (+0000) Subject: add dirty calls to mask system (#27128) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=350843d2c02a77338f2be420e047477f0bc57d9d;p=space-station-14.git add dirty calls to mask system (#27128) * add dirty calls to mask system * among --------- Co-authored-by: deltanedas <@deltanedas:kde.org> --- diff --git a/Content.Shared/Clothing/EntitySystems/MaskSystem.cs b/Content.Shared/Clothing/EntitySystems/MaskSystem.cs index aab2a172dc..4db26a49e7 100644 --- a/Content.Shared/Clothing/EntitySystems/MaskSystem.cs +++ b/Content.Shared/Clothing/EntitySystems/MaskSystem.cs @@ -42,12 +42,9 @@ public sealed class MaskSystem : EntitySystem return; mask.IsToggled ^= true; - _actionSystem.SetToggled(mask.ToggleActionEntity, mask.IsToggled); - if (mask.IsToggled) - _popupSystem.PopupEntity(Loc.GetString("action-mask-pull-down-popup-message", ("mask", uid)), args.Performer, args.Performer); - else - _popupSystem.PopupEntity(Loc.GetString("action-mask-pull-up-popup-message", ("mask", uid)), args.Performer, args.Performer); + var msg = $"action-mask-pull-{mask.IsToggled ? "down" : "up"}-popup-message"; + _popupSystem.PopupEntity(Loc.GetString(msg, ("mask", uid)), args.Performer, args.Performer); ToggleMaskComponents(uid, mask, args.Performer, mask.EquippedPrefix); } @@ -55,18 +52,22 @@ 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.ToggleActionEntity == null) + if (!mask.IsToggled) return; mask.IsToggled = false; - Dirty(uid, mask); - _actionSystem.SetToggled(mask.ToggleActionEntity, mask.IsToggled); - ToggleMaskComponents(uid, mask, args.Equipee, mask.EquippedPrefix, true); } + /// + /// Called after setting IsToggled, raises events and dirties. + /// private void ToggleMaskComponents(EntityUid uid, MaskComponent mask, EntityUid wearer, string? equippedPrefix = null, bool isEquip = false) { + Dirty(uid, mask); + if (mask.ToggleActionEntity is {} action) + _actionSystem.SetToggled(action, mask.IsToggled); + var maskEv = new ItemMaskToggledEvent(wearer, equippedPrefix, mask.IsToggled, isEquip); RaiseLocalEvent(uid, ref maskEv);