using Content.Shared.Mech;
using Content.Shared.Mech.Components;
using Content.Shared.Mech.EntitySystems;
using Robust.Client.GameObjects;
using DrawDepth = Content.Shared.DrawDepth.DrawDepth;
namespace Content.Client.Mech;
///
public sealed partial class MechSystem : SharedMechSystem // Horizon Mech
{
[Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SpriteSystem _sprite = default!;
///
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent(OnAppearanceChanged);
InitializeADT(); // Horizon Mech
}
private void OnAppearanceChanged(EntityUid uid, MechComponent component, ref AppearanceChangeEvent args)
{
if (args.Sprite == null)
return;
if (!args.Sprite.LayerMapTryGet(MechVisualLayers.Base, out var layerId) || // Horizon
!args.Sprite.TryGetLayer(layerId, out var layer)) // Horizon Mech
return;
var state = component.BaseState;
var drawDepth = DrawDepth.Mobs;
if (component.BrokenState != null &&
_appearance.TryGetData(uid, MechVisuals.Broken, out var broken, args.Component) && broken)
{
state = component.BrokenState;
drawDepth = DrawDepth.SmallMobs;
}
else if (component.OpenState != null &&
_appearance.TryGetData(uid, MechVisuals.Open, out var open, args.Component) && open)
{
state = component.OpenState;
drawDepth = DrawDepth.SmallMobs;
}
layer.SetState(state);
args.Sprite.DrawDepth = (int)drawDepth; // Horizon Mech
}
}