2021-02-28 19:57:44 +00:00
|
|
|
using System;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Shared.Singularity.Components;
|
2021-10-29 00:29:19 +13:00
|
|
|
using Content.Shared.Storage;
|
2020-12-08 11:56:10 +01:00
|
|
|
using JetBrains.Annotations;
|
2020-10-28 19:19:47 +01:00
|
|
|
using Robust.Client.GameObjects;
|
2021-11-22 23:22:59 -08:00
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-05 18:09:01 +01:00
|
|
|
using Robust.Shared.IoC;
|
2020-10-28 19:19:47 +01:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.Singularity.Visualizers
|
2020-10-28 19:19:47 +01:00
|
|
|
{
|
2020-12-08 11:56:10 +01:00
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class EmitterVisualizer : AppearanceVisualizer
|
2020-10-28 19:19:47 +01:00
|
|
|
{
|
2021-02-28 19:57:44 +00:00
|
|
|
private const string OverlayBeam = "beam";
|
|
|
|
|
private const string OverlayUnderPowered = "underpowered";
|
2020-10-28 19:19:47 +01:00
|
|
|
|
|
|
|
|
public override void OnChangeData(AppearanceComponent component)
|
|
|
|
|
{
|
|
|
|
|
base.OnChangeData(component);
|
|
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
var entities = IoCManager.Resolve<IEntityManager>();
|
|
|
|
|
if (!entities.TryGetComponent(component.Owner, out ISpriteComponent? sprite))
|
2020-10-28 19:19:47 +01:00
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2021-10-29 00:29:19 +13:00
|
|
|
if (!component.TryGetData(StorageVisuals.Locked, out bool locked))
|
2020-10-28 19:19:47 +01:00
|
|
|
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.LayerSetVisible(2, locked);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|