1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 07:22:54 +08:00

Add basic osu! hit object parsing

This commit is contained in:
Drew DeVault 2016-10-07 16:35:14 -04:00 committed by Dean Herbert
parent 9b4bc3e36d
commit 4851f49ad5
3 changed files with 40 additions and 4 deletions

View File

@ -1,17 +1,53 @@
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using OpenTK;
using osu.Game.Beatmaps.Samples;
namespace osu.Game.Beatmaps.Objects.Osu
{
public abstract class OsuBaseHit : HitObject
{
public Vector2 Position;
public Vector2 Position { get; set; }
public bool NewCombo { get; set; }
[Flags]
private enum HitObjectType
{
Circle = 1,
Slider = 2,
NewCombo = 4,
Spinner = 8,
}
public static OsuBaseHit Parse(string val)
{
return null;
string[] split = val.Split(',');
var type = (HitObjectType)int.Parse(split[3]);
bool combo = type.HasFlag(HitObjectType.NewCombo);
type &= ~HitObjectType.NewCombo;
OsuBaseHit result;
switch (type)
{
case HitObjectType.Circle:
result = new Circle();
break;
case HitObjectType.Slider:
result = new Slider();
break;
case HitObjectType.Spinner:
result = new Spinner();
break;
default:
throw new InvalidOperationException($@"Unknown hit object type {type}");
}
result.Position = new Vector2(int.Parse(split[0]), int.Parse(split[1]));
result.StartTime = double.Parse(split[2]);
result.Sample = new HitSampleInfo { Type = (SampleType)int.Parse(split[3]) };
result.NewCombo = combo;
// TODO: "addition" field
return result;
}
}
}

View File

@ -3,7 +3,7 @@
namespace osu.Game.Beatmaps.Objects.Osu
{
public class Spinner
public class Spinner : OsuBaseHit
{
}
}

View File

@ -5,6 +5,6 @@ namespace osu.Game.Beatmaps.Samples
{
public class HitSampleInfo : SampleInfo
{
SampleType Type;
public SampleType Type { get; set; }
}
}