v0.3.0c: refactored finding a character, no longer need to maintain chars[] array

This commit is contained in:
Evan Debenham
2015-06-06 00:17:07 -04:00
parent 3cf7979a4c
commit dbeff25d2c
12 changed files with 9 additions and 46 deletions
@@ -102,13 +102,10 @@ public abstract class Actor implements Bundlable {
private static float now = 0;
private static Char[] chars = new Char[Level.LENGTH];
public static void clear() {
now = 0;
Arrays.fill( chars, null );
all.clear();
ids.clear();
@@ -160,14 +157,6 @@ public abstract class Actor implements Bundlable {
public static void resetNextID(){
nextID = 1;
}
public static void occupyCell( Char ch ) {
chars[ch.pos] = ch;
}
public static void freeCell( int pos ) {
chars[pos] = null;
}
/*protected*/public void next() {
if (current == this) {
@@ -186,8 +175,7 @@ public abstract class Actor implements Bundlable {
do {
now = Float.MAX_VALUE;
current = null;
Arrays.fill( chars, null );
for (Actor actor : all) {
@@ -197,11 +185,7 @@ public abstract class Actor implements Bundlable {
now = actor.time;
current = actor;
}
if (actor instanceof Char) {
Char ch = (Char)actor;
chars[ch.pos] = ch;
}
}
if (current != null) {
@@ -247,7 +231,6 @@ public abstract class Actor implements Bundlable {
if (actor instanceof Char) {
Char ch = (Char)actor;
chars[ch.pos] = ch;
for (Buff buff : ch.buffs()) {
all.add( buff );
buff.onAdd();
@@ -268,7 +251,11 @@ public abstract class Actor implements Bundlable {
}
public static Char findChar( int pos ) {
return chars[pos];
for (Actor actor : all){
if (actor instanceof Char && ((Char)actor).pos == pos)
return (Char)actor;
}
return null;
}
public static Actor findById( int id ) {