+using System.Diagnostics;
using System.Linq;
using Content.Server.Administration;
using Content.Server.Chat.Managers;
using Robust.Shared.Prototypes;
using Robust.Shared.Toolshed;
using Robust.Shared.Audio;
-using Robust.Shared.GameObjects;
namespace Content.Server.Silicons.Laws;
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)
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))
// 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);
}
}
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
{
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)
+++ /dev/null
-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()}");
- }
-}