1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 15:33:05 +08:00
osu-lazer/osu.Game.Rulesets.Taiko/Difficulty/Preprocessing/TaikoDifficultyHitObject.cs

42 lines
1.5 KiB
C#
Raw Normal View History

// 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;
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;
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)
: base(hitObject, lastObject, clockRate)
{
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;
}
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();
}
}
}