2016-09-02 17:27:38 +08:00
|
|
|
|
//Copyright (c) 2007-2016 ppy Pty Ltd <contact@ppy.sh>.
|
|
|
|
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
|
|
|
|
|
2016-10-08 04:35:14 +08:00
|
|
|
|
using System;
|
2016-09-02 17:27:38 +08:00
|
|
|
|
using OpenTK;
|
2016-10-08 04:35:14 +08:00
|
|
|
|
using osu.Game.Beatmaps.Samples;
|
2016-09-02 17:27:38 +08:00
|
|
|
|
|
2016-09-02 17:35:49 +08:00
|
|
|
|
namespace osu.Game.Beatmaps.Objects.Osu
|
2016-09-02 17:27:38 +08:00
|
|
|
|
{
|
2016-09-26 14:07:29 +08:00
|
|
|
|
public abstract class OsuBaseHit : HitObject
|
2016-09-02 17:27:38 +08:00
|
|
|
|
{
|
2016-10-08 04:35:14 +08:00
|
|
|
|
public Vector2 Position { get; set; }
|
|
|
|
|
|
|
|
|
|
[Flags]
|
|
|
|
|
private enum HitObjectType
|
|
|
|
|
{
|
|
|
|
|
Circle = 1,
|
|
|
|
|
Slider = 2,
|
|
|
|
|
NewCombo = 4,
|
2016-10-11 22:53:16 +08:00
|
|
|
|
CircleNewCombo = 5,
|
|
|
|
|
SliderNewCombo = 6,
|
2016-10-08 04:35:14 +08:00
|
|
|
|
Spinner = 8,
|
2016-10-11 22:53:16 +08:00
|
|
|
|
ColourHax = 122,
|
|
|
|
|
Hold = 128,
|
|
|
|
|
ManiaLong = 128,
|
2016-10-08 04:35:14 +08:00
|
|
|
|
}
|
2016-10-08 04:19:24 +08:00
|
|
|
|
|
|
|
|
|
public static OsuBaseHit Parse(string val)
|
|
|
|
|
{
|
2016-10-08 04:35:14 +08:00
|
|
|
|
string[] split = val.Split(',');
|
|
|
|
|
var type = (HitObjectType)int.Parse(split[3]);
|
|
|
|
|
bool combo = type.HasFlag(HitObjectType.NewCombo);
|
2016-10-11 22:53:16 +08:00
|
|
|
|
type &= (HitObjectType)0xF;
|
2016-10-08 04:35:14 +08:00
|
|
|
|
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]);
|
2016-10-11 01:08:07 +08:00
|
|
|
|
result.Sample = new HitSampleInfo { Type = (SampleType)int.Parse(split[4]) };
|
2016-10-08 04:35:14 +08:00
|
|
|
|
result.NewCombo = combo;
|
|
|
|
|
// TODO: "addition" field
|
|
|
|
|
return result;
|
2016-10-08 04:19:24 +08:00
|
|
|
|
}
|
2016-09-02 17:27:38 +08:00
|
|
|
|
}
|
|
|
|
|
}
|