Bugfix microwaves staying locked out after cooking finishes (#4352)

* fix microwaves staying locked out after cooking finishes (issue 4201)

upstream issue (goob is where the breaking changes came from): https://github.com/Goob-Station/Goob-Station/issues/4086

* minor style fixes
This commit is contained in:
Charlie Morley 2025-09-08 23:54:09 -06:00 committed by GitHub
parent feaa4dd65c
commit 223b81ea35
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 34 additions and 4 deletions

View File

@ -444,8 +444,15 @@ namespace Content.Server.Kitchen.EntitySystems
private void OnAnchorChanged(EntityUid uid, MicrowaveComponent component, ref AnchorStateChangedEvent args)
{
if (!args.Anchored)
// DeltaV - start of microwave ejection bugfix
if (!args.Anchored)
{
// DeltaV's MicrowaveEventsSystem changes prevent ejection from active microwave, so stop cooking first
StopCooking((uid, component));
_container.EmptyContainer(component.Storage);
UpdateUserInterfaceState(uid, component);
}
// DeltaV - end of microwave ejection bugfix
}
private void OnSignalReceived(Entity<MicrowaveComponent> ent, ref SignalReceivedEvent args)
@ -463,7 +470,12 @@ namespace Content.Server.Kitchen.EntitySystems
{
_userInterface.SetUiState(uid, MicrowaveUiKey.Key, new MicrowaveUpdateUserInterfaceState(
GetNetEntityArray(component.Storage.ContainedEntities.ToArray()),
HasComp<ActiveMicrowaveComponent>(uid),
// DeltaV - start of microwave ejection bugfix
(
EntityManager.TryGetComponent<ActiveMicrowaveComponent>(uid, out var active)
&& active.LifeStage < ComponentLifeStage.Stopping
),
// DeltaV - end of microwave ejection bugfix
component.CurrentCookTimeButtonIndex,
component.CurrentCookTimerTime,
component.CurrentCookTimeEnd
@ -489,6 +501,10 @@ namespace Content.Server.Kitchen.EntitySystems
/// <param name="ent"></param>
public void Explode(Entity<MicrowaveComponent> ent)
{
// DeltaV - start of microwave ejection bugfix
// DeltaV's MicrowaveEventsSystem changes prevent ejection from active microwave, so stop cooking first
StopCooking(ent);
// DeltaV - end of microwave ejection bugfix
ent.Comp.Broken = true; // Make broken so we stop processing stuff
_explosion.TriggerExplosive(ent);
if (TryComp<MachineComponent>(ent, out var machine))
@ -497,6 +513,10 @@ namespace Content.Server.Kitchen.EntitySystems
_container.EmptyContainer(machine.PartContainer);
}
// DeltaV - start of microwave ejection bugfix
UpdateUserInterfaceState(ent, ent.Comp);
// DeltaV - end of microwave ejection bugfix
_adminLogger.Add(LogType.Action, LogImpact.Medium,
$"{ToPrettyString(ent)} exploded from unsafe cooking!");
}
@ -710,11 +730,16 @@ namespace Content.Server.Kitchen.EntitySystems
}
}
// DeltaV - start of microwave ejection bugfix
// StopCooking should be in front of both:
// - EmptyContainer() call, because DeltaV MicrowaveEventsSystem prevents ejection from active microwave
// - UpdateUserInterfaceState() call - not very relevant, but UI shouldn't be "busy" after cooking is done
StopCooking((uid, microwave));
_container.EmptyContainer(microwave.Storage);
microwave.CurrentCookTimeEnd = TimeSpan.Zero;
UpdateUserInterfaceState(uid, microwave);
_audio.PlayPvs(microwave.FoodDoneSound, uid);
StopCooking((uid, microwave));
// DeltaV - end of microwave ejection bugfix
}
}

View File

@ -23,6 +23,11 @@ public sealed class MicrowaveEventsSystem : EntitySystem
private void OnRemoveAttempt(Entity<ActiveMicrowaveComponent> ent, ref ContainerIsRemovingAttemptEvent args)
{
args.Cancel();
// DeltaV - start of microwave ejection bugfix
if (ent.Comp.LifeStage < ComponentLifeStage.Stopping)
{
args.Cancel();
}
// DeltaV - end of microwave ejection bugfix
}
}