Refactor and cleanup

This commit is contained in:
Pavel Kolchev 2015-03-28 21:49:25 +03:00
parent 2aaf5e73be
commit 2e5226ecd5

View File

@ -666,10 +666,7 @@ public class Game extends BasicGameState {
if (timingPointIndex < osu.timingPoints.size()) { if (timingPointIndex < osu.timingPoints.size()) {
OsuTimingPoint timingPoint = osu.timingPoints.get(timingPointIndex); OsuTimingPoint timingPoint = osu.timingPoints.get(timingPointIndex);
if (trackPosition >= timingPoint.getTime()) { if (trackPosition >= timingPoint.getTime()) {
if (!timingPoint.isInherited()) setBeatLength(timingPoint);
beatLengthBase = beatLength = timingPoint.getBeatLength();
else
beatLength = beatLengthBase * timingPoint.getSliderMultiplier();
HitSound.setDefaultSampleSet(timingPoint.getSampleType()); HitSound.setDefaultSampleSet(timingPoint.getSampleType());
SoundController.setSampleVolume(timingPoint.getSampleVolume()); SoundController.setSampleVolume(timingPoint.getSampleVolume());
timingPointIndex++; timingPointIndex++;
@ -1039,10 +1036,7 @@ public class Game extends BasicGameState {
while (timingPointIndex < osu.timingPoints.size()) { while (timingPointIndex < osu.timingPoints.size()) {
OsuTimingPoint timingPoint = osu.timingPoints.get(timingPointIndex); OsuTimingPoint timingPoint = osu.timingPoints.get(timingPointIndex);
if (timingPoint.getTime() <= hitObjectTime) { if (timingPoint.getTime() <= hitObjectTime) {
if (!timingPoint.isInherited()) setBeatLength(timingPoint);
beatLengthBase = beatLength = timingPoint.getBeatLength();
else
beatLength = beatLengthBase * timingPoint.getSliderMultiplier();
} else } else
break; break;
timingPointIndex++; timingPointIndex++;
@ -1065,6 +1059,8 @@ public class Game extends BasicGameState {
} }
// stack calculation // stack calculation
// more info: https://gist.github.com/peppy/1167470
// @author peppy
for (int i = hitObjects.length - 1; i > 0; i--) { for (int i = hitObjects.length - 1; i > 0; i--) {
OsuHitObject hitObjectI = osu.objects[i]; OsuHitObject hitObjectI = osu.objects[i];
@ -1112,7 +1108,7 @@ public class Game extends BasicGameState {
break; break;
} }
} }
// no special case. stack moves up left // not a special case. stack moves up left
float x1 = hitObjectI.getX(); float x1 = hitObjectI.getX();
float y1 = hitObjectI.getY(); float y1 = hitObjectI.getY();
float x2 = hitObjectN.getX(); float x2 = hitObjectN.getX();
@ -1472,6 +1468,16 @@ public class Game extends BasicGameState {
*/ */
public float getBeatLength() { return beatLength; } public float getBeatLength() { return beatLength; }
/**
* Sets the beat length fields based on a given timing point.
*/
private void setBeatLength(OsuTimingPoint timingPoint) {
if (!timingPoint.isInherited())
beatLengthBase = beatLength = timingPoint.getBeatLength();
else
beatLength = beatLengthBase * timingPoint.getSliderMultiplier();
}
/** /**
* Returns the slider multiplier given by the current timing point. * Returns the slider multiplier given by the current timing point.
*/ */