Generic morgue visualizer (#9696)

This commit is contained in:
Leon Friedrich
2022-07-14 17:25:44 +12:00
committed by GitHub
parent d509aacbf6
commit bad837fb85
7 changed files with 68 additions and 91 deletions

View File

@@ -0,0 +1,7 @@
namespace Content.Client.Morgue.Visualizers;
public enum MorgueVisualLayers : byte
{
Base,
Light,
}

View File

@@ -1,37 +0,0 @@
using Content.Shared.Morgue;
using Content.Shared.Storage;
using Robust.Client.GameObjects;
namespace Content.Client.Morgue.Visualizers;
public sealed class MorgueVisualizerSystem : VisualizerSystem<MorgueVisualsComponent>
{
public override void Initialize()
{
base.Initialize();
}
protected override void OnAppearanceChange(EntityUid uid, MorgueVisualsComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
string? lightState = null;
if (args.Component.TryGetData(MorgueVisuals.HasSoul, out bool hasSoul) && hasSoul)
lightState = component.LightSoul;
else if (args.Component.TryGetData(MorgueVisuals.HasMob, out bool hasMob) && hasMob)
lightState = component.LightMob;
else if (args.Component.TryGetData(StorageVisuals.HasContents, out bool hasContents) && hasContents)
lightState = component.LightContents;
if (lightState != null)
{
args.Sprite.LayerSetState(MorgueVisualLayers.Light, lightState);
args.Sprite.LayerSetVisible(MorgueVisualLayers.Light, true);
}
else
{
args.Sprite.LayerSetVisible(MorgueVisualLayers.Light, false);
}
}
}

View File

@@ -1,18 +0,0 @@
namespace Content.Client.Morgue.Visualizers;
[RegisterComponent]
public sealed class MorgueVisualsComponent : Component
{
[DataField("lightContents", required: true)]
public string LightContents = default!;
[DataField("lightMob", required: true)]
public string LightMob = default!;
[DataField("lightSoul", required: true)]
public string LightSoul = default!;
}
public enum MorgueVisualLayers : byte
{
Base,
Light,
}