From: degradka Date: Sat, 13 Jan 2024 21:11:09 +0000 (+0300) Subject: Add a check for item size in the microwave system (#24026) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=562d7b4b82a49001179c1252064c8610174f8716;p=space-station-14.git Add a check for item size in the microwave system (#24026) * Add a check for item size in the microwave system * DataField suggestion * Merge TryComp with HasComp * Add datafield changeability for admins --- diff --git a/Content.Server/Kitchen/Components/MicrowaveComponent.cs b/Content.Server/Kitchen/Components/MicrowaveComponent.cs index f0d0ffd95f..1fb5d8d2fd 100644 --- a/Content.Server/Kitchen/Components/MicrowaveComponent.cs +++ b/Content.Server/Kitchen/Components/MicrowaveComponent.cs @@ -1,5 +1,6 @@ using Content.Shared.Construction.Prototypes; using Content.Shared.DeviceLinking; +using Content.Shared.Item; using Robust.Shared.Audio; using Robust.Shared.Containers; using Robust.Shared.Prototypes; @@ -73,6 +74,9 @@ namespace Content.Server.Kitchen.Components [DataField, ViewVariables(VVAccess.ReadWrite)] public int Capacity = 10; + + [DataField, ViewVariables(VVAccess.ReadWrite)] + public ProtoId MaxItemSize = "Normal"; } public sealed class BeingMicrowavedEvent : HandledEntityEventArgs diff --git a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs index 930318609b..1411f85013 100644 --- a/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs +++ b/Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs @@ -51,6 +51,7 @@ namespace Content.Server.Kitchen.EntitySystems [Dependency] private readonly TemperatureSystem _temperature = default!; [Dependency] private readonly UserInterfaceSystem _userInterface = default!; [Dependency] private readonly HandsSystem _handsSystem = default!; + [Dependency] private readonly SharedItemSystem _item = default!; public override void Initialize() { @@ -282,8 +283,18 @@ namespace Content.Server.Kitchen.EntitySystems return; } - if (!HasComp(args.Used)) + if (TryComp(args.Used, out var item)) { + // check if size of an item you're trying to put in is too big + if (_item.GetSizePrototype(item.Size) > _item.GetSizePrototype(ent.Comp.MaxItemSize)) + { + _popupSystem.PopupEntity(Loc.GetString("microwave-component-interact-item-too-big", ("item", args.Used)), ent, args.User); + return; + } + } + else + { + // check if thing you're trying to put in isn't an item _popupSystem.PopupEntity(Loc.GetString("microwave-component-interact-using-transfer-fail"), ent, args.User); return; } diff --git a/Resources/Locale/en-US/kitchen/components/microwave-component.ftl b/Resources/Locale/en-US/kitchen/components/microwave-component.ftl index f6be847874..41d42a744e 100644 --- a/Resources/Locale/en-US/kitchen/components/microwave-component.ftl +++ b/Resources/Locale/en-US/kitchen/components/microwave-component.ftl @@ -11,6 +11,7 @@ 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. +microwave-component-interact-item-too-big = { CAPITALIZE(THE($item)) } is too big to fit in the microwave! ## Bound UI