mirror of
https://github.com/ppy/osu.git
synced 2025-01-21 12:12:56 +08:00
Avoid AliveObject
enumeration when not in kiai section
This commit is contained in:
parent
7812c33ddd
commit
20eeb36567
@ -4,6 +4,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.Textures;
|
using osu.Framework.Graphics.Textures;
|
||||||
@ -12,6 +13,7 @@ using osu.Framework.Input.Bindings;
|
|||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Osu.UI;
|
using osu.Game.Rulesets.Osu.UI;
|
||||||
using osu.Game.Screens.Play;
|
using osu.Game.Screens.Play;
|
||||||
@ -32,7 +34,13 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
private Player player { get; set; }
|
private Player player { get; set; }
|
||||||
|
|
||||||
[Resolved(canBeNull: true)]
|
[Resolved(canBeNull: true)]
|
||||||
private OsuPlayfield osuPlayfield { get; set; }
|
private OsuPlayfield playfield { get; set; }
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private GameplayBeatmap gameplayBeatmap { get; set; }
|
||||||
|
|
||||||
|
[Resolved(canBeNull: true)]
|
||||||
|
private GameplayClock gameplayClock { get; set; }
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(ISkinSource skin, OsuColour colours)
|
private void load(ISkinSource skin, OsuColour colours)
|
||||||
@ -65,27 +73,39 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
|||||||
};
|
};
|
||||||
|
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
((IBindable<bool>)breakSpewer.Active).BindTo(player.IsBreakTime);
|
||||||
breakSpewer.Active.BindTarget = player.IsBreakTime;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
{
|
{
|
||||||
if (osuPlayfield == null) return;
|
if (playfield == null || gameplayBeatmap == null) return;
|
||||||
|
|
||||||
// find active kiai slider or spinner.
|
DrawableHitObject kiaiHitObject = null;
|
||||||
var kiaiHitObject = osuPlayfield.HitObjectContainer.AliveObjects.FirstOrDefault(h =>
|
|
||||||
h.HitObject.Kiai &&
|
// Check whether currently in a kiai section first. This is only done as an optimisation to avoid enumerating AliveObjects when not necessary.
|
||||||
(
|
if (gameplayBeatmap.ControlPointInfo.EffectPointAt(gameplayBeatmap.Time.Current).KiaiMode)
|
||||||
(h is DrawableSlider slider && slider.Tracking.Value) ||
|
kiaiHitObject = playfield.HitObjectContainer.AliveObjects.FirstOrDefault(isTracking);
|
||||||
(h is DrawableSpinner spinner && spinner.RotationTracker.Tracking)
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
kiaiSpewer.Active.Value = kiaiHitObject != null;
|
kiaiSpewer.Active.Value = kiaiHitObject != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool isTracking(DrawableHitObject h)
|
||||||
|
{
|
||||||
|
if (!h.HitObject.Kiai)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (h)
|
||||||
|
{
|
||||||
|
case DrawableSlider slider:
|
||||||
|
return slider.Tracking.Value;
|
||||||
|
|
||||||
|
case DrawableSpinner spinner:
|
||||||
|
return spinner.RotationTracker.Tracking;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public bool OnPressed(KeyBindingPressEvent<OsuAction> e)
|
public bool OnPressed(KeyBindingPressEvent<OsuAction> e)
|
||||||
{
|
{
|
||||||
handleInput(e.Action, true);
|
handleInput(e.Action, true);
|
||||||
|
Loading…
Reference in New Issue
Block a user