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
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
using Content.Shared.Construction.Prototypes;
|
using Content.Shared.Construction.Prototypes;
|
||||||
using Content.Shared.DeviceLinking;
|
using Content.Shared.DeviceLinking;
|
||||||
|
using Content.Shared.Item;
|
||||||
using Robust.Shared.Audio;
|
using Robust.Shared.Audio;
|
||||||
using Robust.Shared.Containers;
|
using Robust.Shared.Containers;
|
||||||
using Robust.Shared.Prototypes;
|
using Robust.Shared.Prototypes;
|
||||||
@@ -73,6 +74,9 @@ namespace Content.Server.Kitchen.Components
|
|||||||
|
|
||||||
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
public int Capacity = 10;
|
public int Capacity = 10;
|
||||||
|
|
||||||
|
[DataField, ViewVariables(VVAccess.ReadWrite)]
|
||||||
|
public ProtoId<ItemSizePrototype> MaxItemSize = "Normal";
|
||||||
}
|
}
|
||||||
|
|
||||||
public sealed class BeingMicrowavedEvent : HandledEntityEventArgs
|
public sealed class BeingMicrowavedEvent : HandledEntityEventArgs
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
[Dependency] private readonly TemperatureSystem _temperature = default!;
|
[Dependency] private readonly TemperatureSystem _temperature = default!;
|
||||||
[Dependency] private readonly UserInterfaceSystem _userInterface = default!;
|
[Dependency] private readonly UserInterfaceSystem _userInterface = default!;
|
||||||
[Dependency] private readonly HandsSystem _handsSystem = default!;
|
[Dependency] private readonly HandsSystem _handsSystem = default!;
|
||||||
|
[Dependency] private readonly SharedItemSystem _item = default!;
|
||||||
|
|
||||||
public override void Initialize()
|
public override void Initialize()
|
||||||
{
|
{
|
||||||
@@ -282,8 +283,18 @@ namespace Content.Server.Kitchen.EntitySystems
|
|||||||
return;
|
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);
|
_popupSystem.PopupEntity(Loc.GetString("microwave-component-interact-using-transfer-fail"), ent, args.User);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ microwave-component-suicide-multi-head-message = You cook your heads!
|
|||||||
microwave-component-suicide-message = You cook your head!
|
microwave-component-suicide-message = You cook your head!
|
||||||
microwave-component-upgrade-cook-time = cook time
|
microwave-component-upgrade-cook-time = cook time
|
||||||
microwave-component-interact-full = It's full.
|
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
|
## Bound UI
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user