2020-08-19 11:41:33 -07:00
|
|
|
|
using Content.Shared.GameObjects.Components.PDA;
|
2020-10-26 20:35:20 +02:00
|
|
|
|
using JetBrains.Annotations;
|
2020-05-28 06:22:47 -05:00
|
|
|
|
using Robust.Client.GameObjects;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-10-26 20:35:20 +02:00
|
|
|
|
using Robust.Shared.Utility;
|
|
|
|
|
|
using YamlDotNet.RepresentationModel;
|
2020-05-28 06:22:47 -05:00
|
|
|
|
|
|
|
|
|
|
namespace Content.Client.GameObjects.Components.PDA
|
|
|
|
|
|
{
|
2020-10-26 20:35:20 +02:00
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
|
// ReSharper disable once InconsistentNaming
|
2020-05-28 06:22:47 -05:00
|
|
|
|
public class PDAVisualizer : AppearanceVisualizer
|
|
|
|
|
|
{
|
2020-10-26 20:35:20 +02:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// The base PDA sprite state, eg. "pda", "pda-clown"
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
private string _state;
|
2020-05-28 06:22:47 -05:00
|
|
|
|
|
2020-12-04 11:57:33 +01:00
|
|
|
|
private enum PDAVisualLayers : byte
|
2020-05-28 06:22:47 -05:00
|
|
|
|
{
|
|
|
|
|
|
Base,
|
2020-10-26 20:35:20 +02:00
|
|
|
|
Flashlight,
|
|
|
|
|
|
IDLight
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void LoadData(YamlMappingNode node)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.LoadData(node);
|
|
|
|
|
|
if (node.TryGetNode("state", out var child))
|
|
|
|
|
|
{
|
|
|
|
|
|
_state = child.AsString();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void InitializeEntity(IEntity entity)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.InitializeEntity(entity);
|
|
|
|
|
|
var sprite = entity.GetComponent<ISpriteComponent>();
|
|
|
|
|
|
|
|
|
|
|
|
sprite.LayerMapSet(PDAVisualLayers.Base, sprite.AddLayerState(_state));
|
|
|
|
|
|
sprite.LayerMapSet(PDAVisualLayers.Flashlight, sprite.AddLayerState("light_overlay"));
|
|
|
|
|
|
sprite.LayerSetShader(PDAVisualLayers.Flashlight, "unshaded");
|
|
|
|
|
|
sprite.LayerMapSet(PDAVisualLayers.IDLight, sprite.AddLayerState("id_overlay"));
|
|
|
|
|
|
sprite.LayerSetShader(PDAVisualLayers.IDLight, "unshaded");
|
2020-05-28 06:22:47 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnChangeData(AppearanceComponent component)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnChangeData(component);
|
2020-11-14 00:42:35 +11:00
|
|
|
|
|
2020-05-28 06:22:47 -05:00
|
|
|
|
var sprite = component.Owner.GetComponent<ISpriteComponent>();
|
2020-08-19 11:41:33 -07:00
|
|
|
|
sprite.LayerSetVisible(PDAVisualLayers.Flashlight, false);
|
2020-10-26 20:35:20 +02:00
|
|
|
|
if (component.TryGetData(PDAVisuals.FlashlightLit, out bool isScreenLit))
|
2020-05-28 06:22:47 -05:00
|
|
|
|
{
|
2020-10-26 20:35:20 +02:00
|
|
|
|
sprite.LayerSetVisible(PDAVisualLayers.Flashlight, isScreenLit);
|
2020-05-28 06:22:47 -05:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-10-26 20:35:20 +02:00
|
|
|
|
if (component.TryGetData(PDAVisuals.IDCardInserted, out bool isCardInserted))
|
|
|
|
|
|
{
|
|
|
|
|
|
sprite.LayerSetVisible(PDAVisualLayers.IDLight, isCardInserted);
|
|
|
|
|
|
}
|
2020-05-28 06:22:47 -05:00
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|