The model is now working and downwards compatible

This commit is contained in:
Awlex 2016-11-20 13:49:40 +01:00
parent b36d7d487f
commit 14d88f38bf
6 changed files with 27 additions and 11 deletions

View File

@ -21,7 +21,6 @@ public class ArcMover implements PolyMover {
this.middle = middle;
this.p2 = p2;
init();
System.out.println("r: " + r + " xm: " + xm + " ym: " + ym);
}
private void init() {
@ -99,4 +98,9 @@ public class ArcMover implements PolyMover {
}
return true;
}
@Override
public GameObject getLastItem() {
return p2;
}
}

View File

@ -41,4 +41,15 @@ public class LineMover implements PolyMover {
return objects;
}
@Override
public GameObject getLastItem() {
int i = objects.length - 1;
while (i > 0) {
if (objects[i] != null) {
break;
}
i--;
}
return objects[i];
}
}

View File

@ -10,4 +10,6 @@ public interface PolyMover {
double[] getPointAt(int time);
GameObject[] getItems();
GameObject getLastItem();
}

View File

@ -16,8 +16,7 @@ public class ArcFactory extends PolyMoverFactory {
private static final int PREFFERED_BUFFER_SIZE = 3;
public void init(GameObject[] objects, int count) {
System.out.println("count: " + count);
if (count < 3 || !ArcMover.canCricleExistBetweenItems(objects[0], objects[1], objects[2]))
if (count < 3 || (!ArcMover.canCricleExistBetweenItems(objects[0], objects[1], objects[2])))
addMover(new LineMover(objects, 3));
else
addMover(new ArcMover(objects[0], objects[1], objects[2]));
@ -30,7 +29,7 @@ public class ArcFactory extends PolyMoverFactory {
@Override
public int getMinBufferSize() {
return ArcMover.ITEMS_NEEDED;
return LineMover.ITEMS_NEEDED;
}
@Override

View File

@ -4,7 +4,9 @@ import awlex.ospu.polymover.LineMover;
import awlex.ospu.polymover.PolyMover;
import itdelatrisu.opsu.objects.DummyObject;
import itdelatrisu.opsu.objects.GameObject;
import yugecin.opsudance.Dancer;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@ -28,8 +30,7 @@ public abstract class PolyMoverFactory {
double[] ret = new double[2];
int i = 0;
while (i < movers.size()) {
GameObject[] items = movers.get(i).getItems();
if (items[items.length - 1].getEndTime() < time)
if (movers.get(i).getLastItem().getEndTime() < time)
break;
double[] point = movers.get(i).getPointAt(time);
ret[0] += point[0];
@ -47,17 +48,16 @@ public abstract class PolyMoverFactory {
}
GameObject[] items = new GameObject[getMaxBufferSize()];
int i = 1;
items[0] = startIndex == -1 ? new DummyObject() : objects[startIndex];
while (i < items.length - 2) {
items[0] = startIndex == -1 ? Dancer.d : objects[startIndex];
while (i < items.length - 1) {
GameObject g = objects[startIndex + i];
if (g.isSlider() || g.isSpinner())
break;
items[i++] = g;
}
items[i] = objects[startIndex + i];
i++;
latestIndex = startIndex + getMaxBufferSize() + i - items.length;
if (i >= getMinBufferSize()) {
if (++i >= getMinBufferSize()) {
init(items, i);
}
else {

View File

@ -250,6 +250,7 @@ public class Dancer {
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) {
@ -275,7 +276,6 @@ public class Dancer {
polyMoverFactory.create(gameObjects, objectIndex - 1);
}
}
if (time < c.getTime()) {
if (!(p.isSpinner() || c.isSpinner())) {
double[] point = polyMoverFactory.getPointAt(time);