Align spawn location with town
This commit is contained in:
parent
78ac717283
commit
20baca4884
@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -108,6 +108,10 @@ public class Town {
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public List<Vector2i> getPositions(){
|
||||
return positions;
|
||||
}
|
||||
|
||||
public void addStructure(Structure structure){
|
||||
structures.add(structure);
|
||||
}
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user