move realmManager to serverState
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
Some checks reported errors
studiorailgun/Renderer/pipeline/head Something is wrong with the build of this commit
This commit is contained in:
parent
96f6577f95
commit
5b8509a7f4
@ -10,7 +10,7 @@ Recommended flow and tips for spawning entities from the server
|
||||
CreatureTemplate template = <get creature template somehow>;
|
||||
String raceName = template.getCreatureType();
|
||||
//spawn creature in world
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
Entity newCreature = CreatureUtils.serverSpawnBasicCreature(realm,new Vector3d(Globals.spawnPoint.x,Globals.spawnPoint.y,Globals.spawnPoint.z),raceName,template);
|
||||
```
|
||||
|
||||
@ -19,7 +19,7 @@ Entity newCreature = CreatureUtils.serverSpawnBasicCreature(realm,new Vector3d(G
|
||||
CreatureTemplate template = <get creature template somehow>;
|
||||
String raceName = template.getCreatureType();
|
||||
//spawn creature in world
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
Entity newCreature = CreatureUtils.serverSpawnBasicCreature(realm,new Vector3d(Globals.spawnPoint.x,Globals.spawnPoint.y,Globals.spawnPoint.z),raceName,template);
|
||||
```
|
||||
|
||||
|
||||
@ -1812,7 +1812,7 @@ Move playerCamera to clientState
|
||||
Move global cursor entities into cursorState
|
||||
Move lots of global state to clientState
|
||||
Create ServerState global
|
||||
|
||||
Move realmManager to serverState
|
||||
|
||||
|
||||
|
||||
|
||||
@ -71,10 +71,10 @@ public class ScriptClientVoxelUtils {
|
||||
if(
|
||||
collisionEngine != null &&
|
||||
camera != null &&
|
||||
Globals.realmManager != null &&
|
||||
Globals.realmManager.first() != null &&
|
||||
Globals.realmManager.first().getServerWorldData() != null &&
|
||||
Globals.realmManager.first().getServerWorldData().getServerFluidManager() != null
|
||||
Globals.serverState.realmManager != null &&
|
||||
Globals.serverState.realmManager.first() != null &&
|
||||
Globals.serverState.realmManager.first().getServerWorldData() != null &&
|
||||
Globals.serverState.realmManager.first().getServerWorldData().getServerFluidManager() != null
|
||||
){
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(camera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(camera));
|
||||
@ -93,7 +93,7 @@ public class ScriptClientVoxelUtils {
|
||||
(int)(Math.ceil(cursorPos.y) % ServerTerrainChunk.CHUNK_DIMENSION),
|
||||
(int)(Math.ceil(cursorPos.z) % ServerTerrainChunk.CHUNK_DIMENSION)
|
||||
);
|
||||
Globals.realmManager.first().getServerWorldData().getServerFluidManager().deformFluidAtLocationToValue(worldPos, voxelPos, 1.0f, 0);
|
||||
Globals.serverState.realmManager.first().getServerWorldData().getServerFluidManager().deformFluidAtLocationToValue(worldPos, voxelPos, 1.0f, 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -171,10 +171,10 @@ public class ImGuiWindowMacros {
|
||||
}
|
||||
//test gen window (only drawn if realm is a test generation realm)
|
||||
if(
|
||||
Globals.realmManager != null &&
|
||||
Globals.realmManager.first() != null &&
|
||||
Globals.realmManager.first().getServerWorldData() != null &&
|
||||
Globals.realmManager.first().getServerWorldData().getServerTerrainManager().getChunkGenerator() instanceof ProceduralChunkGenerator &&
|
||||
Globals.serverState.realmManager != null &&
|
||||
Globals.serverState.realmManager.first() != null &&
|
||||
Globals.serverState.realmManager.first().getServerWorldData() != null &&
|
||||
Globals.serverState.realmManager.first().getServerWorldData().getServerTerrainManager().getChunkGenerator() instanceof ProceduralChunkGenerator &&
|
||||
ImGui.button("Test Terrain Gen")
|
||||
){
|
||||
ImGuiTestGen.testGenWindow.setOpen(true);
|
||||
|
||||
@ -116,7 +116,7 @@ public class ImGuiAI {
|
||||
if(ImGui.button("Increase pathfinding Iteration Cap (" + numIterations + ")")){
|
||||
numIterations = numIterations + 1;
|
||||
VoxelPathfinder voxelPathfinder = new VoxelPathfinder();
|
||||
GriddedDataCellManager griddedDataCellManager = (GriddedDataCellManager)Globals.realmManager.getEntityRealm(serverPlayerEntity).getDataCellManager();
|
||||
GriddedDataCellManager griddedDataCellManager = (GriddedDataCellManager)Globals.serverState.realmManager.getEntityRealm(serverPlayerEntity).getDataCellManager();
|
||||
Vector3d playerPos = new Vector3d(EntityUtils.getPosition(serverPlayerEntity));
|
||||
Vector3d targetPos = new Vector3d(playerPos).add(10,0,0);
|
||||
if(playerTargetPos != null){
|
||||
@ -142,7 +142,7 @@ public class ImGuiAI {
|
||||
if(ImGui.button("Draw Open Set (" + numIterations + ")")){
|
||||
numIterations = numIterations + 1;
|
||||
VoxelPathfinder voxelPathfinder = new VoxelPathfinder();
|
||||
GriddedDataCellManager griddedDataCellManager = (GriddedDataCellManager)Globals.realmManager.getEntityRealm(serverPlayerEntity).getDataCellManager();
|
||||
GriddedDataCellManager griddedDataCellManager = (GriddedDataCellManager)Globals.serverState.realmManager.getEntityRealm(serverPlayerEntity).getDataCellManager();
|
||||
Vector3d playerPos = new Vector3d(EntityUtils.getPosition(serverPlayerEntity));
|
||||
Vector3d targetPos = new Vector3d(playerPos).add(10,0,0);
|
||||
if(PathfindingNode.hasPathfindingPoint(playerAi.getBlackboard())){
|
||||
@ -168,7 +168,7 @@ public class ImGuiAI {
|
||||
}
|
||||
|
||||
if(ImGui.button("Spawn test macro character")){
|
||||
Realm realm = Globals.realmManager.first();
|
||||
Realm realm = Globals.serverState.realmManager.first();
|
||||
GriddedDataCellManager griddedDataCellManager = (GriddedDataCellManager)realm.getDataCellManager();
|
||||
Entity serverEnt = EntityLookupUtils.getServerEquivalent(Globals.clientState.playerEntity);
|
||||
Vector3d spawnPos = griddedDataCellManager.getMacroEntryPoint(new Vector3d(EntityUtils.getPosition(serverEnt)).add(50,0,0));
|
||||
|
||||
@ -26,8 +26,8 @@ public class ImGuiGriddedManager {
|
||||
@Override
|
||||
public void exec() {
|
||||
GriddedDataCellManager manager = null;
|
||||
if(Globals.realmManager != null && Globals.realmManager.first() != null){
|
||||
Realm realm = Globals.realmManager.first();
|
||||
if(Globals.serverState.realmManager != null && Globals.serverState.realmManager.first() != null){
|
||||
Realm realm = Globals.serverState.realmManager.first();
|
||||
if(realm.getDataCellManager() instanceof GriddedDataCellManager){
|
||||
manager = (GriddedDataCellManager)realm.getDataCellManager();
|
||||
}
|
||||
@ -43,7 +43,7 @@ public class ImGuiGriddedManager {
|
||||
ImGui.text("Cells cleaned last frame: " + manager.getNumCleaned());
|
||||
if(ImGui.button("Player Data Cell Info")){
|
||||
Entity playerEntity = Globals.playerManager.getFirstPlayer().getPlayerEntity();
|
||||
Realm realm = Globals.realmManager.getEntityRealm(playerEntity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(playerEntity);
|
||||
GriddedDataCellManager griddedDataCellManager = (GriddedDataCellManager)realm.getDataCellManager();
|
||||
griddedDataCellManager.printCellInfo(griddedDataCellManager.getDataCellAtPoint(EntityUtils.getPosition(playerEntity)));
|
||||
}
|
||||
|
||||
@ -35,7 +35,7 @@ public class ImGuiTestGen {
|
||||
//ui framework text
|
||||
ImGui.text("Test Terrain Generation");
|
||||
|
||||
TerrainModel terrainModel = Globals.realmManager.first().getServerWorldData().getServerTerrainManager().getModel();
|
||||
TerrainModel terrainModel = Globals.serverState.realmManager.first().getServerWorldData().getServerTerrainManager().getModel();
|
||||
|
||||
//regenerate the test area
|
||||
if(ImGui.button("Regenerate")){
|
||||
@ -45,7 +45,7 @@ public class ImGuiTestGen {
|
||||
//run once script recompilation has completed
|
||||
|
||||
//clear server
|
||||
GriddedDataCellManager gridManager = (GriddedDataCellManager)Globals.realmManager.first().getDataCellManager();
|
||||
GriddedDataCellManager gridManager = (GriddedDataCellManager)Globals.serverState.realmManager.first().getDataCellManager();
|
||||
gridManager.evictAll();
|
||||
|
||||
//clear client
|
||||
|
||||
@ -171,7 +171,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + data.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.clientState.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.clientState.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
CollisionEngine clientCollisionEngine = Globals.clientState.clientSceneWrapper.getCollisionEngine(); //using client collision engine so ray doesn't collide with player entity
|
||||
Vector3d cursorPos = clientCollisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE).add(cursorVerticalOffset);
|
||||
CreatureUtils.serverSpawnBasicCreature(realm, cursorPos, data.getId(), null);
|
||||
@ -201,7 +201,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + unitDefinition.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.clientState.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.clientState.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
CollisionEngine clientCollisionEngine = Globals.clientState.clientSceneWrapper.getCollisionEngine(); //using client collision engine so ray doesn't collide with player entity
|
||||
Vector3d cursorPos = clientCollisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||
if(cursorPos == null){
|
||||
@ -234,7 +234,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + data.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.clientState.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.clientState.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
CollisionEngine clientCollisionEngine = Globals.clientState.clientSceneWrapper.getCollisionEngine(); //using client collision engine so ray doesn't collide with player entity
|
||||
Vector3d cursorPos = clientCollisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE).add(cursorVerticalOffset);
|
||||
FoliageUtils.serverSpawnTreeFoliage(realm, cursorPos, data.getId());
|
||||
@ -263,7 +263,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + item.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.clientState.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.clientState.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
CollisionEngine clientCollisionEngine = Globals.clientState.clientSceneWrapper.getCollisionEngine(); //using client collision engine so ray doesn't collide with player entity
|
||||
Vector3d cursorPos = clientCollisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE).add(cursorVerticalOffset);
|
||||
ItemUtils.serverSpawnBasicItem(realm, cursorPos, item.getId());
|
||||
@ -293,7 +293,7 @@ public class MenuGeneratorsLevelEditor {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + object.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.clientState.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.clientState.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
CollisionEngine clientCollisionEngine = Globals.clientState.clientSceneWrapper.getCollisionEngine(); //using client collision engine so ray doesn't collide with player entity
|
||||
Vector3d cursorPos = clientCollisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE).add(cursorVerticalOffset);
|
||||
CommonEntityUtils.serverSpawnBasicObject(realm, cursorPos, object.getId());
|
||||
|
||||
@ -36,7 +36,7 @@ public class ScriptLevelEditorUtils {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + Globals.clientState.selectedSpawntype.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.clientState.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.clientState.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
CollisionEngine clientCollisionEngine = Globals.clientState.clientSceneWrapper.getCollisionEngine(); //using client collision engine so ray doesn't collide with player entity
|
||||
Vector3d cursorPos = clientCollisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||
if(cursorPos == null){
|
||||
@ -48,7 +48,7 @@ public class ScriptLevelEditorUtils {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + Globals.clientState.selectedSpawntype.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.clientState.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.clientState.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
CollisionEngine clientCollisionEngine = Globals.clientState.clientSceneWrapper.getCollisionEngine(); //using client collision engine so ray doesn't collide with player entity
|
||||
Vector3d cursorPos = clientCollisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||
if(cursorPos == null){
|
||||
@ -60,7 +60,7 @@ public class ScriptLevelEditorUtils {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + Globals.clientState.selectedSpawntype.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.clientState.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.clientState.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
CollisionEngine clientCollisionEngine = Globals.clientState.clientSceneWrapper.getCollisionEngine(); //using client collision engine so ray doesn't collide with player entity
|
||||
Vector3d cursorPos = clientCollisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||
if(cursorPos == null){
|
||||
@ -72,7 +72,7 @@ public class ScriptLevelEditorUtils {
|
||||
LoggerInterface.loggerEngine.INFO("spawn " + Globals.clientState.selectedSpawntype.getId() + "!");
|
||||
Vector3d eyePos = new Vector3d(CameraEntityUtils.getCameraEye(Globals.clientState.playerCamera));
|
||||
Vector3d centerPos = new Vector3d(CameraEntityUtils.getCameraCenter(Globals.clientState.playerCamera));
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
CollisionEngine clientCollisionEngine = Globals.clientState.clientSceneWrapper.getCollisionEngine(); //using client collision engine so ray doesn't collide with player entity
|
||||
Vector3d cursorPos = clientCollisionEngine.rayCastPosition(new Vector3d(centerPos), new Vector3d(eyePos).mul(-1.0), CollisionEngine.DEFAULT_INTERACT_DISTANCE);
|
||||
if(cursorPos == null){
|
||||
|
||||
@ -534,7 +534,7 @@ public class PhysicsEntityUtils {
|
||||
* @return The rigid body created (note, attachment has already been performed)
|
||||
*/
|
||||
public static DBody serverAttachTriGeomRigidBody(Entity terrain, TriGeomData data){
|
||||
Realm realm = Globals.realmManager.getEntityRealm(terrain);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(terrain);
|
||||
DBody terrainBody = CollisionBodyCreation.generateBodyFromTerrainData(realm.getCollisionEngine(),data,Collidable.TYPE_STATIC_BIT);
|
||||
CollisionBodyCreation.setAutoDisable(realm.getCollisionEngine(), terrainBody, true, LINEAR_THRESHOLD, ANGULAR_THRESHOLD, STEP_THRESHOLD);
|
||||
|
||||
@ -551,7 +551,7 @@ public class PhysicsEntityUtils {
|
||||
* @return The rigid body created (note, attachment has already been performed)
|
||||
*/
|
||||
public static DBody serverAttachMultiShapeTriGeomRigidBody(Entity terrain, MultiShapeTriGeomData data){
|
||||
Realm realm = Globals.realmManager.getEntityRealm(terrain);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(terrain);
|
||||
DBody terrainBody = CollisionBodyCreation.generateBodyFromMultiShapeMeshData(realm.getCollisionEngine(),data,Collidable.TYPE_STATIC_BIT);
|
||||
CollisionBodyCreation.setAutoDisable(realm.getCollisionEngine(), terrainBody, true, LINEAR_THRESHOLD, ANGULAR_THRESHOLD, STEP_THRESHOLD);
|
||||
|
||||
|
||||
@ -59,7 +59,6 @@ import electrosphere.renderer.ui.elements.ImagePanel;
|
||||
import electrosphere.renderer.ui.font.FontManager;
|
||||
import electrosphere.script.ScriptEngine;
|
||||
import electrosphere.server.ServerState;
|
||||
import electrosphere.server.datacell.RealmManager;
|
||||
import electrosphere.server.db.DatabaseController;
|
||||
import electrosphere.server.entity.poseactor.PoseModel;
|
||||
import electrosphere.server.saves.Save;
|
||||
@ -203,11 +202,6 @@ public class Globals {
|
||||
//Camera handler stuff
|
||||
//
|
||||
public static CameraHandler cameraHandler = new CameraHandler();
|
||||
|
||||
//
|
||||
//Server scene management
|
||||
//
|
||||
public static RealmManager realmManager;
|
||||
|
||||
//
|
||||
//behavior tree tracking service
|
||||
@ -424,8 +418,6 @@ public class Globals {
|
||||
skyboxColors = new ArrayList<Vector3f>();
|
||||
//load asset manager
|
||||
assetManager = new AssetManager();
|
||||
//realm & data cell manager
|
||||
realmManager = new RealmManager();
|
||||
//game config
|
||||
gameConfigDefault = electrosphere.data.Config.loadDefaultConfig();
|
||||
gameConfigCurrent = gameConfigDefault;
|
||||
@ -622,13 +614,11 @@ public class Globals {
|
||||
*/
|
||||
public static void unloadScene(){
|
||||
Globals.serverState.aiManager.shutdown();
|
||||
Globals.serverState.realmManager.reset();
|
||||
|
||||
Globals.playerManager = new PlayerManager();
|
||||
Globals.clientState = new ClientState();
|
||||
Globals.serverState = new ServerState();
|
||||
if(Globals.realmManager != null){
|
||||
Globals.realmManager.reset();
|
||||
}
|
||||
Globals.dbController.disconnect();
|
||||
Globals.serviceManager.unloadScene();
|
||||
}
|
||||
@ -645,7 +635,6 @@ public class Globals {
|
||||
//Actual globals to destroy
|
||||
Globals.assetManager = null;
|
||||
Globals.elementService = null;
|
||||
Globals.realmManager = null;
|
||||
Globals.clientState = null;
|
||||
Globals.serverState = null;
|
||||
Globals.audioEngine = null;
|
||||
|
||||
@ -185,7 +185,7 @@ public class LoadingUtils {
|
||||
|
||||
//set player world-space coordinates
|
||||
Player playerObject = Globals.playerManager.getFirstPlayer();
|
||||
Realm realm = Globals.realmManager.getRealms().iterator(). next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator(). next();
|
||||
Vector3d spawnPoint = realm.getSpawnPoint();
|
||||
playerObject.setWorldPos(new Vector3i(
|
||||
ServerWorldData.convertRealToChunkSpace(spawnPoint.x),
|
||||
|
||||
@ -9,7 +9,6 @@ import electrosphere.engine.signal.Signal.SignalType;
|
||||
import electrosphere.engine.threads.LabeledThread.ThreadLabel;
|
||||
import electrosphere.renderer.ui.elements.Window;
|
||||
import electrosphere.server.ServerState;
|
||||
import electrosphere.server.datacell.RealmManager;
|
||||
|
||||
/**
|
||||
* Loading thread that returns the client to the main menu
|
||||
@ -63,7 +62,6 @@ public class MainMenuLoading {
|
||||
private static void resetServerState(){
|
||||
Globals.serverState.server.close();
|
||||
Globals.serverState = new ServerState();
|
||||
Globals.realmManager = new RealmManager();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -37,7 +37,7 @@ public class ViewportLoading {
|
||||
|
||||
//
|
||||
//init realm manager with viewport realm
|
||||
Globals.realmManager.createViewportRealm(new Vector3d(0,0,0), new Vector3d(16,16,16));
|
||||
Globals.serverState.realmManager.createViewportRealm(new Vector3d(0,0,0), new Vector3d(16,16,16));
|
||||
|
||||
//
|
||||
//connect client to server
|
||||
@ -57,7 +57,7 @@ public class ViewportLoading {
|
||||
}
|
||||
//add player to viewport realm
|
||||
Player localPlayer = Globals.playerManager.getFirstPlayer();
|
||||
Globals.realmManager.first().getDataCellManager().addPlayerToRealm(localPlayer);
|
||||
Globals.serverState.realmManager.first().getDataCellManager().addPlayerToRealm(localPlayer);
|
||||
|
||||
//initialize the "real" objects simulation
|
||||
LoadingUtils.initMicroSimulation();
|
||||
|
||||
@ -149,8 +149,8 @@ public class ThreadManager {
|
||||
Globals.serverState.server.close();
|
||||
}
|
||||
|
||||
if(Globals.realmManager != null && Globals.realmManager.getRealms() != null){
|
||||
Globals.realmManager.reset();
|
||||
if(Globals.serverState.realmManager != null && Globals.serverState.realmManager.getRealms() != null){
|
||||
Globals.serverState.realmManager.reset();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -38,7 +38,7 @@ public class EntityCreationUtils {
|
||||
//register to global entity id lookup table
|
||||
EntityLookupUtils.registerServerEntity(rVal);
|
||||
//assign to realm
|
||||
Globals.realmManager.mapEntityToRealm(rVal, realm);
|
||||
Globals.serverState.realmManager.mapEntityToRealm(rVal, realm);
|
||||
//init data cell if it doesn't exist
|
||||
ServerDataCell cell = realm.getDataCellManager().getDataCellAtPoint(position);
|
||||
if(cell == null){
|
||||
@ -71,7 +71,7 @@ public class EntityCreationUtils {
|
||||
//register to global entity id lookup table
|
||||
EntityLookupUtils.registerServerEntity(rVal);
|
||||
//assign to realm
|
||||
Globals.realmManager.mapEntityToRealm(rVal, realm);
|
||||
Globals.serverState.realmManager.mapEntityToRealm(rVal, realm);
|
||||
//init data cell if it doesn't exist
|
||||
ServerDataCell cell = realm.getInventoryCell();
|
||||
//If a server data cell was not created, this is considered illegal state
|
||||
|
||||
@ -39,8 +39,8 @@ public class EntityUtils {
|
||||
Globals.clientState.clientSceneWrapper.deregisterTranslationMapping(e);
|
||||
}
|
||||
//remove from all server classes
|
||||
if(Globals.realmManager != null){
|
||||
Realm realm = Globals.realmManager.getEntityRealm(e);
|
||||
if(Globals.serverState.realmManager != null){
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(e);
|
||||
if(realm != null){
|
||||
//get data cell
|
||||
ServerDataCell dataCell = Globals.serverState.entityDataCellMapper.getEntityDataCell(e);
|
||||
@ -48,7 +48,7 @@ public class EntityUtils {
|
||||
dataCell.getScene().deregisterEntity(e);
|
||||
}
|
||||
}
|
||||
Globals.realmManager.removeEntity(e);
|
||||
Globals.serverState.realmManager.removeEntity(e);
|
||||
}
|
||||
Globals.serverState.entityDataCellMapper.ejectEntity(e);
|
||||
EntityLookupUtils.removeEntity(e);
|
||||
|
||||
@ -69,7 +69,7 @@ public class ServerEntityUtils {
|
||||
if(AttachUtils.getParent(entity) != null){
|
||||
throw new Error("Trying to reposition attached entity!");
|
||||
}
|
||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
ServerWorldData worldDat = realm.getServerWorldData();
|
||||
if(
|
||||
position.x < 0 ||
|
||||
@ -122,7 +122,7 @@ public class ServerEntityUtils {
|
||||
if(AttachUtils.hasChildren(entity)){
|
||||
List<Entity> children = AttachUtils.getChildrenList(entity);
|
||||
for(Entity child : children){
|
||||
if(Globals.realmManager.getEntityRealm(child) == null){
|
||||
if(Globals.serverState.realmManager.getEntityRealm(child) == null){
|
||||
continue;
|
||||
}
|
||||
ServerEntityUtils.repositionEntityRecursive(realm, child, position);
|
||||
@ -141,7 +141,7 @@ public class ServerEntityUtils {
|
||||
|
||||
//
|
||||
//get info required to destroy
|
||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
ServerDataCell cell = null;
|
||||
|
||||
//
|
||||
@ -162,7 +162,7 @@ public class ServerEntityUtils {
|
||||
//
|
||||
//detatch from all global tracking
|
||||
HitboxCollectionState.destroyHitboxState(entity,true);
|
||||
Globals.realmManager.removeEntity(entity);
|
||||
Globals.serverState.realmManager.removeEntity(entity);
|
||||
EntityLookupUtils.removeEntity(entity);
|
||||
if(Globals.serverState.aiManager != null){
|
||||
Globals.serverState.aiManager.removeAI(entity);
|
||||
|
||||
@ -88,7 +88,7 @@ public class SceneLoader {
|
||||
Realm realm = null;
|
||||
switch(file.realmDescriptor.getType()){
|
||||
case RealmDescriptor.REALM_DESCRIPTOR_GRIDDED: {
|
||||
realm = Globals.realmManager.createGriddedRealm(serverWorldData,serverContentManager);
|
||||
realm = Globals.serverState.realmManager.createGriddedRealm(serverWorldData,serverContentManager);
|
||||
if(file.loadAllCells()){
|
||||
((GriddedDataCellManager)realm.getDataCellManager()).loadAllCells();
|
||||
}
|
||||
@ -103,7 +103,7 @@ public class SceneLoader {
|
||||
}
|
||||
} break;
|
||||
case RealmDescriptor.REALM_DESCRIPTOR_PROCEDURAL: {
|
||||
realm = Globals.realmManager.createGriddedRealm(serverWorldData,serverContentManager);
|
||||
realm = Globals.serverState.realmManager.createGriddedRealm(serverWorldData,serverContentManager);
|
||||
//generate spawns
|
||||
Vector3d spawnPoint = new Vector3d(serverWorldData.getWorldSizeDiscrete() * ServerTerrainChunk.CHUNK_PLACEMENT_OFFSET / 2);
|
||||
spawnPoint.y = serverWorldData.getServerTerrainManager().getElevation(
|
||||
@ -116,7 +116,7 @@ public class SceneLoader {
|
||||
} break;
|
||||
case RealmDescriptor.REALM_DESCRIPTOR_GENERATION_TESTING: {
|
||||
ServerWorldData newWorldData = ServerWorldData.createGenerationTestWorldData();
|
||||
realm = Globals.realmManager.createGriddedRealm(newWorldData, serverContentManager);
|
||||
realm = Globals.serverState.realmManager.createGriddedRealm(newWorldData, serverContentManager);
|
||||
} break;
|
||||
default: {
|
||||
throw new Error("Unhandled case! " + file.realmDescriptor.getType());
|
||||
|
||||
@ -418,7 +418,7 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
// EntityUtils.getRotation(currentEntity).rotationTo(MathUtils.ORIGIN_VECTORF, new Vector3f((float)facingAngle.x,(float)facingAngle.y,(float)facingAngle.z)).mul(parentActor.getBoneRotation(targetBone)).normalize();
|
||||
}
|
||||
Vector3f initialVector = new Vector3f((float)movementVector.x,(float)movementVector.y,(float)movementVector.z).normalize();
|
||||
Realm parentRealm = Globals.realmManager.getEntityRealm(parent);
|
||||
Realm parentRealm = Globals.serverState.realmManager.getEntityRealm(parent);
|
||||
ProjectileUtils.serverSpawnBasicProjectile(parentRealm, projectileToFire, spawnPosition, arrowRotation, 750, initialVector, 0.03f);
|
||||
projectileToFire = null;
|
||||
}
|
||||
|
||||
@ -43,7 +43,7 @@ public class ShooterTree implements BehaviorTree {
|
||||
Vector3d parentPosition = EntityUtils.getPosition(parent);
|
||||
Vector3d movementDir = CreatureUtils.getFacingVector(parent);
|
||||
if(EntityLookupUtils.isServerEntity(parent)){
|
||||
Realm parentRealm = Globals.realmManager.getEntityRealm(parent);
|
||||
Realm parentRealm = Globals.serverState.realmManager.getEntityRealm(parent);
|
||||
ProjectileUtils.serverSpawnProjectile(parentRealm, "missile1", parentPosition, new Vector3d(movementDir),parent);
|
||||
} else {
|
||||
ProjectileUtils.clientSpawnProjectile("missile1", parentPosition, new Vector3d(movementDir),parent);
|
||||
|
||||
@ -104,7 +104,7 @@ public class ServerEquipState implements BehaviorTree {
|
||||
if(!hasEquipped && targetIsItem && itemIsInPointWhitelist){
|
||||
//hydrate inventory item
|
||||
String itemType = ItemUtils.getType(inInventoryEntity);
|
||||
Realm realm = Globals.realmManager.getEntityRealm(parent);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(parent);
|
||||
Entity inWorldItem = ItemUtils.serverSpawnBasicItem(realm,new Vector3d(0,0,0),itemType);
|
||||
//bind in world with in inventory
|
||||
ItemUtils.setRealWorldEntity(inInventoryEntity, inWorldItem);
|
||||
@ -131,7 +131,7 @@ public class ServerEquipState implements BehaviorTree {
|
||||
);
|
||||
//make uncollidable
|
||||
if(PhysicsEntityUtils.containsDBody(inWorldItem) && inWorldItem.containsKey(EntityDataStrings.PHYSICS_COLLIDABLE)){
|
||||
Realm inWorldRealm = Globals.realmManager.getEntityRealm(inWorldItem);
|
||||
Realm inWorldRealm = Globals.serverState.realmManager.getEntityRealm(inWorldItem);
|
||||
inWorldRealm.getCollisionEngine().destroyPhysics(inWorldItem);
|
||||
}
|
||||
//make untargetable
|
||||
@ -150,7 +150,7 @@ public class ServerEquipState implements BehaviorTree {
|
||||
AttachUtils.getEquipPointRotationOffset(point.getOffsetRotationThirdPerson())
|
||||
);
|
||||
if(PhysicsEntityUtils.containsDBody(inWorldItem) && inWorldItem.containsKey(EntityDataStrings.PHYSICS_COLLIDABLE)){
|
||||
Realm inWorldRealm = Globals.realmManager.getEntityRealm(inWorldItem);
|
||||
Realm inWorldRealm = Globals.serverState.realmManager.getEntityRealm(inWorldItem);
|
||||
inWorldRealm.getCollisionEngine().destroyPhysics(inWorldItem);
|
||||
}
|
||||
ServerEntityTagUtils.removeTagFromEntity(inWorldItem, EntityTags.TARGETABLE);
|
||||
|
||||
@ -134,7 +134,7 @@ public class ServerToolbarState implements BehaviorTree {
|
||||
String equipItemClass = ItemUtils.getEquipClass(inInventoryEntity);
|
||||
//hydrate inventory item
|
||||
String itemType = ItemUtils.getType(inInventoryEntity);
|
||||
Realm realm = Globals.realmManager.getEntityRealm(parent);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(parent);
|
||||
realWorldItem = ItemUtils.serverSpawnBasicItem(realm,new Vector3d(parentPos),itemType);
|
||||
//bind in world with in inventory
|
||||
ItemUtils.setRealWorldEntity(inInventoryEntity, realWorldItem);
|
||||
@ -177,7 +177,7 @@ public class ServerToolbarState implements BehaviorTree {
|
||||
);
|
||||
//make uncollidable
|
||||
if(PhysicsEntityUtils.containsDBody(realWorldItem) && realWorldItem.containsKey(EntityDataStrings.PHYSICS_COLLIDABLE)){
|
||||
Realm inWorldRealm = Globals.realmManager.getEntityRealm(realWorldItem);
|
||||
Realm inWorldRealm = Globals.serverState.realmManager.getEntityRealm(realWorldItem);
|
||||
inWorldRealm.getCollisionEngine().destroyPhysics(realWorldItem);
|
||||
}
|
||||
//make untargetable
|
||||
@ -195,7 +195,7 @@ public class ServerToolbarState implements BehaviorTree {
|
||||
AttachUtils.getEquipPointRotationOffset(targetPoint.getOffsetRotationThirdPerson())
|
||||
);
|
||||
if(PhysicsEntityUtils.containsDBody(realWorldItem) && realWorldItem.containsKey(EntityDataStrings.PHYSICS_COLLIDABLE)){
|
||||
Realm inWorldRealm = Globals.realmManager.getEntityRealm(realWorldItem);
|
||||
Realm inWorldRealm = Globals.serverState.realmManager.getEntityRealm(realWorldItem);
|
||||
inWorldRealm.getCollisionEngine().destroyPhysics(realWorldItem);
|
||||
}
|
||||
ServerEntityTagUtils.removeTagFromEntity(realWorldItem, EntityTags.TARGETABLE);
|
||||
|
||||
@ -70,7 +70,7 @@ public class ServerDoorState implements BehaviorTree {
|
||||
doorData.getOpening(),
|
||||
() -> {
|
||||
this.setState(DoorState.OPEN);
|
||||
Realm parentRealm = Globals.realmManager.getEntityRealm(this.parent);
|
||||
Realm parentRealm = Globals.serverState.realmManager.getEntityRealm(this.parent);
|
||||
parentRealm.getCollisionEngine().destroyPhysics(this.parent);
|
||||
}
|
||||
),
|
||||
@ -84,7 +84,7 @@ public class ServerDoorState implements BehaviorTree {
|
||||
doorData.getClosing(),
|
||||
() -> {
|
||||
this.setState(DoorState.CLOSED);
|
||||
Realm parentRealm = Globals.realmManager.getEntityRealm(this.parent);
|
||||
Realm parentRealm = Globals.serverState.realmManager.getEntityRealm(this.parent);
|
||||
Vector3d pos = EntityUtils.getPosition(this.parent);
|
||||
PhysicsEntityUtils.serverAttachCollidableTemplate(parentRealm, this.parent, PhysicsEntityUtils.getPhysicsTemplate(this.parent));
|
||||
ServerEntityUtils.repositionEntity(this.parent, pos);
|
||||
|
||||
@ -626,7 +626,7 @@ public class HitboxCollectionState {
|
||||
protected void destroy(boolean isServer){
|
||||
CollisionEngine engine = null;
|
||||
if(isServer){
|
||||
Realm realm = Globals.realmManager.getEntityRealm(parent);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(parent);
|
||||
if(realm != null){
|
||||
engine = realm.getHitboxManager().getCollisionEngine();
|
||||
}
|
||||
|
||||
@ -511,7 +511,7 @@ public class ServerInventoryState implements BehaviorTree {
|
||||
Entity realWorldItem = ItemUtils.getRealWorldEntity(item);
|
||||
if(realWorldItem != null){
|
||||
//Tell players to unequip the item
|
||||
Realm realm = Globals.realmManager.getEntityRealm(realWorldItem);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(realWorldItem);
|
||||
if(realm != null){
|
||||
//get closest chunk
|
||||
ServerDataCell dataCell = Globals.serverState.entityDataCellMapper.getEntityDataCell(realWorldItem);
|
||||
@ -527,7 +527,7 @@ public class ServerInventoryState implements BehaviorTree {
|
||||
}
|
||||
ServerInventoryState.serverRemoveItemFromInventories(creature, item);
|
||||
//get parent realm
|
||||
Realm realm = Globals.realmManager.getEntityRealm(creature);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(creature);
|
||||
//find "in front of creature"
|
||||
Vector3d dropSpot = new Vector3d(EntityUtils.getPosition(creature));
|
||||
if(CreatureUtils.getFacingVector(creature) != null){
|
||||
|
||||
@ -144,7 +144,7 @@ public class ServerLifeTree implements BehaviorTree {
|
||||
}
|
||||
Random random = new Random();
|
||||
Vector3d position = new Vector3d(EntityUtils.getPosition(parent));
|
||||
Realm realm = Globals.realmManager.getEntityRealm(parent);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(parent);
|
||||
for(LootTicket ticket : lootPool.getTickets()){
|
||||
if(random.nextDouble() <= ticket.getRarity()){
|
||||
int numToGen = random.nextInt(ticket.getMinQuantity(), ticket.getMaxQuantity()+1);
|
||||
|
||||
@ -35,7 +35,7 @@ public class ServerAlwaysUprightTree implements BehaviorTree {
|
||||
public void simulate(float deltaTime) {
|
||||
DBody body = PhysicsEntityUtils.getDBody(parent);
|
||||
if(body != null){
|
||||
Realm realm = Globals.realmManager.getEntityRealm(parent);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(parent);
|
||||
Vector3d position = EntityUtils.getPosition(parent);
|
||||
Quaterniond sourceRotation = new Quaterniond(EntityUtils.getRotation(parent));
|
||||
Vector3d linearVelocity = PhysicsUtils.odeVecToJomlVec(body.getLinearVel());
|
||||
|
||||
@ -52,7 +52,7 @@ public class CollisionObjUtils {
|
||||
public static void serverAttachCollisionObjectToEntity(Entity entity, DBody collisionObject, float mass, String collidableType){
|
||||
Vector3d position = EntityUtils.getPosition(entity);
|
||||
Collidable collidable = new Collidable(entity, collidableType, true);
|
||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
realm.getCollisionEngine().registerCollisionObject(collisionObject, collidable);
|
||||
|
||||
PhysicsEntityUtils.setDBody(entity, collisionObject);
|
||||
@ -74,7 +74,7 @@ public class CollisionObjUtils {
|
||||
EntityUtils.getPosition(e).set(position);
|
||||
Quaterniond rotation = EntityUtils.getRotation(e);
|
||||
DBody body = PhysicsEntityUtils.getDBody(e);
|
||||
CollisionEngine collisionEngine = Globals.realmManager.getEntityRealm(e).getCollisionEngine();
|
||||
CollisionEngine collisionEngine = Globals.serverState.realmManager.getEntityRealm(e).getCollisionEngine();
|
||||
if(body != null){
|
||||
PhysicsUtils.setRigidBodyTransform(collisionEngine, position, rotation, body);
|
||||
}
|
||||
|
||||
@ -297,7 +297,7 @@ public class CreatureUtils {
|
||||
ServerEntityUtils.initiallyPositionEntity(realm,rVal,position);
|
||||
|
||||
//error checking
|
||||
if(Globals.realmManager.getEntityRealm(rVal) == null){
|
||||
if(Globals.serverState.realmManager.getEntityRealm(rVal) == null){
|
||||
LoggerInterface.loggerEngine.ERROR(new IllegalStateException("Created creature without it being assigned to a realm!"));
|
||||
}
|
||||
|
||||
|
||||
@ -291,7 +291,7 @@ public class ItemUtils {
|
||||
ServerEntityUtils.initiallyPositionEntity(realm,rVal,correctedPosition);
|
||||
|
||||
//error checking
|
||||
if(Globals.realmManager.getEntityRealm(rVal) == null){
|
||||
if(Globals.serverState.realmManager.getEntityRealm(rVal) == null){
|
||||
LoggerInterface.loggerEngine.ERROR(new IllegalStateException("Created item without it being assigned to a realm!"));
|
||||
}
|
||||
|
||||
@ -570,7 +570,7 @@ public class ItemUtils {
|
||||
public static Entity serverRecreateContainerItem(Entity item, Entity containingParent){
|
||||
if(ItemUtils.isItem(item)){
|
||||
Item itemData = Globals.gameConfigCurrent.getItemMap().getItem(ItemUtils.getType(item));
|
||||
Realm realm = Globals.realmManager.getEntityRealm(containingParent);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(containingParent);
|
||||
Entity rVal = EntityCreationUtils.createServerInventoryEntity(realm);
|
||||
|
||||
//apply normal item transforms
|
||||
@ -580,7 +580,7 @@ public class ItemUtils {
|
||||
ItemUtils.serverApplyInInventoryItemTransforms(itemData, rVal, containingParent);
|
||||
|
||||
//error checking
|
||||
if(Globals.realmManager.getEntityRealm(rVal) == null){
|
||||
if(Globals.serverState.realmManager.getEntityRealm(rVal) == null){
|
||||
LoggerInterface.loggerEngine.ERROR(new IllegalStateException("Created item without it being assigned to a realm!"));
|
||||
}
|
||||
if(Globals.serverState.entityDataCellMapper.getEntityDataCell(rVal) == null){
|
||||
@ -608,7 +608,7 @@ public class ItemUtils {
|
||||
if(naturalInventory == null && toolbarInventory == null){
|
||||
throw new Error("Trying to store an item in an entity with no inventories!");
|
||||
}
|
||||
Realm realm = Globals.realmManager.getEntityRealm(parent);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(parent);
|
||||
|
||||
|
||||
|
||||
@ -625,7 +625,7 @@ public class ItemUtils {
|
||||
naturalInventory.addItem(rVal);
|
||||
|
||||
//error checking
|
||||
if(Globals.realmManager.getEntityRealm(rVal) == null){
|
||||
if(Globals.serverState.realmManager.getEntityRealm(rVal) == null){
|
||||
LoggerInterface.loggerEngine.ERROR(new IllegalStateException("Created item without it being assigned to a realm!"));
|
||||
}
|
||||
if(Globals.serverState.entityDataCellMapper.getEntityDataCell(rVal) == null){
|
||||
|
||||
@ -116,7 +116,7 @@ public class BlockChunkEntity {
|
||||
public static void serverCreateBlockChunkEntity(Entity entity, BlockMeshData blockChunkData){
|
||||
if(blockChunkData.getVertices().length > 0){
|
||||
PhysicsEntityUtils.serverAttachMultiShapeTriGeomRigidBody(entity, blockChunkData);
|
||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
DBody terrainBody = PhysicsEntityUtils.getDBody(entity);
|
||||
Vector3d entityPos = EntityUtils.getPosition(entity);
|
||||
Quaterniond entityRot = EntityUtils.getRotation(entity);
|
||||
|
||||
@ -129,7 +129,7 @@ public class TerrainChunk {
|
||||
*/
|
||||
public static void serverCreateTerrainChunkEntity(Entity entity, TerrainChunkData data){
|
||||
if(data.getVertices().length > 0){
|
||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
if(realm != null){
|
||||
PhysicsEntityUtils.serverAttachTriGeomRigidBody(entity, data);
|
||||
DBody terrainBody = PhysicsEntityUtils.getDBody(entity);
|
||||
@ -141,7 +141,7 @@ public class TerrainChunk {
|
||||
}
|
||||
// ServerEntityUtils.initiallyPositionEntity(realm, rVal, position);
|
||||
// physicsObject = PhysicsUtils.attachTerrainRigidBody(physicsEntity,heightmap,true);
|
||||
// Realm realm = Globals.realmManager.getEntityRealm(physicsEntity);
|
||||
// Realm realm = Globals.serverState.realmManager.getEntityRealm(physicsEntity);
|
||||
// realm.getCollisionEngine().registerPhysicsEntity(physicsEntity);
|
||||
|
||||
}
|
||||
|
||||
@ -49,14 +49,14 @@ public class PlayerManager {
|
||||
* @return The realm if it exists, null otherwise
|
||||
*/
|
||||
public Realm getPlayerRealm(Player player){
|
||||
if(Globals.realmManager.getRealms().size() == 1){
|
||||
return Globals.realmManager.first();
|
||||
if(Globals.serverState.realmManager.getRealms().size() == 1){
|
||||
return Globals.serverState.realmManager.first();
|
||||
}
|
||||
Entity playerEntity = player.getPlayerEntity();
|
||||
if(playerEntity == null){
|
||||
throw new IllegalStateException("Trying to get realm of player who does not have an entity assigned!");
|
||||
}
|
||||
return Globals.realmManager.getEntityRealm(playerEntity);
|
||||
return Globals.serverState.realmManager.getEntityRealm(playerEntity);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -70,7 +70,7 @@ public class CharacterProtocol implements ServerProtocolTemplate<CharacterMessag
|
||||
ObjectTemplate template = Utilities.deserialize(message.getdata(), ObjectTemplate.class);
|
||||
if(template != null){
|
||||
Character charaData = Globals.characterService.createCharacter(template, connectionHandler.getPlayer().getDBID());
|
||||
charaData.setPos(Globals.realmManager.first().getSpawnPoint());
|
||||
charaData.setPos(Globals.serverState.realmManager.first().getSpawnPoint());
|
||||
connectionHandler.setCreatureTemplate(Utilities.deserialize(message.getdata(), ObjectTemplate.class));
|
||||
connectionHandler.setCharacterId(charaData.getId());
|
||||
connectionHandler.addMessagetoOutgoingQueue(CharacterMessage.constructResponseCreateCharacterSuccessMessage());
|
||||
@ -200,8 +200,8 @@ public class CharacterProtocol implements ServerProtocolTemplate<CharacterMessag
|
||||
Player player = connectionHandler.getPlayer();
|
||||
Entity playerEntity = player.getPlayerEntity();
|
||||
Vector3d position = EntityUtils.getPosition(playerEntity);
|
||||
Globals.realmManager.getEntityRealm(playerEntity).registerSpawnPoint(position);
|
||||
Globals.realmManager.getEntityRealm(playerEntity).getSpawnPoint().set(position);
|
||||
Globals.serverState.realmManager.getEntityRealm(playerEntity).registerSpawnPoint(position);
|
||||
Globals.serverState.realmManager.getEntityRealm(playerEntity).getSpawnPoint().set(position);
|
||||
ServerEntityUtils.destroyEntity(playerEntity);
|
||||
|
||||
//spawn the new one
|
||||
|
||||
@ -439,7 +439,7 @@ public class TerrainProtocol implements ServerProtocolTemplate<TerrainMessage> {
|
||||
*/
|
||||
static void attemptUseTerrainEditPalette(ServerConnectionHandler connectionHandler, TerrainMessage message){
|
||||
Player player = Globals.playerManager.getPlayerFromId(connectionHandler.getPlayerId());
|
||||
Realm realm = Globals.realmManager.getPlayerRealm(player);
|
||||
Realm realm = Globals.serverState.realmManager.getPlayerRealm(player);
|
||||
Vector3d location = new Vector3d(message.getrealLocationX(), message.getrealLocationY(), message.getrealLocationZ());
|
||||
TerrainEditing.editTerrain(realm, location, message.getvalue(), message.getterrainValue(), message.getterrainWeight());
|
||||
}
|
||||
@ -451,7 +451,7 @@ public class TerrainProtocol implements ServerProtocolTemplate<TerrainMessage> {
|
||||
*/
|
||||
static void attemptDestroyTerrain(ServerConnectionHandler connectionHandler, TerrainMessage message){
|
||||
Player player = Globals.playerManager.getPlayerFromId(connectionHandler.getPlayerId());
|
||||
Realm realm = Globals.realmManager.getPlayerRealm(player);
|
||||
Realm realm = Globals.serverState.realmManager.getPlayerRealm(player);
|
||||
Vector3d location = new Vector3d(message.getrealLocationX(), message.getrealLocationY(), message.getrealLocationZ());
|
||||
TerrainEditing.destroyTerrain(realm, player.getPlayerEntity(), location, message.getvalue(), message.getterrainWeight());
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ public class DebugContentPipeline implements RenderPipeline {
|
||||
Model hitboxModel;
|
||||
int serverIdForClientEntity = Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.clientState.playerEntity.getId());
|
||||
Entity serverPlayerEntity = EntityLookupUtils.getEntityById(serverIdForClientEntity);
|
||||
Realm playerRealm = Globals.realmManager.getEntityRealm(serverPlayerEntity);
|
||||
Realm playerRealm = Globals.serverState.realmManager.getEntityRealm(serverPlayerEntity);
|
||||
List<HitboxCollectionState> hitboxStates = new LinkedList<HitboxCollectionState>(playerRealm.getHitboxManager().getAllHitboxes());
|
||||
for(HitboxCollectionState hitboxState : hitboxStates){
|
||||
for(DGeom geom : hitboxState.getGeometries()){
|
||||
|
||||
@ -50,9 +50,7 @@ public class MainServerFunctions {
|
||||
//Simulation
|
||||
Globals.profiler.beginCpuSample("MainServerFunctions.simulate - Realm simulation");
|
||||
LoggerInterface.loggerEngine.DEBUG_LOOP("Begin server realm simulation");
|
||||
if(Globals.realmManager != null){
|
||||
Globals.realmManager.simulate();
|
||||
}
|
||||
Globals.serverState.realmManager.simulate();
|
||||
Globals.profiler.endCpuSample();
|
||||
|
||||
Globals.profiler.endCpuSample();
|
||||
|
||||
@ -4,6 +4,7 @@ import electrosphere.net.server.Server;
|
||||
import electrosphere.net.synchronization.server.ServerSynchronizationManager;
|
||||
import electrosphere.server.ai.AIManager;
|
||||
import electrosphere.server.datacell.EntityDataCellMapper;
|
||||
import electrosphere.server.datacell.RealmManager;
|
||||
|
||||
/**
|
||||
* Server state
|
||||
@ -23,11 +24,16 @@ public class ServerState {
|
||||
/**
|
||||
* ai manager
|
||||
*/
|
||||
public AIManager aiManager = new AIManager(0);
|
||||
public final AIManager aiManager = new AIManager(0);
|
||||
|
||||
/**
|
||||
* The entity->datacell mapper
|
||||
*/
|
||||
public final EntityDataCellMapper entityDataCellMapper = new EntityDataCellMapper();
|
||||
|
||||
/**
|
||||
* Realm manager
|
||||
*/
|
||||
public final RealmManager realmManager = new RealmManager();
|
||||
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public class MeleeTargetingNode implements AITreeNode {
|
||||
*/
|
||||
private Entity searchForTarget(Entity parent, Blackboard blackboard){
|
||||
Vector3d position = EntityUtils.getPosition(parent);
|
||||
Realm realm = Globals.realmManager.getEntityRealm(parent);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(parent);
|
||||
for(Entity current : DataCellSearchUtils.getEntitiesWithTagAroundLocation(realm,position,EntityTags.LIFE_STATE)){
|
||||
if(current != parent){
|
||||
Vector3d potentialTargetPosition = EntityUtils.getPosition(current);
|
||||
@ -72,7 +72,7 @@ public class MeleeTargetingNode implements AITreeNode {
|
||||
*/
|
||||
private boolean targetIsValid(Entity entity){
|
||||
return
|
||||
Globals.realmManager.getEntityRealm(entity) != null
|
||||
Globals.serverState.realmManager.getEntityRealm(entity) != null
|
||||
;
|
||||
}
|
||||
|
||||
|
||||
@ -19,7 +19,7 @@ public class HasShelter implements AITreeNode {
|
||||
public AITreeNodeResult evaluate(Entity entity, Blackboard blackboard) {
|
||||
ServerCharacterData serverCharacterData = ServerCharacterData.getServerCharacterData(entity);
|
||||
Character character = serverCharacterData.getCharacterData();
|
||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
if(character == null){
|
||||
throw new Error("Character is null");
|
||||
}
|
||||
|
||||
@ -13,7 +13,7 @@ public class MacroDataExists implements AITreeNode {
|
||||
|
||||
@Override
|
||||
public AITreeNodeResult evaluate(Entity entity, Blackboard blackboard) {
|
||||
Realm entityRealm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm entityRealm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
if(entityRealm.getMacroData() == null){
|
||||
return AITreeNodeResult.FAILURE;
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ public class BeginStructureNode implements AITreeNode {
|
||||
public AITreeNodeResult evaluate(Entity entity, Blackboard blackboard) {
|
||||
if(!BeginStructureNode.hasStructureTarget(blackboard)){
|
||||
//requisite data
|
||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
MacroData macroData = realm.getMacroData();
|
||||
Vector3d position = EntityUtils.getPosition(entity);
|
||||
|
||||
|
||||
@ -63,7 +63,7 @@ public class MacroCharacterGoalNode implements AITreeNode {
|
||||
}
|
||||
switch(goal.getType()){
|
||||
case LEAVE_SIM_RANGE: {
|
||||
// Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
// Realm realm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
Vector3d entityPos = EntityUtils.getPosition(entity);
|
||||
Vector3d offset = new Vector3d(entityPos).add(1000,0,0);
|
||||
// GriddedDataCellManager griddedDataCellManager = (GriddedDataCellManager)realm.getDataCellManager();
|
||||
|
||||
@ -89,7 +89,7 @@ public class PathfindingNode implements AITreeNode {
|
||||
throw new Error("Unsupported target type " + targetRaw);
|
||||
}
|
||||
|
||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
PathfindingManager pathfindingManager = realm.getPathfindingManager();
|
||||
|
||||
Vector3d entityPos = EntityUtils.getPosition(entity);
|
||||
|
||||
@ -48,7 +48,7 @@ public class TargetExploreNode implements AITreeNode {
|
||||
if(!blackboard.has(targetKey)){
|
||||
Vector3d entPos = new Vector3d(EntityUtils.getPosition(entity));
|
||||
Random rand = new Random();
|
||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
Vector3d offsetVec = new Vector3d(rand.nextDouble(),0,rand.nextDouble()).normalize().mul(OFFSET_DIST);
|
||||
targetPos = entPos.add(offsetVec);
|
||||
//solve for height via world data
|
||||
|
||||
@ -31,7 +31,7 @@ public class SolveBuildMaterialNode implements AITreeNode {
|
||||
return AITreeNodeResult.FAILURE;
|
||||
}
|
||||
//solve for repairable block
|
||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
Vector3i repairPos = StructureRepairUtils.getRepairablePosition(realm, struct);
|
||||
|
||||
//get the id of item entity type for the block we need
|
||||
|
||||
@ -26,7 +26,7 @@ public class NearbyEntityService implements AIService {
|
||||
public void exec(){
|
||||
for(AI ai : Globals.serverState.aiManager.getAIList()){
|
||||
Entity entity = ai.getParent();
|
||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
if(realm != null){
|
||||
Vector3d position = EntityUtils.getPosition(entity);
|
||||
Collection<Entity> nearbyEntities = realm.getDataCellManager().entityLookup(position, NearbyEntityService.SEARCH_DIST);
|
||||
|
||||
@ -174,7 +174,7 @@ public class Realm {
|
||||
*/
|
||||
public void initializeServerSideEntity(Entity entity, ServerDataCell cell){
|
||||
//register entity to this realm
|
||||
Globals.realmManager.mapEntityToRealm(entity, this);
|
||||
Globals.serverState.realmManager.mapEntityToRealm(entity, this);
|
||||
//add the entity to the cell
|
||||
cell.getScene().registerEntity(entity);
|
||||
//send the entity to all players
|
||||
|
||||
@ -214,7 +214,7 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
|
||||
* @param player The player
|
||||
*/
|
||||
public void addPlayerToRealm(Player player){
|
||||
Globals.realmManager.setPlayerRealm(player, parent);
|
||||
Globals.serverState.realmManager.setPlayerRealm(player, parent);
|
||||
int playerSimulationRadius = player.getSimulationRadius();
|
||||
Vector3i worldPos = player.getWorldPos();
|
||||
Vector3i tempVec = new Vector3i();
|
||||
|
||||
@ -93,7 +93,7 @@ public class PhysicsDataCell {
|
||||
this.blockPhysicsEntity.putData(EntityDataStrings.TERRAIN_IS_TERRAIN, true);
|
||||
// //then actually perform the attach
|
||||
// physicsObject = PhysicsUtils.attachTerrainRigidBody(physicsEntity,heightmap,true);
|
||||
// Realm realm = Globals.realmManager.getEntityRealm(physicsEntity);
|
||||
// Realm realm = Globals.serverState.realmManager.getEntityRealm(physicsEntity);
|
||||
// realm.getCollisionEngine().registerPhysicsEntity(physicsEntity);
|
||||
}
|
||||
|
||||
@ -101,7 +101,7 @@ public class PhysicsDataCell {
|
||||
* Destroys the physics for this data cell
|
||||
*/
|
||||
public void destroyPhysics(){
|
||||
Realm realm = Globals.realmManager.getEntityRealm(physicsEntity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(physicsEntity);
|
||||
realm.getCollisionEngine().destroyPhysics(physicsEntity);
|
||||
realm.getCollisionEngine().destroyPhysics(blockPhysicsEntity);
|
||||
}
|
||||
|
||||
@ -24,7 +24,7 @@ public class DataCellSearchUtils {
|
||||
if(entity == null){
|
||||
LoggerInterface.loggerEngine.ERROR(new IllegalArgumentException("Trying to get entity data cell of null!"));
|
||||
}
|
||||
Realm realm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm realm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
if(realm == null){
|
||||
LoggerInterface.loggerEngine.ERROR(new IllegalArgumentException("Trying to get entity data cell of an entity that is not assigned to a realm!"));
|
||||
return null;
|
||||
|
||||
@ -27,7 +27,7 @@ public class PlayerCharacterCreation {
|
||||
*/
|
||||
public static Entity spawnPlayerCharacter(ServerConnectionHandler connectionHandler){
|
||||
Player playerObject = Globals.playerManager.getPlayerFromId(connectionHandler.getPlayerId());
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
|
||||
//
|
||||
//get template
|
||||
@ -59,7 +59,7 @@ public class PlayerCharacterCreation {
|
||||
|
||||
//
|
||||
//error checking
|
||||
Realm searchedRealm = Globals.realmManager.getEntityRealm(newPlayerEntity);
|
||||
Realm searchedRealm = Globals.serverState.realmManager.getEntityRealm(newPlayerEntity);
|
||||
if(searchedRealm == null){
|
||||
LoggerInterface.loggerEngine.ERROR(new IllegalArgumentException("Player entity created but not attached to a realm!"));
|
||||
}
|
||||
|
||||
@ -7,7 +7,7 @@ public class VirtualStructureUtils {
|
||||
|
||||
|
||||
// public static Structure placeStructureAtPoint(float posX, float posY, float posZ, String type){
|
||||
// Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
// Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
// int worldX = realm.getServerWorldData().convertRealToChunkSpace(posX);
|
||||
// int worldY = realm.getServerWorldData().convertRealToChunkSpace(posY);
|
||||
// Structure rVal = new Structure(worldX,worldY,posX,posY,type);
|
||||
|
||||
@ -29,7 +29,7 @@ public class BlockActions {
|
||||
* @param editSize The size of the edit
|
||||
*/
|
||||
public static void editBlockArea(Entity creature, Vector3i chunkPos, Vector3i blockPos, short blockType, int editSize){
|
||||
Realm playerRealm = Globals.realmManager.getEntityRealm(creature);
|
||||
Realm playerRealm = Globals.serverState.realmManager.getEntityRealm(creature);
|
||||
if(ServerToolbarState.hasServerToolbarState(creature)){
|
||||
//check that we have the block equipped
|
||||
ServerToolbarState serverToolbarState = ServerToolbarState.getServerToolbarState(creature);
|
||||
@ -59,7 +59,7 @@ public class BlockActions {
|
||||
* @param fabPath The path to the fab itself
|
||||
*/
|
||||
public static void placeFab(Entity creature, Vector3i chunkPos, Vector3i blockPos, int blockRotation, String fabPath){
|
||||
Realm playerRealm = Globals.realmManager.getEntityRealm(creature);
|
||||
Realm playerRealm = Globals.serverState.realmManager.getEntityRealm(creature);
|
||||
ServerBlockEditing.placeBlockFab(playerRealm, chunkPos, blockPos, blockRotation, fabPath);
|
||||
ServerChargeState.attemptRemoveCharges(creature, 1);
|
||||
if(CreatureUtils.hasControllerPlayerId(creature)){
|
||||
|
||||
@ -100,7 +100,7 @@ public class PlayerActions {
|
||||
*/
|
||||
private static void secondaryUsage(Entity playerEntity, Entity itemEnt, Item item, InventoryMessage message){
|
||||
ItemUsage secondaryUsage = item.getSecondaryUsage();
|
||||
Realm playerRealm = Globals.realmManager.getEntityRealm(playerEntity);
|
||||
Realm playerRealm = Globals.serverState.realmManager.getEntityRealm(playerEntity);
|
||||
|
||||
//entity spawning
|
||||
if(secondaryUsage.getSpawnEntityId() != null){
|
||||
|
||||
@ -163,7 +163,7 @@ public class SaveUtils {
|
||||
FileUtils.serializeObjectToSavePath(saveName, "/save.json", Globals.currentSave);
|
||||
|
||||
//write server structures
|
||||
Globals.realmManager.save(saveName);
|
||||
Globals.serverState.realmManager.save(saveName);
|
||||
|
||||
//store character service
|
||||
Globals.characterService.saveAll();
|
||||
|
||||
@ -16,7 +16,7 @@ public class ServerScriptUtils {
|
||||
* @param args The args provided with the signal
|
||||
*/
|
||||
public static void fireSignalOnEntity(Entity entity, String signal, Object ... args){
|
||||
Realm entityRealm = Globals.realmManager.getEntityRealm(entity);
|
||||
Realm entityRealm = Globals.serverState.realmManager.getEntityRealm(entity);
|
||||
|
||||
Object finalArgs[] = new Object[args.length + 1];
|
||||
finalArgs[0] = entity.getId();
|
||||
|
||||
@ -29,7 +29,7 @@ public class GlobalsTests {
|
||||
Globals.initGlobals();
|
||||
Globals.unloadScene();
|
||||
assertNotNull(Globals.assetManager);
|
||||
assertNotNull(Globals.realmManager);
|
||||
assertNotNull(Globals.serverState.realmManager);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -6,8 +6,8 @@ import org.joml.Vector3d;
|
||||
|
||||
import electrosphere.test.annotations.UnitTest;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.server.ServerState;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
import electrosphere.server.datacell.RealmManager;
|
||||
|
||||
/**
|
||||
* Unit tests for the server entity utils
|
||||
@ -17,15 +17,15 @@ public class ServerEntityUtilsUnitTests {
|
||||
@UnitTest
|
||||
public void destroyEntity_ValidEntity_NoRealm(){
|
||||
//setup
|
||||
Globals.realmManager = new RealmManager();
|
||||
Realm realm = Globals.realmManager.createViewportRealm(new Vector3d(0,0,0), new Vector3d(1,1,1));
|
||||
Globals.serverState = new ServerState();
|
||||
Realm realm = Globals.serverState.realmManager.createViewportRealm(new Vector3d(0,0,0), new Vector3d(1,1,1));
|
||||
Entity entity = EntityCreationUtils.createServerEntity(realm, new Vector3d());
|
||||
|
||||
//perform action
|
||||
ServerEntityUtils.destroyEntity(entity);
|
||||
|
||||
//verify
|
||||
assertEquals(null, Globals.realmManager.getEntityRealm(entity));
|
||||
assertEquals(null, Globals.serverState.realmManager.getEntityRealm(entity));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -37,22 +37,22 @@ public class SpawnAllEntitiesTests extends EntityTestTemplate {
|
||||
|
||||
CreatureTypeLoader creatureLoader = Globals.gameConfigCurrent.getCreatureTypeLoader();
|
||||
for(CreatureData creature : creatureLoader.getTypes()){
|
||||
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0.1,0.1,0.1), creature.getId(), ObjectTemplate.createDefault(EntityType.CREATURE, creature.getId()));
|
||||
CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0.1,0.1,0.1), creature.getId(), ObjectTemplate.createDefault(EntityType.CREATURE, creature.getId()));
|
||||
}
|
||||
|
||||
ItemDataMap itemMap = Globals.gameConfigCurrent.getItemMap();
|
||||
for(Item item : itemMap.getTypes()){
|
||||
ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0.1,0.1,0.1), item.getId());
|
||||
ItemUtils.serverSpawnBasicItem(Globals.serverState.realmManager.first(), new Vector3d(0.1,0.1,0.1), item.getId());
|
||||
}
|
||||
|
||||
FoliageTypeLoader foliageTypeMap = Globals.gameConfigCurrent.getFoliageMap();
|
||||
for(FoliageType foliage : foliageTypeMap.getTypes()){
|
||||
FoliageUtils.serverSpawnTreeFoliage(Globals.realmManager.first(), new Vector3d(0.1,0.1,0.1), foliage.getId());
|
||||
FoliageUtils.serverSpawnTreeFoliage(Globals.serverState.realmManager.first(), new Vector3d(0.1,0.1,0.1), foliage.getId());
|
||||
}
|
||||
|
||||
CommonEntityMap commonEntityMap = Globals.gameConfigCurrent.getObjectTypeMap();
|
||||
for(CommonEntityType entity : commonEntityMap.getTypes()){
|
||||
CommonEntityUtils.serverSpawnBasicObject(Globals.realmManager.first(), new Vector3d(0.1,0.1,0.1), entity.getId());
|
||||
CommonEntityUtils.serverSpawnBasicObject(Globals.serverState.realmManager.first(), new Vector3d(0.1,0.1,0.1), entity.getId());
|
||||
}
|
||||
|
||||
//wait for entities to propagate across network
|
||||
|
||||
@ -20,7 +20,7 @@ public class SpawningCreaturesTest extends EntityTestTemplate {
|
||||
//must wait on viewport testing, otherwise number of entities isn't going to be correct because the player character is spawning
|
||||
@IntegrationTest
|
||||
public void testSpawnCreature(){
|
||||
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
assertEquals(1, TestEntityUtils.numberOfEntitiesInBox(new Vector3d(-1,-1,-1),new Vector3d(1,1,1)));
|
||||
}
|
||||
|
||||
@ -29,7 +29,7 @@ public class SpawningCreaturesTest extends EntityTestTemplate {
|
||||
public void testSpawnMultipleCreatures(){
|
||||
int numberToSpawn = 100;
|
||||
for(int i = 0; i < numberToSpawn; i++){
|
||||
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
}
|
||||
assertEquals(numberToSpawn, TestEntityUtils.numberOfEntitiesInBox(new Vector3d(-1,-1,-1),new Vector3d(1,1,1)));
|
||||
}
|
||||
|
||||
@ -36,8 +36,8 @@ public class ServerAttackTreeTests extends EntityTestTemplate {
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
|
||||
//spawn on server
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
|
||||
//equip
|
||||
Entity inInventoryItem = ServerInventoryState.attemptStoreItemAnyInventory(creature, katana);
|
||||
@ -71,8 +71,8 @@ public class ServerAttackTreeTests extends EntityTestTemplate {
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
|
||||
//spawn on server
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
|
||||
//equip
|
||||
Entity inInventoryItem = ServerInventoryState.attemptStoreItemAnyInventory(creature, katana);
|
||||
|
||||
@ -26,7 +26,7 @@ public class ClientCollidableTreeTests extends EntityTestTemplate {
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
|
||||
//spawn on server
|
||||
CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
|
||||
//wait for the creature to land
|
||||
TestEngineUtils.simulateFrames(3);
|
||||
|
||||
@ -25,7 +25,7 @@ public class ServerCollidableTreeTests extends EntityTestTemplate {
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
|
||||
//spawn on server
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
|
||||
//wait for the creature to land
|
||||
TestEngineUtils.simulateFrames(3);
|
||||
|
||||
@ -43,8 +43,8 @@ public class ClientEquipStateTests extends EntityTestTemplate {
|
||||
|
||||
//spawn entities
|
||||
ObjectTemplate creatureTemplate = ObjectTemplate.createDefault(EntityType.CREATURE, "human");
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate);
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate);
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
|
||||
//wait for entities to propagate to client
|
||||
TestEngineUtils.simulateFrames(5);
|
||||
@ -95,7 +95,7 @@ public class ClientEquipStateTests extends EntityTestTemplate {
|
||||
//spawn entities
|
||||
TestViewportUtils.spawnPlayerCharacter("human");
|
||||
//TODO: associate creature with player object created for viewport
|
||||
ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
ItemUtils.serverSpawnBasicItem(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
|
||||
//wait for entities to propagate to client
|
||||
TestEngineUtils.simulateFrames(5);
|
||||
|
||||
@ -33,8 +33,8 @@ public class ServerEquipStateTests extends EntityTestTemplate {
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
//spawn entities
|
||||
ObjectTemplate creatureTemplate = ObjectTemplate.createDefault(EntityType.CREATURE, "human");
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate);
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate);
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
|
||||
//equip
|
||||
Entity inInventoryItem = ServerInventoryState.attemptStoreItemAnyInventory(creature, katana);
|
||||
@ -65,9 +65,9 @@ public class ServerEquipStateTests extends EntityTestTemplate {
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
//spawn entities
|
||||
ObjectTemplate creatureTemplate = ObjectTemplate.createDefault(EntityType.CREATURE, "human");
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate);
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
Entity katana2 = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "human", creatureTemplate);
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
Entity katana2 = ItemUtils.serverSpawnBasicItem(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
|
||||
//equip
|
||||
Entity inInventoryItem = ServerInventoryState.attemptStoreItemAnyInventory(creature, katana);
|
||||
|
||||
@ -32,7 +32,7 @@ public class InventoryUtilsTests extends EntityTestTemplate {
|
||||
|
||||
//spawn entities
|
||||
TestEngineUtils.spawnPlayerEntity();
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
|
||||
//wait for entities to propagate to client
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
@ -85,7 +85,7 @@ public class InventoryUtilsTests extends EntityTestTemplate {
|
||||
|
||||
//spawn entities
|
||||
TestEngineUtils.spawnPlayerEntity();
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
Entity katana = ItemUtils.serverSpawnBasicItem(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "Katana2H");
|
||||
|
||||
//wait for entities to propagate to client
|
||||
TestEngineUtils.simulateFrames(1);
|
||||
|
||||
@ -22,7 +22,7 @@ public class ClientFallTreeTests extends EntityTestTemplate {
|
||||
|
||||
@IntegrationTest
|
||||
public void isFalling_AtRest_false(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity clientEntity = TestEngineUtils.getClientEquivalent(serverEntity);
|
||||
|
||||
ClientFallTree clientFallTree = ClientFallTree.getFallTree(clientEntity);
|
||||
@ -31,7 +31,7 @@ public class ClientFallTreeTests extends EntityTestTemplate {
|
||||
|
||||
@IntegrationTest
|
||||
public void isFalling_AfterJump_true(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity clientEntity = TestEngineUtils.getClientEquivalent(serverEntity);
|
||||
|
||||
ClientFallTree clientFallTree = ClientFallTree.getFallTree(clientEntity);
|
||||
@ -44,7 +44,7 @@ public class ClientFallTreeTests extends EntityTestTemplate {
|
||||
|
||||
@IntegrationTest
|
||||
public void isFalling_AfterLand_false(){
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity serverEntity = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity clientEntity = TestEngineUtils.getClientEquivalent(serverEntity);
|
||||
|
||||
ClientFallTree clientFallTree = ClientFallTree.getFallTree(clientEntity);
|
||||
|
||||
@ -23,7 +23,7 @@ public class ServerFallTreeTests extends EntityTestTemplate {
|
||||
|
||||
@IntegrationTest
|
||||
public void isFalling_AtRest_false(){
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
|
||||
ServerFallTree serverFallTree = ServerFallTree.getFallTree(creature);
|
||||
assertEquals(false, serverFallTree.isFalling());
|
||||
@ -31,7 +31,7 @@ public class ServerFallTreeTests extends EntityTestTemplate {
|
||||
|
||||
@IntegrationTest
|
||||
public void isFalling_AfterJump_true(){
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
|
||||
ServerFallTree serverFallTree = ServerFallTree.getFallTree(creature);
|
||||
ServerJumpTree serverJumpTree = ServerJumpTree.getServerJumpTree(creature);
|
||||
@ -46,7 +46,7 @@ public class ServerFallTreeTests extends EntityTestTemplate {
|
||||
|
||||
@IntegrationTest
|
||||
public void isFalling_AfterLand_false(){
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
|
||||
ServerFallTree serverFallTree = ServerFallTree.getFallTree(creature);
|
||||
ServerJumpTree serverJumpTree = ServerJumpTree.getServerJumpTree(creature);
|
||||
|
||||
@ -26,8 +26,8 @@ public class MeleeTargetingNodeTests extends EntityTestTemplate {
|
||||
float aggroRange = 10;
|
||||
|
||||
//spawn test entities
|
||||
Entity swordsman = UnitUtils.spawnUnit(Globals.realmManager.first(), new Vector3d(0,0,0), "humanSwordsman");
|
||||
Entity target = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(1,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
Entity swordsman = UnitUtils.spawnUnit(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), "humanSwordsman");
|
||||
Entity target = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(1,0,0), "human", ObjectTemplate.createDefault(EntityType.CREATURE, "human"));
|
||||
|
||||
//check if the swordsman can find a target
|
||||
Blackboard blackboard = new Blackboard();
|
||||
|
||||
@ -15,7 +15,6 @@ public class StateCleanupCheckerExtension implements AfterEachCallback {
|
||||
@Override
|
||||
public void afterEach(ExtensionContext context) throws Exception {
|
||||
Object[] objectsToCheck = new Object[]{
|
||||
Globals.realmManager,
|
||||
Globals.signalSystem,
|
||||
Globals.threadManager,
|
||||
Globals.renderingEngine,
|
||||
|
||||
@ -29,7 +29,7 @@ public class TestEntityUtils {
|
||||
|
||||
int accumulator = 0;
|
||||
|
||||
Realm realm = Globals.realmManager.getRealms().iterator().next();
|
||||
Realm realm = Globals.serverState.realmManager.getRealms().iterator().next();
|
||||
ServerDataCell dataCell = realm.getDataCellManager().getDataCellAtPoint(new Vector3d(minX,minY,minZ));
|
||||
for(Entity entity : dataCell.getScene().getEntityList()){
|
||||
if(EntityUtils.getPosition(entity) != null){
|
||||
|
||||
@ -31,7 +31,7 @@ public class TestViewportUtils {
|
||||
public static Entity spawnPlayerCharacter(String creatureType){
|
||||
//spawn creature
|
||||
ObjectTemplate creatureTemplate = ObjectTemplate.createDefault(EntityType.CREATURE, creatureType);
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.realmManager.first(), new Vector3d(0,0,0), creatureType, creatureTemplate);
|
||||
Entity creature = CreatureUtils.serverSpawnBasicCreature(Globals.serverState.realmManager.first(), new Vector3d(0,0,0), creatureType, creatureTemplate);
|
||||
|
||||
//get required data
|
||||
ServerConnectionHandler connectionHandler = Globals.serverState.server.getFirstConnection();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user