mirror of
https://github.com/osukey/osukey.git
synced 2025-06-05 12:57:39 +09:00
Add/use IHitObjectContainer interface instead of IEnumerables
This commit is contained in:
parent
64a2c7825e
commit
f4a31287bf
@ -1,19 +1,18 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.UI
|
namespace osu.Game.Rulesets.Osu.UI
|
||||||
{
|
{
|
||||||
public interface IHitPolicy
|
public interface IHitPolicy
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sets the <see cref="DrawableHitObject"/>s which this <see cref="IHitPolicy"/> controls.
|
/// The <see cref="IHitObjectContainer"/> containing the <see cref="DrawableHitObject"/>s which this <see cref="IHitPolicy"/> applies to.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="hitObjects">An enumeration of the <see cref="DrawableHitObject"/>s.</param>
|
IHitObjectContainer HitObjectContainer { set; }
|
||||||
void SetHitObjects(IEnumerable<DrawableHitObject> hitObjects);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines whether a <see cref="DrawableHitObject"/> can be hit at a point in time.
|
/// Determines whether a <see cref="DrawableHitObject"/> can be hit at a point in time.
|
||||||
|
@ -54,8 +54,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
approachCircles = new ProxyContainer { RelativeSizeAxes = Axes.Both },
|
approachCircles = new ProxyContainer { RelativeSizeAxes = Axes.Both },
|
||||||
};
|
};
|
||||||
|
|
||||||
hitPolicy = new StartTimeOrderedHitPolicy();
|
hitPolicy = new StartTimeOrderedHitPolicy { HitObjectContainer = HitObjectContainer };
|
||||||
hitPolicy.SetHitObjects(HitObjectContainer.AliveObjects);
|
|
||||||
|
|
||||||
var hitWindows = new OsuHitWindows();
|
var hitWindows = new OsuHitWindows();
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ using System.Collections.Generic;
|
|||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
||||||
|
using osu.Game.Rulesets.UI;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.UI
|
namespace osu.Game.Rulesets.Osu.UI
|
||||||
{
|
{
|
||||||
@ -19,9 +20,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public class StartTimeOrderedHitPolicy : IHitPolicy
|
public class StartTimeOrderedHitPolicy : IHitPolicy
|
||||||
{
|
{
|
||||||
private IEnumerable<DrawableHitObject> hitObjects;
|
public IHitObjectContainer HitObjectContainer { get; set; }
|
||||||
|
|
||||||
public void SetHitObjects(IEnumerable<DrawableHitObject> hitObjects) => this.hitObjects = hitObjects;
|
|
||||||
|
|
||||||
public bool IsHittable(DrawableHitObject hitObject, double time)
|
public bool IsHittable(DrawableHitObject hitObject, double time)
|
||||||
{
|
{
|
||||||
@ -73,7 +72,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
|||||||
|
|
||||||
private IEnumerable<DrawableHitObject> enumerateHitObjectsUpTo(double targetTime)
|
private IEnumerable<DrawableHitObject> enumerateHitObjectsUpTo(double targetTime)
|
||||||
{
|
{
|
||||||
foreach (var obj in hitObjects)
|
foreach (var obj in HitObjectContainer.AliveObjects)
|
||||||
{
|
{
|
||||||
if (obj.HitObject.StartTime >= targetTime)
|
if (obj.HitObject.StartTime >= targetTime)
|
||||||
yield break;
|
yield break;
|
||||||
|
@ -17,19 +17,10 @@ using osu.Game.Rulesets.Objects.Drawables;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.UI
|
namespace osu.Game.Rulesets.UI
|
||||||
{
|
{
|
||||||
public class HitObjectContainer : LifetimeManagementContainer
|
public class HitObjectContainer : LifetimeManagementContainer, IHitObjectContainer
|
||||||
{
|
{
|
||||||
/// <summary>
|
|
||||||
/// All currently in-use <see cref="DrawableHitObject"/>s.
|
|
||||||
/// </summary>
|
|
||||||
public IEnumerable<DrawableHitObject> Objects => InternalChildren.Cast<DrawableHitObject>().OrderBy(h => h.HitObject.StartTime);
|
public IEnumerable<DrawableHitObject> Objects => InternalChildren.Cast<DrawableHitObject>().OrderBy(h => h.HitObject.StartTime);
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// All currently in-use <see cref="DrawableHitObject"/>s that are alive.
|
|
||||||
/// </summary>
|
|
||||||
/// <remarks>
|
|
||||||
/// If this <see cref="HitObjectContainer"/> uses pooled objects, this is equivalent to <see cref="Objects"/>.
|
|
||||||
/// </remarks>
|
|
||||||
public IEnumerable<DrawableHitObject> AliveObjects => AliveInternalChildren.Cast<DrawableHitObject>().OrderBy(h => h.HitObject.StartTime);
|
public IEnumerable<DrawableHitObject> AliveObjects => AliveInternalChildren.Cast<DrawableHitObject>().OrderBy(h => h.HitObject.StartTime);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
24
osu.Game/Rulesets/UI/IHitObjectContainer.cs
Normal file
24
osu.Game/Rulesets/UI/IHitObjectContainer.cs
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.UI
|
||||||
|
{
|
||||||
|
public interface IHitObjectContainer
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// All currently in-use <see cref="DrawableHitObject"/>s.
|
||||||
|
/// </summary>
|
||||||
|
IEnumerable<DrawableHitObject> Objects { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// All currently in-use <see cref="DrawableHitObject"/>s that are alive.
|
||||||
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
|
/// If this <see cref="IHitObjectContainer"/> uses pooled objects, this is equivalent to <see cref="Objects"/>.
|
||||||
|
/// </remarks>
|
||||||
|
IEnumerable<DrawableHitObject> AliveObjects { get; }
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user