From 94f3cf1cbf86c5885684df649b11217ac0344b29 Mon Sep 17 00:00:00 2001 From: Nikita-str Date: Fri, 27 Dec 2024 18:25:38 +0300 Subject: [PATCH] naming & some comments --- .../Edit/TaikoEditorPlayfield.cs | 7 ++++++- .../Objects/Drawables/DrawableTaikoHitObject.cs | 2 ++ osu.Game.Rulesets.Taiko/UI/HitExplosionBase.cs | 1 + osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs | 4 +++- osu.Game/Rulesets/UI/Playfield.cs | 17 +++++++++++++---- 5 files changed, 25 insertions(+), 6 deletions(-) diff --git a/osu.Game.Rulesets.Taiko/Edit/TaikoEditorPlayfield.cs b/osu.Game.Rulesets.Taiko/Edit/TaikoEditorPlayfield.cs index c1b5e3c3ac..8ec9db4656 100644 --- a/osu.Game.Rulesets.Taiko/Edit/TaikoEditorPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/Edit/TaikoEditorPlayfield.cs @@ -6,6 +6,7 @@ using osu.Framework.Graphics; using osu.Framework.Graphics.Pooling; using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Taiko.Objects; +using osu.Game.Rulesets.Taiko.Objects.Drawables; using osu.Game.Rulesets.Taiko.UI; using osu.Game.Skinning; @@ -27,9 +28,13 @@ namespace osu.Game.Rulesets.Taiko.Edit AddRangeInternal([poolHitEditorMode]); } + /// + /// to pool that + /// returns in editor mode (it will recreates its drawable hierarchy each OnApply). + /// private readonly HitPool poolHitEditorMode = new HitPool(50, editorMode: true); - protected override IDrawablePool? AdditionalPrepareDrawablePool(HitObject hitObject) + protected override IDrawablePool? PropertyBasedDrawableHitObjectPool(HitObject hitObject) { switch (hitObject) { diff --git a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs index 6ec16f0f7f..57bbb191f0 100644 --- a/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs +++ b/osu.Game.Rulesets.Taiko/Objects/Drawables/DrawableTaikoHitObject.cs @@ -160,6 +160,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables } protected abstract void RestorePieceState(); + + /// Creates MainPiece. Calls only on load or in EditorMode. protected abstract SkinnableDrawable OnLoadCreateMainPiece(); } } diff --git a/osu.Game.Rulesets.Taiko/UI/HitExplosionBase.cs b/osu.Game.Rulesets.Taiko/UI/HitExplosionBase.cs index b6c447ff71..e96acab31b 100644 --- a/osu.Game.Rulesets.Taiko/UI/HitExplosionBase.cs +++ b/osu.Game.Rulesets.Taiko/UI/HitExplosionBase.cs @@ -15,6 +15,7 @@ namespace osu.Game.Rulesets.Taiko.UI /// internal abstract partial class HitExplosionBase : PoolableDrawable { + /// Creates Skinnable. Calls only on load. protected abstract SkinnableDrawable OnLoadSkinnableCreate(); public override bool RemoveWhenNotAlive => true; diff --git a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs index 375fa24e2e..590ae908ed 100644 --- a/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs +++ b/osu.Game.Rulesets.Taiko/UI/TaikoPlayfield.cs @@ -210,6 +210,7 @@ namespace osu.Game.Rulesets.Taiko.UI AddRangeInternal(poolsHit.Values); } + /// to pools based on its (HitType, IsStrong) properties. private readonly IDictionary<(HitType, bool), HitPool> poolsHit = new Dictionary<(HitType, bool), HitPool>() { // Non strong (pool size is 50 for each type): @@ -219,10 +220,11 @@ namespace osu.Game.Rulesets.Taiko.UI {(HitType.Centre, true), new HitPool(20, HitType.Centre, true)}, {(HitType.Rim, true), new HitPool(20, HitType.Rim, true)}, }; - protected override IDrawablePool? AdditionalPrepareDrawablePool(HitObject hitObject) + protected override IDrawablePool? PropertyBasedDrawableHitObjectPool(HitObject hitObject) { switch (hitObject) { + // IDrawablePool for `Hit` object determined by its `HitType` & `IsStrong` properties. case Hit hit: return poolsHit[(hit.Type, hit.IsStrong)]; default: return null; } diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index c3a978f05b..7e46dc5edc 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -350,8 +350,6 @@ namespace osu.Game.Rulesets.UI OnHitObjectRemoved(entry.HitObject); } - protected virtual IDrawablePool AdditionalPrepareDrawablePool(HitObject hitObject) => null; - /// /// Creates the for a given . /// @@ -430,10 +428,21 @@ namespace osu.Game.Rulesets.UI }); } + /// + /// Returns a pool for given in case when it can not be determined only by type alone.
+ /// It only have sense if the same can have different for its representation. + ///
+ /// The for which will be returned. + /// + /// * null if no property based pool is required for given ;
+ /// * if given requires property based pool. + ///
+ protected virtual IDrawablePool PropertyBasedDrawableHitObjectPool(HitObject hitObject) => null; + private IDrawablePool prepareDrawableHitObjectPool(HitObject hitObject) { - var additional = AdditionalPrepareDrawablePool(hitObject); - if (additional is not null) return additional; + var property_based_pool = PropertyBasedDrawableHitObjectPool(hitObject); + if (property_based_pool is not null) return property_based_pool; var lookupType = hitObject.GetType();