1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-30 01:32:55 +08:00

naming & some comments

This commit is contained in:
Nikita-str 2024-12-27 18:25:38 +03:00
parent 696b7006a3
commit 94f3cf1cbf
5 changed files with 25 additions and 6 deletions

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Pooling; using osu.Framework.Graphics.Pooling;
using osu.Game.Rulesets.Objects; using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Taiko.Objects; using osu.Game.Rulesets.Taiko.Objects;
using osu.Game.Rulesets.Taiko.Objects.Drawables;
using osu.Game.Rulesets.Taiko.UI; using osu.Game.Rulesets.Taiko.UI;
using osu.Game.Skinning; using osu.Game.Skinning;
@ -27,9 +28,13 @@ namespace osu.Game.Rulesets.Taiko.Edit
AddRangeInternal([poolHitEditorMode]); AddRangeInternal([poolHitEditorMode]);
} }
/// <summary>
/// <see cref="Hit"/> to <see cref="DrawableHit"/> pool that
/// returns <see cref="DrawableHit"/> in editor mode (it will recreates its drawable hierarchy each <c>OnApply</c>).
/// </summary>
private readonly HitPool poolHitEditorMode = new HitPool(50, editorMode: true); private readonly HitPool poolHitEditorMode = new HitPool(50, editorMode: true);
protected override IDrawablePool? AdditionalPrepareDrawablePool(HitObject hitObject) protected override IDrawablePool? PropertyBasedDrawableHitObjectPool(HitObject hitObject)
{ {
switch (hitObject) switch (hitObject)
{ {

View File

@ -160,6 +160,8 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
} }
protected abstract void RestorePieceState(); protected abstract void RestorePieceState();
/// <summary>Creates <c>MainPiece</c>. Calls only on <c>load</c> or in EditorMode.</summary>
protected abstract SkinnableDrawable OnLoadCreateMainPiece(); protected abstract SkinnableDrawable OnLoadCreateMainPiece();
} }
} }

View File

@ -15,6 +15,7 @@ namespace osu.Game.Rulesets.Taiko.UI
/// </summary> /// </summary>
internal abstract partial class HitExplosionBase : PoolableDrawable internal abstract partial class HitExplosionBase : PoolableDrawable
{ {
/// <summary>Creates <c>Skinnable</c>. Calls only on <c>load</c>.</summary>
protected abstract SkinnableDrawable OnLoadSkinnableCreate(); protected abstract SkinnableDrawable OnLoadSkinnableCreate();
public override bool RemoveWhenNotAlive => true; public override bool RemoveWhenNotAlive => true;

View File

@ -210,6 +210,7 @@ namespace osu.Game.Rulesets.Taiko.UI
AddRangeInternal(poolsHit.Values); AddRangeInternal(poolsHit.Values);
} }
/// <summary><see cref="Hit"/> to <see cref="DrawableHit"/> pools based on its <c>(HitType, IsStrong)</c> properties.</summary>
private readonly IDictionary<(HitType, bool), HitPool> poolsHit = new Dictionary<(HitType, bool), HitPool>() private readonly IDictionary<(HitType, bool), HitPool> poolsHit = new Dictionary<(HitType, bool), HitPool>()
{ {
// Non strong (pool size is 50 for each type): // 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.Centre, true), new HitPool(20, HitType.Centre, true)},
{(HitType.Rim, true), new HitPool(20, HitType.Rim, true)}, {(HitType.Rim, true), new HitPool(20, HitType.Rim, true)},
}; };
protected override IDrawablePool? AdditionalPrepareDrawablePool(HitObject hitObject) protected override IDrawablePool? PropertyBasedDrawableHitObjectPool(HitObject hitObject)
{ {
switch (hitObject) switch (hitObject)
{ {
// IDrawablePool for `Hit` object determined by its `HitType` & `IsStrong` properties.
case Hit hit: return poolsHit[(hit.Type, hit.IsStrong)]; case Hit hit: return poolsHit[(hit.Type, hit.IsStrong)];
default: return null; default: return null;
} }

View File

@ -350,8 +350,6 @@ namespace osu.Game.Rulesets.UI
OnHitObjectRemoved(entry.HitObject); OnHitObjectRemoved(entry.HitObject);
} }
protected virtual IDrawablePool AdditionalPrepareDrawablePool(HitObject hitObject) => null;
/// <summary> /// <summary>
/// Creates the <see cref="HitObjectLifetimeEntry"/> for a given <see cref="HitObject"/>. /// Creates the <see cref="HitObjectLifetimeEntry"/> for a given <see cref="HitObject"/>.
/// </summary> /// </summary>
@ -430,10 +428,21 @@ namespace osu.Game.Rulesets.UI
}); });
} }
/// <summary>
/// Returns a pool for given <see cref="HitObject"/> in case when it can not be determined only by <see cref="HitObject"/> type alone.<br/>
/// It only have sense if the same <see cref="HitObject"/> can have different <see cref="PoolableDrawable"/> for its representation.
/// </summary>
/// <param name="hitObject">The <see cref="HitObject"/> for which <see cref="IDrawablePool"/> will be returned.</param>
/// <returns>
/// * <c>null</c> if no property based pool is required for given <see cref="HitObject"/>;<br/>
/// * <see cref="IDrawablePool"/> if given <see cref="HitObject"/> requires property based pool.
/// </returns>
protected virtual IDrawablePool PropertyBasedDrawableHitObjectPool(HitObject hitObject) => null;
private IDrawablePool prepareDrawableHitObjectPool(HitObject hitObject) private IDrawablePool prepareDrawableHitObjectPool(HitObject hitObject)
{ {
var additional = AdditionalPrepareDrawablePool(hitObject); var property_based_pool = PropertyBasedDrawableHitObjectPool(hitObject);
if (additional is not null) return additional; if (property_based_pool is not null) return property_based_pool;
var lookupType = hitObject.GetType(); var lookupType = hitObject.GetType();