move more global state into clientState

This commit is contained in:
austin 2025-05-15 12:09:07 -04:00
parent 295c94f392
commit eddadf8b57
11 changed files with 30 additions and 23 deletions

View File

@ -1806,6 +1806,8 @@ Properly reset ClientState
Move clientWorldData to clientState Move clientWorldData to clientState
Move clientScene to clientState Move clientScene to clientState
Move clientSceneWrapper to clientState Move clientSceneWrapper to clientState
Move clientSimulation to clientState
Move clientSynchronizationMAnager to clientState

View File

@ -2,7 +2,9 @@ package electrosphere.client;
import electrosphere.client.scene.ClientSceneWrapper; import electrosphere.client.scene.ClientSceneWrapper;
import electrosphere.client.scene.ClientWorldData; import electrosphere.client.scene.ClientWorldData;
import electrosphere.client.sim.ClientSimulation;
import electrosphere.entity.scene.Scene; import electrosphere.entity.scene.Scene;
import electrosphere.net.synchronization.client.ClientSynchronizationManager;
/** /**
* State on the client * State on the client
@ -24,4 +26,14 @@ public class ClientState {
*/ */
public ClientSceneWrapper clientSceneWrapper; public ClientSceneWrapper clientSceneWrapper;
/**
* The client simulation
*/
public ClientSimulation clientSimulation;
/**
* The synchronization manager on the client
*/
public ClientSynchronizationManager clientSynchronizationManager;
} }

View File

@ -94,7 +94,7 @@ public class ClientSceneWrapper {
lock.lock(); lock.lock();
clientToServerIdMap.put(clientId, serverId); clientToServerIdMap.put(clientId, serverId);
serverToClientIdMap.put(serverId, clientId); serverToClientIdMap.put(serverId, clientId);
Globals.clientSynchronizationManager.ejectDeletedKey(serverId); Globals.clientState.clientSynchronizationManager.ejectDeletedKey(serverId);
lock.unlock(); lock.unlock();
} }

View File

@ -52,7 +52,7 @@ public class ClientSimulation {
//process all server synchronization messages //process all server synchronization messages
Globals.profiler.beginCpuSample("clientSynchronizationManager.processMessages"); Globals.profiler.beginCpuSample("clientSynchronizationManager.processMessages");
Globals.clientSynchronizationManager.processMessages(); Globals.clientState.clientSynchronizationManager.processMessages();
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();
// //
//simulate bullet physics engine step //simulate bullet physics engine step

View File

@ -24,7 +24,6 @@ import electrosphere.client.fluid.manager.ClientFluidManager;
import electrosphere.client.player.ClientPlayerData; import electrosphere.client.player.ClientPlayerData;
import electrosphere.client.scene.ClientLevelEditorData; import electrosphere.client.scene.ClientLevelEditorData;
import electrosphere.client.scene.ClientSceneWrapper; import electrosphere.client.scene.ClientSceneWrapper;
import electrosphere.client.sim.ClientSimulation;
import electrosphere.client.terrain.cells.ClientDrawCellManager; import electrosphere.client.terrain.cells.ClientDrawCellManager;
import electrosphere.client.terrain.cells.VoxelTextureAtlas; import electrosphere.client.terrain.cells.VoxelTextureAtlas;
import electrosphere.client.terrain.foliage.FoliageCellManager; import electrosphere.client.terrain.foliage.FoliageCellManager;
@ -337,10 +336,6 @@ public class Globals {
//services //services
public static MainThreadSignalService mainThreadSignalService; public static MainThreadSignalService mainThreadSignalService;
//client scene management
public static ClientSimulation clientSimulation;
public static ClientSynchronizationManager clientSynchronizationManager;
//instanced actor manager //instanced actor manager
public static InstanceManager clientInstanceManager = new InstanceManager(); public static InstanceManager clientInstanceManager = new InstanceManager();
@ -536,7 +531,7 @@ public class Globals {
netMonitor = new NetMonitor(); netMonitor = new NetMonitor();
} }
//client synchronization manager //client synchronization manager
clientSynchronizationManager = new ClientSynchronizationManager(); Globals.clientState.clientSynchronizationManager = new ClientSynchronizationManager();
//profiler //profiler
profiler = new Profiler(); profiler = new Profiler();
Globals.serverSynchronizationManager = new ServerSynchronizationManager(); Globals.serverSynchronizationManager = new ServerSynchronizationManager();
@ -725,7 +720,7 @@ public class Globals {
Globals.clientState.clientScene = new Scene(); Globals.clientState.clientScene = new Scene();
Globals.clientState.clientSceneWrapper = new ClientSceneWrapper(Globals.clientState.clientScene, new CollisionEngine(), CollisionEngine.create(new ClientChemistryCollisionCallback()), new CollisionEngine()); Globals.clientState.clientSceneWrapper = new ClientSceneWrapper(Globals.clientState.clientScene, new CollisionEngine(), CollisionEngine.create(new ClientChemistryCollisionCallback()), new CollisionEngine());
Globals.clientState = new ClientState(); Globals.clientState = new ClientState();
Globals.clientSynchronizationManager = new ClientSynchronizationManager(); Globals.clientState.clientSynchronizationManager = new ClientSynchronizationManager();
Globals.server = null; Globals.server = null;
Globals.serverSynchronizationManager = new ServerSynchronizationManager(); Globals.serverSynchronizationManager = new ServerSynchronizationManager();
if(Globals.aiManager != null){ if(Globals.aiManager != null){
@ -759,7 +754,6 @@ public class Globals {
Globals.serviceManager = null; Globals.serviceManager = null;
Globals.fileWatcherService = null; Globals.fileWatcherService = null;
Globals.clientConnection = null; Globals.clientConnection = null;
Globals.clientSynchronizationManager = null;
Globals.server = null; Globals.server = null;
Globals.serverSynchronizationManager = null; Globals.serverSynchronizationManager = null;
Globals.aiManager = null; Globals.aiManager = null;

View File

@ -295,9 +295,9 @@ public class Main {
/// C L I E N T S I M U L A T I O N S T U F F /// C L I E N T S I M U L A T I O N S T U F F
/// ///
LoggerInterface.loggerEngine.DEBUG_LOOP("Begin client simulation"); LoggerInterface.loggerEngine.DEBUG_LOOP("Begin client simulation");
if(Globals.clientSimulation != null){ if(Globals.clientState != null && Globals.clientState.clientSimulation != null){
Globals.profiler.beginCpuSample("Client simulation"); Globals.profiler.beginCpuSample("Client simulation");
Globals.clientSimulation.simulate(); Globals.clientState.clientSimulation.simulate();
Globals.profiler.endCpuSample(); Globals.profiler.endCpuSample();
} }

View File

@ -213,8 +213,8 @@ public class ClientLoading {
* Creates client simulation object * Creates client simulation object
*/ */
private static void initClientSimulation(){ private static void initClientSimulation(){
if(Globals.clientSimulation == null){ if(Globals.clientState.clientSimulation == null){
Globals.clientSimulation = new ClientSimulation(); Globals.clientState.clientSimulation = new ClientSimulation();
} }
} }
@ -222,7 +222,7 @@ public class ClientLoading {
* Sets client simulation object state to ready * Sets client simulation object state to ready
*/ */
private static void setSimulationsToReady(){ private static void setSimulationsToReady(){
Globals.clientSimulation.setReady(true); Globals.clientState.clientSimulation.setReady(true);
} }
@ -338,7 +338,7 @@ public class ClientLoading {
// Globals.drawCellManager = new DrawCellManager(Globals.clientTerrainManager, 0, 0, 0); // Globals.drawCellManager = new DrawCellManager(Globals.clientTerrainManager, 0, 0, 0);
Globals.clientDrawCellManager = new ClientDrawCellManager(Globals.voxelTextureAtlas, Globals.clientState.clientWorldData.getWorldDiscreteSize()); Globals.clientDrawCellManager = new ClientDrawCellManager(Globals.voxelTextureAtlas, Globals.clientState.clientWorldData.getWorldDiscreteSize());
//Alerts the client simulation that it should start loading terrain //Alerts the client simulation that it should start loading terrain
Globals.clientSimulation.setLoadingTerrain(true); Globals.clientState.clientSimulation.setLoadingTerrain(true);
//wait for all the terrain data to arrive //wait for all the terrain data to arrive
int i = 0; int i = 0;
while( while(
@ -376,7 +376,7 @@ public class ClientLoading {
//initialize draw cell manager //initialize draw cell manager
Globals.fluidCellManager = new FluidCellManager(Globals.clientTerrainManager, 0, 0, 0); Globals.fluidCellManager = new FluidCellManager(Globals.clientTerrainManager, 0, 0, 0);
Globals.fluidCellManager.setGenerateDrawables(true); Globals.fluidCellManager.setGenerateDrawables(true);
Globals.clientSimulation.setLoadingTerrain(true); Globals.clientState.clientSimulation.setLoadingTerrain(true);
//wait for all the terrain data to arrive //wait for all the terrain data to arrive
WindowUtils.updateLoadingWindow("REQUESTING FLUID CHUNKS FROM SERVER (" + Globals.fluidCellManager.getUnrequestedSize() + ")"); WindowUtils.updateLoadingWindow("REQUESTING FLUID CHUNKS FROM SERVER (" + Globals.fluidCellManager.getUnrequestedSize() + ")");
@ -422,7 +422,7 @@ public class ClientLoading {
} }
Globals.clientBlockCellManager = new ClientBlockCellManager(Globals.blockTextureAtlas, Globals.clientState.clientWorldData.getWorldDiscreteSize()); Globals.clientBlockCellManager = new ClientBlockCellManager(Globals.blockTextureAtlas, Globals.clientState.clientWorldData.getWorldDiscreteSize());
//Alerts the client simulation that it should start loading blocks //Alerts the client simulation that it should start loading blocks
Globals.clientSimulation.setLoadingTerrain(true); Globals.clientState.clientSimulation.setLoadingTerrain(true);
//wait for all the block data to arrive //wait for all the block data to arrive
int i = 0; int i = 0;
while( while(

View File

@ -51,7 +51,7 @@ public class MainMenuLoading {
*/ */
private static void resetClientState(){ private static void resetClientState(){
Globals.playerEntity = null; Globals.playerEntity = null;
Globals.clientSimulation = null; Globals.clientState.clientSimulation = null;
Globals.clientConnection.setShouldDisconnect(true); Globals.clientConnection.setShouldDisconnect(true);
Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(false); Globals.renderingEngine.getPostProcessingPipeline().setApplyBlur(false);
} }

View File

@ -49,7 +49,7 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
Globals.profiler.beginAggregateCpuSample("EntityProtocol.handleEntityMessage"); Globals.profiler.beginAggregateCpuSample("EntityProtocol.handleEntityMessage");
LoggerInterface.loggerNetworking.DEBUG_LOOP("Parse entity message of type " + message.getMessageSubtype()); LoggerInterface.loggerNetworking.DEBUG_LOOP("Parse entity message of type " + message.getMessageSubtype());
if(Globals.clientState.clientScene != null && Globals.clientSynchronizationManager.isDeleted(message.getentityID())){ if(Globals.clientState.clientScene != null && Globals.clientState.clientSynchronizationManager.isDeleted(message.getentityID())){
return; return;
} }
@ -157,7 +157,7 @@ public class EntityProtocol implements ClientProtocolTemplate<EntityMessage> {
if(entity != null){ if(entity != null){
ClientEntityUtils.destroyEntity(entity); ClientEntityUtils.destroyEntity(entity);
} }
Globals.clientSynchronizationManager.addDeletedId(message.getentityID()); Globals.clientState.clientSynchronizationManager.addDeletedId(message.getentityID());
Globals.clientConnection.release(message); Globals.clientConnection.release(message);
} break; } break;

View File

@ -28,7 +28,7 @@ public class SynchronizationProtocol implements ClientProtocolTemplate<Synchroni
case ATTACHTREE: case ATTACHTREE:
case DETATCHTREE: case DETATCHTREE:
case SERVERNOTIFYBTREETRANSITION: case SERVERNOTIFYBTREETRANSITION:
Globals.clientSynchronizationManager.pushMessage(message); Globals.clientState.clientSynchronizationManager.pushMessage(message);
break; break;
case LOADSCENE: case LOADSCENE:
throw new UnsupportedOperationException("Received synchronization message on the client of unsupported type: " + message.getMessageSubtype()); throw new UnsupportedOperationException("Received synchronization message on the client of unsupported type: " + message.getMessageSubtype());

View File

@ -22,7 +22,6 @@ public class StateCleanupCheckerExtension implements AfterEachCallback {
Globals.audioEngine, Globals.audioEngine,
Globals.javaPID, Globals.javaPID,
Globals.clientConnection, Globals.clientConnection,
Globals.clientSynchronizationManager,
Globals.server, Globals.server,
Globals.serverSynchronizationManager, Globals.serverSynchronizationManager,
Globals.playerManager, Globals.playerManager,