mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 14:12:56 +08:00
Add basic osu! hit object parsing
This commit is contained in:
parent
9b4bc3e36d
commit
4851f49ad5
@ -1,17 +1,53 @@
|
|||||||
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
|
using System;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
|
using osu.Game.Beatmaps.Samples;
|
||||||
|
|
||||||
namespace osu.Game.Beatmaps.Objects.Osu
|
namespace osu.Game.Beatmaps.Objects.Osu
|
||||||
{
|
{
|
||||||
public abstract class OsuBaseHit : HitObject
|
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)
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
namespace osu.Game.Beatmaps.Objects.Osu
|
namespace osu.Game.Beatmaps.Objects.Osu
|
||||||
{
|
{
|
||||||
public class Spinner
|
public class Spinner : OsuBaseHit
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,6 @@ namespace osu.Game.Beatmaps.Samples
|
|||||||
{
|
{
|
||||||
public class HitSampleInfo : SampleInfo
|
public class HitSampleInfo : SampleInfo
|
||||||
{
|
{
|
||||||
SampleType Type;
|
public SampleType Type { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user