progress
This commit is contained in:
@@ -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)
|
||||
private void EnsureSubvertedSiliconRole(EntityUid uid)
|
||||
{
|
||||
if (HasComp<EmaggedComponent>(uid))
|
||||
EnsureEmaggedRole(uid, component);
|
||||
}
|
||||
|
||||
private void OnEmagMindRemoved(EntityUid uid, EmagSiliconLawComponent component, MindRemovedMessage args)
|
||||
{
|
||||
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)
|
||||
private void RemoveSubvertedSiliconRole(EntityUid uid)
|
||||
{
|
||||
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 _))
|
||||
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)
|
||||
|
||||
@@ -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()}");
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
Reference in New Issue
Block a user