PoweredLight uses PointLights for appearance (#4540)

* PoweredLight uses PointLights for appearance

Previously this just set PointLightComponent data via the visualizer which lead to desyncs in the data between client and server. If the server pointlight was dirtied at any point then the pointlight data set via appearance visualizers was bulldozed.

* Address review
This commit is contained in:
metalgearsloth
2021-08-31 18:45:02 +10:00
committed by GitHub
parent 09ff15da1f
commit df7d6c4d90
3 changed files with 17 additions and 15 deletions

View File

@@ -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;
}
}