From b35d2902d4fc0c0322a1f74d0f208ca860990eee Mon Sep 17 00:00:00 2001 From: The Canned One Date: Sat, 5 Oct 2024 15:09:36 +0200 Subject: [PATCH] Fixed cyborgs with the StartIonStormedComponent (which is just the Derelict Cyborg right now) not showing up as 'antag' in the admin player overlay. --- .../Silicons/Laws/SiliconLawSystem.cs | 27 +++++++++++++++++++ .../Components/StartIonStormedComponent.cs | 10 +++++++ 2 files changed, 37 insertions(+) diff --git a/Content.Server/Silicons/Laws/SiliconLawSystem.cs b/Content.Server/Silicons/Laws/SiliconLawSystem.cs index 6b7df52a6e..27ed6702d6 100644 --- a/Content.Server/Silicons/Laws/SiliconLawSystem.cs +++ b/Content.Server/Silicons/Laws/SiliconLawSystem.cs @@ -51,6 +51,8 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem SubscribeLocalEvent(OnEmagLawsAdded); SubscribeLocalEvent(OnEmagMindAdded); SubscribeLocalEvent(OnEmagMindRemoved); + SubscribeLocalEvent(OnStartIonStormedMindAdded); + SubscribeLocalEvent(OnStartIonStormedMindRemoved); } private void OnMapInit(EntityUid uid, SiliconLawBoundComponent component, MapInitEvent args) @@ -184,6 +186,31 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem _roles.MindAddRole(mindId, new SubvertedSiliconRoleComponent { PrototypeId = component.AntagonistRole }); } + private void OnStartIonStormedMindAdded(EntityUid uid, StartIonStormedComponent component, MindAddedMessage args) + { + if (HasComp(uid)) + EnsureStartIonStormedRole(uid, component); + } + + private void OnStartIonStormedMindRemoved(EntityUid uid, StartIonStormedComponent component, MindRemovedMessage args) + { + if (component.AntagonistRole == null) + return; + + _roles.MindTryRemoveRole(args.Mind); + } + + private void EnsureStartIonStormedRole(EntityUid uid, StartIonStormedComponent component) + { + if (component.AntagonistRole == null || !_mind.TryGetMind(uid, out var mindId, out _)) + return; + + if (_roles.MindHasRole(mindId)) + return; + + _roles.MindAddRole(mindId, new SubvertedSiliconRoleComponent { PrototypeId = component.AntagonistRole }); + } + public SiliconLawset GetLaws(EntityUid uid, SiliconLawBoundComponent? component = null) { if (!Resolve(uid, ref component)) diff --git a/Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs b/Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs index e73d17b87b..d57241c857 100644 --- a/Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs +++ b/Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs @@ -1,3 +1,6 @@ +using Content.Shared.Roles;//Used +using Robust.Shared.Prototypes;// + namespace Content.Shared.Silicons.Laws.Components; /// @@ -11,4 +14,11 @@ public sealed partial class StartIonStormedComponent : Component /// [DataField] public int IonStormAmount = 1; + + /// + /// A role given to entities with this component when they are thing-that-is-not-emagged. + /// Mostly just for admin purposes. + /// + [DataField] + public ProtoId? AntagonistRole = "SubvertedSilicon"; } -- 2.52.0