diff --git a/osu.Game/Rulesets/UI/DrawableRuleset.cs b/osu.Game/Rulesets/UI/DrawableRuleset.cs index 1a00346d6a..357f2d27d9 100644 --- a/osu.Game/Rulesets/UI/DrawableRuleset.cs +++ b/osu.Game/Rulesets/UI/DrawableRuleset.cs @@ -314,9 +314,6 @@ namespace osu.Game.Rulesets.UI } } - public sealed override DrawableHitObject GetDrawableRepresentation(HitObject hitObject) - => base.GetDrawableRepresentation(hitObject) ?? CreateDrawableRepresentation((TObject)hitObject); - /// /// Creates a DrawableHitObject from a HitObject. /// @@ -552,7 +549,7 @@ namespace osu.Game.Rulesets.UI /// /// Registers a pool with this which is to be used whenever - /// representations are requested for the given type (via ). + /// representations are requested for the given type (via ). /// /// The number of drawables to be prepared for initial consumption. /// An optional maximum size after which the pool will no longer be expanded. @@ -574,16 +571,18 @@ namespace osu.Game.Rulesets.UI /// An optional maximum size after which the pool will no longer be expanded. /// The type of retrievable from this pool. /// The . + [NotNull] protected virtual DrawablePool CreatePool(int initialSize, int? maximumSize = null) where TDrawable : DrawableHitObject, new() => new DrawablePool(initialSize, maximumSize); /// - /// Retrieves the drawable representation of a . + /// Attempts to retrieve the poolable representation of a . /// - /// The to retrieve the drawable representation of. - /// The representing . - public virtual DrawableHitObject GetDrawableRepresentation(HitObject hitObject) + /// The to retrieve the representation of. + /// The representing , or null if no poolable representation exists. + [CanBeNull] + public DrawableHitObject GetPooledDrawableRepresentation([NotNull] HitObject hitObject) { if (!pools.TryGetValue(hitObject.GetType(), out var pool)) return null; @@ -612,14 +611,16 @@ namespace osu.Game.Rulesets.UI /// /// The to create the entry for. /// The . - protected abstract HitObjectLifetimeEntry CreateLifetimeEntry(HitObject hitObject); + [NotNull] + protected abstract HitObjectLifetimeEntry CreateLifetimeEntry([NotNull] HitObject hitObject); /// /// Retrieves or creates the for a given . /// /// The to retrieve or create the for. /// The for . - protected HitObjectLifetimeEntry GetLifetimeEntry(HitObject hitObject) + [NotNull] + protected HitObjectLifetimeEntry GetLifetimeEntry([NotNull] HitObject hitObject) { if (lifetimeEntries.TryGetValue(hitObject, out var entry)) return entry; diff --git a/osu.Game/Rulesets/UI/HitObjectContainer.cs b/osu.Game/Rulesets/UI/HitObjectContainer.cs index ff358e2e75..d55288b978 100644 --- a/osu.Game/Rulesets/UI/HitObjectContainer.cs +++ b/osu.Game/Rulesets/UI/HitObjectContainer.cs @@ -70,7 +70,7 @@ namespace osu.Game.Rulesets.UI { Debug.Assert(!drawableMap.ContainsKey(entry)); - var drawable = drawableRuleset.GetDrawableRepresentation(entry.HitObject); + var drawable = drawableRuleset.GetPooledDrawableRepresentation(entry.HitObject); drawable.OnNewResult += onNewResult; drawable.OnRevertResult += onRevertResult;