]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fixed cyborgs with the StartIonStormedComponent (which is just the Derelict Cyborg...
authorThe Canned One <greentopcan@gmail.com>
Sat, 5 Oct 2024 13:09:36 +0000 (15:09 +0200)
committerThe Canned One <greentopcan@gmail.com>
Sat, 5 Oct 2024 13:09:36 +0000 (15:09 +0200)
Content.Server/Silicons/Laws/SiliconLawSystem.cs
Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs

index 6b7df52a6ebc1de13b9a2b98fe5f5983d06f9a46..27ed6702d6a8ba9814c293a907ecfe8ecf429961 100644 (file)
@@ -51,6 +51,8 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
         SubscribeLocalEvent<SiliconLawProviderComponent, GotEmaggedEvent>(OnEmagLawsAdded);
         SubscribeLocalEvent<EmagSiliconLawComponent, MindAddedMessage>(OnEmagMindAdded);
         SubscribeLocalEvent<EmagSiliconLawComponent, MindRemovedMessage>(OnEmagMindRemoved);
+        SubscribeLocalEvent<StartIonStormedComponent, MindAddedMessage>(OnStartIonStormedMindAdded);
+        SubscribeLocalEvent<StartIonStormedComponent, MindRemovedMessage>(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<StartIonStormedComponent>(uid))
+            EnsureStartIonStormedRole(uid, component);
+    }
+
+    private void OnStartIonStormedMindRemoved(EntityUid uid, StartIonStormedComponent component, MindRemovedMessage args)
+    {
+        if (component.AntagonistRole == null)
+            return;
+
+        _roles.MindTryRemoveRole<SubvertedSiliconRoleComponent>(args.Mind);
+    }
+
+    private void EnsureStartIonStormedRole(EntityUid uid, StartIonStormedComponent component)
+    {
+        if (component.AntagonistRole == null || !_mind.TryGetMind(uid, out var mindId, out _))
+            return;
+
+        if (_roles.MindHasRole<SubvertedSiliconRoleComponent>(mindId))
+            return;
+
+        _roles.MindAddRole(mindId, new SubvertedSiliconRoleComponent { PrototypeId = component.AntagonistRole });
+    }
+
     public SiliconLawset GetLaws(EntityUid uid, SiliconLawBoundComponent? component = null)
     {
         if (!Resolve(uid, ref component))
index e73d17b87bc194605e87bec45e33fe48b224b9d6..d57241c857ca869cbb0523c5b2c7e2db43fef8b5 100644 (file)
@@ -1,3 +1,6 @@
+using Content.Shared.Roles;//Used 
+using Robust.Shared.Prototypes;//
+
 namespace Content.Shared.Silicons.Laws.Components;
 
 /// <summary>
@@ -11,4 +14,11 @@ public sealed partial class StartIonStormedComponent : Component
     /// </summary>
     [DataField]
     public int IonStormAmount = 1;
+
+    /// <summary>
+    /// A role given to entities with this component when they are thing-that-is-not-emagged.
+    /// Mostly just for admin purposes.
+    /// </summary>
+    [DataField]
+    public ProtoId<AntagPrototype>? AntagonistRole = "SubvertedSilicon";
 }