This commit is contained in:
Terochi 2023-04-21 21:46:03 +02:00
parent cc96d275c2
commit 847b63066b
1 changed files with 8 additions and 5 deletions

View File

@ -418,10 +418,13 @@ private CaughtObject getDroppedObject(CaughtObject caughtObject)
private void clearPlate(DroppedObjectAnimation animation)
{
var droppedObjects = caughtObjectContainer.Children.Select(getDroppedObject).ToArray();
var caughtObjects = caughtObjectContainer.Children.ToArray();
caughtObjectContainer.Clear(false);
//use the already returned PoolableDrawables for new objects
var droppedObjects = caughtObjects.Select(getDroppedObject).ToArray();
droppedObjectTarget.AddRange(droppedObjects);
foreach (var droppedObject in droppedObjects)
@ -430,13 +433,11 @@ private void clearPlate(DroppedObjectAnimation animation)
private void removeFromPlate(CaughtObject caughtObject, DroppedObjectAnimation animation)
{
var droppedObject = getDroppedObject(caughtObject);
caughtObjectContainer.Remove(caughtObject, false);
droppedObjectTarget.Add(droppedObject);
droppedObjectTarget.Add(getDroppedObject(caughtObject));
applyDropAnimation(droppedObject, animation);
applyDropAnimation(caughtObject, animation);
}
private void applyDropAnimation(Drawable d, DroppedObjectAnimation animation)
@ -456,6 +457,8 @@ private void applyDropAnimation(Drawable d, DroppedObjectAnimation animation)
break;
}
//define lifetime start for dropped objects to be disposed correctly when rewinding replay
d.LifetimeStart = Clock.CurrentTime;
d.Expire();
}