mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-10-19 07:01:09 +03:00
* Scope creep my ass * why was this shit not pushed???? * gone... * fix that * review plus buildd * asfsafsafsafsafas * grug * burber * I'll fix this later * shrimply die * also this * it's snerf or snuthin * assaads * round snend * aaaa * fix this shit for real * actually, don't start GameRules until MapInit now that I think aboot it. * forgot u * don't actually need this part nullable * Deffer comp removal * one liner * do that too * chungus * Honestly makes more sense here, plus WHY are we doing all that shit on "GameRuleAdded" rather than GameRuleStarted(?) * deferred removal :V * aaaaaaaaaaaaaaa * whhop * Whoop * better * landmine that I placed for myself then forgot about lmao * cleanup * FUCKING `!` * gotovo * amogus * please don't check by metadata I beg * waawsasfdfsasfa * sfafsasfafsas * fdsaasffsasfa * code * fix * fasasffasfasfsad * chungaas * I may be stupid * gra * graaaaaaaaaaaaaaaaa * comment * gra * clearing is not predicted and would require major refactors, so don't cache on client. * lame shit :P * last holes * nukeopsfsafsasafsfafsa * why was that shit public bruh * bubrbgwahrghfaka * dynamic * revert change that did nothing lmao
64 lines
2.5 KiB
C#
64 lines
2.5 KiB
C#
using Content.Server.Shuttles.Systems;
|
|
using Content.Server.Station.Components;
|
|
using Content.Server.Station.Events;
|
|
using Content.Shared.GameTicking.Components;
|
|
using Content.Shared.GameTicking.Rules;
|
|
using Content.Shared.GameTicking.Rules.Components;
|
|
using Content.Shared.Station.Components;
|
|
using Content.Shared.Storage;
|
|
using Robust.Shared.Random;
|
|
|
|
namespace Content.Server.GameTicking.Rules;
|
|
|
|
/// <inheritdoc cref="RoundstartStationVariationRuleComponent"/>
|
|
public sealed partial class RoundstartStationVariationRuleSystem : GameRuleSystem<RoundstartStationVariationRuleComponent>
|
|
{
|
|
[Dependency] private IRobustRandom _random = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<StationPostInitEvent>(OnStationPostInit, after: new []{typeof(ShuttleSystem)});
|
|
}
|
|
|
|
protected override void Added(EntityUid uid, RoundstartStationVariationRuleComponent component, GameRuleComponent gameRule, GameRuleAddedEvent args)
|
|
{
|
|
var spawns = EntitySpawnCollection.GetSpawns(component.Rules, _random);
|
|
foreach (var rule in spawns)
|
|
{
|
|
GameTicker.AddGameRule(rule);
|
|
}
|
|
}
|
|
|
|
private void OnStationPostInit(ref StationPostInitEvent ev)
|
|
{
|
|
// as long as one is running
|
|
if (!GameTicker.IsGameRuleAdded<RoundstartStationVariationRuleComponent>())
|
|
return;
|
|
|
|
// this is unlikely, but could theoretically happen if it was saved and reloaded, so check anyway
|
|
if (HasComp<StationVariationHasRunComponent>(ev.Station))
|
|
return;
|
|
|
|
Log.Info($"Running variation rules for station {ToPrettyString(ev.Station)}");
|
|
|
|
// raise the event on any passes that have been added
|
|
var passEv = new StationVariationPassEvent(ev.Station);
|
|
var passQuery = EntityQueryEnumerator<StationVariationPassRuleComponent, GameRuleComponent>();
|
|
while (passQuery.MoveNext(out var uid, out _, out _))
|
|
{
|
|
RaiseLocalEvent(uid, ref passEv);
|
|
}
|
|
|
|
EnsureComp<StationVariationHasRunComponent>(ev.Station);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Raised directed on game rule entities which are added and marked as <see cref="Shared.GameTicking.Rules.Components.StationVariationPassRuleComponent"/>
|
|
/// when a new station is initialized that should be varied.
|
|
/// </summary>
|
|
/// <param name="Station">The new station that was added, and its config & grids.</param>
|
|
[ByRefEvent]
|
|
public readonly record struct StationVariationPassEvent(Entity<StationDataComponent> Station);
|