2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.MachineLinking;
|
2021-03-31 12:41:23 -07:00
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
using Robust.Client.GameObjects;
|
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 14:17:01 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
2021-03-31 12:41:23 -07:00
|
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
|
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Client.MachineLinking
|
2021-03-31 12:41:23 -07:00
|
|
|
|
{
|
|
|
|
|
|
[UsedImplicitly]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class SignalSwitchVisualizer : AppearanceVisualizer
|
2021-03-31 12:41:23 -07:00
|
|
|
|
{
|
2021-05-04 15:37:16 +02:00
|
|
|
|
[DataField("layer")]
|
2021-03-31 12:41:23 -07:00
|
|
|
|
private int Layer { get; }
|
|
|
|
|
|
|
2022-08-14 07:28:34 +02:00
|
|
|
|
[Obsolete("Subscribe to your component being initialised instead.")]
|
2021-12-05 18:09:01 +01:00
|
|
|
|
public override void InitializeEntity(EntityUid entity)
|
2021-03-31 12:41:23 -07:00
|
|
|
|
{
|
|
|
|
|
|
base.InitializeEntity(entity);
|
|
|
|
|
|
|
2021-12-03 15:53:09 +01:00
|
|
|
|
if (IoCManager.Resolve<IEntityManager>().TryGetComponent(entity, out SpriteComponent? sprite))
|
2021-03-31 12:41:23 -07:00
|
|
|
|
{
|
|
|
|
|
|
sprite.LayerMapReserveBlank(Layer);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2022-08-14 07:28:34 +02:00
|
|
|
|
[Obsolete("Subscribe to AppearanceChangeEvent instead.")]
|
2021-03-31 12:41:23 -07: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 SpriteComponent? sprite))
|
2021-03-31 12:41:23 -07:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!component.TryGetData(SignalSwitchVisuals.On, out bool on))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
sprite.LayerSetState(0, on ? "on" : "off");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|