From c35bf9ef14ac46db85c999243db56473fedb4dd2 Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:01:48 +1000 Subject: [PATCH 01/18] make changes --- .../Inventory/StrippableBoundUserInterface.cs | 5 +- Content.Server/Strip/StrippableSystem.cs | 70 ++++++++++++------- .../EntitySystems/ToggleableClothingSystem.cs | 12 +++- .../Strip/Components/StrippableComponent.cs | 8 +-- .../Strip/Components/ThievingComponent.cs | 20 ++++-- .../Strip/SharedStrippableSystem.cs | 2 +- Content.Shared/Strip/ThievingSystem.cs | 22 +++++- Resources/Locale/en-US/traits/traits.ftl | 4 ++ .../Entities/Mobs/Species/felinid.yml | 5 ++ Resources/Prototypes/Traits/skills.yml | 14 ++++ 10 files changed, 121 insertions(+), 41 deletions(-) create mode 100644 Resources/Prototypes/Traits/skills.yml diff --git a/Content.Client/Inventory/StrippableBoundUserInterface.cs b/Content.Client/Inventory/StrippableBoundUserInterface.cs index f8eb12df914..4bb49fecc14 100644 --- a/Content.Client/Inventory/StrippableBoundUserInterface.cs +++ b/Content.Client/Inventory/StrippableBoundUserInterface.cs @@ -19,6 +19,7 @@ using Robust.Client.GameObjects; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; +using Robust.Client.Player; using Robust.Shared.Input; using Robust.Shared.Map; using Robust.Shared.Prototypes; @@ -31,6 +32,7 @@ namespace Content.Client.Inventory public sealed class StrippableBoundUserInterface : BoundUserInterface { [Dependency] private readonly IUserInterfaceManager _ui = default!; + [Dependency] private readonly IPlayerManager _playerManager = default!; private readonly ExamineSystem _examine; private readonly InventorySystem _inv; private readonly SharedCuffableSystem _cuffable; @@ -198,7 +200,8 @@ private void AddInventoryButton(EntityUid invUid, string slotId, InventoryCompon var entity = container.ContainedEntity; // If this is a full pocket, obscure the real entity - if (entity != null && slotDef.StripHidden) + if (entity != null && slotDef.StripHidden + && !(EntMan.TryGetComponent(_playerManager.LocalEntity, out var thiefcomponent) && thiefcomponent.IgnoreStripHidden)) entity = _virtualHiddenEntity; var button = new SlotButton(new SlotData(slotDef, container)); diff --git a/Content.Server/Strip/StrippableSystem.cs b/Content.Server/Strip/StrippableSystem.cs index 96b2ecc00c6..0a22b8390c0 100644 --- a/Content.Server/Strip/StrippableSystem.cs +++ b/Content.Server/Strip/StrippableSystem.cs @@ -219,10 +219,12 @@ bool Check() var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth); RaiseLocalEvent(target, ev); + bool hidden = ev.Stealth == ThievingStealth.Hidden; + var doAfterArgs = new DoAfterArgs(EntityManager, user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: held) { ExtraCheck = Check, - Hidden = ev.Stealth, + Hidden = hidden, AttemptFrequency = AttemptFrequency.EveryTick, BreakOnDamage = true, BreakOnTargetMove = true, @@ -231,14 +233,18 @@ bool Check() DuplicateCondition = DuplicateConditions.SameTool // Block any other DoAfters featuring this same entity. }; - if (!ev.Stealth && Check() && userHands.ActiveHandEntity != null) + if (!hidden && Check() && userHands.ActiveHandEntity != null) { - var message = Loc.GetString("strippable-component-alert-owner-insert", - ("user", Identity.Entity(user, EntityManager)), ("item", userHands.ActiveHandEntity)); - _popup.PopupEntity(message, target, target, PopupType.Large); + bool subtle = (ev.Stealth == ThievingStealth.Subtle); + PopupType popupSize = subtle ? PopupType.Small : PopupType.Large; + + _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-insert", + ("user", subtle ? "Someone" : Identity.Entity(user, EntityManager)), + ("item", subtle ? "something" : userHands.ActiveHandEntity)), + target, target, popupSize); } - var prefix = ev.Stealth ? "stealthily " : ""; + var prefix = hidden ? "stealthily " : ""; _adminLogger.Add(LogType.Stripping, LogImpact.Low, $"{ToPrettyString(user):actor} is trying to {prefix}place the item {ToPrettyString(held):item} in {ToPrettyString(target):target}'s {slot} slot"); var result = await _doAfter.WaitDoAfter(doAfterArgs); @@ -294,10 +300,12 @@ bool Check() var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth); RaiseLocalEvent(target, ev); + bool hidden = (ev.Stealth == ThievingStealth.Hidden); + var doAfterArgs = new DoAfterArgs(EntityManager, user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: held) { ExtraCheck = Check, - Hidden = ev.Stealth, + Hidden = hidden, AttemptFrequency = AttemptFrequency.EveryTick, BreakOnDamage = true, BreakOnTargetMove = true, @@ -306,14 +314,14 @@ bool Check() DuplicateCondition = DuplicateConditions.SameTool }; - var prefix = ev.Stealth ? "stealthily " : ""; + var prefix = hidden ? "stealthily " : ""; _adminLogger.Add(LogType.Stripping, LogImpact.Low, $"{ToPrettyString(user):actor} is trying to {prefix}place the item {ToPrettyString(held):item} in {ToPrettyString(target):target}'s hands"); var result = await _doAfter.WaitDoAfter(doAfterArgs); if (result != DoAfterStatus.Finished) return; _handsSystem.TryDrop(user, checkActionBlocker: false, handsComp: userHands); - _handsSystem.TryPickup(target, held, handName, checkActionBlocker: false, animateUser: !ev.Stealth, animate: !ev.Stealth, handsComp: hands); + _handsSystem.TryPickup(target, held, handName, checkActionBlocker: false, animateUser: !hidden, animate: !hidden, handsComp: hands); _adminLogger.Add(LogType.Stripping, LogImpact.Medium, $"{ToPrettyString(user):actor} has placed the item {ToPrettyString(held):item} in {ToPrettyString(target):target}'s hands"); // hand update will trigger strippable update } @@ -356,10 +364,12 @@ bool Check() var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth); RaiseLocalEvent(target, ev); + bool hidden = (ev.Stealth == ThievingStealth.Hidden); + var doAfterArgs = new DoAfterArgs(EntityManager, user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: item) { ExtraCheck = Check, - Hidden = ev.Stealth, + Hidden = hidden, AttemptFrequency = AttemptFrequency.EveryTick, BreakOnDamage = true, BreakOnTargetMove = true, @@ -369,21 +379,26 @@ bool Check() DuplicateCondition = DuplicateConditions.SameTool }; - if (!ev.Stealth && Check()) + if (!hidden && Check()) { + PopupType popupSize = (ev.Stealth == ThievingStealth.Subtle) ? PopupType.Small : PopupType.Large; + if (slotDef.StripHidden) { - _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-hidden", ("slot", slot)), target, - target, PopupType.Large); + _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-hidden", + ("slot", slot)), + target, target, popupSize); } else if (_inventorySystem.TryGetSlotEntity(strippable, slot, out var slotItem)) { - _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner", ("user", Identity.Entity(user, EntityManager)), ("item", slotItem)), target, - target, PopupType.Large); + _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner", + ("user", (ev.Stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)), + ("item", slotItem)), + target, target, popupSize); } } - var prefix = ev.Stealth ? "stealthily " : ""; + var prefix = hidden ? "stealthily " : ""; _adminLogger.Add(LogType.Stripping, LogImpact.Low, $"{ToPrettyString(user):actor} is trying to {prefix}strip the item {ToPrettyString(item):item} from {ToPrettyString(target):target}'s {slot} slot"); var result = await _doAfter.WaitDoAfter(doAfterArgs); @@ -396,7 +411,7 @@ bool Check() // Raise a dropped event, so that things like gas tank internals properly deactivate when stripping RaiseLocalEvent(item, new DroppedEvent(user), true); - _handsSystem.PickupOrDrop(user, item, animateUser: !ev.Stealth, animate: !ev.Stealth); + _handsSystem.PickupOrDrop(user, item, animateUser: !hidden, animate: !hidden); _adminLogger.Add(LogType.Stripping, LogImpact.Medium, $"{ToPrettyString(user):actor} has stripped the item {ToPrettyString(item):item} from {ToPrettyString(target):target}'s {slot} slot"); } @@ -434,10 +449,12 @@ bool Check() var ev = new BeforeGettingStrippedEvent(userEv.Time, userEv.Stealth); RaiseLocalEvent(target, ev); + bool hidden = (ev.Stealth == ThievingStealth.Hidden); + var doAfterArgs = new DoAfterArgs(EntityManager, user, ev.Time, new AwaitedDoAfterEvent(), null, target: target, used: item) { ExtraCheck = Check, - Hidden = ev.Stealth, + Hidden = hidden, AttemptFrequency = AttemptFrequency.EveryTick, BreakOnDamage = true, BreakOnTargetMove = true, @@ -447,16 +464,17 @@ bool Check() DuplicateCondition = DuplicateConditions.SameTool }; - if (!ev.Stealth && Check() && _handsSystem.TryGetHand(target, handName, out var handSlot, hands) && handSlot.HeldEntity != null) + if (!hidden && Check() && _handsSystem.TryGetHand(target, handName, out var handSlot, hands) && handSlot.HeldEntity != null) { - _popup.PopupEntity( - Loc.GetString("strippable-component-alert-owner", - ("user", Identity.Entity(user, EntityManager)), ("item", item)), - strippable.Owner, - strippable.Owner); + PopupType popupSize = (ev.Stealth == ThievingStealth.Subtle) ? PopupType.Small : PopupType.Large; + + _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner", + ("user", (ev.Stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)), + ("item", item)), + strippable.Owner,strippable.Owner, popupSize); } - var prefix = ev.Stealth ? "stealthily " : ""; + var prefix = hidden ? "stealthily " : ""; _adminLogger.Add(LogType.Stripping, LogImpact.Low, $"{ToPrettyString(user):actor} is trying to {prefix}strip the item {ToPrettyString(item):item} from {ToPrettyString(target):target}'s hands"); @@ -465,7 +483,7 @@ bool Check() return; _handsSystem.TryDrop(target, item, checkActionBlocker: false, handsComp: hands); - _handsSystem.PickupOrDrop(user, item, animateUser: !ev.Stealth, animate: !ev.Stealth, handsComp: userHands); + _handsSystem.PickupOrDrop(user, item, animateUser: !hidden, animate: !hidden, handsComp: userHands); // hand update will trigger strippable update _adminLogger.Add(LogType.Stripping, LogImpact.Medium, $"{ToPrettyString(user):actor} has stripped the item {ToPrettyString(item):item} from {ToPrettyString(target):target}'s hands"); diff --git a/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs b/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs index 0138de7a98f..5218e700acd 100644 --- a/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs +++ b/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs @@ -97,6 +97,8 @@ private void StartDoAfter(EntityUid user, EntityUid item, EntityUid wearer, Togg var (time, stealth) = _strippable.GetStripTimeModifiers(user, wearer, (float) component.StripDelay.Value.TotalSeconds); + bool hidden = (stealth == ThievingStealth.Hidden); + var args = new DoAfterArgs(EntityManager, user, time, new ToggleClothingDoAfterEvent(), item, wearer, item) { BreakOnDamage = true, @@ -110,10 +112,14 @@ private void StartDoAfter(EntityUid user, EntityUid item, EntityUid wearer, Togg if (!_doAfter.TryStartDoAfter(args)) return; - if (!stealth) + if (!hidden) { - var popup = Loc.GetString("strippable-component-alert-owner-interact", ("user", Identity.Entity(user, EntityManager)), ("item", item)); - _popupSystem.PopupEntity(popup, wearer, wearer, PopupType.Large); + PopupType popupSize = (stealth == ThievingStealth.Subtle); + + _popupSystem.PopupEntity(Loc.GetString("strippable-component-alert-owner-interact", + ("user", (stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)), + ("item", item)), + wearer, wearer, popupSize); } } diff --git a/Content.Shared/Strip/Components/StrippableComponent.cs b/Content.Shared/Strip/Components/StrippableComponent.cs index fbf99992e3c..abfdfc98199 100644 --- a/Content.Shared/Strip/Components/StrippableComponent.cs +++ b/Content.Shared/Strip/Components/StrippableComponent.cs @@ -48,11 +48,11 @@ public abstract class BaseBeforeStripEvent : EntityEventArgs, IInventoryRelayEve public float Time => MathF.Max(InitialTime * Multiplier + Additive, 0f); public float Additive = 0; public float Multiplier = 1f; - public bool Stealth; + public ThievingStealth Stealth; public SlotFlags TargetSlots { get; } = SlotFlags.GLOVES; - public BaseBeforeStripEvent(float initialTime, bool stealth = false) + public BaseBeforeStripEvent(float initialTime, ThievingStealth stealth = ThievingStealth.Obvious) { InitialTime = initialTime; Stealth = stealth; @@ -67,7 +67,7 @@ public BaseBeforeStripEvent(float initialTime, bool stealth = false) /// public sealed class BeforeStripEvent : BaseBeforeStripEvent { - public BeforeStripEvent(float initialTime, bool stealth = false) : base(initialTime, stealth) { } + public BeforeStripEvent(float initialTime, ThievingStealth stealth = ThievingStealth.Obvious) : base(initialTime, stealth) { } } /// @@ -78,6 +78,6 @@ public BeforeStripEvent(float initialTime, bool stealth = false) : base(initialT /// public sealed class BeforeGettingStrippedEvent : BaseBeforeStripEvent { - public BeforeGettingStrippedEvent(float initialTime, bool stealth = false) : base(initialTime, stealth) { } + public BeforeGettingStrippedEvent(float initialTime, ThievingStealth stealth = ThievingStealth.Obvious) : base(initialTime, stealth) { } } } diff --git a/Content.Shared/Strip/Components/ThievingComponent.cs b/Content.Shared/Strip/Components/ThievingComponent.cs index 83679f132c4..5873853f852 100644 --- a/Content.Shared/Strip/Components/ThievingComponent.cs +++ b/Content.Shared/Strip/Components/ThievingComponent.cs @@ -9,14 +9,24 @@ public sealed partial class ThievingComponent : Component /// /// How much the strip time should be shortened by /// - [ViewVariables(VVAccess.ReadWrite)] - [DataField("stripTimeReduction")] + [DataField] public float StripTimeReduction = 0.5f; + /// + /// A multiplier coefficient for strip time + /// + [DataField] + public float StripTimeMultiplier = 1f; + /// /// Should it notify the user if they're stripping a pocket? /// - [ViewVariables(VVAccess.ReadWrite)] - [DataField("stealthy")] - public bool Stealthy; + [DataField] + public ThievingStealth Stealth = ThievingStealth.Hidden; + + /// + /// Should the user be able to see hidden items? (i.e pockets) + /// + [DataField] + public bool IgnoreStripHidden; } diff --git a/Content.Shared/Strip/SharedStrippableSystem.cs b/Content.Shared/Strip/SharedStrippableSystem.cs index a698ae5035a..ebbd9da45a2 100644 --- a/Content.Shared/Strip/SharedStrippableSystem.cs +++ b/Content.Shared/Strip/SharedStrippableSystem.cs @@ -14,7 +14,7 @@ public override void Initialize() SubscribeLocalEvent(OnDragDrop); } - public (float Time, bool Stealth) GetStripTimeModifiers(EntityUid user, EntityUid target, float initialTime) + public (float Time, ThievingStealth Stealth) GetStripTimeModifiers(EntityUid user, EntityUid target, float initialTime) { var userEv = new BeforeStripEvent(initialTime); RaiseLocalEvent(user, userEv); diff --git a/Content.Shared/Strip/ThievingSystem.cs b/Content.Shared/Strip/ThievingSystem.cs index 0ef4b66571f..af7284f3522 100644 --- a/Content.Shared/Strip/ThievingSystem.cs +++ b/Content.Shared/Strip/ThievingSystem.cs @@ -1,5 +1,6 @@ using Content.Shared.Inventory; using Content.Shared.Strip.Components; +using Robust.Shared.Serialization; namespace Content.Shared.Strip; @@ -16,7 +17,26 @@ public override void Initialize() private void OnBeforeStrip(EntityUid uid, ThievingComponent component, BeforeStripEvent args) { - args.Stealth |= component.Stealthy; + args.Stealth = (ThievingStealth) Math.Max(((sbyte) args.Stealth), (sbyte) component.Stealth); args.Additive -= component.StripTimeReduction; + args.Multiplier *= component.StripTimeMultiplier; } } +[Serializable, NetSerializable] +public enum ThievingStealth : sbyte +{ + /// + /// Target sees a large popup indicating that an item is being stolen by who + /// + Obvious = 0, + + /// + /// Target sees a small popup indicating that an item is being stolen + /// + Subtle = 1, + + /// + /// Target does not see any popup regarding the stealing of an item + /// + Hidden = 2 +} \ No newline at end of file diff --git a/Resources/Locale/en-US/traits/traits.ftl b/Resources/Locale/en-US/traits/traits.ftl index e9163bdb548..e6aca46d716 100644 --- a/Resources/Locale/en-US/traits/traits.ftl +++ b/Resources/Locale/en-US/traits/traits.ftl @@ -31,3 +31,7 @@ trait-description-SocialAnxiety = You are anxious when you speak and stutter. trait-name-Snoring = Snoring trait-description-Snoring = You will snore while sleeping. + +trait-name-Thieving = Thieving +trait-description-Thieving = You are deft with your hands, and talented at convincing people of their belongings. + Your attempts at stealing items are quieter, and you steal ~33% faster. \ No newline at end of file diff --git a/Resources/Prototypes/Nyanotrasen/Entities/Mobs/Species/felinid.yml b/Resources/Prototypes/Nyanotrasen/Entities/Mobs/Species/felinid.yml index 5bc02461eed..d23607b16d5 100644 --- a/Resources/Prototypes/Nyanotrasen/Entities/Mobs/Species/felinid.yml +++ b/Resources/Prototypes/Nyanotrasen/Entities/Mobs/Species/felinid.yml @@ -74,6 +74,11 @@ - GalacticCommon - SolCommon - Nekomimetic + - type: Thieving + ignoreStripHidden: true + stealth: Subtle + stripTimeReduction: 0 + stripTimeMultiplier: 0.667 - type: entity save: false diff --git a/Resources/Prototypes/Traits/skills.yml b/Resources/Prototypes/Traits/skills.yml new file mode 100644 index 00000000000..2cf60be97aa --- /dev/null +++ b/Resources/Prototypes/Traits/skills.yml @@ -0,0 +1,14 @@ +- type: trait + id: Thieving + category: Uncategorized + points: -4 + components: + - type: Thieving + ignoreStripHidden: true + stealth: Subtle + stripTimeReduction: 0 + stripTimeMultiplier: 0.667 + requirements: + - !type:CharacterSpeciesRequirement + inverted: true + species: Felinid \ No newline at end of file From a9b6ac59b1be75b4491dad3e5ba43b33d42822df Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:06:41 +1000 Subject: [PATCH 02/18] fix other thief prototypes --- Resources/Prototypes/Entities/Clothing/Hands/gloves.yml | 2 -- Resources/Prototypes/Entities/Clothing/Hands/specific.yml | 1 - Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml | 4 ++-- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/Resources/Prototypes/Entities/Clothing/Hands/gloves.yml b/Resources/Prototypes/Entities/Clothing/Hands/gloves.yml index bf08db78f71..4cd0c04e2be 100644 --- a/Resources/Prototypes/Entities/Clothing/Hands/gloves.yml +++ b/Resources/Prototypes/Entities/Clothing/Hands/gloves.yml @@ -231,7 +231,6 @@ - type: FingerprintMask - type: Thieving stripTimeReduction: 1 - stealthy: true - type: NinjaGloves - type: entity @@ -332,7 +331,6 @@ tags: [] # ignore "WhitelistChameleon" tag - type: Thieving stripTimeReduction: 1.5 - stealthy: true - type: entity parent: ClothingHandsGlovesColorWhite diff --git a/Resources/Prototypes/Entities/Clothing/Hands/specific.yml b/Resources/Prototypes/Entities/Clothing/Hands/specific.yml index e6a57319999..db34297b42a 100644 --- a/Resources/Prototypes/Entities/Clothing/Hands/specific.yml +++ b/Resources/Prototypes/Entities/Clothing/Hands/specific.yml @@ -29,4 +29,3 @@ components: - type: Thieving stripTimeReduction: 2 - stealthy: true diff --git a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml index 80e87d3670c..9bdfb18830e 100644 --- a/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml +++ b/Resources/Prototypes/Entities/Mobs/Player/admin_ghost.yml @@ -85,8 +85,8 @@ range: 500 - type: StationLimitedNetwork - type: Thieving - stripTimeReduction: 9999 - stealthy: true + stripTimeMultiplier: 0 + ignoreStripHidden: true - type: Stripping - type: SolutionScanner - type: IgnoreUIRange From b0e8f096f50b3580cc90b45ec2587dedc4c7f52b Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:08:01 +1000 Subject: [PATCH 03/18] description adjust --- Resources/Locale/en-US/traits/traits.ftl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Locale/en-US/traits/traits.ftl b/Resources/Locale/en-US/traits/traits.ftl index e6aca46d716..63a3a42dcc6 100644 --- a/Resources/Locale/en-US/traits/traits.ftl +++ b/Resources/Locale/en-US/traits/traits.ftl @@ -34,4 +34,4 @@ trait-description-Snoring = You will snore while sleeping. trait-name-Thieving = Thieving trait-description-Thieving = You are deft with your hands, and talented at convincing people of their belongings. - Your attempts at stealing items are quieter, and you steal ~33% faster. \ No newline at end of file + You can identify pocketed items, steal them quieter, and steal ~33% faster. \ No newline at end of file From c684193f73d5934dd5951c417655de9ed6b6b0af Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 15:50:23 +1000 Subject: [PATCH 04/18] oops --- .../Clothing/EntitySystems/ToggleableClothingSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs b/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs index 5218e700acd..08c81edd224 100644 --- a/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs +++ b/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs @@ -114,7 +114,7 @@ private void StartDoAfter(EntityUid user, EntityUid item, EntityUid wearer, Togg if (!hidden) { - PopupType popupSize = (stealth == ThievingStealth.Subtle); + PopupType popupSize = (stealth == ThievingStealth.Subtle) ? PopupType.Small : PopupType.Large; _popupSystem.PopupEntity(Loc.GetString("strippable-component-alert-owner-interact", ("user", (stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)), From 197e1de08791dc0057eef34d7fcc29ad7f96da92 Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 16:25:32 +1000 Subject: [PATCH 05/18] replace boolean assignment with switch case --- Content.Server/Strip/StrippableSystem.cs | 46 ++++++++++--------- .../EntitySystems/ToggleableClothingSystem.cs | 8 ++-- Content.Shared/Strip/ThievingSystem.cs | 17 +++++++ 3 files changed, 47 insertions(+), 24 deletions(-) diff --git a/Content.Server/Strip/StrippableSystem.cs b/Content.Server/Strip/StrippableSystem.cs index 0a22b8390c0..c2647fb2158 100644 --- a/Content.Server/Strip/StrippableSystem.cs +++ b/Content.Server/Strip/StrippableSystem.cs @@ -34,6 +34,7 @@ public sealed class StrippableSystem : SharedStrippableSystem [Dependency] private readonly EnsnareableSystem _ensnaring = default!; [Dependency] private readonly UserInterfaceSystem _userInterfaceSystem = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!; + [Dependency] private readonly ThievingSystem _thieving = default!; // TODO: ECS popups. Not all of these have ECS equivalents yet. @@ -236,12 +237,13 @@ bool Check() if (!hidden && Check() && userHands.ActiveHandEntity != null) { bool subtle = (ev.Stealth == ThievingStealth.Subtle); - PopupType popupSize = subtle ? PopupType.Small : PopupType.Large; + PopupType? popupSize = _thieving.GetPopupTypeFromStealth(ev.Stealth); - _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-insert", + if (popupSize.HasValue) // we should always have a value if we're not hidden + _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-insert", ("user", subtle ? "Someone" : Identity.Entity(user, EntityManager)), ("item", subtle ? "something" : userHands.ActiveHandEntity)), - target, target, popupSize); + target, target, popupSize.Value); } var prefix = hidden ? "stealthily " : ""; @@ -381,21 +383,22 @@ bool Check() if (!hidden && Check()) { - PopupType popupSize = (ev.Stealth == ThievingStealth.Subtle) ? PopupType.Small : PopupType.Large; - - if (slotDef.StripHidden) - { - _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-hidden", - ("slot", slot)), - target, target, popupSize); - } - else if (_inventorySystem.TryGetSlotEntity(strippable, slot, out var slotItem)) - { - _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner", - ("user", (ev.Stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)), - ("item", slotItem)), - target, target, popupSize); - } + PopupType? popupSize = _thieving.GetPopupTypeFromStealth(ev.Stealth); + + if (popupSize.HasValue) // we should always have a value if we're not hidden + if (slotDef.StripHidden) + { + _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-hidden", + ("slot", slot)), + target, target, popupSize.Value); + } + else if (_inventorySystem.TryGetSlotEntity(strippable, slot, out var slotItem)) + { + _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner", + ("user", (ev.Stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)), + ("item", slotItem)), + target, target, popupSize.Value); + } } var prefix = hidden ? "stealthily " : ""; @@ -466,12 +469,13 @@ bool Check() if (!hidden && Check() && _handsSystem.TryGetHand(target, handName, out var handSlot, hands) && handSlot.HeldEntity != null) { - PopupType popupSize = (ev.Stealth == ThievingStealth.Subtle) ? PopupType.Small : PopupType.Large; + PopupType? popupSize = _thieving.GetPopupTypeFromStealth(ev.Stealth); - _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner", + if (popupSize.HasValue) // we should always have a value if we're not hidden + _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner", ("user", (ev.Stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)), ("item", item)), - strippable.Owner,strippable.Owner, popupSize); + strippable.Owner, strippable.Owner, popupSize.Value); } var prefix = hidden ? "stealthily " : ""; diff --git a/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs b/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs index 08c81edd224..d15272d6730 100644 --- a/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs +++ b/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs @@ -27,6 +27,7 @@ public sealed class ToggleableClothingSystem : EntitySystem [Dependency] private readonly SharedPopupSystem _popupSystem = default!; [Dependency] private readonly SharedDoAfterSystem _doAfter = default!; [Dependency] private readonly SharedStrippableSystem _strippable = default!; + [Dependency] private readonly ThievingSystem _thieving = default!; public override void Initialize() { @@ -114,12 +115,13 @@ private void StartDoAfter(EntityUid user, EntityUid item, EntityUid wearer, Togg if (!hidden) { - PopupType popupSize = (stealth == ThievingStealth.Subtle) ? PopupType.Small : PopupType.Large; + PopupType? popupSize = _thieving.GetPopupTypeFromStealth(stealth); - _popupSystem.PopupEntity(Loc.GetString("strippable-component-alert-owner-interact", + if (popupSize.HasValue) // we should always have a value if we're not hidden + _popupSystem.PopupEntity(Loc.GetString("strippable-component-alert-owner-interact", ("user", (stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)), ("item", item)), - wearer, wearer, popupSize); + wearer, wearer, popupSize.Value); } } diff --git a/Content.Shared/Strip/ThievingSystem.cs b/Content.Shared/Strip/ThievingSystem.cs index af7284f3522..83955132ff0 100644 --- a/Content.Shared/Strip/ThievingSystem.cs +++ b/Content.Shared/Strip/ThievingSystem.cs @@ -1,6 +1,8 @@ using Content.Shared.Inventory; +using Content.Shared.Popups; using Content.Shared.Strip.Components; using Robust.Shared.Serialization; +using Robust.Shared.Utility; namespace Content.Shared.Strip; @@ -21,6 +23,21 @@ private void OnBeforeStrip(EntityUid uid, ThievingComponent component, BeforeStr args.Additive -= component.StripTimeReduction; args.Multiplier *= component.StripTimeMultiplier; } + + public PopupType? GetPopupTypeFromStealth(ThievingStealth stealth) + { + switch (stealth) + { + case ThievingStealth.Hidden: + return null; + + case ThievingStealth.Subtle: + return PopupType.Small; + + default: + return PopupType.Large; + } + } } [Serializable, NetSerializable] public enum ThievingStealth : sbyte From d32f39a5914be439f94ae62e0cf6f35ff03626db Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:25:40 +1000 Subject: [PATCH 06/18] Update Content.Server/Strip/StrippableSystem.cs Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Signed-off-by: WarMechanic <69510347+WarMechanic@users.noreply.github.com> --- Content.Server/Strip/StrippableSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Strip/StrippableSystem.cs b/Content.Server/Strip/StrippableSystem.cs index c2647fb2158..efe3178e0c7 100644 --- a/Content.Server/Strip/StrippableSystem.cs +++ b/Content.Server/Strip/StrippableSystem.cs @@ -239,7 +239,7 @@ bool Check() bool subtle = (ev.Stealth == ThievingStealth.Subtle); PopupType? popupSize = _thieving.GetPopupTypeFromStealth(ev.Stealth); - if (popupSize.HasValue) // we should always have a value if we're not hidden + if (popupSize.HasValue) // We should always have a value if we're not hidden _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-insert", ("user", subtle ? "Someone" : Identity.Entity(user, EntityManager)), ("item", subtle ? "something" : userHands.ActiveHandEntity)), From cd6d27c8ee0c6503522444b8bf1f5a8fbf766c45 Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:25:50 +1000 Subject: [PATCH 07/18] Update Content.Server/Strip/StrippableSystem.cs Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Signed-off-by: WarMechanic <69510347+WarMechanic@users.noreply.github.com> --- Content.Server/Strip/StrippableSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Strip/StrippableSystem.cs b/Content.Server/Strip/StrippableSystem.cs index efe3178e0c7..dc43fcf3bc2 100644 --- a/Content.Server/Strip/StrippableSystem.cs +++ b/Content.Server/Strip/StrippableSystem.cs @@ -385,7 +385,7 @@ bool Check() { PopupType? popupSize = _thieving.GetPopupTypeFromStealth(ev.Stealth); - if (popupSize.HasValue) // we should always have a value if we're not hidden + if (popupSize.HasValue) // We should always have a value if we're not hidden if (slotDef.StripHidden) { _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-hidden", From 2e79e5b9d588f8afb0d4b5d5fd2327354504bca2 Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:25:59 +1000 Subject: [PATCH 08/18] Update Content.Server/Strip/StrippableSystem.cs Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Signed-off-by: WarMechanic <69510347+WarMechanic@users.noreply.github.com> --- Content.Server/Strip/StrippableSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Server/Strip/StrippableSystem.cs b/Content.Server/Strip/StrippableSystem.cs index dc43fcf3bc2..3ae835082cb 100644 --- a/Content.Server/Strip/StrippableSystem.cs +++ b/Content.Server/Strip/StrippableSystem.cs @@ -471,7 +471,7 @@ bool Check() { PopupType? popupSize = _thieving.GetPopupTypeFromStealth(ev.Stealth); - if (popupSize.HasValue) // we should always have a value if we're not hidden + if (popupSize.HasValue) // We should always have a value if we're not hidden _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner", ("user", (ev.Stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)), ("item", item)), From bd7197a8b866095d09356781d5513631196b4eea Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:26:09 +1000 Subject: [PATCH 09/18] Update Content.Shared/Strip/ThievingSystem.cs Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Signed-off-by: WarMechanic <69510347+WarMechanic@users.noreply.github.com> --- Content.Shared/Strip/ThievingSystem.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Content.Shared/Strip/ThievingSystem.cs b/Content.Shared/Strip/ThievingSystem.cs index 83955132ff0..64d7c24dede 100644 --- a/Content.Shared/Strip/ThievingSystem.cs +++ b/Content.Shared/Strip/ThievingSystem.cs @@ -56,4 +56,4 @@ public enum ThievingStealth : sbyte /// Target does not see any popup regarding the stealing of an item /// Hidden = 2 -} \ No newline at end of file +} From 98190e061d04a4abf5c3bc9e0c884c03a7316ab6 Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:26:19 +1000 Subject: [PATCH 10/18] Update Content.Shared/Strip/ThievingSystem.cs Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Signed-off-by: WarMechanic <69510347+WarMechanic@users.noreply.github.com> --- Content.Shared/Strip/ThievingSystem.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Content.Shared/Strip/ThievingSystem.cs b/Content.Shared/Strip/ThievingSystem.cs index 64d7c24dede..0d6655db59b 100644 --- a/Content.Shared/Strip/ThievingSystem.cs +++ b/Content.Shared/Strip/ThievingSystem.cs @@ -43,17 +43,17 @@ private void OnBeforeStrip(EntityUid uid, ThievingComponent component, BeforeStr public enum ThievingStealth : sbyte { /// - /// Target sees a large popup indicating that an item is being stolen by who + /// Target sees a large popup indicating that an item is being stolen by who /// Obvious = 0, /// - /// Target sees a small popup indicating that an item is being stolen + /// Target sees a small popup indicating that an item is being stolen /// Subtle = 1, /// - /// Target does not see any popup regarding the stealing of an item + /// Target does not see any popup regarding the stealing of an item /// Hidden = 2 } From a1f46f45fbba4ccd7d9c2fcfcdd00fb429a8f2a2 Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:26:38 +1000 Subject: [PATCH 11/18] Update Resources/Locale/en-US/traits/traits.ftl Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Signed-off-by: WarMechanic <69510347+WarMechanic@users.noreply.github.com> --- Resources/Locale/en-US/traits/traits.ftl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Resources/Locale/en-US/traits/traits.ftl b/Resources/Locale/en-US/traits/traits.ftl index 63a3a42dcc6..80680ac0db2 100644 --- a/Resources/Locale/en-US/traits/traits.ftl +++ b/Resources/Locale/en-US/traits/traits.ftl @@ -33,5 +33,6 @@ trait-name-Snoring = Snoring trait-description-Snoring = You will snore while sleeping. trait-name-Thieving = Thieving -trait-description-Thieving = You are deft with your hands, and talented at convincing people of their belongings. - You can identify pocketed items, steal them quieter, and steal ~33% faster. \ No newline at end of file +trait-description-Thieving = + You are deft with your hands, and talented at convincing people of their belongings. + You can identify pocketed items, steal them quieter, and steal ~33% faster. From cc17194605c66343b3f76ecdb38697d2c1ca4dcd Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 17:26:49 +1000 Subject: [PATCH 12/18] Update Resources/Prototypes/Traits/skills.yml Co-authored-by: DEATHB4DEFEAT <77995199+DEATHB4DEFEAT@users.noreply.github.com> Signed-off-by: WarMechanic <69510347+WarMechanic@users.noreply.github.com> --- Resources/Prototypes/Traits/skills.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Prototypes/Traits/skills.yml b/Resources/Prototypes/Traits/skills.yml index 2cf60be97aa..93cb01102b4 100644 --- a/Resources/Prototypes/Traits/skills.yml +++ b/Resources/Prototypes/Traits/skills.yml @@ -11,4 +11,4 @@ requirements: - !type:CharacterSpeciesRequirement inverted: true - species: Felinid \ No newline at end of file + species: Felinid From 2d977aa9974d36b9a5cc913b9c450a1430ae703d Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 18:12:51 +1000 Subject: [PATCH 13/18] cleanup popup code --- Content.Server/Strip/StrippableSystem.cs | 53 ++++++++----------- .../en-US/strip/strippable-component.ftl | 6 ++- 2 files changed, 28 insertions(+), 31 deletions(-) diff --git a/Content.Server/Strip/StrippableSystem.cs b/Content.Server/Strip/StrippableSystem.cs index 3ae835082cb..695867d7196 100644 --- a/Content.Server/Strip/StrippableSystem.cs +++ b/Content.Server/Strip/StrippableSystem.cs @@ -160,6 +160,19 @@ private void AddStripExamineVerb(EntityUid uid, StrippableComponent component, G args.Verbs.Add(verb); } + private void StripPopup(string messageId, ThievingStealth stealth, EntityUid target, EntityUid? user = null, EntityUid? item = null, string slot = "") + { + bool subtle = (stealth == ThievingStealth.Subtle); + PopupType? popupSize = _thieving.GetPopupTypeFromStealth(stealth); + + if (popupSize.HasValue) // We should always have a value if we're not hidden + _popup.PopupEntity(Loc.GetString(messageId, + ("user", subtle ? Loc.GetString("thieving-component-user") : user ?? EntityUid.Invalid), + ("item", subtle ? Loc.GetString("thieving-component-item") : item ?? EntityUid.Invalid), + ("slot", slot)), + target, target, popupSize.Value); + } + private void OnActivateInWorld(EntityUid uid, StrippableComponent component, ActivateInWorldEvent args) { if (args.Target == args.User) @@ -235,16 +248,9 @@ bool Check() }; if (!hidden && Check() && userHands.ActiveHandEntity != null) - { - bool subtle = (ev.Stealth == ThievingStealth.Subtle); - PopupType? popupSize = _thieving.GetPopupTypeFromStealth(ev.Stealth); - - if (popupSize.HasValue) // We should always have a value if we're not hidden - _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-insert", - ("user", subtle ? "Someone" : Identity.Entity(user, EntityManager)), - ("item", subtle ? "something" : userHands.ActiveHandEntity)), - target, target, popupSize.Value); - } + StripPopup("strippable-component-alert-owner-insert", ev.Stealth, target, + user: Identity.Entity(user, EntityManager), + item: userHands.ActiveHandEntity.Value); var prefix = hidden ? "stealthily " : ""; _adminLogger.Add(LogType.Stripping, LogImpact.Low, $"{ToPrettyString(user):actor} is trying to {prefix}place the item {ToPrettyString(held):item} in {ToPrettyString(target):target}'s {slot} slot"); @@ -387,18 +393,11 @@ bool Check() if (popupSize.HasValue) // We should always have a value if we're not hidden if (slotDef.StripHidden) - { - _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner-hidden", - ("slot", slot)), - target, target, popupSize.Value); - } + StripPopup("strippable-component-alert-owner-hidden", ev.Stealth, target, slot: slot); else if (_inventorySystem.TryGetSlotEntity(strippable, slot, out var slotItem)) - { - _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner", - ("user", (ev.Stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)), - ("item", slotItem)), - target, target, popupSize.Value); - } + StripPopup("strippable-component-alert-owner", ev.Stealth, target, + user: Identity.Entity(user, EntityManager), + item: slotItem); } var prefix = hidden ? "stealthily " : ""; @@ -468,15 +467,9 @@ bool Check() }; if (!hidden && Check() && _handsSystem.TryGetHand(target, handName, out var handSlot, hands) && handSlot.HeldEntity != null) - { - PopupType? popupSize = _thieving.GetPopupTypeFromStealth(ev.Stealth); - - if (popupSize.HasValue) // We should always have a value if we're not hidden - _popup.PopupEntity(Loc.GetString("strippable-component-alert-owner", - ("user", (ev.Stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)), - ("item", item)), - strippable.Owner, strippable.Owner, popupSize.Value); - } + StripPopup("strippable-component-alert-owner", ev.Stealth, target, + user: Identity.Entity(user, EntityManager), + item: item); var prefix = hidden ? "stealthily " : ""; _adminLogger.Add(LogType.Stripping, LogImpact.Low, diff --git a/Resources/Locale/en-US/strip/strippable-component.ftl b/Resources/Locale/en-US/strip/strippable-component.ftl index 7654b20b03f..65d7844ee22 100644 --- a/Resources/Locale/en-US/strip/strippable-component.ftl +++ b/Resources/Locale/en-US/strip/strippable-component.ftl @@ -19,4 +19,8 @@ strip-verb-get-data-text = Strip ## UI strippable-bound-user-interface-stripping-menu-title = {$ownerName}'s inventory -strippable-bound-user-interface-stripping-menu-ensnare-button = Remove Leg Restraints \ No newline at end of file +strippable-bound-user-interface-stripping-menu-ensnare-button = Remove Leg Restraints + +# Stealth +thieving-component-user = Someone +thieving-component-item = something \ No newline at end of file From 469f728a5acc97e99a719c78226eeb0363723ea2 Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 18:14:48 +1000 Subject: [PATCH 14/18] move Thieving to Physical category --- Resources/Prototypes/Traits/skills.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Resources/Prototypes/Traits/skills.yml b/Resources/Prototypes/Traits/skills.yml index 93cb01102b4..6175834c1fc 100644 --- a/Resources/Prototypes/Traits/skills.yml +++ b/Resources/Prototypes/Traits/skills.yml @@ -1,6 +1,6 @@ - type: trait id: Thieving - category: Uncategorized + category: Physical points: -4 components: - type: Thieving From 60ba9af831585bc0c8fedb2f974017ce29ae2711 Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Mon, 1 Jul 2024 18:27:39 +1000 Subject: [PATCH 15/18] move StripPopup(...) to shared --- Content.Server/Strip/StrippableSystem.cs | 13 ------------- .../EntitySystems/ToggleableClothingSystem.cs | 10 +--------- Content.Shared/Strip/SharedStrippableSystem.cs | 17 +++++++++++++++++ 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/Content.Server/Strip/StrippableSystem.cs b/Content.Server/Strip/StrippableSystem.cs index 695867d7196..3617b2e6828 100644 --- a/Content.Server/Strip/StrippableSystem.cs +++ b/Content.Server/Strip/StrippableSystem.cs @@ -160,19 +160,6 @@ private void AddStripExamineVerb(EntityUid uid, StrippableComponent component, G args.Verbs.Add(verb); } - private void StripPopup(string messageId, ThievingStealth stealth, EntityUid target, EntityUid? user = null, EntityUid? item = null, string slot = "") - { - bool subtle = (stealth == ThievingStealth.Subtle); - PopupType? popupSize = _thieving.GetPopupTypeFromStealth(stealth); - - if (popupSize.HasValue) // We should always have a value if we're not hidden - _popup.PopupEntity(Loc.GetString(messageId, - ("user", subtle ? Loc.GetString("thieving-component-user") : user ?? EntityUid.Invalid), - ("item", subtle ? Loc.GetString("thieving-component-item") : item ?? EntityUid.Invalid), - ("slot", slot)), - target, target, popupSize.Value); - } - private void OnActivateInWorld(EntityUid uid, StrippableComponent component, ActivateInWorldEvent args) { if (args.Target == args.User) diff --git a/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs b/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs index d15272d6730..4a823b96a86 100644 --- a/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs +++ b/Content.Shared/Clothing/EntitySystems/ToggleableClothingSystem.cs @@ -114,15 +114,7 @@ private void StartDoAfter(EntityUid user, EntityUid item, EntityUid wearer, Togg return; if (!hidden) - { - PopupType? popupSize = _thieving.GetPopupTypeFromStealth(stealth); - - if (popupSize.HasValue) // we should always have a value if we're not hidden - _popupSystem.PopupEntity(Loc.GetString("strippable-component-alert-owner-interact", - ("user", (stealth == ThievingStealth.Subtle) ? "Someone" : Identity.Entity(user, EntityManager)), - ("item", item)), - wearer, wearer, popupSize.Value); - } + _strippable.StripPopup("strippable-component-alert-owner-interact", stealth, wearer, user: Identity.Entity(user, EntityManager), item: item); } private void OnGetAttachedStripVerbsEvent(EntityUid uid, AttachedClothingComponent component, GetVerbsEvent args) diff --git a/Content.Shared/Strip/SharedStrippableSystem.cs b/Content.Shared/Strip/SharedStrippableSystem.cs index ebbd9da45a2..6c4f86981f6 100644 --- a/Content.Shared/Strip/SharedStrippableSystem.cs +++ b/Content.Shared/Strip/SharedStrippableSystem.cs @@ -1,11 +1,15 @@ using Content.Shared.DragDrop; using Content.Shared.Hands.Components; +using Content.Shared.Popups; +using Content.Shared.Strip; using Content.Shared.Strip.Components; namespace Content.Shared.Strip; public abstract class SharedStrippableSystem : EntitySystem { + [Dependency] private readonly SharedPopupSystem _popup = default!; + [Dependency] private readonly ThievingSystem _thieving = default!; public override void Initialize() { base.Initialize(); @@ -55,4 +59,17 @@ private void OnCanDrop(EntityUid uid, StrippableComponent component, ref CanDrop if (args.CanDrop) args.Handled = true; } + + public void StripPopup(string messageId, ThievingStealth stealth, EntityUid target, EntityUid? user = null, EntityUid? item = null, string slot = "") + { + bool subtle = stealth == ThievingStealth.Subtle; + PopupType? popupSize = _thieving.GetPopupTypeFromStealth(stealth); + + if (popupSize.HasValue) // We should always have a value if we're not hidden + _popup.PopupEntity(Loc.GetString(messageId, + ("user", subtle ? Loc.GetString("thieving-component-user") : user ?? EntityUid.Invalid), + ("item", subtle ? Loc.GetString("thieving-component-item") : item ?? EntityUid.Invalid), + ("slot", slot)), + target, target, popupSize.Value); + } } From 93a658ca49cfa80923fcffbf4a51b557a567384d Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:41:26 +1000 Subject: [PATCH 16/18] cull namespace diffs --- Content.Shared/Strip/SharedStrippableSystem.cs | 1 - Content.Shared/Strip/ThievingSystem.cs | 2 -- 2 files changed, 3 deletions(-) diff --git a/Content.Shared/Strip/SharedStrippableSystem.cs b/Content.Shared/Strip/SharedStrippableSystem.cs index 1a6c7c9734f..64dd6a81f3a 100644 --- a/Content.Shared/Strip/SharedStrippableSystem.cs +++ b/Content.Shared/Strip/SharedStrippableSystem.cs @@ -1,7 +1,6 @@ using Content.Shared.DragDrop; using Content.Shared.Hands.Components; using Content.Shared.Popups; -using Content.Shared.Strip; using Content.Shared.Strip.Components; namespace Content.Shared.Strip; diff --git a/Content.Shared/Strip/ThievingSystem.cs b/Content.Shared/Strip/ThievingSystem.cs index 4ac5ffd80ac..8f523accfea 100644 --- a/Content.Shared/Strip/ThievingSystem.cs +++ b/Content.Shared/Strip/ThievingSystem.cs @@ -1,9 +1,7 @@ using Content.Shared.Inventory; using Content.Shared.Popups; -using Content.Shared.Strip; using Content.Shared.Strip.Components; using Robust.Shared.Serialization; -using Robust.Shared.Utility; namespace Content.Shared.Strip; From 35d710385b80aeb1e08b2329f02ac47750801fb3 Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Tue, 2 Jul 2024 11:44:08 +1000 Subject: [PATCH 17/18] change multiplier back to timespan --- Content.Shared/Strip/Components/StrippableComponent.cs | 4 ++-- Content.Shared/Strip/Components/ThievingComponent.cs | 2 +- Content.Shared/Strip/ThievingSystem.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Content.Shared/Strip/Components/StrippableComponent.cs b/Content.Shared/Strip/Components/StrippableComponent.cs index 00725808297..7afeb45e83f 100644 --- a/Content.Shared/Strip/Components/StrippableComponent.cs +++ b/Content.Shared/Strip/Components/StrippableComponent.cs @@ -35,11 +35,11 @@ public sealed class StrippingEnsnareButtonPressed : BoundUserInterfaceMessage; public abstract class BaseBeforeStripEvent(TimeSpan initialTime, ThievingStealth stealth = ThievingStealth.Obvious) : EntityEventArgs, IInventoryRelayEvent { public readonly TimeSpan InitialTime = initialTime; - public float Multiplier = 1f; + public TimeSpan Multiplier = TimeSpan.FromSeconds(1f); public TimeSpan Additive = TimeSpan.Zero; public ThievingStealth Stealth = stealth; - public TimeSpan Time => TimeSpan.FromSeconds(MathF.Max(InitialTime.Seconds * Multiplier + Additive.Seconds, 0f)); + public TimeSpan Time => TimeSpan.FromSeconds(MathF.Max(InitialTime.Seconds * Multiplier.Seconds + Additive.Seconds, 0f)); public SlotFlags TargetSlots { get; } = SlotFlags.GLOVES; } diff --git a/Content.Shared/Strip/Components/ThievingComponent.cs b/Content.Shared/Strip/Components/ThievingComponent.cs index 1d584627727..fd65d4e3bd9 100644 --- a/Content.Shared/Strip/Components/ThievingComponent.cs +++ b/Content.Shared/Strip/Components/ThievingComponent.cs @@ -16,7 +16,7 @@ public sealed partial class ThievingComponent : Component /// A multiplier coefficient for strip time /// [DataField] - public float StripTimeMultiplier = 1f; + public TimeSpan StripTimeMultiplier = TimeSpan.FromSeconds(1f); /// /// Should it notify the user if they're stripping a pocket? diff --git a/Content.Shared/Strip/ThievingSystem.cs b/Content.Shared/Strip/ThievingSystem.cs index 8f523accfea..6dd0af9c296 100644 --- a/Content.Shared/Strip/ThievingSystem.cs +++ b/Content.Shared/Strip/ThievingSystem.cs @@ -20,7 +20,7 @@ private void OnBeforeStrip(EntityUid uid, ThievingComponent component, BeforeStr { args.Stealth = (ThievingStealth) Math.Max((sbyte) args.Stealth, (sbyte) component.Stealth); args.Additive -= component.StripTimeReduction; - args.Multiplier *= component.StripTimeMultiplier; + args.Multiplier *= component.StripTimeMultiplier.Seconds; } public PopupType? GetPopupTypeFromStealth(ThievingStealth stealth) From ddb64fa091ad4222446ddf42fd041e4591b727a1 Mon Sep 17 00:00:00 2001 From: WarMechanic <69510347+WarMechanic@users.noreply.github.com> Date: Tue, 2 Jul 2024 17:40:38 +1000 Subject: [PATCH 18/18] change strip multiplier back to float --- Content.Shared/Strip/Components/ThievingComponent.cs | 2 +- Content.Shared/Strip/ThievingSystem.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Content.Shared/Strip/Components/ThievingComponent.cs b/Content.Shared/Strip/Components/ThievingComponent.cs index fd65d4e3bd9..1d584627727 100644 --- a/Content.Shared/Strip/Components/ThievingComponent.cs +++ b/Content.Shared/Strip/Components/ThievingComponent.cs @@ -16,7 +16,7 @@ public sealed partial class ThievingComponent : Component /// A multiplier coefficient for strip time /// [DataField] - public TimeSpan StripTimeMultiplier = TimeSpan.FromSeconds(1f); + public float StripTimeMultiplier = 1f; /// /// Should it notify the user if they're stripping a pocket? diff --git a/Content.Shared/Strip/ThievingSystem.cs b/Content.Shared/Strip/ThievingSystem.cs index 6dd0af9c296..8f523accfea 100644 --- a/Content.Shared/Strip/ThievingSystem.cs +++ b/Content.Shared/Strip/ThievingSystem.cs @@ -20,7 +20,7 @@ private void OnBeforeStrip(EntityUid uid, ThievingComponent component, BeforeStr { args.Stealth = (ThievingStealth) Math.Max((sbyte) args.Stealth, (sbyte) component.Stealth); args.Additive -= component.StripTimeReduction; - args.Multiplier *= component.StripTimeMultiplier.Seconds; + args.Multiplier *= component.StripTimeMultiplier; } public PopupType? GetPopupTypeFromStealth(ThievingStealth stealth)