* 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
37 lines
1.2 KiB
C#
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);
|
|
}
|
|
}
|
|
}
|
|
}
|