2021-10-03 07:05:52 +03:00
|
|
|
using Content.Shared.Light;
|
|
|
|
|
using Content.Shared.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;
|
2021-12-03 11:55:25 +01:00
|
|
|
using Robust.Shared.IoC;
|
2021-03-05 01:08:38 +01:00
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2020-05-28 06:22:47 -05:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.PDA
|
2020-05-28 06:22:47 -05:00
|
|
|
{
|
2020-10-26 20:35:20 +02:00
|
|
|
[UsedImplicitly]
|
|
|
|
|
// ReSharper disable once InconsistentNaming
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class PDAVisualizer : AppearanceVisualizer
|
2020-05-28 06:22:47 -05:00
|
|
|
{
|
2020-10-26 20:35:20 +02:00
|
|
|
/// <summary>
|
|
|
|
|
/// The base PDA sprite state, eg. "pda", "pda-clown"
|
|
|
|
|
/// </summary>
|
2021-03-05 01:08:38 +01:00
|
|
|
[DataField("state")]
|
2021-03-10 14:48:29 +01:00
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-05 18:09:01 +01:00
|
|
|
public override void InitializeEntity(EntityUid entity)
|
2020-10-26 20:35:20 +02:00
|
|
|
{
|
|
|
|
|
base.InitializeEntity(entity);
|
2021-12-03 15:53:09 +01:00
|
|
|
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(entity);
|
2020-10-26 20:35:20 +02:00
|
|
|
|
2021-03-10 14:48:29 +01:00
|
|
|
if (_state != null)
|
|
|
|
|
{
|
|
|
|
|
sprite.LayerMapSet(PDAVisualLayers.Base, sprite.AddLayerState(_state));
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-26 20:35:20 +02:00
|
|
|
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
|
|
|
|
2021-12-03 15:53:09 +01:00
|
|
|
var sprite = IoCManager.Resolve<IEntityManager>().GetComponent<ISpriteComponent>(component.Owner);
|
2020-08-19 11:41:33 -07:00
|
|
|
sprite.LayerSetVisible(PDAVisualLayers.Flashlight, false);
|
2021-10-03 07:05:52 +03:00
|
|
|
if (component.TryGetData(UnpoweredFlashlightVisuals.LightOn, out bool isFlashlightOn))
|
2020-05-28 06:22:47 -05:00
|
|
|
{
|
2021-10-03 07:05:52 +03:00
|
|
|
sprite.LayerSetVisible(PDAVisualLayers.Flashlight, isFlashlightOn);
|
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
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|