2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Shared.Singularity;
|
2021-03-31 12:41:23 -07:00
|
|
|
|
using JetBrains.Annotations;
|
|
|
|
|
|
using Robust.Client.GameObjects;
|
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2021-12-03 15:09:45 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
2021-03-31 12:41:23 -07:00
|
|
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
2021-08-23 00:54:03 +10:00
|
|
|
|
using Robust.Shared.Utility;
|
2021-03-31 12:41:23 -07:00
|
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
|
namespace Content.Client.Singularity.Visualizers
|
2021-03-31 12:41:23 -07:00
|
|
|
|
{
|
|
|
|
|
|
[UsedImplicitly]
|
|
|
|
|
|
public class SingularityVisualizer : AppearanceVisualizer
|
|
|
|
|
|
{
|
2021-05-04 15:37:16 +02:00
|
|
|
|
[DataField("layer")]
|
2021-03-31 12:41:23 -07:00
|
|
|
|
private int Layer { get; } = 0;
|
|
|
|
|
|
|
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
|
|
|
|
IoCManager.Resolve<IEntityManager>().GetComponentOrNull<SpriteComponent>(entity)?.LayerMapReserveBlank(Layer);
|
2021-03-31 12:41:23 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnChangeData(AppearanceComponent component)
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnChangeData(component);
|
|
|
|
|
|
|
2021-12-07 22:22:34 +11:00
|
|
|
|
if (!IoCManager.Resolve<IEntityManager>().TryGetComponent(component.Owner, out SpriteComponent? sprite))
|
2021-03-31 12:41:23 -07:00
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (!component.TryGetData(SingularityVisuals.Level, out int level))
|
|
|
|
|
|
{
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-08-23 00:54:03 +10:00
|
|
|
|
sprite.LayerSetSprite(Layer, new SpriteSpecifier.Rsi(new ResourcePath("Structures/Power/Generation/Singularity/singularity_" + level + ".rsi"), "singularity_" + level));
|
2021-03-31 12:41:23 -07:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|