From 2a143c873cd2e5ee6e7492b36946847fe350f0a8 Mon Sep 17 00:00:00 2001
From: Morb <14136326+Morb0@users.noreply.github.com>
Date: Mon, 11 Sep 2023 08:52:56 +0300
Subject: [PATCH] SSD Indicator (#19701)
---
.../SSDIndicator/SSDIndicatorSystem.cs | 32 ++++++++++++++++++
Content.Shared/CCVar/CCVars.cs | 6 ++++
.../SSDIndicator/SSDIndicatorComponent.cs | 21 ++++++++++++
.../SSDIndicator/SSDIndicatorSystem.cs | 27 +++++++++++++++
.../Prototypes/Entities/Mobs/Species/base.yml | 1 +
Resources/Prototypes/StatusEffects/ssd.yml | 6 ++++
.../Textures/Effects/ssd.rsi/default0.png | Bin 0 -> 200 bytes
Resources/Textures/Effects/ssd.rsi/meta.json | 14 ++++++++
8 files changed, 107 insertions(+)
create mode 100644 Content.Client/SSDIndicator/SSDIndicatorSystem.cs
create mode 100644 Content.Shared/SSDIndicator/SSDIndicatorComponent.cs
create mode 100644 Content.Shared/SSDIndicator/SSDIndicatorSystem.cs
create mode 100644 Resources/Prototypes/StatusEffects/ssd.yml
create mode 100644 Resources/Textures/Effects/ssd.rsi/default0.png
create mode 100644 Resources/Textures/Effects/ssd.rsi/meta.json
diff --git a/Content.Client/SSDIndicator/SSDIndicatorSystem.cs b/Content.Client/SSDIndicator/SSDIndicatorSystem.cs
new file mode 100644
index 0000000000..dc7548f8e4
--- /dev/null
+++ b/Content.Client/SSDIndicator/SSDIndicatorSystem.cs
@@ -0,0 +1,32 @@
+using Content.Shared.CCVar;
+using Content.Shared.SSDIndicator;
+using Content.Shared.StatusIcon;
+using Content.Shared.StatusIcon.Components;
+using Robust.Shared.Configuration;
+using Robust.Shared.Prototypes;
+
+namespace Content.Client.SSDIndicator;
+
+///
+/// Handles displaying SSD indicator as status icon
+///
+public sealed class SSDIndicatorSystem : EntitySystem
+{
+ [Dependency] private readonly IPrototypeManager _prototype = default!;
+ [Dependency] private readonly IConfigurationManager _cfg = default!;
+
+ public override void Initialize()
+ {
+ base.Initialize();
+
+ SubscribeLocalEvent(OnGetStatusIcon);
+ }
+
+ private void OnGetStatusIcon(EntityUid uid, SSDIndicatorComponent component, ref GetStatusIconsEvent args)
+ {
+ if (!component.IsSSD || !_cfg.GetCVar(CCVars.ICShowSSDIndicator))
+ return;
+
+ args.StatusIcons.Add(_prototype.Index(component.Icon));
+ }
+}
diff --git a/Content.Shared/CCVar/CCVars.cs b/Content.Shared/CCVar/CCVars.cs
index bd9375f103..34294ebcbd 100644
--- a/Content.Shared/CCVar/CCVars.cs
+++ b/Content.Shared/CCVar/CCVars.cs
@@ -1461,6 +1461,12 @@ namespace Content.Shared.CCVar
public static readonly CVarDef ICRandomSpeciesWeights =
CVarDef.Create("ic.random_species_weights", "SpeciesWeights", CVar.SERVER);
+ ///
+ /// Control displaying SSD indicators near players
+ ///
+ public static readonly CVarDef ICShowSSDIndicator =
+ CVarDef.Create("ic.show_ssd_indicator", true, CVar.CLIENTONLY);
+
/*
* Salvage
*/
diff --git a/Content.Shared/SSDIndicator/SSDIndicatorComponent.cs b/Content.Shared/SSDIndicator/SSDIndicatorComponent.cs
new file mode 100644
index 0000000000..66310505a1
--- /dev/null
+++ b/Content.Shared/SSDIndicator/SSDIndicatorComponent.cs
@@ -0,0 +1,21 @@
+using Content.Shared.StatusIcon;
+using Robust.Shared.GameStates;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
+
+namespace Content.Shared.SSDIndicator;
+
+///
+/// Shows status icon when player in SSD
+///
+[RegisterComponent, NetworkedComponent]
+[AutoGenerateComponentState]
+public sealed partial class SSDIndicatorComponent : Component
+{
+ [ViewVariables(VVAccess.ReadWrite)]
+ [AutoNetworkedField]
+ public bool IsSSD = true;
+
+ [ViewVariables(VVAccess.ReadWrite)]
+ [DataField("icon", customTypeSerializer: typeof(PrototypeIdSerializer))]
+ public string Icon = "SSDIcon";
+}
diff --git a/Content.Shared/SSDIndicator/SSDIndicatorSystem.cs b/Content.Shared/SSDIndicator/SSDIndicatorSystem.cs
new file mode 100644
index 0000000000..d6db56be9c
--- /dev/null
+++ b/Content.Shared/SSDIndicator/SSDIndicatorSystem.cs
@@ -0,0 +1,27 @@
+using Content.Shared.Mind.Components;
+
+namespace Content.Shared.SSDIndicator;
+
+///
+/// Handle changing player SSD indicator status
+///
+public sealed class SSDIndicatorSystem : EntitySystem
+{
+ public override void Initialize()
+ {
+ SubscribeLocalEvent(OnMindAdded);
+ SubscribeLocalEvent(OnMindRemoved);
+ }
+
+ private void OnMindAdded(EntityUid uid, SSDIndicatorComponent component, MindAddedMessage args)
+ {
+ component.IsSSD = false;
+ Dirty(uid, component);
+ }
+
+ private void OnMindRemoved(EntityUid uid, SSDIndicatorComponent component, MindRemovedMessage args)
+ {
+ component.IsSSD = true;
+ Dirty(uid, component);
+ }
+}
diff --git a/Resources/Prototypes/Entities/Mobs/Species/base.yml b/Resources/Prototypes/Entities/Mobs/Species/base.yml
index f2625090f6..464e8b510b 100644
--- a/Resources/Prototypes/Entities/Mobs/Species/base.yml
+++ b/Resources/Prototypes/Entities/Mobs/Species/base.yml
@@ -312,6 +312,7 @@
deathPenalty: 0.01 # However they really ought to be living and intact, otherwise they're worth 100x less.
- type: ContentEye
- type: SleepEmitSound
+ - type: SSDIndicator
- type: entity
save: false
diff --git a/Resources/Prototypes/StatusEffects/ssd.yml b/Resources/Prototypes/StatusEffects/ssd.yml
new file mode 100644
index 0000000000..70253cc6b1
--- /dev/null
+++ b/Resources/Prototypes/StatusEffects/ssd.yml
@@ -0,0 +1,6 @@
+- type: statusIcon
+ id: SSDIcon
+ icon:
+ sprite: /Textures/Effects/ssd.rsi
+ state: default0
+ locationPreference: Left
diff --git a/Resources/Textures/Effects/ssd.rsi/default0.png b/Resources/Textures/Effects/ssd.rsi/default0.png
new file mode 100644
index 0000000000000000000000000000000000000000..bfd8c84da99a874861d8ef47b8c7f4891adf1901
GIT binary patch
literal 200
zcmeAS@N?(olHy`uVBq!ia0vp^3LwnE1|*BCs=fdz&H|6fVg?4jBOuH;Rhv&5C|Kp`
z;uumf=j|0kt_BAI<^vpdul~i~UGFDw<;~8F$H&xGvUKx!mmEEx=-_|PT$MrM%N~bG
z92Q>sCu*ji*FV&-O}tMesBGd6M!n}jZ6ZublGDZCDc)yD?mBLf-*DNVMd9WF+a~{y
ooB{uYtC&5K8W`Cm5}<^1V+enV!Z
literal 0
HcmV?d00001
diff --git a/Resources/Textures/Effects/ssd.rsi/meta.json b/Resources/Textures/Effects/ssd.rsi/meta.json
new file mode 100644
index 0000000000..6c5e7b24e3
--- /dev/null
+++ b/Resources/Textures/Effects/ssd.rsi/meta.json
@@ -0,0 +1,14 @@
+{
+ "version": 1,
+ "license": "CC-BY-SA-3.0",
+ "copyright": "Take from https://github.com/Skyrat-SS13/Skyrat-tg/blob/92377cd6203bc4d93a6e289d7b857e19bb6cf338/modular_skyrat/modules/indicators/icons/ssd_indicator.dmi",
+ "size": {
+ "x": 32,
+ "y": 32
+ },
+ "states": [
+ {
+ "name": "default0"
+ }
+ ]
+}
--
2.51.2