Merge branch 'master' into vaults

# Conflicts:
#	Server/src/main/java/net/simon987/server/GameServer.java
#	Server/src/main/java/net/simon987/server/game/World.java
This commit is contained in:
simon
2018-01-17 20:29:37 -05:00
46 changed files with 698 additions and 643 deletions

View File

@@ -52,7 +52,6 @@ public class CubotLaser extends CpuHardware {
Point frontTile = cubot.getFrontTile();
ArrayList<GameObject> objects = cubot.getWorld().getGameObjectsBlockingAt(frontTile.x, frontTile.y);
if (cubot.getCurrentAction() == Action.IDLE && objects.size() > 0) {
//FIXME: Problem here if more than 1 object
if (objects.get(0) instanceof InventoryHolder) {

View File

@@ -37,37 +37,40 @@ public class CubotLeg extends CpuHardware implements JSONSerialisable {
@Override
public void handleInterrupt(Status status) {
int a = getCpu().getRegisterSet().getRegister("A").getValue();
int b = getCpu().getRegisterSet().getRegister("B").getValue();
if (a == LEGS_SET_DIR) {
if (cubot.getCurrentAction() == Action.IDLE) {
int a = getCpu().getRegisterSet().getRegister("A").getValue();
int b = getCpu().getRegisterSet().getRegister("B").getValue();
if (a == LEGS_SET_DIR) {
Direction dir = Direction.getDirection(b);
if (dir != null) {
if (cubot.spendEnergy(20)) {
cubot.setDirection(Direction.getDirection(b));
status.setErrorFlag(false);
}
} else {
status.setErrorFlag(true);
}
} else if (a == LEGS_SET_DIR_AND_WALK) {
if (cubot.getMaxEnergy() >= 100) {
Direction dir = Direction.getDirection(b);
if (dir != null) {
cubot.setDirection(Direction.getDirection(b));
status.setErrorFlag(false);
if (cubot.spendEnergy(20)) {
cubot.setDirection(Direction.getDirection(b));
status.setErrorFlag(false);
}
} else {
status.setErrorFlag(true);
}
cubot.setCurrentAction(Action.WALKING);
} else if (a == LEGS_SET_DIR_AND_WALK) {
if (cubot.getMaxEnergy() >= 100) {
Direction dir = Direction.getDirection(b);
if (dir != null) {
cubot.setDirection(Direction.getDirection(b));
status.setErrorFlag(false);
} else {
status.setErrorFlag(true);
}
cubot.setCurrentAction(Action.WALKING);
}
}
}
}

View File

@@ -20,35 +20,35 @@ public class UserCreationListener implements GameEventListener {
@Override
public void handle(GameEvent event) {
User user = (User) event.getSource();
LogManager.LOGGER.fine("(Plugin) Handled User creation event (Cubot Plugin)");
Cubot cubot = new Cubot();
Random random = new Random();
int spawnX = GameServer.INSTANCE.getConfig().getInt("new_user_worldX") + random.nextInt(5);
int spawnY = GameServer.INSTANCE.getConfig().getInt("new_user_worldY") + random.nextInt(5);
cubot.setWorld(GameServer.INSTANCE.getGameUniverse().getWorld(spawnX, spawnY, true));
cubot.getWorld().getGameObjects().add(cubot);
cubot.getWorld().incUpdatable();
User user = (User) event.getSource();
Cubot cubot = new Cubot();
cubot.setObjectId(GameServer.INSTANCE.getGameUniverse().getNextObjectId());
cubot.setHeldItem(GameServer.INSTANCE.getConfig().getInt("new_user_item"));
Point point = null;
while (point == null || cubot.getWorld() == null) {
int spawnX = GameServer.INSTANCE.getConfig().getInt("new_user_worldX") + random.nextInt(5);
int spawnY = GameServer.INSTANCE.getConfig().getInt("new_user_worldY") + random.nextInt(5);
cubot.setWorld(GameServer.INSTANCE.getGameUniverse().getWorld(spawnX, spawnY, true));
point = cubot.getWorld().getRandomPassableTile();
}
cubot.setX(point.x);
cubot.setY(point.y);
cubot.getWorld().addObject(cubot);
cubot.getWorld().incUpdatable();
cubot.setHeldItem(GameServer.INSTANCE.getConfig().getInt("new_user_item"));
cubot.setEnergy(GameServer.INSTANCE.getConfig().getInt("battery_max_energy"));
cubot.setMaxEnergy(GameServer.INSTANCE.getConfig().getInt("battery_max_energy"));
cubot.setParent(user);
Point point = cubot.getWorld().getRandomPassableTile();
cubot.setX(point.x);
cubot.setY(point.y);
user.setControlledUnit(cubot);
LogManager.LOGGER.fine("(Plugin) Handled User creation event (Cubot Plugin)");
}
}