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",
|
"PotencyVisuals",
|
||||||
"PaperVisuals",
|
"PaperVisuals",
|
||||||
"SurveillanceCameraVisuals",
|
"SurveillanceCameraVisuals",
|
||||||
|
"KudzuVisuals",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,7 @@
|
|||||||
drawdepth: Overdoors
|
drawdepth: Overdoors
|
||||||
netsync: false
|
netsync: false
|
||||||
- type: Appearance
|
- type: Appearance
|
||||||
visuals:
|
- type: KudzuVisuals
|
||||||
- type: KudzuVisualizer
|
|
||||||
- type: Clickable
|
- type: Clickable
|
||||||
- type: Transform
|
- type: Transform
|
||||||
anchored: true
|
anchored: true
|
||||||
|
|||||||
Reference in New Issue
Block a user