mirror of
https://github.com/ppy/osu.git
synced 2025-01-27 10:23:03 +08:00
Add hitobject usage events
This commit is contained in:
parent
fe347c8661
commit
243e913e4a
@ -42,6 +42,22 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<DrawableHitObject, JudgementResult> RevertResult;
|
public event Action<DrawableHitObject, JudgementResult> RevertResult;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when a <see cref="HitObject"/> becomes used by a <see cref="DrawableHitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// If this <see cref="HitObjectContainer"/> uses pooled objects, this represents the time when the <see cref="HitObject"/>s become alive.
|
||||||
|
/// </remarks>
|
||||||
|
public event Action<HitObject> HitObjectUsageBegan;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when a <see cref="HitObject"/> becomes unused by a <see cref="DrawableHitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// If this <see cref="HitObjectContainer"/> uses pooled objects, this represents the time when the <see cref="HitObject"/>s become dead.
|
||||||
|
/// </remarks>
|
||||||
|
public event Action<HitObject> HitObjectUsageFinished;
|
||||||
|
|
||||||
private readonly Dictionary<DrawableHitObject, IBindable> startTimeMap = new Dictionary<DrawableHitObject, IBindable>();
|
private readonly Dictionary<DrawableHitObject, IBindable> startTimeMap = new Dictionary<DrawableHitObject, IBindable>();
|
||||||
private readonly Dictionary<HitObjectLifetimeEntry, DrawableHitObject> drawableMap = new Dictionary<HitObjectLifetimeEntry, DrawableHitObject>();
|
private readonly Dictionary<HitObjectLifetimeEntry, DrawableHitObject> drawableMap = new Dictionary<HitObjectLifetimeEntry, DrawableHitObject>();
|
||||||
private readonly LifetimeEntryManager lifetimeManager = new LifetimeEntryManager();
|
private readonly LifetimeEntryManager lifetimeManager = new LifetimeEntryManager();
|
||||||
@ -88,6 +104,8 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
bindStartTime(drawable);
|
bindStartTime(drawable);
|
||||||
AddInternal(drawableMap[entry] = drawable, false);
|
AddInternal(drawableMap[entry] = drawable, false);
|
||||||
|
|
||||||
|
HitObjectUsageBegan?.Invoke(entry.HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void removeDrawable(HitObjectLifetimeEntry entry)
|
private void removeDrawable(HitObjectLifetimeEntry entry)
|
||||||
@ -103,6 +121,8 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
unbindStartTime(drawable);
|
unbindStartTime(drawable);
|
||||||
RemoveInternal(drawable);
|
RemoveInternal(drawable);
|
||||||
|
|
||||||
|
HitObjectUsageFinished?.Invoke(entry.HitObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
@ -29,6 +29,22 @@ namespace osu.Game.Rulesets.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public event Action<DrawableHitObject, JudgementResult> RevertResult;
|
public event Action<DrawableHitObject, JudgementResult> RevertResult;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when a <see cref="HitObject"/> becomes used by a <see cref="DrawableHitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// If this <see cref="HitObjectContainer"/> uses pooled objects, this represents the time when the <see cref="HitObject"/>s become alive.
|
||||||
|
/// </remarks>
|
||||||
|
public event Action<HitObject> HitObjectUsageBegan;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Invoked when a <see cref="HitObject"/> becomes unused by a <see cref="DrawableHitObject"/>.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// If this <see cref="HitObjectContainer"/> uses pooled objects, this represents the time when the <see cref="HitObject"/>s become dead.
|
||||||
|
/// </remarks>
|
||||||
|
public event Action<HitObject> HitObjectUsageFinished;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The <see cref="DrawableHitObject"/> contained in this Playfield.
|
/// The <see cref="DrawableHitObject"/> contained in this Playfield.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -88,6 +104,8 @@ namespace osu.Game.Rulesets.UI
|
|||||||
{
|
{
|
||||||
h.NewResult += (d, r) => NewResult?.Invoke(d, r);
|
h.NewResult += (d, r) => NewResult?.Invoke(d, r);
|
||||||
h.RevertResult += (d, r) => RevertResult?.Invoke(d, r);
|
h.RevertResult += (d, r) => RevertResult?.Invoke(d, r);
|
||||||
|
h.HitObjectUsageBegan += o => HitObjectUsageBegan?.Invoke(o);
|
||||||
|
h.HitObjectUsageFinished += o => HitObjectUsageFinished?.Invoke(o);
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -247,6 +265,8 @@ namespace osu.Game.Rulesets.UI
|
|||||||
|
|
||||||
otherPlayfield.NewResult += (d, r) => NewResult?.Invoke(d, r);
|
otherPlayfield.NewResult += (d, r) => NewResult?.Invoke(d, r);
|
||||||
otherPlayfield.RevertResult += (d, r) => RevertResult?.Invoke(d, r);
|
otherPlayfield.RevertResult += (d, r) => RevertResult?.Invoke(d, r);
|
||||||
|
otherPlayfield.HitObjectUsageBegan += h => HitObjectUsageBegan?.Invoke(h);
|
||||||
|
otherPlayfield.HitObjectUsageFinished += h => HitObjectUsageFinished?.Invoke(h);
|
||||||
|
|
||||||
nestedPlayfields.Value.Add(otherPlayfield);
|
nestedPlayfields.Value.Add(otherPlayfield);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user