diff --git a/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs b/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs index 626da3a2e1..9b61da8e49 100644 --- a/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs +++ b/Content.Client/Light/Visualizers/PoweredLightVisualizer.cs @@ -29,7 +29,6 @@ namespace Content.Client.Light.Visualizers base.OnChangeData(component); if (!component.Owner.TryGetComponent(out ISpriteComponent? sprite)) return; - if (!component.Owner.TryGetComponent(out PointLightComponent? light)) return; if (!component.TryGetData(PoweredLightVisuals.BulbState, out PoweredLightState state)) return; switch (state) @@ -37,33 +36,26 @@ namespace Content.Client.Light.Visualizers case PoweredLightState.Empty: sprite.LayerSetState(PoweredLightLayers.Base, "empty"); ToggleBlinkingAnimation(component, false); - light.Enabled = false; break; case PoweredLightState.Off: sprite.LayerSetState(PoweredLightLayers.Base, "off"); ToggleBlinkingAnimation(component, false); - light.Enabled = false; break; case PoweredLightState.On: - if (component.TryGetData(PoweredLightVisuals.BulbColor, out Color color)) - light.Color = color; if (component.TryGetData(PoweredLightVisuals.Blinking, out bool isBlinking)) ToggleBlinkingAnimation(component, isBlinking); if (!isBlinking) { sprite.LayerSetState(PoweredLightLayers.Base, "on"); - light.Enabled = true; } break; case PoweredLightState.Broken: sprite.LayerSetState(PoweredLightLayers.Base, "broken"); ToggleBlinkingAnimation(component, false); - light.Enabled = false; break; case PoweredLightState.Burned: sprite.LayerSetState(PoweredLightLayers.Base, "burn"); ToggleBlinkingAnimation(component, false); - light.Enabled = false; break; } } diff --git a/Content.Server/Light/Components/PoweredLightComponent.cs b/Content.Server/Light/Components/PoweredLightComponent.cs index 46a7d60408..f5fc932908 100644 --- a/Content.Server/Light/Components/PoweredLightComponent.cs +++ b/Content.Server/Light/Components/PoweredLightComponent.cs @@ -17,6 +17,7 @@ using Robust.Shared.GameObjects; using Robust.Shared.IoC; using Robust.Shared.Prototypes; using Robust.Shared.Localization; +using Robust.Shared.Maths; using Robust.Shared.Player; using Robust.Shared.Serialization.Manager.Attributes; using Robust.Shared.Timing; @@ -89,7 +90,7 @@ namespace Content.Server.Light.Components { base.Initialize(); DamageType = IoCManager.Resolve().Index(_damageTypeID); - _lightBulbContainer = ContainerHelpers.EnsureContainer(Owner, "light_bulb"); + _lightBulbContainer = Owner.EnsureContainer("light_bulb"); } [ViewVariables] @@ -236,10 +237,9 @@ namespace Content.Server.Light.Components case LightBulbState.Normal: if (powerReceiver.Powered && _on) { - _currentLit = true; + SetLight(true, LightBulb.Color); powerReceiver.Load = LightBulb.PowerUse; _appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.On); - _appearance?.SetData(PoweredLightVisuals.BulbColor, LightBulb.Color); var time = _gameTiming.CurTime; if (time > _lastThunk + _thunkDelay) { @@ -249,21 +249,32 @@ namespace Content.Server.Light.Components } else { - _currentLit = false; + SetLight(false); _appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.Off); } break; case LightBulbState.Broken: - _currentLit = false; + SetLight(false); _appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.Broken); break; case LightBulbState.Burned: - _currentLit = false; + SetLight(false); _appearance?.SetData(PoweredLightVisuals.BulbState, PoweredLightState.Burned); break; } } + private void SetLight(bool value, Color? color = null) + { + _currentLit = value; + + if (!Owner.TryGetComponent(out PointLightComponent? pointLight)) return; + pointLight.Enabled = value; + + if (color != null) + pointLight.Color = color.Value; + } + public override void HandleMessage(ComponentMessage message, IComponent? component) { base.HandleMessage(message, component); diff --git a/Content.Shared/Light/SharedPoweredLightVisuals.cs b/Content.Shared/Light/SharedPoweredLightVisuals.cs index 20f4ddd61e..8fe1e8f37c 100644 --- a/Content.Shared/Light/SharedPoweredLightVisuals.cs +++ b/Content.Shared/Light/SharedPoweredLightVisuals.cs @@ -7,7 +7,6 @@ namespace Content.Shared.Light public enum PoweredLightVisuals : byte { BulbState, - BulbColor, Blinking }