Fix log component parenting issues (#11073)

This commit is contained in:
Leon Friedrich
2022-09-06 17:08:19 +12:00
committed by GitHub
parent 0c8e52c163
commit 2dd804930d
3 changed files with 50 additions and 16 deletions

View File

@@ -64,12 +64,16 @@ namespace Content.Server.Nutrition.EntitySystems
// Fill new slice
FillSlice(sliceUid, lostSolution);
if (EntityManager.TryGetComponent(user, out HandsComponent? handsComponent))
var inCont = _containerSystem.IsEntityInContainer(component.Owner);
if (inCont)
{
if (_containerSystem.IsEntityInContainer(component.Owner))
{
_handsSystem.PickupOrDrop(user, sliceUid, handsComp: handsComponent);
}
_handsSystem.PickupOrDrop(user, sliceUid);
}
else
{
var xform = Transform(sliceUid);
_containerSystem.AttachParentToContainerOrGrid(xform);
xform.LocalRotation = 0;
}
SoundSystem.Play(component.Sound.GetSound(), Filter.Pvs(uid),
@@ -84,15 +88,26 @@ namespace Content.Server.Nutrition.EntitySystems
}
// Split last slice
if (component.Count == 1) {
var lastSlice = EntityManager.SpawnEntity(component.Slice, transform.Coordinates);
if (component.Count > 1)
return true;
// Fill last slice with the rest of the solution
FillSlice(lastSlice, solution);
sliceUid = EntityManager.SpawnEntity(component.Slice, transform.Coordinates);
EntityManager.DeleteEntity(uid);
// Fill last slice with the rest of the solution
FillSlice(sliceUid, solution);
if (inCont)
{
_handsSystem.PickupOrDrop(user, sliceUid);
}
else
{
var xform = Transform(sliceUid);
_containerSystem.AttachParentToContainerOrGrid(xform);
xform.LocalRotation = 0;
}
EntityManager.DeleteEntity(uid);
return true;
}