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

@@ -67,18 +67,29 @@ public sealed class AmeControllerSystem : EntitySystem
return; return;
if (TryComp<AmeFuelContainerComponent>(controller.JarSlot.ContainedEntity, out var fuelJar)) if (TryComp<AmeFuelContainerComponent>(controller.JarSlot.ContainedEntity, out var fuelJar))
{
// 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 availableInject = Math.Min(controller.InjectionAmount, fuelJar.FuelAmount);
var powerOutput = group.InjectFuel(availableInject, out var overloading); var powerOutput = group.InjectFuel(availableInject, out var overloading);
if (TryComp<PowerSupplierComponent>(uid, out var powerOutlet)) if (TryComp<PowerSupplierComponent>(uid, out var powerOutlet))
powerOutlet.MaxSupply = powerOutput; powerOutlet.MaxSupply = powerOutput;
fuelJar.FuelAmount -= availableInject; 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)); _audioSystem.PlayPvs(controller.InjectSound, uid, AudioParams.Default.WithVolume(overloading ? 10f : 0f));
UpdateUi(uid, controller); 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;
_appearanceSystem.SetData( var ameControllerState = stability switch
uid,
AmeControllerVisuals.DisplayState,
stability switch
{ {
< 10 => AmeControllerState.Fuck, < 10 => AmeControllerState.Fuck,
< 50 => AmeControllerState.Critical, < 50 => AmeControllerState.Critical,
_ => AmeControllerState.On, _ => AmeControllerState.On,
}, };
if (!controller.Injecting)
ameControllerState = AmeControllerState.Off;
_appearanceSystem.SetData(
uid,
AmeControllerVisuals.DisplayState,
ameControllerState,
appearance appearance
); );
} }