mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 16:59:53 +09:00
Introduce concept of HitObjectParsers, fix tests and stop using reflection (unreliable due to lazy loading).
This commit is contained in:
45
osu.Game.Mode.Osu/Objects/OsuHitObjectParser.cs
Normal file
45
osu.Game.Mode.Osu/Objects/OsuHitObjectParser.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using osu.Game.Beatmaps.Samples;
|
||||
using osu.Game.Modes.Objects;
|
||||
using OpenTK;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects
|
||||
{
|
||||
public class OsuHitObjectParser : HitObjectParser
|
||||
{
|
||||
public override HitObject Parse(string text)
|
||||
{
|
||||
string[] split = text.Split(',');
|
||||
var type = (OsuBaseHit.HitObjectType)int.Parse(split[3]);
|
||||
bool combo = type.HasFlag(OsuBaseHit.HitObjectType.NewCombo);
|
||||
type &= (OsuBaseHit.HitObjectType)0xF;
|
||||
type &= ~OsuBaseHit.HitObjectType.NewCombo;
|
||||
OsuBaseHit result;
|
||||
switch (type)
|
||||
{
|
||||
case OsuBaseHit.HitObjectType.Circle:
|
||||
result = new Circle();
|
||||
break;
|
||||
case OsuBaseHit.HitObjectType.Slider:
|
||||
result = new Slider();
|
||||
break;
|
||||
case OsuBaseHit.HitObjectType.Spinner:
|
||||
result = new Spinner();
|
||||
break;
|
||||
default:
|
||||
//throw new InvalidOperationException($@"Unknown hit object type {type}");
|
||||
return null;
|
||||
}
|
||||
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[4]) };
|
||||
result.NewCombo = combo;
|
||||
// TODO: "addition" field
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user