/// </summary>
public void MakeAntag(Entity<AntagSelectionComponent> ent, ICommonSession? session, AntagSelectionDefinition def, bool ignoreSpawner = false)
{
- var antagEnt = (EntityUid?) null;
+ EntityUid? antagEnt = null;
var isSpawner = false;
if (session != null)
{
var getEntEv = new AntagSelectEntityEvent(session, ent);
RaiseLocalEvent(ent, ref getEntEv, true);
-
- if (!getEntEv.Handled)
- {
- throw new InvalidOperationException($"Attempted to make {session} antagonist in gamerule {ToPrettyString(ent)} but there was no valid entity for player.");
- }
-
antagEnt = getEntEv.Entity;
}
if (antagEnt is not { } player)
+ {
+ Log.Error($"Attempted to make {session} antagonist in gamerule {ToPrettyString(ent)} but there was no valid entity for player.");
+ if (session != null)
+ ent.Comp.SelectedSessions.Remove(session);
return;
+ }
var getPosEv = new AntagSelectLocationEvent(session, ent);
RaiseLocalEvent(ent, ref getPosEv, true);
if (!TryComp<GhostRoleAntagSpawnerComponent>(player, out var spawnerComp))
{
Log.Error($"Antag spawner {player} does not have a GhostRoleAntagSpawnerComponent.");
+ if (session != null)
+ ent.Comp.SelectedSessions.Remove(session);
return;
}