2021-07-19 04:33:22 +00:00
|
|
|
// 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.
|
|
|
|
|
2021-07-21 06:36:34 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2021-07-19 04:33:22 +00:00
|
|
|
using osu.Game.Rulesets.Catch.Objects;
|
2021-07-21 06:36:34 +00:00
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
2021-07-19 04:33:22 +00:00
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.UI.Scrolling;
|
|
|
|
using osuTK;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Edit
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Utility functions used by the editor.
|
|
|
|
/// </summary>
|
|
|
|
public static class CatchHitObjectUtils
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// Get the position of the hit object in the playfield based on <see cref="CatchHitObject.OriginalX"/> and <see cref="HitObject.StartTime"/>.
|
|
|
|
/// </summary>
|
|
|
|
public static Vector2 GetStartPosition(ScrollingHitObjectContainer hitObjectContainer, CatchHitObject hitObject)
|
|
|
|
{
|
|
|
|
return new Vector2(hitObject.OriginalX, hitObjectContainer.PositionAtTime(hitObject.StartTime));
|
|
|
|
}
|
2021-07-21 06:36:34 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get the range of horizontal position occupied by the hit object.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// <see cref="TinyDroplet"/>s are excluded and returns <see cref="PositionRange.EMPTY"/>.
|
|
|
|
/// </remarks>
|
|
|
|
public static PositionRange GetPositionRange(HitObject hitObject)
|
|
|
|
{
|
|
|
|
switch (hitObject)
|
|
|
|
{
|
|
|
|
case Fruit fruit:
|
|
|
|
return new PositionRange(fruit.OriginalX);
|
|
|
|
|
|
|
|
case Droplet droplet:
|
|
|
|
return droplet is TinyDroplet ? PositionRange.EMPTY : new PositionRange(droplet.OriginalX);
|
|
|
|
|
2022-06-24 12:25:23 +00:00
|
|
|
case JuiceStream:
|
2021-07-21 06:36:34 +00:00
|
|
|
return GetPositionRange(hitObject.NestedHitObjects);
|
|
|
|
|
2022-06-24 12:25:23 +00:00
|
|
|
case BananaShower:
|
2021-07-21 06:36:34 +00:00
|
|
|
// A banana shower occupies the whole screen width.
|
|
|
|
return new PositionRange(0, CatchPlayfield.WIDTH);
|
|
|
|
|
|
|
|
default:
|
|
|
|
return PositionRange.EMPTY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Get the range of horizontal position occupied by the hit objects.
|
|
|
|
/// </summary>
|
|
|
|
/// <remarks>
|
|
|
|
/// <see cref="TinyDroplet"/>s are excluded.
|
|
|
|
/// </remarks>
|
|
|
|
public static PositionRange GetPositionRange(IEnumerable<HitObject> hitObjects) => hitObjects.Select(GetPositionRange).Aggregate(PositionRange.EMPTY, PositionRange.Union);
|
2021-07-19 04:33:22 +00:00
|
|
|
}
|
|
|
|
}
|