Remove aliveness hackery

This commit is contained in:
smoogipoo 2020-11-20 16:49:22 +09:00
parent 85eb98a7ec
commit c1f56cd0ba

View File

@ -43,12 +43,9 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
{ {
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
connectionPool = new DrawablePool<FollowPointConnection>(1, 200), connectionPool = new DrawablePoolNoLifetime<FollowPointConnection>(1, 200),
pointPool = new DrawablePool<FollowPoint>(50, 1000) pointPool = new DrawablePoolNoLifetime<FollowPoint>(50, 1000)
}; };
MakeChildAlive(connectionPool);
MakeChildAlive(pointPool);
} }
public void AddFollowPoints(OsuHitObject hitObject) public void AddFollowPoints(OsuHitObject hitObject)
@ -136,7 +133,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
} }
} }
protected override bool CheckChildrenLife() => lifetimeManager.Update(Time.Current); protected override bool CheckChildrenLife()
{
bool anyAliveChanged = base.CheckChildrenLife();
anyAliveChanged |= lifetimeManager.Update(Time.Current);
return anyAliveChanged;
}
private void onEntryBecameAlive(LifetimeEntry entry) private void onEntryBecameAlive(LifetimeEntry entry)
{ {
@ -149,7 +151,6 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
connectionsInUse[entry] = connection; connectionsInUse[entry] = connection;
AddInternal(connection); AddInternal(connection);
MakeChildAlive(connection);
} }
private void onEntryBecameDead(LifetimeEntry entry) private void onEntryBecameDead(LifetimeEntry entry)
@ -173,6 +174,17 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Connections
lifetimeEntries.Clear(); lifetimeEntries.Clear();
} }
private class DrawablePoolNoLifetime<T> : DrawablePool<T>
where T : PoolableDrawable, new()
{
public override bool RemoveWhenNotAlive => false;
public DrawablePoolNoLifetime(int initialSize, int? maximumSize = null)
: base(initialSize, maximumSize)
{
}
}
public class FollowPointLifetimeEntry : LifetimeEntry public class FollowPointLifetimeEntry : LifetimeEntry
{ {
public event Action Invalidated; public event Action Invalidated;