Files
crystall-punk-14/Content.Server/StationEvents/Events/VentCrittersRule.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

60 lines
2.0 KiB
C#

using Content.Server.GameTicking.Components;
using Content.Server.StationEvents.Components;
using Content.Server.GameTicking.Rules.Components;
using Content.Server.Station.Components;
using Content.Shared.Storage;
using Robust.Shared.Map;
using Robust.Shared.Random;
namespace Content.Server.StationEvents.Events;
public sealed class VentCrittersRule : StationEventSystem<VentCrittersRuleComponent>
{
/*
* DO NOT COPY PASTE THIS TO MAKE YOUR MOB EVENT.
* USE THE PROTOTYPE.
*/
protected override void Started(EntityUid uid, VentCrittersRuleComponent component, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, component, gameRule, args);
if (!TryGetRandomStation(out var station))
{
return;
}
var locations = EntityQueryEnumerator<VentCritterSpawnLocationComponent, TransformComponent>();
var validLocations = new List<EntityCoordinates>();
while (locations.MoveNext(out _, out _, out var transform))
{
if (CompOrNull<StationMemberComponent>(transform.GridUid)?.Station == station)
{
validLocations.Add(transform.Coordinates);
foreach (var spawn in EntitySpawnCollection.GetSpawns(component.Entries, RobustRandom))
{
Spawn(spawn, transform.Coordinates);
}
}
}
if (component.SpecialEntries.Count == 0 || validLocations.Count == 0)
{
return;
}
// guaranteed spawn
var specialEntry = RobustRandom.Pick(component.SpecialEntries);
var specialSpawn = RobustRandom.Pick(validLocations);
Spawn(specialEntry.PrototypeId, specialSpawn);
foreach (var location in validLocations)
{
foreach (var spawn in EntitySpawnCollection.GetSpawns(component.SpecialEntries, RobustRandom))
{
Spawn(spawn, location);
}
}
}
}