]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add a check for item size in the microwave system (#24026)
authordegradka <degradka@gmail.com>
Sat, 13 Jan 2024 21:11:09 +0000 (00:11 +0300)
committerGitHub <noreply@github.com>
Sat, 13 Jan 2024 21:11:09 +0000 (13:11 -0800)
* Add a check for item size in the microwave system

* DataField suggestion

* Merge TryComp with HasComp

* Add datafield changeability for admins

Content.Server/Kitchen/Components/MicrowaveComponent.cs
Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs
Resources/Locale/en-US/kitchen/components/microwave-component.ftl

index f0d0ffd95f58a229c87530ddc030b4215657a399..1fb5d8d2fd6cb3e76f25a5529bfc157613311575 100644 (file)
@@ -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<ItemSizePrototype> MaxItemSize = "Normal";
     }
 
     public sealed class BeingMicrowavedEvent : HandledEntityEventArgs
index 930318609bef54c47b560ffd8a6bbfd15d40975f..1411f8501306ca5d71ee3c3eb2b9795d696d0b84 100644 (file)
@@ -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<ItemComponent>(args.Used))
+            if (TryComp<ItemComponent>(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;
             }
index f6be847874a3eefb05ecb9c519a62d23376831c1..41d42a744e087a41eb2c5eb3fef1c1a9b05cd8fd 100644 (file)
@@ -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