Skip to content

Commit

Permalink
untroll glimmermobspawnrule (#1980)
Browse files Browse the repository at this point in the history
* fix your shit

* take 2

* take 3
  • Loading branch information
MilonPL authored Oct 14, 2024
1 parent 7a7a12c commit a64c715
Showing 1 changed file with 15 additions and 6 deletions.
21 changes: 15 additions & 6 deletions Content.Server/DeltaV/StationEvents/Events/GlimmerMobSpawnRule.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using System.Linq;
using Content.Server.Psionics.Glimmer;
using Content.Server.Station.Systems;
using Content.Server.StationEvents;
using Content.Server.StationEvents.Components;
using Content.Server.StationEvents.Events;
Expand All @@ -15,14 +16,18 @@ namespace Content.Server.DeltaV.StationEvents.Events;
public sealed class GlimmerMobRule : StationEventSystem<GlimmerMobRuleComponent>
{
[Dependency] private readonly GlimmerSystem _glimmer = default!;
[Dependency] private readonly StationSystem _stationSystem = default!;

protected override void Started(EntityUid uid, GlimmerMobRuleComponent comp, GameRuleComponent gameRule, GameRuleStartedEvent args)
{
base.Started(uid, comp, gameRule, args);

var glimmerSources = GetCoords<GlimmerSourceComponent>();
var normalSpawns = GetCoords<VentCritterSpawnLocationComponent>();
var hiddenSpawns = GetCoords<MidRoundAntagSpawnLocationComponent>();
if (!TryGetRandomStation(out var station))
return;

var glimmerSources = GetCoords<GlimmerSourceComponent>(station.Value);
var normalSpawns = GetCoords<VentCritterSpawnLocationComponent>(station.Value);
var hiddenSpawns = GetCoords<MidRoundAntagSpawnLocationComponent>(station.Value);

var psionics = EntityQuery<PsionicComponent, NpcFactionMemberComponent>().Count();
var baseCount = Math.Max(1, psionics / comp.MobsPerPsionic);
Expand All @@ -43,15 +48,19 @@ protected override void Started(EntityUid uid, GlimmerMobRuleComponent comp, Gam
}
}

private List<EntityCoordinates> GetCoords<T>() where T : IComponent
private List<EntityCoordinates> GetCoords<T>(EntityUid station) where T : IComponent
{
var coords = new List<EntityCoordinates>();
var query = EntityQueryEnumerator<TransformComponent, T>();

while (query.MoveNext(out var xform, out _))
{
coords.Add(xform.Coordinates);
}
if (xform.GridUid == null)
continue;

if (_stationSystem.GetOwningStation(xform.GridUid.Value) == station)
coords.Add(xform.Coordinates);
}
return coords;
}

Expand Down

0 comments on commit a64c715

Please sign in to comment.