Skip to content

Commit

Permalink
full logger by antag selection
Browse files Browse the repository at this point in the history
  • Loading branch information
Lemirda committed Jun 10, 2024
1 parent a305276 commit 23e3390
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions Content.Server/Antag/AntagSelectionSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ public bool TryMakeAntag(Entity<AntagSelectionComponent> ent, ICommonSession? se
/// </summary>
public void MakeAntag(Entity<AntagSelectionComponent> ent, ICommonSession? session, AntagSelectionDefinition def, bool ignoreSpawner = false)
{
Log.Debug($"MakeAntag: ent={ent}, session={session}, def={def}, ignoreSpawner={ignoreSpawner}"); //A-13 Полное логирование

var antagEnt = (EntityUid?) null;
var isSpawner = false;

Expand All @@ -266,6 +268,7 @@ public void MakeAntag(Entity<AntagSelectionComponent> ent, ICommonSession? sessi

if (!getEntEv.Handled)
{
Log.Error($"Attempted to make {session} antagonist in gamerule {ToPrettyString(ent)} but there was no valid entity for player."); //A-13 Полное логирование
throw new InvalidOperationException($"Attempted to make {session} antagonist in gamerule {ToPrettyString(ent)} but there was no valid entity for player.");
}

Expand All @@ -284,22 +287,9 @@ public void MakeAntag(Entity<AntagSelectionComponent> ent, ICommonSession? sessi
_transform.SetMapCoordinates((player, playerXform), pos);
}

// If we want to just do a ghost role spawner, set up data here and then return early.
// This could probably be an event in the future if we want to be more refined about it.
if (isSpawner)
{
if (!TryComp<GhostRoleAntagSpawnerComponent>(player, out var spawnerComp))
{
Log.Error($"Antag spawner {player} does not have a GhostRoleAntagSpawnerComponent.");
return;
}

spawnerComp.Rule = ent;
spawnerComp.Definition = def;
return;
}

// The following is where we apply components, equipment, and other changes to our antagonist entity.
Log.Debug($"Applying components to antag entity: {antagEnt}"); //A-13 Полное логирование

EntityManager.AddComponents(player, def.Components);
_stationSpawning.EquipStartingGear(player, def.StartingGear);

Expand All @@ -312,12 +302,16 @@ public void MakeAntag(Entity<AntagSelectionComponent> ent, ICommonSession? sessi
_mind.SetUserId(curMind.Value, session.UserId);
}

Log.Debug($"Transferring mind to antag entity: {antagEnt}"); //A-13 Полное логирование

_mind.TransferTo(curMind.Value, antagEnt, ghostCheckOverride: true);
_role.MindAddRoles(curMind.Value, def.MindComponents);
ent.Comp.SelectedMinds.Add((curMind.Value, Name(player)));
SendBriefing(session, def.Briefing);
}

Log.Debug($"Start apply logic to antag entity: {antagEnt}"); //A-13 Полное логирование

var afterEv = new AfterAntagEntitySelectedEvent(session, player, ent, def);
RaiseLocalEvent(ent, ref afterEv, true);
}
Expand Down

0 comments on commit 23e3390

Please sign in to comment.