]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Shutdown AME when the fuel is empty (#20458)
authordaerSeebaer <61566539+daerSeebaer@users.noreply.github.com>
Sun, 24 Sep 2023 20:39:49 +0000 (22:39 +0200)
committerGitHub <noreply@github.com>
Sun, 24 Sep 2023 20:39:49 +0000 (16:39 -0400)
Content.Server/Ame/EntitySystems/AmeControllerSystem.cs

index 00e6c01064844fecab732f7a3367486f333ad1bd..7b9ea7146ef8d93ddfc3817ea66efa2838023fa9 100644 (file)
@@ -68,17 +68,28 @@ public sealed class AmeControllerSystem : EntitySystem
 
         if (TryComp<AmeFuelContainerComponent>(controller.JarSlot.ContainedEntity, out var fuelJar))
         {
-            var availableInject = Math.Min(controller.InjectionAmount, fuelJar.FuelAmount);
-            var powerOutput = group.InjectFuel(availableInject, out var overloading);
-            if (TryComp<PowerSupplierComponent>(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<PowerSupplierComponent>(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<PowerSupplierComponent>(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
         );
     }