diff --git a/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs b/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs index 2bd3e0fd332..2a3c560da52 100644 --- a/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs +++ b/Content.Server/_CorvaxNext/Light/ToggleableOccluderSystem.cs @@ -19,7 +19,8 @@ public override void Initialize() SubscribeLocalEvent(OnInit); } - private void OnInit(EntityUid uid, ToggleableOccluderComponent comp, ComponentInit args) + private void OnInit(Entity uid, ref ComponentInit args) + { _signalSystem.EnsureSinkPorts(uid, comp.OnPort, comp.OffPort, comp.TogglePort); } @@ -29,12 +30,20 @@ private void OnSignalReceived(EntityUid uid, ToggleableOccluderComponent comp, r if (!TryComp(uid, out var occluder)) return; - if (args.Port == comp.OffPort) - SetState(uid, false, occluder); - else if (args.Port == comp.OnPort) - SetState(uid, true, occluder); - else if (args.Port == comp.TogglePort) - ToggleState(uid, occluder); + switch (args.Port) + { + case comp.OffPort: + SetState(uid, false, occluder); + break; + + case comp.OnPort: + SetState(uid, true, occluder); + break; + + case comp.TogglePort: + ToggleState(uid, occluder); + break; + } } public void ToggleState(EntityUid uid, OccluderComponent? occluder = null) @@ -42,7 +51,7 @@ public void ToggleState(EntityUid uid, OccluderComponent? occluder = null) if (!Resolve(uid, ref occluder)) return; - _occluder.SetEnabled(uid, !occluder.Enabled); + SetState(uid, !occluder.Enabled, occluder); } public void SetState(EntityUid uid, bool state, OccluderComponent? occluder = null)