Files
wwdpublic/Content.Server/StationEvents/Events/RandomSpawnRule.cs
PuroSlavKing 7ec558348c [Feature] Wormhole Anomaly (#156)
* [Feature] Wormhole Anomaly

* duration edit

* timed teleportation

* IRobustRandom

* Update Content.Server/_White/Anomaly/Effects/WormholeAnomalySystem.cs

Co-authored-by: Remuchi <72476615+Remuchi@users.noreply.github.com>

* remove on shutdown

* counts

---------

Co-authored-by: Remuchi <72476615+Remuchi@users.noreply.github.com>
2024-12-22 12:19:01 +07:00

31 lines
1.0 KiB
C#

using System;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.StationEvents.Components;
using Content.Shared.GameTicking.Components;
using Robust.Shared.Random;
using Robust.Shared.GameObjects;
namespace Content.Server.StationEvents.Events;
public sealed class RandomSpawnRule : StationEventSystem<RandomSpawnRuleComponent>
{
[Dependency] private readonly IRobustRandom _random = default!; // WWDP
protected override void Started(EntityUid uid, RandomSpawnRuleComponent comp, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, comp, gameRule, args);
// WWDP-EDIT-START
int spawnCount = _random.Next(comp.MinCount, comp.MaxCount + 1);
for (int i = 0; i < spawnCount; i++)
{
if (TryFindRandomTile(out _, out _, out _, out var coords))
{
Sawmill.Info($"Spawning {comp.Prototype} at {coords}");
Spawn(comp.Prototype, coords);
}
// WWDP-EDIT-END
}
}
}