Files
tbd-station-14/Content.Server/StationEvents/Events/AnomalySpawnRule.cs
Nemanja 161fd6c83c Mega Antag Refactor (#25786)
* Mega Antag Refactor

* last minute delta save

* more workshopping

* more shit

* ok tested this for once

* okkkkk sure

* generic delays for starting rules

* well darn

* nukies partially

* ouagh

* ballin' faded and smonkin wed

* obliterated the diff

* Spread my arms and soak up congratulations

* I've got plenty of love, but nothing to show for it

* but there’s too much sunlight
Shining on my laptop monitor, so I
Can’t see anything with any amount of clarity

* ok this junk

* OOK!

* fubar

* most of sloth's review

* oh boy

* eek

* hell yea!

* ASDFJASDJFvsakcvjkzjnhhhyh
2024-04-25 11:31:45 +10:00

44 lines
1.5 KiB
C#

using Content.Server.Anomaly;
using Content.Server.GameTicking.Components;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Station.Components;
using Content.Server.StationEvents.Components;
namespace Content.Server.StationEvents.Events;
public sealed class AnomalySpawnRule : StationEventSystem<AnomalySpawnRuleComponent>
{
[Dependency] private readonly AnomalySystem _anomaly = default!;
protected override void Added(EntityUid uid, AnomalySpawnRuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args)
{
base.Added(uid, component, gameRule, args);
var str = Loc.GetString("anomaly-spawn-event-announcement",
("sighting", Loc.GetString($"anomaly-spawn-sighting-{RobustRandom.Next(1, 6)}")));
ChatSystem.DispatchGlobalAnnouncement(str, colorOverride: Color.FromHex("#18abf5"));
}
protected override void Started(EntityUid uid, AnomalySpawnRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);
if (!TryGetRandomStation(out var chosenStation))
return;
if (!TryComp<StationDataComponent>(chosenStation, out var stationData))
return;
var grid = StationSystem.GetLargestGrid(stationData);
if (grid is null)
return;
var amountToSpawn = 1;
for (var i = 0; i < amountToSpawn; i++)
{
_anomaly.SpawnOnRandomGridLocation(grid.Value, component.AnomalySpawnerPrototype);
}
}
}