From 1c3c596bae1bc463ce05f3ae6f5cbe09ac59ed4c Mon Sep 17 00:00:00 2001 From: GreyMario Date: Fri, 12 Jan 2024 00:42:15 -0800 Subject: [PATCH] Pie tins returned from all pies in all situations, add lathe recipes for pie tin and some other basic kitchenwares (#23217) * move pietin trash to FoodPieBase so all pies return their pie tin when eaten * spawn trash from a SliceableFood if the Food has a trash * add a limited selection of additional tablewares to the autolathe * kitchenware material adjustments * fix crash when slice pie in hand/inventory * use system helpers + slices now go in parent container --- .../EntitySystems/SliceableFoodSystem.cs | 50 ++++++++++++++----- .../Objects/Consumable/Food/Baked/pie.yml | 4 +- .../Consumable/Food/Containers/plate.yml | 2 +- .../Entities/Structures/Machines/lathe.yml | 8 +++ .../Prototypes/Recipes/Lathes/cooking.yml | 41 +++++++++++++-- 5 files changed, 86 insertions(+), 19 deletions(-) diff --git a/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs b/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs index 064d316beff5b0..bb420d246fc5c8 100644 --- a/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs +++ b/Content.Server/Nutrition/EntitySystems/SliceableFoodSystem.cs @@ -5,6 +5,7 @@ using Content.Shared.FixedPoint; using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; +using Robust.Server.GameObjects; using Robust.Shared.Audio; using Robust.Shared.Audio.Systems; using Robust.Shared.Containers; @@ -17,6 +18,7 @@ public sealed class SliceableFoodSystem : EntitySystem [Dependency] private readonly SharedAudioSystem _audio = default!; [Dependency] private readonly SharedContainerSystem _containerSystem = default!; [Dependency] private readonly SharedHandsSystem _handsSystem = default!; + [Dependency] private readonly TransformSystem _xformSystem = default!; public override void Initialize() { @@ -76,7 +78,7 @@ private bool TrySliceFood(EntityUid uid, EntityUid user, EntityUid usedItem, // If someone makes food proto with 1 slice... if (component.Count < 1) { - DeleteFood(uid, user); + DeleteFood(uid, user, food); return true; } @@ -89,7 +91,7 @@ private bool TrySliceFood(EntityUid uid, EntityUid user, EntityUid usedItem, // Fill last slice with the rest of the solution FillSlice(sliceUid, solution); - DeleteFood(uid, user); + DeleteFood(uid, user, food); return true; } @@ -102,32 +104,54 @@ public EntityUid Slice(EntityUid uid, EntityUid user, SliceableFoodComponent? co if (!Resolve(uid, ref comp, ref transform)) return EntityUid.Invalid; - var sliceUid = Spawn(comp.Slice, transform.Coordinates); - var inCont = _containerSystem.IsEntityInContainer(uid); - if (inCont) + var sliceUid = Spawn(comp.Slice, _xformSystem.GetMapCoordinates(uid)); + + // try putting the slice into the container if the food being sliced is in a container! + // this lets you do things like slice a pizza up inside of a hot food cart without making a food-everywhere mess + if (_containerSystem.TryGetContainingContainer(uid, out var container) && _containerSystem.CanInsert(sliceUid, container)) { - _handsSystem.PickupOrDrop(user, sliceUid); + _containerSystem.Insert(sliceUid, container); } - else + else // puts it down "right-side up" { - var xform = Transform(sliceUid); - _containerSystem.AttachParentToContainerOrGrid((sliceUid, xform)); - xform.LocalRotation = 0; + _xformSystem.AttachToGridOrMap(sliceUid); + _xformSystem.SetLocalRotation(sliceUid, 0); } return sliceUid; } - private void DeleteFood(EntityUid uid, EntityUid user) + private void DeleteFood(EntityUid uid, EntityUid user, FoodComponent foodComp) { var ev = new BeforeFullySlicedEvent { User = user }; RaiseLocalEvent(uid, ev); + if (ev.Cancelled) + return; + + if (string.IsNullOrEmpty(foodComp.Trash)) + { + QueueDel(uid); + return; + } + + // Locate the sliced food and spawn its trash + var trashUid = Spawn(foodComp.Trash, _xformSystem.GetMapCoordinates(uid)); + + // try putting the trash in the food's container too, to be consistent with slice spawning? + if (_containerSystem.TryGetContainingContainer(uid, out var container) && _containerSystem.CanInsert(trashUid, container)) + { + _containerSystem.Insert(trashUid, container); + } + else // puts it down "right-side up" + { + _xformSystem.AttachToGridOrMap(trashUid); + _xformSystem.SetLocalRotation(trashUid, 0); + } - if (!ev.Cancelled) - Del(uid); + QueueDel(uid); } private void FillSlice(EntityUid sliceUid, Solution solution) diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml index b03be2fea48501..fb3d2682525588 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/Baked/pie.yml @@ -20,6 +20,8 @@ Quantity: 11 - ReagentId: Vitamin Quantity: 5 + - type: Food #All pies here made with a pie tin; unless you're some kind of savage, you're probably not destroying this when you eat or slice the pie! + trash: FoodPlateTin - type: SliceableFood count: 4 - type: Tag @@ -132,8 +134,6 @@ - sweet - banana - creamy - - type: Food - trash: FoodPlateTin - type: Sprite layers: - state: tin diff --git a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/plate.yml b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/plate.yml index 9e0bd89184f121..a6ddd725b00861 100644 --- a/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/plate.yml +++ b/Resources/Prototypes/Entities/Objects/Consumable/Food/Containers/plate.yml @@ -151,5 +151,5 @@ - Trash - type: PhysicalComposition materialComposition: - Steel: 100 + Steel: 60 - type: SpaceGarbage diff --git a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml index 0d9e3ad767cc86..e5a9ccf39042f2 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/lathe.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/lathe.yml @@ -111,10 +111,18 @@ - ExteriorLightTube - LightBulb - Bucket + - DrinkMug + - DrinkMugMetal + - DrinkGlass + - DrinkShotGlass + - DrinkGlassCoupeShaped - FoodPlate - FoodPlateSmall - FoodPlatePlastic - FoodPlateSmallPlastic + - FoodBowlBig + - FoodPlateTin + - FoodKebabSkewer - SprayBottle - MopItem - Holoprojector diff --git a/Resources/Prototypes/Recipes/Lathes/cooking.yml b/Resources/Prototypes/Recipes/Lathes/cooking.yml index b87522e9d35cf4..a8836ff39267e1 100644 --- a/Resources/Prototypes/Recipes/Lathes/cooking.yml +++ b/Resources/Prototypes/Recipes/Lathes/cooking.yml @@ -19,21 +19,35 @@ result: DrinkMug completetime: 0.8 materials: - Glass: 50 + Glass: 100 - type: latheRecipe id: DrinkMugMetal result: DrinkMugMetal completetime: 0.8 materials: - Steel: 50 + Steel: 100 - type: latheRecipe id: DrinkGlass result: DrinkGlass completetime: 0.8 materials: - Glass: 50 + Glass: 100 + +- type: latheRecipe + id: DrinkShotGlass + result: DrinkShotGlass + completetime: 0.4 + materials: + Glass: 100 + +- type: latheRecipe + id: DrinkGlassCoupeShaped + result: DrinkGlassCoupeShaped + completetime: 0.8 + materials: + Glass: 100 - type: latheRecipe id: FoodPlate @@ -62,3 +76,24 @@ completetime: 0.4 materials: Plastic: 50 + +- type: latheRecipe + id: FoodBowlBig + result: FoodBowlBig + completetime: 0.8 + materials: + Glass: 100 + +- type: latheRecipe + id: FoodPlateTin + result: FoodPlateTin + completetime: 0.4 + materials: + Steel: 100 + +- type: latheRecipe + id: FoodKebabSkewer + result: FoodKebabSkewer + completetime: 0.4 + materials: + Steel: 100