move microSim to serverState

This commit is contained in:
austin 2025-05-15 15:45:05 -04:00
parent 94304c4675
commit cd1fef2d3a
12 changed files with 16 additions and 39 deletions

View File

@ -1824,6 +1824,7 @@ Move signalSystem into engineState
Move some global state into rendering engine Move some global state into rendering engine
Push settings into config variable Push settings into config variable
Move window pointer into rendering engine Move window pointer into rendering engine
Move microSimulation into serverState

View File

@ -14,7 +14,6 @@ import electrosphere.controls.ControlHandler;
import electrosphere.controls.MouseCallback; import electrosphere.controls.MouseCallback;
import electrosphere.controls.ScrollCallback; import electrosphere.controls.ScrollCallback;
import electrosphere.controls.cursor.CursorState; import electrosphere.controls.cursor.CursorState;
import electrosphere.data.particle.ParticleDefinition;
import electrosphere.data.voxel.VoxelType; import electrosphere.data.voxel.VoxelType;
import electrosphere.engine.assetmanager.AssetDataStrings; import electrosphere.engine.assetmanager.AssetDataStrings;
import electrosphere.engine.assetmanager.AssetManager; import electrosphere.engine.assetmanager.AssetManager;
@ -41,7 +40,6 @@ import electrosphere.server.db.DatabaseController;
import electrosphere.server.entity.poseactor.PoseModel; import electrosphere.server.entity.poseactor.PoseModel;
import electrosphere.server.service.CharacterService; import electrosphere.server.service.CharacterService;
import electrosphere.server.service.StructureScanningService; import electrosphere.server.service.StructureScanningService;
import electrosphere.server.simulation.MicroSimulation;
import electrosphere.util.FileUtils; import electrosphere.util.FileUtils;
/** /**
@ -179,6 +177,8 @@ public class Globals {
// //
public static TextureMap textureMapDefault; public static TextureMap textureMapDefault;
public static ModelPretransforms modelPretransforms; public static ModelPretransforms modelPretransforms;
public static ShaderOptionMap shaderOptionMap;
public static FontManager fontManager;
// //
@ -192,14 +192,7 @@ public class Globals {
// //
// Particle stuff // Particle stuff
// //
public static ParticleDefinition particleDefinition; public static ParticleService particleService;
public static ParticleService particleService;
public static ShaderOptionMap shaderOptionMap;
//manages all loaded fonts
public static FontManager fontManager;
// //
@ -209,9 +202,6 @@ public class Globals {
//manages all models loaded into memory //manages all models loaded into memory
public static AssetManager assetManager; public static AssetManager assetManager;
//micro simulation
public static MicroSimulation microSimulation;
//script engine //script engine
public static ScriptEngine scriptEngine; public static ScriptEngine scriptEngine;

View File

@ -88,8 +88,6 @@ public class ChunkGenerationTestLoading {
e.printStackTrace(); e.printStackTrace();
} }
} }
//initialize the "real" objects simulation
LoadingUtils.initMicroSimulation();
//init game specific stuff (ie different skybox colors) //init game specific stuff (ie different skybox colors)
LoadingUtils.initGameGraphicalEntities(); LoadingUtils.initGameGraphicalEntities();
//set simulations to ready if they exist //set simulations to ready if they exist

View File

@ -56,8 +56,6 @@ public class DebugSPWorldLoading {
e.printStackTrace(); e.printStackTrace();
} }
} }
//initialize the "real" objects simulation
LoadingUtils.initMicroSimulation();
//init game specific stuff (ie different skybox colors) //init game specific stuff (ie different skybox colors)
LoadingUtils.initGameGraphicalEntities(); LoadingUtils.initGameGraphicalEntities();
//set simulations to ready if they exist //set simulations to ready if they exist

View File

@ -84,8 +84,6 @@ public class LevelEditorLoading {
e.printStackTrace(); e.printStackTrace();
} }
} }
//initialize the "real" objects simulation
LoadingUtils.initMicroSimulation();
//init game specific stuff (ie different skybox colors) //init game specific stuff (ie different skybox colors)
LoadingUtils.initGameGraphicalEntities(); LoadingUtils.initGameGraphicalEntities();
//set simulations to ready if they exist //set simulations to ready if they exist

View File

@ -55,8 +55,6 @@ public class LevelLoading {
} }
} }
//initialize the "real" objects simulation
LoadingUtils.initMicroSimulation();
//init game specific stuff (ie different skybox colors) //init game specific stuff (ie different skybox colors)
LoadingUtils.initGameGraphicalEntities(); LoadingUtils.initGameGraphicalEntities();
//set simulations to ready if they exist //set simulations to ready if they exist

View File

@ -27,7 +27,6 @@ import electrosphere.net.server.player.Player;
import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.Realm;
import electrosphere.server.datacell.ServerWorldData; import electrosphere.server.datacell.ServerWorldData;
import electrosphere.server.entity.serialization.ContentSerialization; import electrosphere.server.entity.serialization.ContentSerialization;
import electrosphere.server.simulation.MicroSimulation;
import electrosphere.server.macro.character.Character; import electrosphere.server.macro.character.Character;
/** /**
@ -206,20 +205,12 @@ public class LoadingUtils {
// Globals.spawnPoint.set((float)startX,(float)Globals.commonWorldData.getElevationAtPoint(new Vector3d(startX,0,startZ)),(float)startZ); // Globals.spawnPoint.set((float)startX,(float)Globals.commonWorldData.getElevationAtPoint(new Vector3d(startX,0,startZ)),(float)startZ);
// Globals.macroSimulation.setReady(true); // Globals.macroSimulation.setReady(true);
} }
static void initMicroSimulation(){
if(Globals.microSimulation == null){
Globals.microSimulation = new MicroSimulation();
}
}
/** /**
* Sets the server simulations to ready * Sets the server simulations to ready
*/ */
static void setSimulationsToReady(){ static void setSimulationsToReady(){
if(Globals.microSimulation != null){ Globals.serverState.microSimulation.setReady(true);
Globals.microSimulation.setReady(true);
}
} }
} }

View File

@ -51,8 +51,6 @@ public class ServerLoading {
//initialize the local connection //initialize the local connection
Globals.clientState.clientUsername = username; Globals.clientState.clientUsername = username;
Globals.clientState.clientPassword = password; Globals.clientState.clientPassword = password;
//initialize the "real" objects simulation
LoadingUtils.initMicroSimulation();
//init game specific stuff (ie different skybox colors) //init game specific stuff (ie different skybox colors)
LoadingUtils.initGameGraphicalEntities(); LoadingUtils.initGameGraphicalEntities();
//log //log

View File

@ -60,7 +60,6 @@ public class ViewportLoading {
Globals.serverState.realmManager.first().getDataCellManager().addPlayerToRealm(localPlayer); Globals.serverState.realmManager.first().getDataCellManager().addPlayerToRealm(localPlayer);
//initialize the "real" objects simulation //initialize the "real" objects simulation
LoadingUtils.initMicroSimulation();
LoadingUtils.setSimulationsToReady(); LoadingUtils.setSimulationsToReady();
LoggerInterface.loggerEngine.INFO("[Server]Finished loading level editor"); LoggerInterface.loggerEngine.INFO("[Server]Finished loading level editor");

View File

@ -9,6 +9,7 @@ import electrosphere.server.datacell.EntityDataCellMapper;
import electrosphere.server.datacell.RealmManager; import electrosphere.server.datacell.RealmManager;
import electrosphere.server.saves.Save; import electrosphere.server.saves.Save;
import electrosphere.server.service.CharacterService; import electrosphere.server.service.CharacterService;
import electrosphere.server.simulation.MicroSimulation;
/** /**
* Server state * Server state
@ -60,4 +61,9 @@ public class ServerState {
*/ */
public PlayerManager playerManager = new PlayerManager(); public PlayerManager playerManager = new PlayerManager();
/**
* The micro simulation
*/
public final MicroSimulation microSimulation = new MicroSimulation();
} }

View File

@ -88,10 +88,10 @@ public class ViewportDataCellManager implements DataCellManager {
@Override @Override
public void simulate() { public void simulate() {
if(Globals.microSimulation != null && Globals.microSimulation.isReady()){ if(Globals.serverState.microSimulation != null && Globals.serverState.microSimulation.isReady()){
Globals.microSimulation.simulate(this.serverDataCell); Globals.serverState.microSimulation.simulate(this.serverDataCell);
} }
updatePlayerPositions(); this.updatePlayerPositions();
} }
@Override @Override

View File

@ -704,10 +704,10 @@ public class GriddedDataCellManager implements DataCellManager, VoxelCellManager
//micro simulation //micro simulation
boolean runMicroSim = Globals.microSimulation != null && Globals.microSimulation.isReady(); boolean runMicroSim = Globals.serverState.microSimulation != null && Globals.serverState.microSimulation.isReady();
for(ServerDataCell cell : this.groundDataCells.values()){ for(ServerDataCell cell : this.groundDataCells.values()){
if(runMicroSim && this.shouldSimulate(cell)){ if(runMicroSim && this.shouldSimulate(cell)){
Globals.microSimulation.simulate(cell); Globals.serverState.microSimulation.simulate(cell);
} }
//queue fluid simulation //queue fluid simulation