diff --git a/.editorconfig b/.editorconfig index 3e44d1a2811..370c3f9dee6 100644 --- a/.editorconfig +++ b/.editorconfig @@ -72,7 +72,7 @@ csharp_style_expression_bodied_constructors = false:suggestion #csharp_style_expression_bodied_indexers = true:silent #csharp_style_expression_bodied_lambdas = true:silent #csharp_style_expression_bodied_local_functions = false:silent -csharp_style_expression_bodied_methods = false:suggestion +csharp_style_expression_bodied_methods = true:suggestion #csharp_style_expression_bodied_operators = false:silent csharp_style_expression_bodied_properties = true:suggestion diff --git a/Content.Client/FootPrint/FootPrintsVisualizerSystem.cs b/Content.Client/FootPrint/FootPrintsVisualizerSystem.cs new file mode 100644 index 00000000000..3998d6b3c17 --- /dev/null +++ b/Content.Client/FootPrint/FootPrintsVisualizerSystem.cs @@ -0,0 +1,65 @@ +using Content.Shared.FootPrint; +using Robust.Client.GameObjects; +using Robust.Client.Graphics; +using Robust.Shared.Random; + +namespace Content.Client.FootPrint; + +public sealed class FootPrintsVisualizerSystem : VisualizerSystem +{ + [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly IRobustRandom _random = default!; + + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent(OnInitialized); + SubscribeLocalEvent(OnShutdown); + } + + private void OnInitialized(EntityUid uid, FootPrintComponent comp, ComponentInit args) + { + if (!TryComp(uid, out var sprite)) + return; + + sprite.LayerMapReserveBlank(FootPrintVisualLayers.Print); + UpdateAppearance(uid, comp, sprite); + } + + private void OnShutdown(EntityUid uid, FootPrintComponent comp, ComponentShutdown args) + { + if (TryComp(uid, out var sprite) + && sprite.LayerMapTryGet(FootPrintVisualLayers.Print, out var layer)) + sprite.RemoveLayer(layer); + } + + private void UpdateAppearance(EntityUid uid, FootPrintComponent component, SpriteComponent sprite) + { + if (!sprite.LayerMapTryGet(FootPrintVisualLayers.Print, out var layer) + || !TryComp(component.PrintOwner, out var printsComponent) + || !TryComp(uid, out var appearance) + || !_appearance.TryGetData(uid, FootPrintVisualState.State, out var printVisuals, appearance)) + return; + + sprite.LayerSetState(layer, new RSI.StateId(printVisuals switch + { + FootPrintVisuals.BareFootPrint => printsComponent.RightStep ? printsComponent.RightBarePrint : printsComponent.LeftBarePrint, + FootPrintVisuals.ShoesPrint => printsComponent.ShoesPrint, + FootPrintVisuals.SuitPrint => printsComponent.SuitPrint, + FootPrintVisuals.Dragging => _random.Pick(printsComponent.DraggingPrint), + _ => throw new ArgumentOutOfRangeException($"Unknown {printVisuals} parameter.") + }), printsComponent.RsiPath); + + if (_appearance.TryGetData(uid, FootPrintVisualState.Color, out var printColor, appearance)) + sprite.LayerSetColor(layer, printColor); + } + + protected override void OnAppearanceChange (EntityUid uid, FootPrintComponent component, ref AppearanceChangeEvent args) + { + if (args.Sprite is not { } sprite) + return; + + UpdateAppearance(uid, component, sprite); + } +} diff --git a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml index a096caa4cfd..e070af95d82 100644 --- a/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml +++ b/Content.Client/HealthAnalyzer/UI/HealthAnalyzerWindow.xaml @@ -21,6 +21,7 @@ Orientation="Vertical"> +