* move MinMax to shared * cleanup MinMax * move other ticking components to shared just because * remove unused prototype file * update everything to use shared components * test * test 2 * test 3 --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
46 lines
1.5 KiB
C#
46 lines
1.5 KiB
C#
using Content.Server.Anomaly;
|
||
using Content.Server.Station.Components;
|
||
using Content.Server.StationEvents.Components;
|
||
using Content.Shared.GameTicking.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)
|
||
{
|
||
if (!TryComp<StationEventComponent>(uid, out var stationEvent))
|
||
return;
|
||
|
||
var str = Loc.GetString("anomaly-spawn-event-announcement",
|
||
("sighting", Loc.GetString($"anomaly-spawn-sighting-{RobustRandom.Next(1, 6)}")));
|
||
stationEvent.StartAnnouncement = str;
|
||
|
||
base.Added(uid, component, gameRule, args);
|
||
}
|
||
|
||
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);
|
||
}
|
||
}
|
||
}
|