mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 13:32:54 +08:00
Return null for out of range objects
This commit is contained in:
parent
30b9e0e7ab
commit
1ef711de41
@ -78,7 +78,7 @@ namespace osu.Game.Rulesets.Osu.Difficulty.Preprocessing
|
|||||||
public OsuDifficultyHitObject(HitObject hitObject, HitObject lastObject, double clockRate, List<DifficultyHitObject> objects)
|
public OsuDifficultyHitObject(HitObject hitObject, HitObject lastObject, double clockRate, List<DifficultyHitObject> objects)
|
||||||
: base(hitObject, lastObject, clockRate, objects)
|
: base(hitObject, lastObject, clockRate, objects)
|
||||||
{
|
{
|
||||||
lastLastObject = Position > 1 ? (OsuHitObject)Previous(1).BaseObject : null;
|
lastLastObject = (OsuHitObject)Previous(1)?.BaseObject;
|
||||||
this.lastObject = (OsuHitObject)lastObject;
|
this.lastObject = (OsuHitObject)lastObject;
|
||||||
|
|
||||||
// Capped to 25ms to prevent difficulty calculation breaking from simultaneous objects.
|
// Capped to 25ms to prevent difficulty calculation breaking from simultaneous objects.
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
namespace osu.Game.Rulesets.Difficulty.Preprocessing
|
namespace osu.Game.Rulesets.Difficulty.Preprocessing
|
||||||
@ -61,8 +62,8 @@ namespace osu.Game.Rulesets.Difficulty.Preprocessing
|
|||||||
EndTime = hitObject.GetEndTime() / clockRate;
|
EndTime = hitObject.GetEndTime() / clockRate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DifficultyHitObject Previous(int backwardsIndex) => difficultyHitObjects[Position - (backwardsIndex + 1)];
|
public DifficultyHitObject Previous(int backwardsIndex) => difficultyHitObjects.ElementAtOrDefault(Position - (backwardsIndex + 1));
|
||||||
|
|
||||||
public DifficultyHitObject Next(int forwardsIndex) => difficultyHitObjects[Position + (forwardsIndex + 1)];
|
public DifficultyHitObject Next(int forwardsIndex) => difficultyHitObjects.ElementAtOrDefault(Position - (forwardsIndex + 1));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user