Vending machines properly show their current state after an animation (#12201)

This commit is contained in:
Mervill 2022-10-29 23:12:05 -07:00 committed by GitHub
parent f03b74c227
commit 69dd3a0454
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -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<SpriteComponent>(uid, out var sprite))
return;
UpdateAppearance(uid, VendingMachineVisualState.Normal, component, sprite);
if (!TryComp<AppearanceComponent>(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)