| 1234567891011121314151617181920212223242526272829303132333435 |
- using Content.Server.Light.Components;
- using Content.Server.Power.Components;
- using Content.Server.Power.EntitySystems;
- using Content.Shared.Power;
- 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);
- }
- }
- }
- }
|