From: ScarKy0 Date: Thu, 14 Nov 2024 16:21:03 +0000 (+0100) Subject: progress X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=0f30639cf25866f285638d36632e4c3ddf07874e;p=space-station-14.git progress --- diff --git a/Content.Server/Silicons/Laws/SiliconLawSystem.cs b/Content.Server/Silicons/Laws/SiliconLawSystem.cs index c2aa20f401..a4a7ee528f 100644 --- a/Content.Server/Silicons/Laws/SiliconLawSystem.cs +++ b/Content.Server/Silicons/Laws/SiliconLawSystem.cs @@ -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(OnDirectedGetLaws); SubscribeLocalEvent(OnIonStormLaws); + SubscribeLocalEvent(OnLawProviderMindAdded); + SubscribeLocalEvent(OnLawProviderMindRemoved); SubscribeLocalEvent(OnEmagLawsAdded); - SubscribeLocalEvent(OnEmagMindAdded); - SubscribeLocalEvent(OnEmagMindRemoved); - SubscribeLocalEvent(OnStartIonStormedMindAdded); - SubscribeLocalEvent(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(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(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(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(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(mindId)) _roles.MindAddRole(mindId, "MindRoleSubvertedSilicon"); - } - - 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) + 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(mindId)) - return; - - _roles.MindAddRole(mindId, new SubvertedSiliconRoleComponent { PrototypeId = component.AntagonistRole }); + _roles.MindTryRemoveRole(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 index ee2ce7b9ed..0000000000 --- a/Content.Server/Silicons/Laws/StartIonStormedSystem.cs +++ /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; - -/// -/// This handles running the ion storm event a on specific entity when that entity is spawned in. -/// -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(OnMapInit); - } - - //private void OnMapInit(EntityUid uid, StartIonStormedComponent component, ref MapInitEvent args)' - private void OnMapInit(Entity ent, ref MapInitEvent args) - { - if (!TryComp(ent.Owner, out var lawBound)) - return; - if (!TryComp(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()}"); - } -} diff --git a/Content.Shared/Silicons/Laws/Components/EmagSiliconLawComponent.cs b/Content.Shared/Silicons/Laws/Components/EmagSiliconLawComponent.cs index 1b5338a7f7..5fe867ae29 100644 --- a/Content.Shared/Silicons/Laws/Components/EmagSiliconLawComponent.cs +++ b/Content.Shared/Silicons/Laws/Components/EmagSiliconLawComponent.cs @@ -29,13 +29,6 @@ public sealed partial class EmagSiliconLawComponent : Component [DataField, ViewVariables(VVAccess.ReadWrite)] public TimeSpan StunTime = TimeSpan.Zero; - /// - /// A role given to entities with this component when they are emagged. - /// Mostly just for admin purposes. - /// - [DataField] - public ProtoId? AntagonistRole = "SubvertedSilicon"; - /// /// The sound that plays for the borg player /// to let them know they've been emagged diff --git a/Content.Shared/Silicons/Laws/Components/SiliconLawProviderComponent.cs b/Content.Shared/Silicons/Laws/Components/SiliconLawProviderComponent.cs index 4885bd0265..d78e539aa9 100644 --- a/Content.Shared/Silicons/Laws/Components/SiliconLawProviderComponent.cs +++ b/Content.Shared/Silicons/Laws/Components/SiliconLawProviderComponent.cs @@ -29,4 +29,10 @@ public sealed partial class SiliconLawProviderComponent : Component [DataField] public SoundSpecifier? LawUploadSound = new SoundPathSpecifier("/Audio/Misc/cryo_warning.ogg"); + /// + /// Whether this silicon is subverted by an ion storm or emag. + /// + [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 index 75d7412166..0000000000 --- a/Content.Shared/Silicons/Laws/Components/StartIonStormedComponent.cs +++ /dev/null @@ -1,24 +0,0 @@ -using Content.Shared.Roles; -using Robust.Shared.Prototypes; - -namespace Content.Shared.Silicons.Laws.Components; - -/// -/// Applies law altering ion storms on a specific entity IonStormAmount times when the entity is spawned. -/// -[RegisterComponent] -public sealed partial class StartIonStormedComponent : Component -{ - /// - /// Amount of times that the ion storm will be run on the entity on spawn. - /// - [DataField] - public int IonStormAmount = 1; - - /// - /// A role given to entities with this component when a mind enters it. - /// Mostly just for admin purposes. - /// - [DataField] - public ProtoId? AntagonistRole = "SubvertedSilicon"; -}