From: daerSeebaer <61566539+daerSeebaer@users.noreply.github.com> Date: Sun, 24 Sep 2023 20:39:49 +0000 (+0200) Subject: Shutdown AME when the fuel is empty (#20458) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=d4a6982b8163618a286ee60884ed6c567521ba11;p=space-station-14.git Shutdown AME when the fuel is empty (#20458) --- diff --git a/Content.Server/Ame/EntitySystems/AmeControllerSystem.cs b/Content.Server/Ame/EntitySystems/AmeControllerSystem.cs index 00e6c01064..7b9ea7146e 100644 --- a/Content.Server/Ame/EntitySystems/AmeControllerSystem.cs +++ b/Content.Server/Ame/EntitySystems/AmeControllerSystem.cs @@ -68,17 +68,28 @@ public sealed class AmeControllerSystem : EntitySystem if (TryComp(controller.JarSlot.ContainedEntity, out var fuelJar)) { - var availableInject = Math.Min(controller.InjectionAmount, fuelJar.FuelAmount); - var powerOutput = group.InjectFuel(availableInject, out var overloading); - if (TryComp(uid, out var powerOutlet)) - powerOutlet.MaxSupply = powerOutput; - fuelJar.FuelAmount -= availableInject; - _audioSystem.PlayPvs(controller.InjectSound, uid, AudioParams.Default.WithVolume(overloading ? 10f : 0f)); - UpdateUi(uid, controller); + // if the jar is empty shut down the AME + if (fuelJar.FuelAmount <= 0) + { + SetInjecting(uid, false, null, controller); + } + else + { + var availableInject = Math.Min(controller.InjectionAmount, fuelJar.FuelAmount); + var powerOutput = group.InjectFuel(availableInject, out var overloading); + if (TryComp(uid, out var powerOutlet)) + powerOutlet.MaxSupply = powerOutput; + fuelJar.FuelAmount -= availableInject; + // only play audio if we actually had an injection + if (availableInject > 0) + _audioSystem.PlayPvs(controller.InjectSound, uid, AudioParams.Default.WithVolume(overloading ? 10f : 0f)); + UpdateUi(uid, controller); + } } controller.Stability = group.GetTotalStability(); + group.UpdateCoreVisuals(); UpdateDisplay(uid, controller.Stability, controller); if (controller.Stability <= 0) @@ -155,7 +166,7 @@ public sealed class AmeControllerSystem : EntitySystem return; controller.Injecting = value; - _appearanceSystem.SetData(uid, AmeControllerVisuals.DisplayState, value ? AmeControllerState.On : AmeControllerState.Off); + UpdateDisplay(uid, controller.Stability, controller); if (!value && TryComp(uid, out var powerOut)) powerOut.MaxSupply = 0; @@ -215,15 +226,20 @@ public sealed class AmeControllerSystem : EntitySystem if (!Resolve(uid, ref controller, ref appearance)) return; + var ameControllerState = stability switch + { + < 10 => AmeControllerState.Fuck, + < 50 => AmeControllerState.Critical, + _ => AmeControllerState.On, + }; + + if (!controller.Injecting) + ameControllerState = AmeControllerState.Off; + _appearanceSystem.SetData( uid, AmeControllerVisuals.DisplayState, - stability switch - { - < 10 => AmeControllerState.Fuck, - < 50 => AmeControllerState.Critical, - _ => AmeControllerState.On, - }, + ameControllerState, appearance ); }