CatStation/Content.Server/Power/EntitySystems/UnpowerAllOnMapInitSystem.cs
Killerqu00 f8b96d39b7
[April Fools] Very Bad Day (#35691)
* very bad day preset

* unpowerAll systems and components

* make everyone hurt and drunk

* the rest is done

* turn very bad day into very bad 15 minutes godo
2025-03-31 12:57:04 +02:00

31 lines
987 B
C#

using Content.Server.Power.Components;
using Robust.Shared.Random;
namespace Content.Server.Power.EntitySystems;
/// <summary>
/// Handles unpowering entities on map init>
/// </summary>
public sealed partial class UnpowerAllOnMapInitSystem : EntitySystem
{
[Dependency] private readonly BatterySystem _battery = default!;
[Dependency] private readonly IRobustRandom _random = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<UnpowerOnMapInitComponent, MapInitEvent>(OnMapInit, after: [typeof(BatterySystem)]);
}
private void OnMapInit(Entity<UnpowerOnMapInitComponent> entity, ref MapInitEvent args)
{
if (TryComp<BatteryComponent>(entity, out var battery) && _random.Prob(0.9f)) // this is a piece of code for one day, i am hardcoding this
{
_battery.SetCharge(entity, 0f);
}
// Our work here is done
RemCompDeferred(entity, entity.Comp);
}
}