diff --git a/Content.Server/Antag/AntagRandomSpawnRule.cs b/Content.Server/Antag/AntagRandomSpawnRule.cs index 499761a8df..58fab5414c 100644 --- a/Content.Server/Antag/AntagRandomSpawnRule.cs +++ b/Content.Server/Antag/AntagRandomSpawnRule.cs @@ -1,4 +1,5 @@ using Content.Server.Antag.Components; +using Content.Shared.GameTicking.Components; using Content.Server.GameTicking.Rules; namespace Content.Server.Antag; @@ -14,9 +15,20 @@ public sealed class AntagRandomSpawnSystem : GameRuleSystem(OnSelectLocation); } + protected override void Added(EntityUid uid, AntagRandomSpawnComponent comp, GameRuleComponent gameRule, GameRuleAddedEvent args) + { + base.Added(uid, comp, gameRule, args); + + // we have to select this here because AntagSelectLocationEvent is raised twice because MakeAntag is called twice + // once when a ghost role spawner is created and once when someone takes the ghost role + + if (TryFindRandomTile(out _, out _, out _, out var coords)) + comp.Coords = coords; + } + private void OnSelectLocation(Entity ent, ref AntagSelectLocationEvent args) { - if (TryFindRandomTile(out _, out _, out _, out var coords)) - args.Coordinates.Add(_transform.ToMapCoordinates(coords)); + if (ent.Comp.Coords != null) + args.Coordinates.Add(_transform.ToMapCoordinates(ent.Comp.Coords.Value)); } } diff --git a/Content.Server/Antag/AntagSelectionSystem.cs b/Content.Server/Antag/AntagSelectionSystem.cs index c8b2a7d4bb..62fbeefb65 100644 --- a/Content.Server/Antag/AntagSelectionSystem.cs +++ b/Content.Server/Antag/AntagSelectionSystem.cs @@ -393,6 +393,11 @@ public sealed partial class AntagSelectionSystem : GameRuleSystem @@ -5,4 +7,11 @@ namespace Content.Server.Antag.Components; /// Requires . /// [RegisterComponent] -public sealed partial class AntagRandomSpawnComponent : Component; +public sealed partial class AntagRandomSpawnComponent : Component +{ + /// + /// Location that was picked. + /// + [DataField] + public EntityCoordinates? Coords; +}