]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
progress
authorScarKy0 <scarky0@onet.eu>
Thu, 14 Nov 2024 16:21:03 +0000 (17:21 +0100)
committerScarKy0 <scarky0@onet.eu>
Thu, 14 Nov 2024 16:21:03 +0000 (17:21 +0100)
Content.Server/Silicons/Laws/SiliconLawSystem.cs
Content.Server/Silicons/Laws/StartIonStormedSystem.cs [deleted file]
Content.Shared/Silicons/Laws/Components/EmagSiliconLawComponent.cs
Content.Shared/Silicons/Laws/Components/SiliconLawProviderComponent.cs
Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs [deleted file]

index c2aa20f401c59ca3d0966bbdc921c70853a979d3..a4a7ee528f70978af25fd83f742e6046a893a5a5 100644 (file)
@@ -1,3 +1,4 @@
+using System.Diagnostics;
 using System.Linq;
 using Content.Server.Administration;
 using Content.Server.Chat.Managers;
@@ -22,7 +23,6 @@ using Robust.Shared.Player;
 using Robust.Shared.Prototypes;
 using Robust.Shared.Toolshed;
 using Robust.Shared.Audio;
-using Robust.Shared.GameObjects;
 
 namespace Content.Server.Silicons.Laws;
 
@@ -50,11 +50,9 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
 
         SubscribeLocalEvent<SiliconLawProviderComponent, GetSiliconLawsEvent>(OnDirectedGetLaws);
         SubscribeLocalEvent<SiliconLawProviderComponent, IonStormLawsEvent>(OnIonStormLaws);
+        SubscribeLocalEvent<SiliconLawProviderComponent, MindAddedMessage>(OnLawProviderMindAdded);
+        SubscribeLocalEvent<SiliconLawProviderComponent, MindRemovedMessage>(OnLawProviderMindRemoved);
         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)
@@ -73,6 +71,22 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
             actor.PlayerSession.Channel, colorOverride: Color.FromHex("#2ed2fd"));
     }
 
+    private void OnLawProviderMindAdded(EntityUid uid, SiliconLawProviderComponent component, MindAddedMessage args)
+    {
+        if (!component.Subverted)
+            return;
+        EnsureSubvertedSiliconRole(uid);
+    }
+
+    private void OnLawProviderMindRemoved(EntityUid uid, SiliconLawProviderComponent component, MindRemovedMessage args)
+    {
+        if (!component.Subverted)
+            return;
+        RemoveSubvertedSiliconRole(uid);
+
+    }
+
+
     private void OnToggleLawsScreen(EntityUid uid, SiliconLawBoundComponent component, ToggleLawsScreenEvent args)
     {
         if (args.Handled || !TryComp<ActorComponent>(uid, out var actor))
@@ -119,9 +133,11 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
             // gotta tell player to check their laws
             NotifyLawsChanged(uid, component.LawUploadSound);
 
+            // Show the silicon has been subverted.
+            component.Subverted = true;
+
             // new laws may allow antagonist behaviour so make it clear for admins
-            if (TryComp<EmagSiliconLawComponent>(uid, out var emag))
-                EnsureEmaggedRole(uid, emag);
+            EnsureSubvertedSiliconRole(uid);
 
         }
     }
@@ -132,6 +148,9 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
         if (component.Lawset == null)
             component.Lawset = GetLawset(component.Laws);
 
+        // Show the silicon has been subverted.
+        component.Subverted = true;
+
         // Add the first emag law before the others
         component.Lawset?.Laws.Insert(0, new SiliconLaw
         {
@@ -154,58 +173,29 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem
 
         base.OnGotEmagged(uid, component, ref args);
         NotifyLawsChanged(uid, component.EmaggedSound);
-        EnsureEmaggedRole(uid, component);
+        EnsureSubvertedSiliconRole(uid);
 
         _stunSystem.TryParalyze(uid, component.StunTime, true);
 
     }
 
-    private void OnEmagMindAdded(EntityUid uid, EmagSiliconLawComponent component, MindAddedMessage args)
-    {
-        if (HasComp<EmaggedComponent>(uid))
-            EnsureEmaggedRole(uid, component);
-    }
-
-    private void OnEmagMindRemoved(EntityUid uid, EmagSiliconLawComponent component, MindRemovedMessage args)
+    private void EnsureSubvertedSiliconRole(EntityUid uid)
     {
-        if (component.AntagonistRole == null)
-            return;
-
-        _roles.MindTryRemoveRole<SubvertedSiliconRoleComponent>(args.Mind);
-    }
-
-    private void EnsureEmaggedRole(EntityUid uid, EmagSiliconLawComponent component)
-    {
-        if (component.AntagonistRole == null || !_mind.TryGetMind(uid, out var mindId, out _))
+        if (!_mind.TryGetMind(uid, out var mindId, out _))
             return;
 
         if (!_roles.MindHasRole<SubvertedSiliconRoleComponent>(mindId))
             _roles.MindAddRole(mindId, "MindRoleSubvertedSilicon");
-    }
-
-    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)
+    private void RemoveSubvertedSiliconRole(EntityUid uid)
     {
-        if (component.AntagonistRole == null || !_mind.TryGetMind(uid, out var mindId, out _))
+        if (!_mind.TryGetMind(uid, out var mindId, out _))
             return;
 
         if (_roles.MindHasRole<SubvertedSiliconRoleComponent>(mindId))
-            return;
-
-        _roles.MindAddRole(mindId, new SubvertedSiliconRoleComponent { PrototypeId = component.AntagonistRole });
+            _roles.MindTryRemoveRole<SubvertedSiliconRoleComponent>(mindId);
     }
 
     public SiliconLawset GetLaws(EntityUid uid, SiliconLawBoundComponent? component = null)
diff --git a/Content.Server/Silicons/Laws/StartIonStormedSystem.cs b/Content.Server/Silicons/Laws/StartIonStormedSystem.cs
deleted file mode 100644 (file)
index ee2ce7b..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-using Content.Shared.Silicons.Laws.Components;
-using Content.Shared.Administration.Logs;
-using Content.Shared.Database;
-
-namespace Content.Server.Silicons.Laws;
-
-/// <summary>
-/// This handles running the ion storm event a on specific entity when that entity is spawned in.
-/// </summary>
-public sealed class StartIonStormedSystem : EntitySystem
-{
-    [Dependency] private readonly IonStormSystem _ionStorm = default!;
-    [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
-    [Dependency] private readonly SiliconLawSystem _siliconLaw = default!;
-
-    public override void Initialize()
-    {
-        base.Initialize();
-        SubscribeLocalEvent<StartIonStormedComponent, MapInitEvent>(OnMapInit);
-    }
-
-    //private void OnMapInit(EntityUid uid, StartIonStormedComponent component, ref MapInitEvent args)'
-    private void OnMapInit(Entity<StartIonStormedComponent> ent, ref MapInitEvent args)
-    {
-        if (!TryComp<SiliconLawBoundComponent>(ent.Owner, out var lawBound))
-            return;
-        if (!TryComp<IonStormTargetComponent>(ent.Owner, out var target))
-            return;
-
-        for (int currentIonStorm = 0; currentIonStorm < ent.Comp.IonStormAmount; currentIonStorm++)
-        {
-            _ionStorm.IonStormTarget((ent.Owner, lawBound, target), false);
-        }
-
-        var laws = _siliconLaw.GetLaws(ent.Owner, lawBound);
-        _adminLogger.Add(LogType.Mind, LogImpact.High, $"{ToPrettyString(ent.Owner):silicon} spawned with ion stormed laws: {laws.LoggingString()}");
-    }
-}
index 1b5338a7f758ea8d22a3a3eb388dead42f98d46a..5fe867ae29add59b4f4a5b4b9e7356e3afe7686a 100644 (file)
@@ -29,13 +29,6 @@ public sealed partial class EmagSiliconLawComponent : Component
     [DataField, ViewVariables(VVAccess.ReadWrite)]
     public TimeSpan StunTime = TimeSpan.Zero;
 
-    /// <summary>
-    /// A role given to entities with this component when they are emagged.
-    /// Mostly just for admin purposes.
-    /// </summary>
-    [DataField]
-    public ProtoId<AntagPrototype>? AntagonistRole = "SubvertedSilicon";
-
     /// <summary>
     /// The sound that plays for the borg player
     /// to let them know they've been emagged
index 4885bd0265c489635394eaf7173305f2901b5557..d78e539aa9625a8922481e71ad1aa834265f2047 100644 (file)
@@ -29,4 +29,10 @@ public sealed partial class SiliconLawProviderComponent : Component
     [DataField]
     public SoundSpecifier? LawUploadSound = new SoundPathSpecifier("/Audio/Misc/cryo_warning.ogg");
 
+    /// <summary>
+    /// Whether this silicon is subverted by an ion storm or emag.
+    /// </summary>
+    [DataField]
+    public bool Subverted = false;
+
 }
diff --git a/Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs b/Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs
deleted file mode 100644 (file)
index 75d7412..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-using Content.Shared.Roles;
-using Robust.Shared.Prototypes;
-
-namespace Content.Shared.Silicons.Laws.Components;
-
-/// <summary>
-/// Applies law altering ion storms on a specific entity IonStormAmount times when the entity is spawned.
-/// </summary>
-[RegisterComponent]
-public sealed partial class StartIonStormedComponent : Component
-{
-    /// <summary>
-    /// Amount of times that the ion storm will be run on the entity on spawn.
-    /// </summary>
-    [DataField]
-    public int IonStormAmount = 1;
-
-    /// <summary>
-    /// A role given to entities with this component when a mind enters it.
-    /// Mostly just for admin purposes.
-    /// </summary>
-    [DataField]
-    public ProtoId<AntagPrototype>? AntagonistRole = "SubvertedSilicon";
-}