diff --git a/src/main/java/electrosphere/engine/LoadingThread.java b/src/main/java/electrosphere/engine/LoadingThread.java index c4e0889b..a7935adf 100644 --- a/src/main/java/electrosphere/engine/LoadingThread.java +++ b/src/main/java/electrosphere/engine/LoadingThread.java @@ -27,6 +27,7 @@ import electrosphere.game.server.ai.creature.MindlessAttacker; import electrosphere.game.server.effects.ParticleEffects; import electrosphere.game.server.terrain.models.TerrainModification; import electrosphere.game.server.town.Town; +import electrosphere.game.server.world.MacroData; import electrosphere.game.server.world.datacell.DataCellManager; import electrosphere.game.state.MicroSimulation; import electrosphere.logger.LoggerInterface; @@ -47,6 +48,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.joml.Quaternionf; import org.joml.Vector2i; +import org.joml.Vector3d; import org.joml.Vector3f; /** @@ -124,6 +126,15 @@ public class LoadingThread extends Thread { initServerThread(); } + //collision engine + initCollisionEngine(Globals.RUN_SERVER); + + //initialize the "virtual" objects simulation + initMacroSimulation(); + + //initialize the "real" objects simulation + initMicroSimulation(); + //initialize the client thread (client) if(Globals.RUN_CLIENT){ initClientThread(); @@ -136,9 +147,6 @@ public class LoadingThread extends Thread { //initialize the cell manager (client) initDrawCellManager(); - //collision engine - initCollisionEngine(Globals.RUN_SERVER); - //initialize the basic graphical entities of the world (skybox, camera) initWorldBaseGraphicalEntities(); @@ -150,12 +158,6 @@ public class LoadingThread extends Thread { } } - //initialize the "virtual" objects simulation - initMacroSimulation(); - - //initialize the "real" objects simulation - initMicroSimulation(); - //hide cursor Globals.controlHandler.hideMouse(); @@ -204,6 +206,15 @@ public class LoadingThread extends Thread { initServerThread(); } + //collision engine + initCollisionEngine(Globals.RUN_SERVER); + + //initialize the "virtual" objects simulation + initMacroSimulation(); + + //initialize the "real" objects simulation + initMicroSimulation(); + //initialize the client thread (client) if(Globals.RUN_CLIENT){ initClientThread(); @@ -216,9 +227,6 @@ public class LoadingThread extends Thread { //initialize the cell manager (client) initDrawCellManager(); - //collision engine - initCollisionEngine(Globals.RUN_SERVER); - //initialize the basic graphical entities of the world (skybox, camera) initWorldBaseGraphicalEntities(); @@ -231,12 +239,6 @@ public class LoadingThread extends Thread { } } - //initialize the "virtual" objects simulation - initMacroSimulation(); - - //initialize the "real" objects simulation - initMicroSimulation(); - //hide cursor Globals.controlHandler.hideMouse(); @@ -344,13 +346,13 @@ public class LoadingThread extends Thread { } static void createServerWorld(){ - Vector2i townLoc = Town.findValidTownLocation(); - if(townLoc != null){ - int chunkSize = Globals.serverTerrainManager.getChunkWidth(); - Globals.spawnPoint = new Vector3f(townLoc.x * chunkSize, (float)Globals.serverTerrainManager.getHeightAtPosition(townLoc.x * chunkSize,townLoc.y * chunkSize), townLoc.y * chunkSize); -// System.out.println("Setting spawn point @ " + Globals.spawnPoint); -// Town.createTown(townLoc.x,townLoc.y); - } +// Vector2i townLoc = Town.findValidTownLocation(); +// if(townLoc != null){ +// int chunkSize = Globals.serverTerrainManager.getChunkWidth(); +// Globals.spawnPoint = new Vector3f(townLoc.x * chunkSize, (float)Globals.serverTerrainManager.getHeightAtPosition(townLoc.x * chunkSize,townLoc.y * chunkSize), townLoc.y * chunkSize); +//// System.out.println("Setting spawn point @ " + Globals.spawnPoint); +//// Town.createTown(townLoc.x,townLoc.y); +// } } static void initServerGameWorldData(){ @@ -472,7 +474,15 @@ public class LoadingThread extends Thread { } static void initMacroSimulation(){ + Globals.macroData = MacroData.generateWorld(0); +// Globals.macroData.describeWorld(); Globals.macroSimulation = new MacroSimulation(); + Globals.macroSimulation.simulate(); + Town startTown = Globals.macroData.getTowns().get(0); + Vector2i firstPos = startTown.getPositions().get(0); + double startX = firstPos.x * Globals.serverTerrainManager.getChunkWidth(); + double startZ = firstPos.y * Globals.serverTerrainManager.getChunkWidth(); + Globals.spawnPoint.set((float)startX,(float)Globals.commonWorldData.getElevationAtPoint(new Vector3d(startX,0,startZ)),(float)startZ); } diff --git a/src/main/java/electrosphere/entity/state/movement/MovementTree.java b/src/main/java/electrosphere/entity/state/movement/MovementTree.java index fc5baef0..1e2f4abb 100644 --- a/src/main/java/electrosphere/entity/state/movement/MovementTree.java +++ b/src/main/java/electrosphere/entity/state/movement/MovementTree.java @@ -86,7 +86,7 @@ public class MovementTree { // Model entityModel = Globals.assetManager.fetchModel(EntityUtils.getEntityModelPath(parent)); Vector3d position = EntityUtils.getPosition(parent); Vector3f movementVector = CreatureUtils.getMovementVector(parent); - float movementYaw = CameraEntityUtils.getCameraYaw(Globals.playerCamera); +// float movementYaw = CameraEntityUtils.getCameraYaw(Globals.playerCamera); Quaternionf movementQuaternion = new Quaternionf().rotationTo(new Vector3f(0,0,1), movementVector).normalize(); Quaternionf rotation = EntityUtils.getRotation(parent); Vector3d newPosition; diff --git a/src/main/java/electrosphere/game/server/town/Town.java b/src/main/java/electrosphere/game/server/town/Town.java index 73884a5b..ab21ad84 100644 --- a/src/main/java/electrosphere/game/server/town/Town.java +++ b/src/main/java/electrosphere/game/server/town/Town.java @@ -108,6 +108,10 @@ public class Town { return rVal; } + public List getPositions(){ + return positions; + } + public void addStructure(Structure structure){ structures.add(structure); } diff --git a/src/main/java/electrosphere/game/state/MacroSimulation.java b/src/main/java/electrosphere/game/state/MacroSimulation.java index 907704f7..c2cbf9a6 100644 --- a/src/main/java/electrosphere/game/state/MacroSimulation.java +++ b/src/main/java/electrosphere/game/state/MacroSimulation.java @@ -98,7 +98,6 @@ public class MacroSimulation { } } if(placementPos != null){ - System.out.println("Added shelter"); Structure placedStructure = VirtualStructureUtils.placeStructureAtPoint(placementPos.x, placementPos.y, buildingTypeToPlace); CharacterUtils.addShelter(chara, placedStructure); VirtualStructureUtils.addResident(placedStructure, chara); diff --git a/src/main/java/electrosphere/main/Main.java b/src/main/java/electrosphere/main/Main.java index de455e2f..c03f5d46 100644 --- a/src/main/java/electrosphere/main/Main.java +++ b/src/main/java/electrosphere/main/Main.java @@ -120,22 +120,22 @@ public class Main { //world gen testing //gen terrain - Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,0.0f,0); - Globals.serverTerrainManager.load(); - Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager); - //gen world - Globals.macroData = MacroData.generateWorld(0); - Globals.macroData.describeWorld(); - boolean run = true; - Globals.macroSimulation = new MacroSimulation(); - while(run){ - Globals.macroSimulation.simulate(); - try { - TimeUnit.MILLISECONDS.sleep(1000); - } catch (InterruptedException ex) { - ex.printStackTrace(); - } - } +// Globals.serverTerrainManager = new ServerTerrainManager(2000,50,100,0.0f,0); +// Globals.serverTerrainManager.load(); +// Globals.serverWorldData = ServerWorldData.createGameWorld(Globals.serverTerrainManager); +// //gen world +// Globals.macroData = MacroData.generateWorld(0); +// Globals.macroData.describeWorld(); +// boolean run = true; +// Globals.macroSimulation = new MacroSimulation(); +// while(run){ +// Globals.macroSimulation.simulate(); +// try { +// TimeUnit.MILLISECONDS.sleep(1000); +// } catch (InterruptedException ex) { +// ex.printStackTrace(); +// } +// } //debug: create terrain/world viewer // TerrainViewer.runViewer();