From e4864ac4236a2a51a7fc7aa94e74fcdc1fe8fdf0 Mon Sep 17 00:00:00 2001 From: slarticodefast <161409025+slarticodefast@users.noreply.github.com> Date: Mon, 17 Mar 2025 00:50:23 +0100 Subject: [PATCH] Hotfix: Fix AntagRandomSpawn location preview (#35864) fix AntagRandomSpawn location preview --- Content.Server/Antag/AntagRandomSpawnRule.cs | 16 ++++++++++++++-- Content.Server/Antag/AntagSelectionSystem.cs | 5 +++++ .../Components/AntagRandomSpawnComponent.cs | 11 ++++++++++- 3 files changed, 29 insertions(+), 3 deletions(-) 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; +}