CatStation/Content.Client/Singularity/Visualizers/EmitterVisualizer.cs
Morber 61951a84f1
[Resprite] Singularity stuff (#320)
* Update containment field sprite

* Update 1 level singularity sprite

* Update 3 level singularity sprite

* Fix sprite sizes

* Fix sprite state name

* Update 4 level singularity sprite

* Fix sprite size

* Update 5 level singularity sprite

* Update level 6 singularity sprite

* Remove 6 level sprite of singularity

* Remove 6 level meta.json

* Add level 6 singularity custom sprite

* Update containment generator sprites

* Remake emitter with new sprites

* Update collector sprites

* New emitter sprite files

* Update level 6 singularity sprite

* Update license singularity level 6

* Decrease singularity to 20 fps
2022-07-26 20:56:02 +03:00

56 lines
1.9 KiB
C#

using System;
using Content.Shared.Singularity.Components;
using Content.Shared.Storage;
using JetBrains.Annotations;
using Robust.Client.GameObjects;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
namespace Content.Client.Singularity.Visualizers
{
[UsedImplicitly]
public sealed class EmitterVisualizer : AppearanceVisualizer
{
private const string OverlayBeam = "beam";
private const string OverlayUnderPowered = "underpowered";
private const string OverlayLocked = "lock";
private const string OverlayUnlocked = "unlock";
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
var entities = IoCManager.Resolve<IEntityManager>();
if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
{
return;
}
if (!component.TryGetData(StorageVisuals.Locked, out bool locked))
locked = false;
if (!component.TryGetData(EmitterVisuals.VisualState, out EmitterVisualState state))
state = EmitterVisualState.Off;
switch (state)
{
case EmitterVisualState.On:
sprite.LayerSetVisible(1, true);
sprite.LayerSetState(1, OverlayBeam);
break;
case EmitterVisualState.Underpowered:
sprite.LayerSetVisible(1, true);
sprite.LayerSetState(1, OverlayUnderPowered);
break;
case EmitterVisualState.Off:
sprite.LayerSetVisible(1, false);
break;
default:
throw new ArgumentOutOfRangeException();
}
sprite.LayerSetState(2, locked ? OverlayLocked : OverlayUnlocked);
}
}
}