mirror of
https://github.com/ppy/osu
synced 2024-12-26 00:32:52 +00:00
Make GetNextObject() a virtual method
This commit is contained in:
parent
0f9706e798
commit
b3556403aa
@ -5,7 +5,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Game.Replays;
|
using osu.Game.Replays;
|
||||||
using osu.Game.Rulesets.Mania.Beatmaps;
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
||||||
using osu.Game.Rulesets.Mania.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.Objects.Types;
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
using osu.Game.Rulesets.Replays;
|
using osu.Game.Rulesets.Replays;
|
||||||
|
|
||||||
@ -81,7 +81,7 @@ namespace osu.Game.Rulesets.Mania.Replays
|
|||||||
for (int i = 0; i < Beatmap.HitObjects.Count; i++)
|
for (int i = 0; i < Beatmap.HitObjects.Count; i++)
|
||||||
{
|
{
|
||||||
var currentObject = Beatmap.HitObjects[i];
|
var currentObject = Beatmap.HitObjects[i];
|
||||||
var nextObjectInTheSameColumn = getNextObjectInTheSameColumn(i);
|
var nextObjectInTheSameColumn = GetNextObject(i);
|
||||||
|
|
||||||
double endTime = (currentObject as IHasEndTime)?.EndTime ?? currentObject.StartTime;
|
double endTime = (currentObject as IHasEndTime)?.EndTime ?? currentObject.StartTime;
|
||||||
|
|
||||||
@ -94,19 +94,19 @@ namespace osu.Game.Rulesets.Mania.Replays
|
|||||||
|
|
||||||
yield return new ReleasePoint { Time = endTime + calculatedDelay, Column = currentObject.Column };
|
yield return new ReleasePoint { Time = endTime + calculatedDelay, Column = currentObject.Column };
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ManiaHitObject getNextObjectInTheSameColumn(int currentIndex)
|
protected override HitObject GetNextObject(int currentIndex)
|
||||||
|
{
|
||||||
|
int desiredColumn = Beatmap.HitObjects[currentIndex++].Column;
|
||||||
|
|
||||||
|
for (; currentIndex < Beatmap.HitObjects.Count; currentIndex++)
|
||||||
{
|
{
|
||||||
int desiredColumn = Beatmap.HitObjects[currentIndex++].Column;
|
if (Beatmap.HitObjects[currentIndex].Column == desiredColumn)
|
||||||
|
return Beatmap.HitObjects[currentIndex];
|
||||||
for (; currentIndex < Beatmap.HitObjects.Count; currentIndex++)
|
|
||||||
{
|
|
||||||
if (Beatmap.HitObjects[currentIndex].Column == desiredColumn)
|
|
||||||
return Beatmap.HitObjects[currentIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface IActionPoint
|
private interface IActionPoint
|
||||||
|
@ -10,6 +10,7 @@ using osu.Game.Rulesets.Objects.Types;
|
|||||||
using osu.Game.Rulesets.Taiko.Objects;
|
using osu.Game.Rulesets.Taiko.Objects;
|
||||||
using osu.Game.Rulesets.Replays;
|
using osu.Game.Rulesets.Replays;
|
||||||
using osu.Game.Rulesets.Taiko.Beatmaps;
|
using osu.Game.Rulesets.Taiko.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Taiko.Replays
|
namespace osu.Game.Rulesets.Taiko.Replays
|
||||||
{
|
{
|
||||||
@ -113,16 +114,17 @@ namespace osu.Game.Rulesets.Taiko.Replays
|
|||||||
else
|
else
|
||||||
throw new InvalidOperationException("Unknown hit object type.");
|
throw new InvalidOperationException("Unknown hit object type.");
|
||||||
|
|
||||||
TaikoHitObject nextHitObject = i < Beatmap.HitObjects.Count - 1 ? Beatmap.HitObjects[i + 1] : null;
|
var nextHitObject = GetNextObject(i);
|
||||||
|
|
||||||
bool canDelayKeyUp = nextHitObject == null || nextHitObject.StartTime > endTime + KEY_UP_DELAY;
|
bool canDelayKeyUp = nextHitObject == null || nextHitObject.StartTime > endTime + KEY_UP_DELAY;
|
||||||
|
|
||||||
if (canDelayKeyUp)
|
double calculatedDelay = canDelayKeyUp ? KEY_UP_DELAY : nextHitObject.StartTime - endTime;
|
||||||
Frames.Add(new TaikoReplayFrame(endTime + KEY_UP_DELAY));
|
|
||||||
|
|
||||||
if (nextHitObject != null)
|
Frames.Add(new TaikoReplayFrame(endTime + calculatedDelay));
|
||||||
|
|
||||||
|
if (i < Beatmap.HitObjects.Count - 1)
|
||||||
{
|
{
|
||||||
double waitTime = nextHitObject.StartTime - 1000;
|
double waitTime = Beatmap.HitObjects[i + 1].StartTime - 1000;
|
||||||
if (waitTime > endTime)
|
if (waitTime > endTime)
|
||||||
Frames.Add(new TaikoReplayFrame(waitTime));
|
Frames.Add(new TaikoReplayFrame(waitTime));
|
||||||
}
|
}
|
||||||
@ -132,5 +134,19 @@ namespace osu.Game.Rulesets.Taiko.Replays
|
|||||||
|
|
||||||
return Replay;
|
return Replay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override HitObject GetNextObject(int currentIndex)
|
||||||
|
{
|
||||||
|
Type desiredType = Beatmap.HitObjects[currentIndex++].GetType();
|
||||||
|
|
||||||
|
for (; currentIndex < Beatmap.HitObjects.Count; currentIndex++)
|
||||||
|
{
|
||||||
|
var currentObj = Beatmap.HitObjects[currentIndex];
|
||||||
|
if (currentObj.GetType().Equals(desiredType) || currentObj is DrumRoll)
|
||||||
|
return Beatmap.HitObjects[currentIndex];
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Replays;
|
using osu.Game.Replays;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Replays
|
namespace osu.Game.Rulesets.Replays
|
||||||
{
|
{
|
||||||
@ -34,5 +35,13 @@ namespace osu.Game.Rulesets.Replays
|
|||||||
protected const double KEY_UP_DELAY = 50;
|
protected const double KEY_UP_DELAY = 50;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
protected virtual HitObject GetNextObject(int currentIndex)
|
||||||
|
{
|
||||||
|
if (currentIndex >= Beatmap.HitObjects.Count - 1)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
return Beatmap.HitObjects[currentIndex + 1];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user