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.
This commit is contained in:
Víctor Aguilera Puerto
2020-02-06 16:40:41 +01:00
committed by GitHub
parent 51c24150d3
commit 6bd818c8ce
2 changed files with 19 additions and 1 deletions

View File

@@ -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))

View File

@@ -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