Files
tbd-station-14/Content.Server/GameTicking/Rules/VariationPass/PoweredLightVariationPassSystem.cs
Kara cc24ba6a31 Roundstart variation game rules (#24397)
* Raise `StationPostInitEvent` broadcast

* Basic variation pass handling

* standardize names + rule entities

* why does it work like that?

* add to defaults

* light break variation pass

* ent spawn entry

* move some stationevent utility functions to gamerule + add one for finding random tile on specified station

* forgot how statistics works

* powered light variation pass is good now

* station tile count function

* public method to ensure all solutions (for procedural use before mapinit)

* move gamerulesystem utility funcs to partial

* ensure all solutions before spilling in puddlesystem. for use when spilling before mapinit

* trash & puddle variation passes!

* oh yeah

* ehh lets live a little

* std

* utility for game rule check based on comp

* entprotoid the trash spawner oops

* generalize trash variation

* use added instead of started for secret rule

* random cleanup

* generic replacement variation system

* Wall rusting variation rule

* account for modifying while enumerating

* use localaabb

* fix test

* minor tweaks

* reinforced wall replacer + puddletweaker
2024-01-30 21:52:35 -08:00

52 lines
2.0 KiB
C#

using Content.Server.GameTicking.Rules.VariationPass.Components;
using Content.Server.Light.Components;
using Content.Server.Light.EntitySystems;
using Content.Shared.Light.Components;
using Robust.Shared.Random;
namespace Content.Server.GameTicking.Rules.VariationPass;
/// <inheritdoc cref="PoweredLightVariationPassComponent"/>
public sealed class PoweredLightVariationPassSystem : VariationPassSystem<PoweredLightVariationPassComponent>
{
[Dependency] private readonly PoweredLightSystem _poweredLight = default!;
protected override void ApplyVariation(Entity<PoweredLightVariationPassComponent> ent, ref StationVariationPassEvent args)
{
var query = AllEntityQuery<PoweredLightComponent, TransformComponent>();
while (query.MoveNext(out var uid, out var comp, out var xform))
{
if (!IsMemberOfStation((uid, xform), ref args))
continue;
if (Random.Prob(ent.Comp.LightBreakChance))
{
var proto = comp.BulbType switch
{
LightBulbType.Tube => ent.Comp.BrokenLightTubePrototype,
_ => ent.Comp.BrokenLightBulbPrototype,
};
_poweredLight.ReplaceSpawnedPrototype((uid, comp), proto);
continue;
}
if (!Random.Prob(ent.Comp.LightAgingChance))
continue;
if (comp.BulbType == LightBulbType.Tube)
{
// some aging fluorescents (tubes) start to flicker
// its also way too annoying right now so we wrap it in another prob lol
if (Random.Prob(ent.Comp.AgedLightTubeFlickerChance))
_poweredLight.ToggleBlinkingLight(uid, comp, true);
_poweredLight.ReplaceSpawnedPrototype((uid, comp), ent.Comp.AgedLightTubePrototype);
}
else
{
_poweredLight.ReplaceSpawnedPrototype((uid, comp), ent.Comp.AgedLightBulbPrototype);
}
}
}
}