mirror of
https://github.com/2006-Scape/apollo.git
synced 2026-07-06 16:51:37 +00:00
Format.
This commit is contained in:
@@ -9,7 +9,7 @@ import org.apollo.game.model.Mob;
|
|||||||
* A {@link MobRepository} is a repository of {@link Mob}s that are currently active in the game world.
|
* A {@link MobRepository} is a repository of {@link Mob}s that are currently active in the game world.
|
||||||
*
|
*
|
||||||
* @author Graham
|
* @author Graham
|
||||||
* @param <T> The type of mob..
|
* @param <T> The type of mob.
|
||||||
*/
|
*/
|
||||||
public final class MobRepository<T extends Mob> implements Iterable<T> {
|
public final class MobRepository<T extends Mob> implements Iterable<T> {
|
||||||
|
|
||||||
@@ -52,9 +52,11 @@ public final class MobRepository<T extends Mob> implements Iterable<T> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mob == null) {
|
if (mob == null) {
|
||||||
throw new NoSuchElementException("Mob does not exist.");
|
throw new NoSuchElementException("Mob does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
previousIndex = index;
|
previousIndex = index;
|
||||||
index++;
|
index++;
|
||||||
return mob;
|
return mob;
|
||||||
@@ -106,6 +108,7 @@ public final class MobRepository<T extends Mob> implements Iterable<T> {
|
|||||||
if (size == mobs.length) {
|
if (size == mobs.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
int index = -1;
|
int index = -1;
|
||||||
for (int i = pointer; i < mobs.length; i++) {
|
for (int i = pointer; i < mobs.length; i++) {
|
||||||
if (mobs[i] == null) {
|
if (mobs[i] == null) {
|
||||||
@@ -113,6 +116,7 @@ public final class MobRepository<T extends Mob> implements Iterable<T> {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
for (int i = 0; i < pointer; i++) {
|
for (int i = 0; i < pointer; i++) {
|
||||||
if (mobs[i] == null) {
|
if (mobs[i] == null) {
|
||||||
@@ -121,11 +125,14 @@ public final class MobRepository<T extends Mob> implements Iterable<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (index == -1) {
|
if (index == -1) {
|
||||||
return false; // shouldn't happen, but just in case
|
return false; // shouldn't happen, but just in case
|
||||||
}
|
}
|
||||||
|
|
||||||
mobs[index] = mob;
|
mobs[index] = mob;
|
||||||
mob.setIndex(index + 1);
|
mob.setIndex(index + 1);
|
||||||
|
|
||||||
if (index == mobs.length - 1) {
|
if (index == mobs.length - 1) {
|
||||||
pointer = 0;
|
pointer = 0;
|
||||||
} else {
|
} else {
|
||||||
@@ -161,6 +168,7 @@ public final class MobRepository<T extends Mob> implements Iterable<T> {
|
|||||||
if (index < 0 || index >= mobs.length) {
|
if (index < 0 || index >= mobs.length) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mobs[index] == mob) {
|
if (mobs[index] == mob) {
|
||||||
mobs[index] = null;
|
mobs[index] = null;
|
||||||
mob.setIndex(-1);
|
mob.setIndex(-1);
|
||||||
|
|||||||
Reference in New Issue
Block a user