From 69dd3a04545ec1f63549312a67d8d24dfe4d4e44 Mon Sep 17 00:00:00 2001 From: Mervill Date: Sat, 29 Oct 2022 23:12:05 -0700 Subject: [PATCH] Vending machines properly show their current state after an animation (#12201) --- Content.Client/VendingMachines/VendingMachineSystem.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Content.Client/VendingMachines/VendingMachineSystem.cs b/Content.Client/VendingMachines/VendingMachineSystem.cs index cb9878b119..c18c29fc27 100644 --- a/Content.Client/VendingMachines/VendingMachineSystem.cs +++ b/Content.Client/VendingMachines/VendingMachineSystem.cs @@ -7,6 +7,7 @@ namespace Content.Client.VendingMachines; public sealed class VendingMachineSystem : SharedVendingMachineSystem { [Dependency] private readonly AnimationPlayerSystem _animationPlayer = default!; + [Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!; public override void Initialize() { @@ -21,7 +22,14 @@ public sealed class VendingMachineSystem : SharedVendingMachineSystem if (!TryComp(uid, out var sprite)) return; - UpdateAppearance(uid, VendingMachineVisualState.Normal, component, sprite); + if (!TryComp(uid, out var appearance) || + !_appearanceSystem.TryGetData(uid, VendingMachineVisuals.VisualState, out var visualStateObject, appearance) || + visualStateObject is not VendingMachineVisualState visualState) + { + visualState = VendingMachineVisualState.Normal; + } + + UpdateAppearance(uid, visualState, component, sprite); } private void OnAppearanceChange(EntityUid uid, VendingMachineComponent component, ref AppearanceChangeEvent args)