2019-02-18 13:54:21 +08:00
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
2020-06-08 15:30:26 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2019-02-18 13:54:21 +08:00
|
|
|
using osu.Game.Rulesets.Difficulty.Preprocessing;
|
|
|
|
using osu.Game.Rulesets.Objects;
|
|
|
|
using osu.Game.Rulesets.Taiko.Objects;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Taiko.Difficulty.Preprocessing
|
|
|
|
{
|
|
|
|
public class TaikoDifficultyHitObject : DifficultyHitObject
|
|
|
|
{
|
2020-05-11 13:50:02 +08:00
|
|
|
public readonly TaikoDifficultyHitObjectRhythm Rhythm;
|
2020-08-13 00:35:56 +08:00
|
|
|
public readonly HitType? HitType;
|
2019-02-18 13:54:21 +08:00
|
|
|
|
2020-05-11 13:50:02 +08:00
|
|
|
public bool StaminaCheese = false;
|
|
|
|
|
2020-08-12 23:59:22 +08:00
|
|
|
public readonly int ObjectIndex;
|
2020-05-11 13:50:02 +08:00
|
|
|
|
2020-08-12 23:59:22 +08:00
|
|
|
public TaikoDifficultyHitObject(HitObject hitObject, HitObject lastObject, HitObject lastLastObject, double clockRate, int objectIndex,
|
|
|
|
IEnumerable<TaikoDifficultyHitObjectRhythm> commonRhythms)
|
2019-02-19 16:45:16 +08:00
|
|
|
: base(hitObject, lastObject, clockRate)
|
2019-02-18 13:54:21 +08:00
|
|
|
{
|
2020-05-11 13:53:42 +08:00
|
|
|
var currentHit = hitObject as Hit;
|
|
|
|
|
2020-05-11 13:50:02 +08:00
|
|
|
double prevLength = (lastObject.StartTime - lastLastObject.StartTime) / clockRate;
|
2020-08-12 23:59:22 +08:00
|
|
|
|
|
|
|
Rhythm = getClosestRhythm(DeltaTime / prevLength, commonRhythms);
|
2020-08-13 00:35:56 +08:00
|
|
|
HitType = currentHit?.Type;
|
2020-06-08 15:30:26 +08:00
|
|
|
|
2020-08-12 23:59:22 +08:00
|
|
|
ObjectIndex = objectIndex;
|
2019-02-18 13:54:21 +08:00
|
|
|
}
|
2020-05-11 13:50:02 +08:00
|
|
|
|
2020-06-08 15:30:26 +08:00
|
|
|
private TaikoDifficultyHitObjectRhythm getClosestRhythm(double ratio, IEnumerable<TaikoDifficultyHitObjectRhythm> commonRhythms)
|
|
|
|
{
|
|
|
|
return commonRhythms.OrderBy(x => Math.Abs(x.Ratio - ratio)).First();
|
|
|
|
}
|
2019-02-18 13:54:21 +08:00
|
|
|
}
|
|
|
|
}
|