getting rid of repetitions
This commit is contained in:
parent
726fef9b38
commit
30186b94f4
|
@ -424,58 +424,17 @@ public class Game extends BasicGameState {
|
||||||
autoMousePressed = false;
|
autoMousePressed = false;
|
||||||
if (GameMod.AUTO.isActive() || GameMod.AUTOPILOT.isActive()) {
|
if (GameMod.AUTO.isActive() || GameMod.AUTOPILOT.isActive()) {
|
||||||
Vec2f autoPoint;
|
Vec2f autoPoint;
|
||||||
if (objectIndex < beatmap.objects.length - (Dancer.multipoint ? Dancer.polyMoverFactories[Dancer.instance.getPolyMoverFactoryIndex()].getMinBufferSize() : 0)) {
|
int lastObjectForDancer = beatmap.objects.length;
|
||||||
Dancer d = Dancer.instance;
|
|
||||||
if (Dancer.multipoint) {
|
if (Dancer.multipoint) {
|
||||||
d.update(trackPosition, gameObjects, objectIndex);
|
lastObjectForDancer -= Dancer.polyMoverFactories[Dancer.instance.getPolyMoverFactoryIndex()].getMinBufferSize();
|
||||||
} else {
|
|
||||||
GameObject p;
|
|
||||||
if (objectIndex > 0) {
|
|
||||||
p = gameObjects[objectIndex - 1];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
p = Dancer.d;
|
|
||||||
}
|
|
||||||
d.update(trackPosition, p, gameObjects[objectIndex]);
|
|
||||||
}
|
}
|
||||||
|
if (objectIndex < lastObjectForDancer) {
|
||||||
|
Dancer d = Dancer.instance;
|
||||||
|
d.update(trackPosition, objectIndex);
|
||||||
autoPoint = new Vec2f(d.x, d.y);
|
autoPoint = new Vec2f(d.x, d.y);
|
||||||
if (trackPosition < gameObjects[objectIndex].getTime()) {
|
if (trackPosition < gameObjects[objectIndex].getTime()) {
|
||||||
autoMousePressed = true;
|
autoMousePressed = true;
|
||||||
}
|
}
|
||||||
/*
|
|
||||||
// normal object
|
|
||||||
int objectTime = beatmap.objects[objectIndex].getTime();
|
|
||||||
if (trackPosition < objectTime) {
|
|
||||||
Vec2f startPoint = gameObjects[objectIndex - 1].getPointAt(trackPosition);
|
|
||||||
int startTime = gameObjects[objectIndex - 1].getEndTime();
|
|
||||||
if (beatmap.breaks != null && breakIndex < beatmap.breaks.size()) {
|
|
||||||
// starting a break: keep cursor at previous hit object position
|
|
||||||
if (breakTime > 0 || objectTime > beatmap.breaks.get(breakIndex))
|
|
||||||
autoPoint = startPoint;
|
|
||||||
|
|
||||||
// after a break ends: move startTime to break end time
|
|
||||||
else if (breakIndex > 1) {
|
|
||||||
int lastBreakEndTime = beatmap.breaks.get(breakIndex - 1);
|
|
||||||
if (objectTime > lastBreakEndTime && startTime < lastBreakEndTime)
|
|
||||||
startTime = lastBreakEndTime;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (autoPoint == null) {
|
|
||||||
Vec2f endPoint = gameObjects[objectIndex].getPointAt(trackPosition);
|
|
||||||
int totalTime = objectTime - startTime;
|
|
||||||
autoPoint = getPointAt(startPoint.x, startPoint.y, endPoint.x, endPoint.y, (float) (trackPosition - startTime) / totalTime);
|
|
||||||
|
|
||||||
// hit circles: show a mouse press
|
|
||||||
int offset300 = hitResultOffset[GameData.HIT_300];
|
|
||||||
if ((beatmap.objects[objectIndex].isCircle() && objectTime - trackPosition < offset300) ||
|
|
||||||
(beatmap.objects[objectIndex - 1].isCircle() && trackPosition - beatmap.objects[objectIndex - 1].getTime() < offset300))
|
|
||||||
autoMousePressed = true;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
autoPoint = gameObjects[objectIndex].getPointAt(trackPosition);
|
|
||||||
autoMousePressed = true;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
} else {
|
} else {
|
||||||
// last object
|
// last object
|
||||||
autoPoint = gameObjects[objectIndex - 1].getPointAt(trackPosition);
|
autoPoint = gameObjects[objectIndex - 1].getPointAt(trackPosition);
|
||||||
|
@ -1501,6 +1460,7 @@ public class Game extends BasicGameState {
|
||||||
sbOverlay.updateIndex(0);
|
sbOverlay.updateIndex(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Dancer.instance.setGameObjects(gameObjects);
|
||||||
Pippi.reset();
|
Pippi.reset();
|
||||||
mirrorFrom = 0;
|
mirrorFrom = 0;
|
||||||
mirrorTo = gameObjects.length;
|
mirrorTo = gameObjects.length;
|
||||||
|
|
|
@ -101,6 +101,8 @@ public class Dancer {
|
||||||
public static final GameObject d = new DummyObject();
|
public static final GameObject d = new DummyObject();
|
||||||
private GameObject p;
|
private GameObject p;
|
||||||
|
|
||||||
|
private GameObject[] gameObjects;
|
||||||
|
|
||||||
private MoverFactory moverFactory;
|
private MoverFactory moverFactory;
|
||||||
private PolyMoverFactory polyMoverFactory;
|
private PolyMoverFactory polyMoverFactory;
|
||||||
private Mover mover;
|
private Mover mover;
|
||||||
|
@ -169,7 +171,18 @@ public class Dancer {
|
||||||
polyMoverFactory = polyMoverFactories[polyMoverFactoryIndex];
|
polyMoverFactory = polyMoverFactories[polyMoverFactoryIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(int time, GameObject p, GameObject c) {
|
public void setGameObjects(GameObject[] objs) {
|
||||||
|
this.gameObjects = objs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void update(int time, int objectIndex) {
|
||||||
|
GameObject p;
|
||||||
|
if (objectIndex == 0) {
|
||||||
|
p = d;
|
||||||
|
} else {
|
||||||
|
p = gameObjects[objectIndex - 1];
|
||||||
|
}
|
||||||
|
GameObject c = gameObjects[objectIndex];
|
||||||
GameObject[] e = sliderMoverController.process(p, c, time);
|
GameObject[] e = sliderMoverController.process(p, c, time);
|
||||||
p = e[0];
|
p = e[0];
|
||||||
c = e[1];
|
c = e[1];
|
||||||
|
@ -198,31 +211,41 @@ public class Dancer {
|
||||||
double[] spinnerStartPoint = spinner.getPoint();
|
double[] spinnerStartPoint = spinner.getPoint();
|
||||||
c.start = new Vec2f((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]);
|
c.start = new Vec2f((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]);
|
||||||
}
|
}
|
||||||
if (mover == null || mover.getEnd() != c)
|
|
||||||
|
if (multipoint) {
|
||||||
|
if (polyMoverFactory.isInitialized() && polyMoverFactory.getLatestIndex() < objectIndex + polyMoverFactory.getLatestIndex() - 1) {
|
||||||
|
polyMoverFactory.update(gameObjects[objectIndex + polyMoverFactory.getMaxBufferSize() - 1]);
|
||||||
|
} else {
|
||||||
|
polyMoverFactory.create(gameObjects, objectIndex - 1);
|
||||||
|
}
|
||||||
|
} else if (mover == null || mover.getEnd() != c) {
|
||||||
if (p == d) {
|
if (p == d) {
|
||||||
mover = new LinearMover(p, c, dir);
|
mover = new LinearMover(p, c, dir);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
mover = moverFactory.create(p, c, dir);
|
mover = moverFactory.create(p, c, dir);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (time < c.getTime()) {
|
if (time < c.getTime()) {
|
||||||
if (!p.isSpinner() || !c.isSpinner()) {
|
if (!p.isSpinner() || !c.isSpinner()) {
|
||||||
double[] point = mover.getPointAt(time);
|
double[] point;
|
||||||
|
if (multipoint) {
|
||||||
|
point = polyMoverFactory.getPointAt(time);
|
||||||
|
} else {
|
||||||
|
point = mover.getPointAt(time);
|
||||||
|
}
|
||||||
x = (float) point[0];
|
x = (float) point[0];
|
||||||
y = (float) point[1];
|
y = (float) point[1];
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if (c.isSpinner()) {
|
if (c.isSpinner()) {
|
||||||
Spinner.PROGRESS = (double) (time - c.getTime()) / (double) (c.getEndTime() - c.getTime());
|
Spinner.PROGRESS = (double) (time - c.getTime()) / (double) (c.getEndTime() - c.getTime());
|
||||||
double[] point = spinner.getPoint();
|
double[] point = spinner.getPoint();
|
||||||
x = (float) point[0];
|
x = (float) point[0];
|
||||||
y = (float) point[1];
|
y = (float) point[1];
|
||||||
c.end = new Vec2f(x, y);
|
c.end = new Vec2f(x, y);
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
Vec2f point = c.getPointAt(time);
|
Vec2f point = c.getPointAt(time);
|
||||||
if (isCurrentLazySlider) {
|
if (isCurrentLazySlider) {
|
||||||
point = c.start;
|
point = c.start;
|
||||||
|
@ -236,72 +259,4 @@ public class Dancer {
|
||||||
y = Utils.clamp(y, 10, Options.height - 10);
|
y = Utils.clamp(y, 10, Options.height - 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(int time, GameObject[] gameObjects, int objectIndex) {
|
|
||||||
GameObject p, c;
|
|
||||||
GameObject[] e = objectIndex > 0 ? sliderMoverController.process(gameObjects[objectIndex - 1], gameObjects[objectIndex], time)
|
|
||||||
: sliderMoverController.process(d, gameObjects[objectIndex], time);
|
|
||||||
p = e[0];
|
|
||||||
c = e[1];
|
|
||||||
if (this.p != p) {
|
|
||||||
this.p = p;
|
|
||||||
if (this.p == d) {
|
|
||||||
if (c.isSpinner()) {
|
|
||||||
double[] spinnerStartPoint = spinner.getPoint();
|
|
||||||
c.start.set((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
isCurrentLazySlider = false;
|
|
||||||
// detect lazy sliders, should work pretty good
|
|
||||||
if (c.isSlider() && LAZY_SLIDERS && Utils.distance(c.start.x, c.start.y, c.end.x, c.end.y) <= Circle.diameter * 0.8f) {
|
|
||||||
Slider s = (Slider) c;
|
|
||||||
Vec2f mid = s.getCurve().pointAt(1f);
|
|
||||||
if (s.getRepeats() == 1 || Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= Circle.diameter * 0.8f) {
|
|
||||||
mid = s.getCurve().pointAt(0.5f);
|
|
||||||
if (Utils.distance(c.start.x, c.start.y, mid.x, mid.y) <= Circle.diameter * 0.8f) {
|
|
||||||
isCurrentLazySlider = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
dir = moverDirection.getDirection(dir);
|
|
||||||
if (c.isSpinner()) {
|
|
||||||
double[] spinnerStartPoint = spinner.getPoint();
|
|
||||||
c.start = new Vec2f((float) spinnerStartPoint[0], (float) spinnerStartPoint[1]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (polyMoverFactory.isInitialized() && polyMoverFactory.getLatestIndex() < objectIndex + polyMoverFactory.getLatestIndex() - 1) {
|
|
||||||
polyMoverFactory.update(gameObjects[objectIndex + polyMoverFactory.getMaxBufferSize() - 1]);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
polyMoverFactory.create(gameObjects, objectIndex - 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (time < c.getTime()) {
|
|
||||||
if (!(p.isSpinner() || c.isSpinner())) {
|
|
||||||
double[] point = polyMoverFactory.getPointAt(time);
|
|
||||||
x = (float) point[0];
|
|
||||||
y = (float) point[1];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
if (c.isSpinner()) {
|
|
||||||
Spinner.PROGRESS = (double) (time - c.getTime()) / (double) (c.getEndTime() - c.getTime());
|
|
||||||
double[] point = spinner.getPoint();
|
|
||||||
x = (float) point[0];
|
|
||||||
y = (float) point[1];
|
|
||||||
c.end = new Vec2f(x, y);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
Vec2f point = c.getPointAt(time);
|
|
||||||
if (isCurrentLazySlider) {
|
|
||||||
point = c.start;
|
|
||||||
}
|
|
||||||
x = point.x;
|
|
||||||
y = point.y;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Pippi.dance(time, c, isCurrentLazySlider);
|
|
||||||
x = Utils.clamp(x, 10, Options.width - 10);
|
|
||||||
y = Utils.clamp(y, 10, Options.height - 10);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user