Renderer/src/main/java/electrosphere/game/client/ClientFunctions.java
austin ebec7a373e
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit
Separation of client and server logic
2023-05-20 19:18:09 -04:00

67 lines
2.2 KiB
Java

package electrosphere.game.client;
import electrosphere.engine.Globals;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.types.camera.CameraEntityUtils;
import electrosphere.game.client.terrain.manager.ClientTerrainManager;
import org.joml.Vector3d;
import org.joml.Vector3f;
/**
*
* @author amaterasu
*/
public class ClientFunctions {
static Vector3d oldPlayerCharacterPosition = new Vector3d();
static Vector3d newPlayerCharacterPosition = new Vector3d();
public static void runBeforeSimulationFunctions(){
//cell tracking values
if(Globals.playerEntity != null){
oldPlayerCharacterPosition = new Vector3d(EntityUtils.getPosition(Globals.playerEntity));
}
}
public static void runClientFunctions(){
ClientTerrainManager.generateTerrainChunkGeometry();
updateSkyboxPos();
// updateCellManager();
}
static void updateSkyboxPos(){
if(Globals.skybox != null && Globals.playerEntity != null){
// Vector3f skyboxPos = EntityUtils.getPosition(Globals.skybox);
//
// Vector3f playerCameraPos = EntityUtils.getPosition(Globals.playerCamera);
// if(skyboxPos != null && playerCameraPos != null){
// skyboxPos.set(playerCameraPos);
// }
EntityUtils.getPosition(Globals.skybox).set(EntityUtils.getPosition(Globals.playerEntity));
}
}
public static void loadTerrain(){
if(Globals.clientTerrainManager != null){
Globals.clientTerrainManager.handleMessages();
Globals.clientTerrainManager.ejectLoadedChunks();
updateCellManager();
}
}
static void updateCellManager(){
///
/// C L I E N T C E L L M A N A G E R
///
if(Globals.drawCellManager != null && Globals.clientWorldData != null){
if(Globals.playerEntity != null){
newPlayerCharacterPosition = EntityUtils.getPosition(Globals.playerEntity);
}
//Cell manager do your things
Globals.drawCellManager.calculateDeltas(oldPlayerCharacterPosition, newPlayerCharacterPosition);
Globals.drawCellManager.update();
}
}
}