From 53f18e8e91a7503bb743549d602c4500fb92641c Mon Sep 17 00:00:00 2001 From: themias <89101928+themias@users.noreply.github.com> Date: Wed, 3 Jan 2024 19:36:31 -0500 Subject: [PATCH] microwave ejection tweak (#23460) --- .../Kitchen/EntitySystems/MicrowaveSystem.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index c7e1824c40..9c3d023966 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -61,6 +61,7 @@ namespace Content.Server.Kitchen.EntitySystems SubscribeLocalEvent(OnInteractUsing, after: new[] { typeof(AnchorableSystem) }); SubscribeLocalEvent(OnBreak); SubscribeLocalEvent(OnPowerChanged); + SubscribeLocalEvent(OnAnchorChanged); SubscribeLocalEvent(OnSuicide); SubscribeLocalEvent(OnRefreshParts); SubscribeLocalEvent(OnUpgradeExamine); @@ -279,11 +280,16 @@ namespace Content.Server.Kitchen.EntitySystems { SetAppearance(ent, MicrowaveVisualState.Idle, ent.Comp); RemComp(ent); - _sharedContainer.EmptyContainer(ent.Comp.Storage); } UpdateUserInterfaceState(ent, ent.Comp); } + private void OnAnchorChanged(EntityUid uid, MicrowaveComponent component, ref AnchorStateChangedEvent args) + { + if(!args.Anchored) + _sharedContainer.EmptyContainer(component.Storage); + } + private void OnRefreshParts(Entity ent, ref RefreshPartsEvent args) { var cookRating = args.PartRatings[ent.Comp.MachinePartCookTimeMultiplier]; @@ -342,7 +348,7 @@ namespace Content.Server.Kitchen.EntitySystems /// public void Wzhzhzh(EntityUid uid, MicrowaveComponent component, EntityUid? user) { - if (!HasContents(component) || HasComp(uid)) + if (!HasContents(component) || HasComp(uid) || !(TryComp(uid, out var apc) && apc.Powered)) return; var solidsDict = new Dictionary();