Files
tbd-station-14/Content.Server/Antag/AntagRandomSpawnRule.cs
deltanedas 5da2151924 dragon antag refactor (#28217)
* remove dragon system usage of GenericAntag

* add AntagRandomSpawn for making antags spawn at a random tile

* add AntagSpawner to make an antag spawner just spawn an entity

* add antag prototype for dragon since it never had one

* make dragon spawner a GhostRoleAntagSpawner, remove GenericAntag

* make dragon rule use AntagSelection and stuff

* remove dragon GenericAntag rule

* add back to spawn menu

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
2024-05-31 11:08:26 -04:00

23 lines
722 B
C#

using Content.Server.Antag.Components;
using Content.Server.GameTicking.Rules;
namespace Content.Server.Antag;
public sealed class AntagRandomSpawnSystem : GameRuleSystem<AntagRandomSpawnComponent>
{
[Dependency] private readonly SharedTransformSystem _transform = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<AntagRandomSpawnComponent, AntagSelectLocationEvent>(OnSelectLocation);
}
private void OnSelectLocation(Entity<AntagRandomSpawnComponent> ent, ref AntagSelectLocationEvent args)
{
if (TryFindRandomTile(out _, out _, out _, out var coords))
args.Coordinates.Add(_transform.ToMapCoordinates(coords));
}
}