1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-09 19:42:59 +08:00

Add IHasLegacyHitObjectType to ConvertHitObject

This commit is contained in:
Dan Balasescu 2024-11-11 15:23:23 +09:00
parent e1d93a7d9c
commit 7206e97b7b
No known key found for this signature in database
4 changed files with 30 additions and 8 deletions

View File

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

View File

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

View File

@ -71,7 +71,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
var soundType = (LegacyHitSoundType)Parsing.ParseInt(split[4]); var soundType = (LegacyHitSoundType)Parsing.ParseInt(split[4]);
var bankInfo = new SampleBankInfo(); var bankInfo = new SampleBankInfo();
HitObject? result = null; ConvertHitObject? result = null;
if (type.HasFlag(LegacyHitObjectType.Circle)) if (type.HasFlag(LegacyHitObjectType.Circle))
{ {
@ -181,6 +181,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
throw new InvalidDataException($"Unknown hit object type: {split[3]}"); throw new InvalidDataException($"Unknown hit object type: {split[3]}");
result.StartTime = startTime; result.StartTime = startTime;
result.LegacyType = type;
if (result.Samples.Count == 0) if (result.Samples.Count == 0)
result.Samples = convertSoundType(soundType, bankInfo); result.Samples = convertSoundType(soundType, bankInfo);
@ -448,7 +449,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <param name="newCombo">Whether the hit object creates a new combo.</param> /// <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="comboOffset">When starting a new combo, the offset of the new combo relative to the current one.</param>
/// <returns>The hit object.</returns> /// <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 return lastObject = new ConvertHitCircle
{ {
@ -469,8 +470,8 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <param name="repeatCount">The slider repeat count.</param> /// <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> /// <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> /// <returns>The hit object.</returns>
private HitObject createSlider(Vector2 position, bool newCombo, int comboOffset, PathControlPoint[] controlPoints, double? length, int repeatCount, private ConvertHitObject createSlider(Vector2 position, bool newCombo, int comboOffset, PathControlPoint[] controlPoints, double? length, int repeatCount,
IList<IList<HitSampleInfo>> nodeSamples) IList<IList<HitSampleInfo>> nodeSamples)
{ {
return lastObject = new ConvertSlider return lastObject = new ConvertSlider
{ {
@ -491,7 +492,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <param name="comboOffset">When starting a new combo, the offset of the new combo relative to the current one.</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 spinner duration.</param> /// <param name="duration">The spinner duration.</param>
/// <returns>The hit object.</returns> /// <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 return lastObject = new ConvertSpinner
{ {
@ -509,7 +510,7 @@ namespace osu.Game.Rulesets.Objects.Legacy
/// <param name="newCombo">Whether the hit object creates a new combo.</param> /// <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="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> /// <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 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; }
}
}