Resolves EmergencyLightVisualizer is Obsolete (#13887)
* Split EmergencyLightVisualizer into Component/System pair * Server ignore EmergencyLightVisualizer * Update YAML * Reviews * small --------- Co-authored-by: AJCM <AJCM@tutanota.com>
This commit is contained in:
@@ -2,11 +2,17 @@
|
|||||||
using Robust.Shared.GameObjects;
|
using Robust.Shared.GameObjects;
|
||||||
using Robust.Shared.GameStates;
|
using Robust.Shared.GameStates;
|
||||||
|
|
||||||
namespace Content.Client.Light.Components
|
namespace Content.Client.Light.Components;
|
||||||
{
|
|
||||||
[RegisterComponent]
|
[RegisterComponent]
|
||||||
[NetworkedComponent]
|
[NetworkedComponent]
|
||||||
public sealed class EmergencyLightComponent : SharedEmergencyLightComponent
|
public sealed class EmergencyLightComponent : SharedEmergencyLightComponent
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum EmergencyLightVisualLayers
|
||||||
|
{
|
||||||
|
Base,
|
||||||
|
LightOff,
|
||||||
|
LightOn,
|
||||||
}
|
}
|
||||||
|
|||||||
26
Content.Client/Light/EntitySystems/EmergencyLightSystem.cs
Normal file
26
Content.Client/Light/EntitySystems/EmergencyLightSystem.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Content.Client.Light.Components;
|
||||||
|
using Content.Shared.Light.Component;
|
||||||
|
using Robust.Client.GameObjects;
|
||||||
|
|
||||||
|
namespace Content.Client.Light.EntitySystems;
|
||||||
|
|
||||||
|
public sealed class EmergencyLightSystem : VisualizerSystem<EmergencyLightComponent>
|
||||||
|
{
|
||||||
|
protected override void OnAppearanceChange(EntityUid uid, EmergencyLightComponent comp, ref AppearanceChangeEvent args)
|
||||||
|
{
|
||||||
|
if (args.Sprite == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!AppearanceSystem.TryGetData<bool>(uid, EmergencyLightVisuals.On, out var on, args.Component))
|
||||||
|
on = false;
|
||||||
|
|
||||||
|
args.Sprite.LayerSetVisible(EmergencyLightVisualLayers.LightOff, !on);
|
||||||
|
args.Sprite.LayerSetVisible(EmergencyLightVisualLayers.LightOn, on);
|
||||||
|
|
||||||
|
if (AppearanceSystem.TryGetData<Color>(uid, EmergencyLightVisuals.Color, out var color, args.Component))
|
||||||
|
{
|
||||||
|
args.Sprite.LayerSetColor(EmergencyLightVisualLayers.LightOn, color);
|
||||||
|
args.Sprite.LayerSetColor(EmergencyLightVisualLayers.LightOff, color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
using Content.Shared.Light.Component;
|
|
||||||
using Robust.Client.GameObjects;
|
|
||||||
using Robust.Shared.GameObjects;
|
|
||||||
using Robust.Shared.IoC;
|
|
||||||
using Robust.Shared.Serialization.Manager.Attributes;
|
|
||||||
|
|
||||||
namespace Content.Client.Light.Visualizers
|
|
||||||
{
|
|
||||||
[DataDefinition]
|
|
||||||
public sealed class EmergencyLightVisualizer : AppearanceVisualizer
|
|
||||||
{
|
|
||||||
[Obsolete("Subscribe to AppearanceChangeEvent instead.")]
|
|
||||||
public override void OnChangeData(AppearanceComponent component)
|
|
||||||
{
|
|
||||||
base.OnChangeData(component);
|
|
||||||
|
|
||||||
var entities = IoCManager.Resolve<IEntityManager>();
|
|
||||||
if (!entities.TryGetComponent(component.Owner, out SpriteComponent? sprite))
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (!component.TryGetData(EmergencyLightVisuals.On, out bool on))
|
|
||||||
on = false;
|
|
||||||
|
|
||||||
sprite.LayerSetState(EmergencyLightVisualLayers.Light, on ? "emergency_light_on" : "emergency_light_off");
|
|
||||||
sprite.LayerSetShader(EmergencyLightVisualLayers.Light, on ? "unshaded" : "shaded");
|
|
||||||
|
|
||||||
if (component.TryGetData(EmergencyLightVisuals.Color, out Color color))
|
|
||||||
{
|
|
||||||
sprite.LayerSetColor(EmergencyLightVisualLayers.Light, color);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum EmergencyLightVisualLayers
|
|
||||||
{
|
|
||||||
Base,
|
|
||||||
Light
|
|
||||||
}
|
|
||||||
@@ -311,11 +311,14 @@
|
|||||||
- state: base
|
- state: base
|
||||||
map: [ "enum.EmergencyLightVisualLayers.Base" ]
|
map: [ "enum.EmergencyLightVisualLayers.Base" ]
|
||||||
- state: emergency_light_off
|
- state: emergency_light_off
|
||||||
map: ["enum.EmergencyLightVisualLayers.Light"]
|
map: [ "enum.EmergencyLightVisualLayers.LightOff" ]
|
||||||
color: "#FF4020"
|
color: "#FF4020"
|
||||||
|
- state: emergency_light_on
|
||||||
|
map: [ "enum.EmergencyLightVisualLayers.LightOn" ]
|
||||||
|
color: "#FF4020"
|
||||||
|
shader: "unshaded"
|
||||||
|
visible: false
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
|
||||||
- type: EmergencyLightVisualizer
|
|
||||||
- type: AmbientSound
|
- type: AmbientSound
|
||||||
sound:
|
sound:
|
||||||
path: /Audio/Ambience/Objects/alarm.ogg
|
path: /Audio/Ambience/Objects/alarm.ogg
|
||||||
|
|||||||
Reference in New Issue
Block a user