Added electric boxes, debug command to teleport objects across Worlds.

This commit is contained in:
simon
2018-02-27 16:49:32 -05:00
parent f530dafdee
commit 039088ac00
16 changed files with 426 additions and 42 deletions

View File

@@ -1,6 +1,7 @@
package net.simon987.biomassplugin;
import net.simon987.server.GameServer;
import net.simon987.server.game.TileMap;
import net.simon987.server.game.World;
import net.simon987.server.logging.LogManager;
@@ -26,7 +27,7 @@ public class WorldUtils {
for (int y = 0; y < world.getWorldSize(); y++) {
for (int x = 0; x < world.getWorldSize(); x++) {
if (tiles[x][y] == 0) {
if (tiles[x][y] == TileMap.PLAIN_TILE) {
plainCount++;
}
}
@@ -39,14 +40,14 @@ public class WorldUtils {
outerLoop:
for (int i = 0; i < blobCount; i++) {
Point p = world.getTileMap().getRandomPlainTile();
Point p = world.getTileMap().getRandomTile(TileMap.PLAIN_TILE);
if (p != null) {
//Don't block worlds
int counter = 0;
while (p.x == 0 || p.y == 0 || p.x == world.getWorldSize() - 1 || p.y == world.getWorldSize() - 1 ||
world.getGameObjectsAt(p.x, p.y).size() != 0) {
p = world.getTileMap().getRandomPlainTile();
p = world.getTileMap().getRandomTile(TileMap.PLAIN_TILE);
counter++;
if (counter > 25) {

View File

@@ -44,31 +44,32 @@ public class WorldUpdateListener implements GameEventListener {
World world = ((WorldUpdateEvent) event).getWorld();
//If there is less than the respawn threshold,
if (world.findObjects(BiomassBlob.class).size() < blobThreshold) {
if (world.getDimension().startsWith("w")) {
//If there is less than the respawn threshold,
if (world.findObjects(BiomassBlob.class).size() < blobThreshold) {
//Set a timer for respawn_time ticks
if (!worldWaitMap.containsKey(world) || worldWaitMap.get(world) == 0L) {
worldWaitMap.put(world, GameServer.INSTANCE.getGameUniverse().getTime() + waitTime);
} else {
//Set a timer for respawn_time ticks
if (!worldWaitMap.containsKey(world) || worldWaitMap.get(world) == 0L) {
worldWaitMap.put(world, GameServer.INSTANCE.getGameUniverse().getTime() + waitTime);
} else {
long waitUntil = worldWaitMap.get(world);
long waitUntil = worldWaitMap.get(world);
if (GameServer.INSTANCE.getGameUniverse().getTime() >= waitUntil) {
if (GameServer.INSTANCE.getGameUniverse().getTime() >= waitUntil) {
//If the timer was set less than respawn_time ticks ago, respawn the blobs
ArrayList<BiomassBlob> newBlobs = WorldUtils.generateBlobs(world, minBlobCount,
maxBlobCount, blobYield);
for (BiomassBlob blob : newBlobs) {
world.addObject(blob);
//If the timer was set less than respawn_time ticks ago, respawn the blobs
ArrayList<BiomassBlob> newBlobs = WorldUtils.generateBlobs(world, minBlobCount,
maxBlobCount, blobYield);
for (BiomassBlob blob : newBlobs) {
world.addObject(blob);
world.incUpdatable();
}
//Set the 'waitUntil' time to 0 to indicate that we are not waiting
worldWaitMap.replace(world, 0L);
}
//Set the 'waitUntil' time to 0 to indicate that we are not waiting
worldWaitMap.replace(world, 0L);
}
}
}
}
}