* 1 warning in MechAssemblyVisualizerSystem * 2 warnings in RecyclerVisualizerSystem * 1 warning in ClusterGrenadeVisualizerSystem * 2 warnings in BarSignSystem * 4 warnings in AlertControl * 1 warning in ToolSystem * 2 warnings in PinpointerSystem * 2 warnings in ClientSpriteMovementSystem * 2 warnings in OptionsVisualizerSystem * 1 warning in FlatpackSystem * 1 warning in ZombieSystem * 1 warning in StackSystem * 1 warning in MiningOverlay * 1 warning in FlippableClothingVisualizerSystem * Guard clause for MechAssemblyVisualizerSystem * Get SpriteSystem in AlertControl constructor
49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
using Content.Shared.Clothing;
|
|
using Content.Shared.Clothing.Components;
|
|
using Content.Shared.Clothing.EntitySystems;
|
|
using Content.Shared.Foldable;
|
|
using Content.Shared.Item;
|
|
using Robust.Client.GameObjects;
|
|
|
|
namespace Content.Client.Clothing;
|
|
|
|
public sealed class FlippableClothingVisualizerSystem : VisualizerSystem<FlippableClothingVisualsComponent>
|
|
{
|
|
[Dependency] private readonly SharedItemSystem _itemSys = default!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
SubscribeLocalEvent<FlippableClothingVisualsComponent, GetEquipmentVisualsEvent>(OnGetVisuals, after: [typeof(ClothingSystem)]);
|
|
SubscribeLocalEvent<FlippableClothingVisualsComponent, FoldedEvent>(OnFolded);
|
|
}
|
|
|
|
private void OnFolded(Entity<FlippableClothingVisualsComponent> ent, ref FoldedEvent args)
|
|
{
|
|
_itemSys.VisualsChanged(ent);
|
|
}
|
|
|
|
private void OnGetVisuals(Entity<FlippableClothingVisualsComponent> ent, ref GetEquipmentVisualsEvent args)
|
|
{
|
|
if (!TryComp(ent, out SpriteComponent? sprite) ||
|
|
!TryComp(ent, out ClothingComponent? clothing))
|
|
return;
|
|
|
|
if (clothing.MappedLayer == null ||
|
|
!AppearanceSystem.TryGetData<bool>(ent, FoldableSystem.FoldedVisuals.State, out var folding) ||
|
|
!SpriteSystem.LayerMapTryGet((ent.Owner, sprite), folding ? ent.Comp.FoldingLayer : ent.Comp.UnfoldingLayer, out var idx, false))
|
|
return;
|
|
|
|
// add each layer to the visuals
|
|
var spriteLayer = sprite[idx];
|
|
foreach (var layer in args.Layers)
|
|
{
|
|
if (layer.Item1 != clothing.MappedLayer)
|
|
continue;
|
|
|
|
layer.Item2.Scale = spriteLayer.Scale;
|
|
}
|
|
}
|
|
}
|