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)
_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))
+using Content.Shared.Roles;//Used
+using Robust.Shared.Prototypes;//
+
namespace Content.Shared.Silicons.Laws.Components;
/// <summary>
/// </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";
}