mirror of
https://github.com/space-syndicate/space-station-14.git
synced 2026-02-15 04:30:57 +01:00
Convert KudzuVisualizer to Visualizer Systems (#9010)
This commit is contained in:
@@ -1,30 +0,0 @@
|
||||
using Content.Shared.Kudzu;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Serialization.Manager.Attributes;
|
||||
|
||||
namespace Content.Client.Kudzu;
|
||||
|
||||
public sealed class KudzuVisualizer : AppearanceVisualizer
|
||||
{
|
||||
[DataField("layer")]
|
||||
private int Layer { get; } = 0;
|
||||
|
||||
public override void OnChangeData(AppearanceComponent component)
|
||||
{
|
||||
base.OnChangeData(component);
|
||||
|
||||
var entities = IoCManager.Resolve<IEntityManager>();
|
||||
if (!entities.TryGetComponent(component.Owner, out SpriteComponent? sprite))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (component.TryGetData(KudzuVisuals.Variant, out int var) && component.TryGetData(KudzuVisuals.GrowthLevel, out int level))
|
||||
{
|
||||
sprite.LayerMapReserveBlank(Layer);
|
||||
sprite.LayerSetState(0, $"kudzu_{level}{var}");
|
||||
}
|
||||
}
|
||||
}
|
||||
10
Content.Client/Kudzu/KudzuVisualizerComponent.cs
Normal file
10
Content.Client/Kudzu/KudzuVisualizerComponent.cs
Normal file
@@ -0,0 +1,10 @@
|
||||
namespace Content.Client.Kudzu
|
||||
{
|
||||
[RegisterComponent]
|
||||
public sealed class KudzuVisualsComponent : Component
|
||||
{
|
||||
[DataField("layer")]
|
||||
public int Layer { get; } = 0;
|
||||
}
|
||||
|
||||
}
|
||||
22
Content.Client/Kudzu/KudzuVisualizerSystem.cs
Normal file
22
Content.Client/Kudzu/KudzuVisualizerSystem.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using Content.Shared.Kudzu;
|
||||
using Robust.Client.GameObjects;
|
||||
|
||||
namespace Content.Client.Kudzu
|
||||
{
|
||||
|
||||
public sealed class KudzuVisualsSystem : VisualizerSystem<KudzuVisualsComponent>
|
||||
{
|
||||
protected override void OnAppearanceChange(EntityUid uid, KudzuVisualsComponent component, ref AppearanceChangeEvent args)
|
||||
{
|
||||
|
||||
if (args.Sprite == null)
|
||||
return;
|
||||
if (args.Component.TryGetData(KudzuVisuals.Variant, out int var)
|
||||
&& args.Component.TryGetData(KudzuVisuals.GrowthLevel, out int level))
|
||||
{
|
||||
var index = args.Sprite.LayerMapReserveBlank(component.Layer);
|
||||
args.Sprite.LayerSetState(index, $"kudzu_{level}{var}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -31,6 +31,7 @@ namespace Content.Server.Entry
|
||||
"PotencyVisuals",
|
||||
"PaperVisuals",
|
||||
"SurveillanceCameraVisuals",
|
||||
"KudzuVisuals",
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,7 @@
|
||||
drawdepth: Overdoors
|
||||
netsync: false
|
||||
- type: Appearance
|
||||
visuals:
|
||||
- type: KudzuVisualizer
|
||||
- type: KudzuVisuals
|
||||
- type: Clickable
|
||||
- type: Transform
|
||||
anchored: true
|
||||
|
||||
Reference in New Issue
Block a user