1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-07 13:07:25 +08:00
osu-lazer/osu.Game/Beatmaps/Objects/Osu/OsuBaseHit.cs

59 lines
1.9 KiB
C#
Raw Normal View History

//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;
using OpenTK;
2016-10-08 04:35:14 +08:00
using osu.Game.Beatmaps.Samples;
namespace osu.Game.Beatmaps.Objects.Osu
{
2016-09-26 14:07:29 +08:00
public abstract class OsuBaseHit : HitObject
{
2016-10-08 04:35:14 +08:00
public Vector2 Position { get; set; }
[Flags]
private enum HitObjectType
{
Circle = 1,
Slider = 2,
NewCombo = 4,
CircleNewCombo = 5,
SliderNewCombo = 6,
2016-10-08 04:35:14 +08:00
Spinner = 8,
ColourHax = 122,
Hold = 128,
ManiaLong = 128,
2016-10-08 04:35:14 +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);
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;
}
}
}