From 655b54145af67966ffffac2bfaaa97fdc407c0be Mon Sep 17 00:00:00 2001 From: SpeltIncorrectyl <66873282+SpeltIncorrectyl@users.noreply.github.com> Date: Fri, 5 Jan 2024 20:03:48 +0000 Subject: [PATCH] Can no longer place an infinite quantity of items inside a microwave (#23577) * initial commit * rewrote code to early return to reduce nesting * added VV to Capacity field of MicrowaveComponent --- Content.Server/Kitchen/Components/MicrowaveComponent.cs | 3 +++ Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs | 7 +++++++ .../en-US/kitchen/components/microwave-component.ftl | 1 + .../Prototypes/Entities/Structures/Machines/microwave.yml | 1 + 4 files changed, 12 insertions(+) diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index 45f927389e..631ce6a450 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -66,6 +66,9 @@ namespace Content.Server.Kitchen.Components public int CurrentCookTimeButtonIndex; public Container Storage = default!; + + [DataField, ViewVariables(VVAccess.ReadWrite)] + public int Capacity = 10; } public sealed class BeingMicrowavedEvent : HandledEntityEventArgs diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index 9c3d023966..fb9ea29042 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -31,6 +31,7 @@ using Robust.Shared.Audio.Systems; using Robust.Shared.Containers; using Robust.Shared.Player; using System.Linq; +using Content.Shared.Access.Components; namespace Content.Server.Kitchen.EntitySystems { @@ -260,6 +261,12 @@ namespace Content.Server.Kitchen.EntitySystems return; } + if (ent.Comp.Storage.Count >= ent.Comp.Capacity) + { + _popupSystem.PopupEntity(Loc.GetString("microwave-component-interact-full"), ent, args.User); + return; + } + args.Handled = true; _handsSystem.TryDropIntoContainer(args.User, args.Used, ent.Comp.Storage); UpdateUserInterfaceState(ent, ent.Comp); diff --git a/Resources/Locale/en-US/kitchen/components/microwave-component.ftl b/Resources/Locale/en-US/kitchen/components/microwave-component.ftl index 74bbd553d9..f6be847874 100644 --- a/Resources/Locale/en-US/kitchen/components/microwave-component.ftl +++ b/Resources/Locale/en-US/kitchen/components/microwave-component.ftl @@ -10,6 +10,7 @@ microwave-component-suicide-others-message = {$victim} is trying to cook their h microwave-component-suicide-multi-head-message = You cook your heads! microwave-component-suicide-message = You cook your head! microwave-component-upgrade-cook-time = cook time +microwave-component-interact-full = It's full. ## Bound UI diff --git a/Resources/Prototypes/Entities/Structures/Machines/microwave.yml b/Resources/Prototypes/Entities/Structures/Machines/microwave.yml index 586b4b0af0..16e43494a6 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/microwave.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/microwave.yml @@ -5,6 +5,7 @@ description: It's magic. components: - type: Microwave + capacity: 10 - type: Appearance - type: GenericVisualizer visuals: -- 2.51.2