Files
tbd-station-14/Content.Server/Light/EntitySystems/LitOnPoweredSystem.cs
metalgearsloth a89d4c750b Power stuff (#31314)
* Power stuff

- Add shared IsPowered
- Add shared ResolveApc
- Move PowerChangedEvent to shared for now
- Add SlimPoweredLight that actually functions how you'd expect a PoweredLight to function it id didn't have a bunch of bloat on it.

* big update

* boing
2024-08-25 22:18:42 +10:00

37 lines
1.2 KiB
C#

using Content.Server.Light.Components;
using Content.Server.Power.Components;
using Content.Server.Power.EntitySystems;
using Content.Shared.Power;
using Content.Shared.Power.Components;
namespace Content.Server.Light.EntitySystems
{
public sealed class LitOnPoweredSystem : EntitySystem
{
[Dependency] private readonly SharedPointLightSystem _lights = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<LitOnPoweredComponent, PowerChangedEvent>(OnPowerChanged);
SubscribeLocalEvent<LitOnPoweredComponent, PowerNetBatterySupplyEvent>(OnPowerSupply);
}
private void OnPowerChanged(EntityUid uid, LitOnPoweredComponent component, ref PowerChangedEvent args)
{
if (_lights.TryGetLight(uid, out var light))
{
_lights.SetEnabled(uid, args.Powered, light);
}
}
private void OnPowerSupply(EntityUid uid, LitOnPoweredComponent component, ref PowerNetBatterySupplyEvent args)
{
if (_lights.TryGetLight(uid, out var light))
{
_lights.SetEnabled(uid, args.Supply, light);
}
}
}
}