Add `IHasLegacyHitObjectType` to ConvertHitObject

This commit is contained in:
Dan Balasescu 2024-11-11 15:23:23 +09:00 committed by Dean Herbert
parent 304bc6c9c7
commit 80a2dbf799
No known key found for this signature in database
4 changed files with 30 additions and 8 deletions

View File

@ -6,7 +6,7 @@
namespace osu.Game.Beatmaps.Legacy
{
[Flags]
internal enum LegacyHitObjectType
public enum LegacyHitObjectType
{
Circle = 1,
Slider = 1 << 1,

View File

@ -1,6 +1,7 @@
// 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 osu.Game.Beatmaps.Legacy;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Types;
using osu.Game.Rulesets.Scoring;
@ -14,7 +15,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <remarks>
/// Only used for parsing beatmaps and not gameplay.
/// </remarks>
internal abstract class ConvertHitObject : HitObject, IHasCombo, IHasPosition
internal abstract class ConvertHitObject : HitObject, IHasCombo, IHasPosition, IHasLegacyHitObjectType
{
public bool NewCombo { get; set; }
@ -26,6 +27,8 @@ internal abstract class ConvertHitObject : HitObject, IHasCombo, IHasPosition
public Vector2 Position { get; set; }
public LegacyHitObjectType LegacyType { get; set; }
public override Judgement CreateJudgement() => new IgnoreJudgement();
protected override HitWindows CreateHitWindows() => HitWindows.Empty;

View File

@ -71,7 +71,7 @@ public override HitObject Parse(string text)
var soundType = (LegacyHitSoundType)Parsing.ParseInt(split[4]);
var bankInfo = new SampleBankInfo();
HitObject? result = null;
ConvertHitObject? result = null;
if (type.HasFlag(LegacyHitObjectType.Circle))
{
@ -181,6 +181,7 @@ public override HitObject Parse(string text)
throw new InvalidDataException($"Unknown hit object type: {split[3]}");
result.StartTime = startTime;
result.LegacyType = type;
if (result.Samples.Count == 0)
result.Samples = convertSoundType(soundType, bankInfo);
@ -448,7 +449,7 @@ private PathControlPoint[] mergeControlPointsLists(List<ArraySegment<PathControl
/// <param name="newCombo">Whether the hit object creates a new combo.</param>
/// <param name="comboOffset">When starting a new combo, the offset of the new combo relative to the current one.</param>
/// <returns>The hit object.</returns>
private HitObject createHitCircle(Vector2 position, bool newCombo, int comboOffset)
private ConvertHitObject createHitCircle(Vector2 position, bool newCombo, int comboOffset)
{
return lastObject = new ConvertHitCircle
{
@ -469,8 +470,8 @@ private HitObject createHitCircle(Vector2 position, bool newCombo, int comboOffs
/// <param name="repeatCount">The slider repeat count.</param>
/// <param name="nodeSamples">The samples to be played when the slider nodes are hit. This includes the head and tail of the slider.</param>
/// <returns>The hit object.</returns>
private HitObject createSlider(Vector2 position, bool newCombo, int comboOffset, PathControlPoint[] controlPoints, double? length, int repeatCount,
IList<IList<HitSampleInfo>> nodeSamples)
private ConvertHitObject createSlider(Vector2 position, bool newCombo, int comboOffset, PathControlPoint[] controlPoints, double? length, int repeatCount,
IList<IList<HitSampleInfo>> nodeSamples)
{
return lastObject = new ConvertSlider
{
@ -491,7 +492,7 @@ private HitObject createSlider(Vector2 position, bool newCombo, int comboOffset,
/// <param name="comboOffset">When starting a new combo, the offset of the new combo relative to the current one.</param>
/// <param name="duration">The spinner duration.</param>
/// <returns>The hit object.</returns>
private HitObject createSpinner(Vector2 position, bool newCombo, int comboOffset, double duration)
private ConvertHitObject createSpinner(Vector2 position, bool newCombo, int comboOffset, double duration)
{
return lastObject = new ConvertSpinner
{
@ -509,7 +510,7 @@ private HitObject createSpinner(Vector2 position, bool newCombo, int comboOffset
/// <param name="newCombo">Whether the hit object creates a new combo.</param>
/// <param name="comboOffset">When starting a new combo, the offset of the new combo relative to the current one.</param>
/// <param name="duration">The hold duration.</param>
private HitObject createHold(Vector2 position, bool newCombo, int comboOffset, double duration)
private ConvertHitObject createHold(Vector2 position, bool newCombo, int comboOffset, double duration)
{
return lastObject = new ConvertHold
{

View File

@ -0,0 +1,18 @@
// 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 osu.Game.Beatmaps.Legacy;
namespace osu.Game.Rulesets.Objects.Legacy
{
/// <summary>
/// A hit object from a legacy beatmap representation.
/// </summary>
public interface IHasLegacyHitObjectType
{
/// <summary>
/// The hit object type.
/// </summary>
LegacyHitObjectType LegacyType { get; }
}
}