44 lines
1.3 KiB
C#
44 lines
1.3 KiB
C#
|
|
using Content.Shared.Mech;
|
|||
|
|
using Content.Shared.Mech.EntitySystems;
|
|||
|
|
using Robust.Client.GameObjects;
|
|||
|
|
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
|
|||
|
|
|
|||
|
|
namespace Content.Client.Mech;
|
|||
|
|
|
|||
|
|
/// <inheritdoc/>
|
|||
|
|
public sealed class MechSystem : SharedMechSystem
|
|||
|
|
{
|
|||
|
|
/// <inheritdoc/>
|
|||
|
|
public override void Initialize()
|
|||
|
|
{
|
|||
|
|
base.Initialize();
|
|||
|
|
|
|||
|
|
SubscribeLocalEvent<MechComponent, AppearanceChangeEvent>(OnAppearanceChanged);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void OnAppearanceChanged(EntityUid uid, MechComponent component, ref AppearanceChangeEvent args)
|
|||
|
|
{
|
|||
|
|
if (args.Sprite == null)
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
if (!args.Sprite.TryGetLayer((int) MechVisualLayers.Base, out var layer))
|
|||
|
|
return;
|
|||
|
|
|
|||
|
|
var state = component.BaseState;
|
|||
|
|
var drawDepth = DrawDepth.Mobs;
|
|||
|
|
if (component.BrokenState != null && args.Component.TryGetData(MechVisuals.Broken, out bool broken) && broken)
|
|||
|
|
{
|
|||
|
|
state = component.BrokenState;
|
|||
|
|
drawDepth = DrawDepth.SmallMobs;
|
|||
|
|
}
|
|||
|
|
else if (component.OpenState != null && args.Component.TryGetData(MechVisuals.Open, out bool open) && open)
|
|||
|
|
{
|
|||
|
|
state = component.OpenState;
|
|||
|
|
drawDepth = DrawDepth.SmallMobs;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
layer.SetState(state);
|
|||
|
|
args.Sprite.DrawDepth = (int) drawDepth;
|
|||
|
|
}
|
|||
|
|
}
|