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 });
+ 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)
+ {
+ 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))