1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 10:12:54 +08:00

Event -> virtual method

This commit is contained in:
ekrctb 2020-11-21 15:20:33 +09:00
parent 281ed49332
commit 4345d8dcb6
4 changed files with 20 additions and 16 deletions

View File

@ -58,7 +58,11 @@ namespace osu.Game.Rulesets.Catch.UI
NewResult += onNewResult;
RevertResult += onRevertResult;
OnNewDrawableHitObject += d => ((DrawableCatchHitObject)d).CheckPosition = CheckIfWeCanCatch;
}
protected override void OnNewDrawableHitObject(DrawableHitObject d)
{
((DrawableCatchHitObject)d).CheckPosition = CheckIfWeCanCatch;
}
public bool CheckIfWeCanCatch(CatchHitObject obj) => CatcherArea.AttemptCatch(obj);

View File

@ -29,9 +29,9 @@ namespace osu.Game.Rulesets.Osu.Edit
{
protected override GameplayCursorContainer CreateCursor() => null;
public OsuEditPlayfield()
protected override void OnNewDrawableHitObject(DrawableHitObject d)
{
OnNewDrawableHitObject += d => d.ApplyCustomUpdateState += updateState;
d.ApplyCustomUpdateState += updateState;
}
private const double editor_hit_object_fade_out_extension = 700;

View File

@ -92,10 +92,9 @@ namespace osu.Game.Rulesets.Osu.UI
AddRangeInternal(poolDictionary.Values);
NewResult += onNewResult;
OnNewDrawableHitObject += onDrawableHitObjectAdded;
}
private void onDrawableHitObjectAdded(DrawableHitObject drawable)
protected override void OnNewDrawableHitObject(DrawableHitObject drawable)
{
((DrawableOsuHitObject)drawable).CheckHittable = CheckHittable;

View File

@ -33,16 +33,6 @@ namespace osu.Game.Rulesets.UI
/// </summary>
public event Action<DrawableHitObject, JudgementResult> RevertResult;
/// <summary>
/// Invoked before a new <see cref="DrawableHitObject"/> is added.
/// This event is invoked only once for each <see cref="DrawableHitObject"/>
/// even the drawable is pooled and used multiple times for different <see cref="HitObject"/>s.
/// </summary>
/// <remarks>
/// This event is also called for nested <see cref="DrawableHitObject"/>s.
/// </remarks>
public event Action<DrawableHitObject> OnNewDrawableHitObject;
/// <summary>
/// The <see cref="DrawableHitObject"/> contained in this Playfield.
/// </summary>
@ -128,7 +118,7 @@ namespace osu.Game.Rulesets.UI
{
d.OnNestedDrawableCreated += onNewDrawableHitObject;
OnNewDrawableHitObject?.Invoke(d);
OnNewDrawableHitObject(d);
Debug.Assert(!d.HasInitialized);
d.HasInitialized = true;
@ -183,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 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>