From 21906f45bf04f7c8dee839e36a77e3f34b0a55b4 Mon Sep 17 00:00:00 2001 From: Rane <60792108+Elijahrane@users.noreply.github.com> Date: Tue, 6 Dec 2022 18:18:46 -0500 Subject: [PATCH] examine for stealth effect (#12486) Co-authored-by: Kara --- Content.Shared/Stealth/Components/StealthComponent.cs | 6 ++++++ Content.Shared/Stealth/SharedStealthSystem.cs | 11 +++++++++-- Resources/Locale/en-US/visual_effects.ftl | 1 + 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 Resources/Locale/en-US/visual_effects.ftl diff --git a/Content.Shared/Stealth/Components/StealthComponent.cs b/Content.Shared/Stealth/Components/StealthComponent.cs index be7bbe2f54..6a4cc23e74 100644 --- a/Content.Shared/Stealth/Components/StealthComponent.cs +++ b/Content.Shared/Stealth/Components/StealthComponent.cs @@ -61,6 +61,12 @@ public sealed class StealthComponent : Component /// [DataField("maxVisibility")] public readonly float MaxVisibility = 1.5f; + + /// + /// Localization string for how you'd like to describe this effect. + /// + [DataField("examinedDesc")] + public string ExaminedDesc = "stealth-visual-effect"; } [Serializable, NetSerializable] diff --git a/Content.Shared/Stealth/SharedStealthSystem.cs b/Content.Shared/Stealth/SharedStealthSystem.cs index 46d04beaff..7d5840c9a2 100644 --- a/Content.Shared/Stealth/SharedStealthSystem.cs +++ b/Content.Shared/Stealth/SharedStealthSystem.cs @@ -19,10 +19,11 @@ public abstract class SharedStealthSystem : EntitySystem SubscribeLocalEvent(OnGetVisibilityModifiers); SubscribeLocalEvent(OnPaused); SubscribeLocalEvent(OnInit); - SubscribeLocalEvent(OnExamine); + SubscribeLocalEvent(OnExamineAttempt); + SubscribeLocalEvent(OnExamined); } - private void OnExamine(EntityUid uid, StealthComponent component, ExamineAttemptEvent args) + private void OnExamineAttempt(EntityUid uid, StealthComponent component, ExamineAttemptEvent args) { if (!component.Enabled || GetVisibility(uid, component) > component.ExamineThreshold) return; @@ -41,6 +42,12 @@ public abstract class SharedStealthSystem : EntitySystem args.Cancel(); } + private void OnExamined(EntityUid uid, StealthComponent component, ExaminedEvent args) + { + if (component.Enabled) + args.PushMarkup(Loc.GetString(component.ExaminedDesc, ("target", uid))); + } + public virtual void SetEnabled(EntityUid uid, bool value, StealthComponent? component = null) { if (!Resolve(uid, ref component, false) || component.Enabled == value) diff --git a/Resources/Locale/en-US/visual_effects.ftl b/Resources/Locale/en-US/visual_effects.ftl new file mode 100644 index 0000000000..d01dd10518 --- /dev/null +++ b/Resources/Locale/en-US/visual_effects.ftl @@ -0,0 +1 @@ +stealth-visual-effect = [color=lightslategray]{CAPITALIZE(SUBJECT($target))} {CONJUGATE-BASIC($target, "shimmer", "shimmers")} with strange transparency.[/color]