Add lazy weak property to DrawableOsuHitObject to find and cache the containing OsuInputManager, if it exists

This commit is contained in:
Shane Woolcock 2017-08-18 16:34:01 +09:30
parent 306c00e593
commit 9c6ca2d159

View File

@ -1,6 +1,7 @@
// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>. // Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE // Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.ComponentModel; using System.ComponentModel;
using osu.Game.Rulesets.Objects.Drawables; using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Judgements; using osu.Game.Rulesets.Osu.Judgements;
@ -51,6 +52,19 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
protected virtual void UpdateCurrentState(ArmedState state) protected virtual void UpdateCurrentState(ArmedState state)
{ {
} }
private WeakReference<OsuInputManager> osuActionInputManager = new WeakReference<OsuInputManager>(null);
internal OsuInputManager OsuActionInputManager
{
get
{
OsuInputManager target = null;
if (osuActionInputManager.TryGetTarget(out target)) return target;
target = GetContainingInputManager() as OsuInputManager;
osuActionInputManager.SetTarget(target);
return target;
}
}
} }
public enum ComboResult public enum ComboResult