Files
crystall-punk-14/Content.Client/Power/APC/ApcVisualizer.cs

46 lines
1.6 KiB
C#
Raw Normal View History

2021-06-09 22:19:39 +02:00
using Content.Shared.APC;
using Robust.Client.GameObjects;
namespace Content.Client.Power.APC
{
public sealed class ApcVisualizer : AppearanceVisualizer
{
2022-01-15 11:32:46 -07:00
public static readonly Color LackColor = Color.FromHex("#d1332e");
public static readonly Color ChargingColor = Color.FromHex("#2e8ad1");
public static readonly Color FullColor = Color.FromHex("#3db83b");
2022-02-17 21:43:24 -05:00
public static readonly Color EmagColor = Color.FromHex("#1f48d6");
2022-01-15 11:32:46 -07:00
[Obsolete("Subscribe to AppearanceChangeEvent instead.")]
public override void OnChangeData(AppearanceComponent component)
{
base.OnChangeData(component);
2022-01-15 11:32:46 -07:00
var ent = IoCManager.Resolve<IEntityManager>();
2023-01-15 13:38:53 +11:00
var sprite = ent.GetComponent<SpriteComponent>(component.Owner);
if (component.TryGetData<ApcChargeState>(ApcVisuals.ChargeState, out var chargeState))
{
2022-01-15 11:32:46 -07:00
if (ent.TryGetComponent(component.Owner, out SharedPointLightComponent? light))
{
light.Color = chargeState switch
2022-01-15 11:32:46 -07:00
{
ApcChargeState.Lack => LackColor,
ApcChargeState.Charging => ChargingColor,
ApcChargeState.Full => FullColor,
2022-02-17 21:43:24 -05:00
ApcChargeState.Emag => EmagColor,
2022-01-15 11:32:46 -07:00
_ => LackColor
};
}
}
}
enum ApcVisualLayers : byte
{
ChargeState,
Lock,
Equipment,
Lighting,
Environment,
}
}
}