Shutdown AME when the fuel is empty (#20458)

This commit is contained in:
daerSeebaer
2023-09-24 22:39:49 +02:00
committed by GitHub
parent 07fb076a26
commit d4a6982b81

View File

@@ -68,17 +68,28 @@ public sealed class AmeControllerSystem : EntitySystem
if (TryComp<AmeFuelContainerComponent>(controller.JarSlot.ContainedEntity, out var fuelJar)) if (TryComp<AmeFuelContainerComponent>(controller.JarSlot.ContainedEntity, out var fuelJar))
{ {
var availableInject = Math.Min(controller.InjectionAmount, fuelJar.FuelAmount); // if the jar is empty shut down the AME
var powerOutput = group.InjectFuel(availableInject, out var overloading); if (fuelJar.FuelAmount <= 0)
if (TryComp<PowerSupplierComponent>(uid, out var powerOutlet)) {
powerOutlet.MaxSupply = powerOutput; SetInjecting(uid, false, null, controller);
fuelJar.FuelAmount -= availableInject; }
_audioSystem.PlayPvs(controller.InjectSound, uid, AudioParams.Default.WithVolume(overloading ? 10f : 0f)); else
UpdateUi(uid, controller); {
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(); controller.Stability = group.GetTotalStability();
group.UpdateCoreVisuals();
UpdateDisplay(uid, controller.Stability, controller); UpdateDisplay(uid, controller.Stability, controller);
if (controller.Stability <= 0) if (controller.Stability <= 0)
@@ -155,7 +166,7 @@ public sealed class AmeControllerSystem : EntitySystem
return; return;
controller.Injecting = value; 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)) if (!value && TryComp<PowerSupplierComponent>(uid, out var powerOut))
powerOut.MaxSupply = 0; powerOut.MaxSupply = 0;
@@ -215,15 +226,20 @@ public sealed class AmeControllerSystem : EntitySystem
if (!Resolve(uid, ref controller, ref appearance)) if (!Resolve(uid, ref controller, ref appearance))
return; return;
var ameControllerState = stability switch
{
< 10 => AmeControllerState.Fuck,
< 50 => AmeControllerState.Critical,
_ => AmeControllerState.On,
};
if (!controller.Injecting)
ameControllerState = AmeControllerState.Off;
_appearanceSystem.SetData( _appearanceSystem.SetData(
uid, uid,
AmeControllerVisuals.DisplayState, AmeControllerVisuals.DisplayState,
stability switch ameControllerState,
{
< 10 => AmeControllerState.Fuck,
< 50 => AmeControllerState.Critical,
_ => AmeControllerState.On,
},
appearance appearance
); );
} }