From 6bd818c8ceb16b731775304d94a4d705303c0692 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Aguilera=20Puerto?= <6766154+Zumorica@users.noreply.github.com> Date: Thu, 6 Feb 2020 16:40:41 +0100 Subject: [PATCH] Fix two crashes relating to food (#600) * Fix crash when eating bread due to a missing prototype * Fix crash when finishing a food. It tried to get the transform component of a deleted entity. --- .../Components/Nutrition/FoodComponent.cs | 3 ++- .../Entities/items/Consumables/food.yml | 17 +++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs b/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs index 14caecb3e2..df990b392c 100644 --- a/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs +++ b/Content.Server/GameObjects/Components/Nutrition/FoodComponent.cs @@ -155,11 +155,12 @@ namespace Content.Server.GameObjects.Components.Nutrition } + var position = Owner.Transform.GridPosition; Owner.Delete(); if (_finishPrototype != null) { - var finisher = Owner.EntityManager.SpawnEntity(_finishPrototype, Owner.Transform.GridPosition); + var finisher = Owner.EntityManager.SpawnEntity(_finishPrototype, position); if (user.TryGetComponent(out HandsComponent handsComponent) && finisher.TryGetComponent(out ItemComponent itemComponent)) { if (handsComponent.CanPutInHand(itemComponent)) diff --git a/Resources/Prototypes/Entities/items/Consumables/food.yml b/Resources/Prototypes/Entities/items/Consumables/food.yml index d0d3ad4f58..8e6dd97175 100644 --- a/Resources/Prototypes/Entities/items/Consumables/food.yml +++ b/Resources/Prototypes/Entities/items/Consumables/food.yml @@ -178,6 +178,23 @@ - type: Icon sprite: Objects/Food/baguette.rsi +- type: entity + name: Bread (slice) + parent: FoodBase + id: FoodBreadSlice + description: + components: + - type: Food + contents: + reagents: + - ReagentId: chem.Nutriment + Quantity: 8 + spawn_on_finish: TrashPlate + - type: Sprite + sprite: Objects/Food/breadslice.rsi + - type: Icon + sprite: Objects/Food/breadslice.rsi + - type: entity name: Banana bread (slice) parent: FoodBase