1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-19 15:02:54 +08:00

Ensure synthetic entries from non-pooled DHO are linked to parents

This commit is contained in:
Bartłomiej Dach 2023-07-03 22:39:39 +02:00
parent bae7670855
commit 0ceaf3c451
No known key found for this signature in database
2 changed files with 17 additions and 1 deletions

View File

@ -218,6 +218,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
protected sealed override void OnApply(HitObjectLifetimeEntry entry)
{
Debug.Assert(Entry != null);
// LifetimeStart is already computed using HitObjectLifetimeEntry's InitialLifetimeOffset.
// We override this with DHO's InitialLifetimeOffset for a non-pooled DHO.
if (entry is SyntheticHitObjectEntry)
@ -247,6 +249,12 @@ namespace osu.Game.Rulesets.Objects.Drawables
drawableNested.ParentHitObject = this;
nestedHitObjects.Add(drawableNested);
// assume that synthetic entries are not pooled and therefore need to be managed from within the DHO.
// this is important for the correctness of value of flags such as `AllJudged`.
if (drawableNested.Entry is SyntheticHitObjectEntry syntheticNestedEntry)
Entry.NestedEntries.Add(syntheticNestedEntry);
AddNestedHitObject(drawableNested);
}
@ -290,6 +298,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
protected sealed override void OnFree(HitObjectLifetimeEntry entry)
{
Debug.Assert(Entry != null);
StartTimeBindable.UnbindFrom(HitObject.StartTimeBindable);
if (HitObject is IHasComboInformation combo)
@ -318,6 +328,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
}
nestedHitObjects.Clear();
// clean up synthetic entries manually added in `Apply()`.
Entry.NestedEntries.RemoveAll(nestedEntry => nestedEntry is SyntheticHitObjectEntry);
ClearNestedHitObjects();
HitObject.DefaultsApplied -= onDefaultsApplied;

View File

@ -65,8 +65,11 @@ namespace osu.Game.Rulesets.Objects.Pooling
OnEntryAdded?.Invoke(entry, parent);
}
public void Remove(HitObjectLifetimeEntry entry)
public bool Remove(HitObjectLifetimeEntry entry)
{
if (entry is SyntheticHitObjectEntry)
return false;
HitObject hitObject = entry.HitObject;
if (!entryMap.ContainsKey(hitObject))
@ -84,6 +87,7 @@ namespace osu.Game.Rulesets.Objects.Pooling
hitObject.DefaultsApplied -= onDefaultsApplied;
OnEntryRemoved?.Invoke(entry, parent);
return true;
}
public bool TryGet(HitObject hitObject, [MaybeNullWhen(false)] out HitObjectLifetimeEntry entry)