mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Merge branch 'master' into pool-scrolling
This commit is contained in:
@ -16,6 +16,7 @@ using osu.Game.Rulesets.Judgements;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osuTK;
|
||||
using System.Diagnostics;
|
||||
|
||||
namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
@ -113,6 +114,16 @@ namespace osu.Game.Rulesets.UI
|
||||
}
|
||||
}
|
||||
|
||||
private void onNewDrawableHitObject(DrawableHitObject d)
|
||||
{
|
||||
d.OnNestedDrawableCreated += onNewDrawableHitObject;
|
||||
|
||||
OnNewDrawableHitObject(d);
|
||||
|
||||
Debug.Assert(!d.IsInitialized);
|
||||
d.IsInitialized = true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Performs post-processing tasks (if any) after all DrawableHitObjects are loaded into this Playfield.
|
||||
/// </summary>
|
||||
@ -124,6 +135,11 @@ namespace osu.Game.Rulesets.UI
|
||||
/// <param name="h">The DrawableHitObject to add.</param>
|
||||
public virtual void Add(DrawableHitObject h)
|
||||
{
|
||||
if (h.IsInitialized)
|
||||
throw new InvalidOperationException($"{nameof(Add)} doesn't support {nameof(DrawableHitObject)} reuse. Use pooling instead.");
|
||||
|
||||
onNewDrawableHitObject(h);
|
||||
|
||||
HitObjectContainer.Add(h);
|
||||
OnHitObjectAdded(h.HitObject);
|
||||
}
|
||||
@ -157,6 +173,17 @@ namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Invoked before a new <see cref="DrawableHitObject"/> is added to this <see cref="Playfield"/>.
|
||||
/// It is invoked only once even if the drawable is pooled and used multiple times for different <see cref="HitObject"/>s.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is also invoked for nested <see cref="DrawableHitObject"/>s.
|
||||
/// </remarks>
|
||||
protected virtual void OnNewDrawableHitObject(DrawableHitObject drawableHitObject)
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The cursor currently being used by this <see cref="Playfield"/>. May be null if no cursor is provided.
|
||||
/// </summary>
|
||||
@ -321,10 +348,12 @@ namespace osu.Game.Rulesets.UI
|
||||
{
|
||||
var dho = (DrawableHitObject)d;
|
||||
|
||||
// If this is the first time this DHO is being used (not loaded), then apply the DHO mods.
|
||||
// This is done before Apply() so that the state is updated once when the hitobject is applied.
|
||||
if (!dho.IsLoaded)
|
||||
if (!dho.IsInitialized)
|
||||
{
|
||||
onNewDrawableHitObject(dho);
|
||||
|
||||
// If this is the first time this DHO is being used, then apply the DHO mods.
|
||||
// This is done before Apply() so that the state is updated once when the hitobject is applied.
|
||||
foreach (var m in mods.OfType<IApplicableToDrawableHitObjects>())
|
||||
m.ApplyToDrawableHitObjects(dho.Yield());
|
||||
}
|
||||
|
Reference in New Issue
Block a user