move timekeeper into engineState
This commit is contained in:
parent
a3650ebc2b
commit
c854be629f
@ -1819,6 +1819,7 @@ Move playerManager to serverState
|
||||
Create EngineState global
|
||||
Move threadManager into engineState
|
||||
Move serviceManager into engineState
|
||||
Move timeKeeper into engineState
|
||||
|
||||
|
||||
|
||||
|
||||
@ -64,7 +64,7 @@ public class ClientSimulation {
|
||||
//
|
||||
//simulate bullet physics engine step
|
||||
if(Globals.RUN_PHYSICS){
|
||||
Globals.clientState.clientSceneWrapper.getCollisionEngine().simulatePhysics((float)Globals.timekeeper.getSimFrameTime());
|
||||
Globals.clientState.clientSceneWrapper.getCollisionEngine().simulatePhysics((float)Globals.engineState.timekeeper.getSimFrameTime());
|
||||
Globals.clientState.clientSceneWrapper.getCollisionEngine().updateDynamicObjectTransforms();
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class ClientSimulation {
|
||||
for(Entity currentEntity : Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.DRAWABLE)){
|
||||
Actor currentActor = EntityUtils.getActor(currentEntity);
|
||||
if(currentActor.isPlayingAnimation()){
|
||||
currentActor.incrementAnimationTime((float)Globals.timekeeper.getSimFrameTime());
|
||||
currentActor.incrementAnimationTime((float)Globals.engineState.timekeeper.getSimFrameTime());
|
||||
}
|
||||
}
|
||||
Globals.profiler.endCpuSample();
|
||||
@ -106,12 +106,12 @@ public class ClientSimulation {
|
||||
Globals.profiler.endCpuSample();
|
||||
//
|
||||
//simulate behavior trees
|
||||
Globals.clientState.clientSceneWrapper.getScene().simulateBehaviorTrees((float)Globals.timekeeper.getSimFrameTime());
|
||||
Globals.clientState.clientSceneWrapper.getScene().simulateBehaviorTrees((float)Globals.engineState.timekeeper.getSimFrameTime());
|
||||
//
|
||||
//sum collidable impulses
|
||||
Globals.profiler.beginCpuSample("collidable logic");
|
||||
for(Entity collidable : Globals.clientState.clientSceneWrapper.getScene().getEntitiesWithTag(EntityTags.COLLIDABLE)){
|
||||
ClientCollidableTree.getClientCollidableTree(collidable).simulate((float)Globals.timekeeper.getSimFrameTime());
|
||||
ClientCollidableTree.getClientCollidableTree(collidable).simulate((float)Globals.engineState.timekeeper.getSimFrameTime());
|
||||
}
|
||||
//
|
||||
//clear collidable impulse lists
|
||||
|
||||
@ -53,7 +53,7 @@ public class ToolbarPreviewWindow {
|
||||
* Checks the visibility of the toolbar preview
|
||||
*/
|
||||
public static void checkVisibility(){
|
||||
long currentFrame = Globals.timekeeper.getNumberOfSimFramesElapsed();
|
||||
long currentFrame = Globals.engineState.timekeeper.getNumberOfSimFramesElapsed();
|
||||
if(currentFrame > frameToHide){
|
||||
if(previewWindow != null && previewWindow.getVisible()){
|
||||
previewWindow.setVisible(false);
|
||||
@ -67,7 +67,7 @@ public class ToolbarPreviewWindow {
|
||||
public static void reveal(){
|
||||
previewWindow = ToolbarPreviewWindow.createToolbarPreviewWindow();
|
||||
WindowUtils.replaceWindow(WindowStrings.TOOLBAR_PREVIEW, previewWindow);
|
||||
frameToHide = Globals.timekeeper.getNumberOfSimFramesElapsed() + REVEAL_FRAME_COUNT;
|
||||
frameToHide = Globals.engineState.timekeeper.getNumberOfSimFramesElapsed() + REVEAL_FRAME_COUNT;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -107,7 +107,7 @@ public class CameraHandler {
|
||||
Globals.profiler.beginCpuSample("updateGlobalCamera");
|
||||
if(update){
|
||||
if(Globals.clientState.playerCamera != null){
|
||||
cameraSpeed = 2.5f * (float)Globals.timekeeper.getMostRecentRawFrametime();
|
||||
cameraSpeed = 2.5f * (float)Globals.engineState.timekeeper.getMostRecentRawFrametime();
|
||||
|
||||
if(Crosshair.getCrosshairActive()){
|
||||
|
||||
@ -154,7 +154,7 @@ public class CameraHandler {
|
||||
Globals.clientState.clientConnection.queueOutgoingMessage(
|
||||
EntityMessage.constructupdateEntityViewDirMessage(
|
||||
Globals.clientState.clientSceneWrapper.mapClientToServerId(Globals.clientState.playerEntity.getId()),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
perspectiveVal,
|
||||
yaw,
|
||||
pitch
|
||||
|
||||
@ -263,10 +263,10 @@ public class ControlHandler {
|
||||
if(!control.isState()){
|
||||
//on press
|
||||
control.onPress(this.mouseState);
|
||||
control.setPressFrame((float)Globals.timekeeper.getNumberOfRenderFramesElapsed());
|
||||
control.setPressFrame((float)Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed());
|
||||
} else {
|
||||
//on repeat
|
||||
if((float)Globals.timekeeper.getNumberOfRenderFramesElapsed() - control.getPressFrame() > control.getRepeatTimeout()){
|
||||
if((float)Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed() - control.getPressFrame() > control.getRepeatTimeout()){
|
||||
control.onRepeat(this.mouseState);
|
||||
}
|
||||
}
|
||||
@ -276,7 +276,7 @@ public class ControlHandler {
|
||||
//on release
|
||||
control.onRelease(this.mouseState);
|
||||
//on click
|
||||
if((float)Globals.timekeeper.getNumberOfRenderFramesElapsed() - control.getPressFrame() < control.getRepeatTimeout()){
|
||||
if((float)Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed() - control.getPressFrame() < control.getRepeatTimeout()){
|
||||
control.onClick(this.mouseState);
|
||||
}
|
||||
} else {
|
||||
@ -289,7 +289,7 @@ public class ControlHandler {
|
||||
if(!control.isState()){
|
||||
//on press
|
||||
control.onPress(this.mouseState);
|
||||
control.setPressFrame((float)Globals.timekeeper.getNumberOfRenderFramesElapsed());
|
||||
control.setPressFrame((float)Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed());
|
||||
} else {
|
||||
//on repeat
|
||||
control.onRepeat(this.mouseState);
|
||||
@ -299,7 +299,7 @@ public class ControlHandler {
|
||||
if(control.isState()){
|
||||
//on release
|
||||
control.onRelease(this.mouseState);
|
||||
if((float)Globals.timekeeper.getNumberOfRenderFramesElapsed() - control.getPressFrame() < control.getRepeatTimeout()){
|
||||
if((float)Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed() - control.getPressFrame() < control.getRepeatTimeout()){
|
||||
control.onClick(this.mouseState);
|
||||
}
|
||||
} else {
|
||||
|
||||
@ -2,11 +2,17 @@ package electrosphere.engine;
|
||||
|
||||
import electrosphere.engine.service.ServiceManager;
|
||||
import electrosphere.engine.threads.ThreadManager;
|
||||
import electrosphere.engine.time.Timekeeper;
|
||||
|
||||
/**
|
||||
* State of the engine
|
||||
*/
|
||||
public class EngineState {
|
||||
|
||||
/**
|
||||
* The time keeping service
|
||||
*/
|
||||
public Timekeeper timekeeper = new Timekeeper();
|
||||
|
||||
/**
|
||||
* The thread manager
|
||||
@ -18,6 +24,13 @@ public class EngineState {
|
||||
*/
|
||||
public final ServiceManager serviceManager = ServiceManager.create();
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public EngineState(){
|
||||
this.threadManager.init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroys the engine state
|
||||
*/
|
||||
|
||||
@ -35,7 +35,6 @@ import electrosphere.engine.os.fs.FileWatcherService;
|
||||
import electrosphere.engine.profiler.Profiler;
|
||||
import electrosphere.engine.signal.SignalSystem;
|
||||
import electrosphere.engine.signal.sync.MainThreadSignalService;
|
||||
import electrosphere.engine.time.Timekeeper;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
import electrosphere.net.config.NetConfig;
|
||||
import electrosphere.net.monitor.NetMonitor;
|
||||
@ -82,11 +81,6 @@ public class Globals {
|
||||
//
|
||||
public static UserSettings userSettings;
|
||||
|
||||
//
|
||||
//Timekeeper
|
||||
//
|
||||
public static Timekeeper timekeeper;
|
||||
|
||||
/**
|
||||
* State for the engine
|
||||
*/
|
||||
@ -359,10 +353,10 @@ public class Globals {
|
||||
Globals.WINDOW_WIDTH = 1920;
|
||||
Globals.WINDOW_HEIGHT = 1080;
|
||||
UserSettings.loadUserSettings();
|
||||
//timekeeper
|
||||
timekeeper = new Timekeeper();
|
||||
|
||||
|
||||
//spin up engine state
|
||||
Globals.engineState = new EngineState();
|
||||
Globals.engineState.threadManager.init();
|
||||
|
||||
//render flags
|
||||
RENDER_FLAG_RENDER_SHADOW_MAP = false;
|
||||
|
||||
@ -159,7 +159,7 @@ public class Main {
|
||||
}
|
||||
|
||||
//init timekeeper
|
||||
Globals.timekeeper.init(targetFramePeriod);
|
||||
Globals.engineState.timekeeper.init(targetFramePeriod);
|
||||
|
||||
//fire off a loading thread for the title menus/screen
|
||||
LoggerInterface.loggerStartup.INFO("Fire off loading thread");
|
||||
@ -207,7 +207,7 @@ public class Main {
|
||||
//
|
||||
//Update timekeeper, thread manager, and process all main thread signals
|
||||
//
|
||||
Globals.timekeeper.update();
|
||||
Globals.engineState.timekeeper.update();
|
||||
Globals.engineState.threadManager.update();
|
||||
|
||||
|
||||
@ -275,10 +275,10 @@ public class Main {
|
||||
///
|
||||
|
||||
int simFrameHardcapCounter = 0;
|
||||
while(Globals.timekeeper.pullFromAccumulator() && framestep > 0 && simFrameHardcapCounter < Timekeeper.SIM_FRAME_HARDCAP){
|
||||
while(Globals.engineState.timekeeper.pullFromAccumulator() && framestep > 0 && simFrameHardcapCounter < Timekeeper.SIM_FRAME_HARDCAP){
|
||||
|
||||
//do not simulate extra frames if we're already behind schedule
|
||||
if(Globals.timekeeper.getMostRecentRawFrametime() > Globals.timekeeper.getSimFrameTime() && simFrameHardcapCounter > 0){
|
||||
if(Globals.engineState.timekeeper.getMostRecentRawFrametime() > Globals.engineState.timekeeper.getSimFrameTime() && simFrameHardcapCounter > 0){
|
||||
break;
|
||||
}
|
||||
|
||||
@ -327,7 +327,7 @@ public class Main {
|
||||
Globals.profiler.beginCpuSample("audio engine update");
|
||||
if(Globals.audioEngine != null && Globals.audioEngine.initialized() && Globals.virtualAudioSourceManager != null){
|
||||
Globals.audioEngine.update();
|
||||
Globals.virtualAudioSourceManager.update((float)Globals.timekeeper.getSimFrameTime());
|
||||
Globals.virtualAudioSourceManager.update((float)Globals.engineState.timekeeper.getSimFrameTime());
|
||||
}
|
||||
Globals.profiler.endCpuSample();
|
||||
|
||||
@ -351,7 +351,7 @@ public class Main {
|
||||
/// G A R B A G E C H E C K
|
||||
///
|
||||
Globals.profiler.beginCpuSample("gc");
|
||||
if(Globals.EXPLICIT_GC && Globals.timekeeper.getNumberOfRenderFramesElapsed() % Globals.GC_FRAME_FREQUENCY == 0){
|
||||
if(Globals.EXPLICIT_GC && Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed() % Globals.GC_FRAME_FREQUENCY == 0){
|
||||
System.gc();
|
||||
}
|
||||
Globals.profiler.endCpuSample();
|
||||
@ -381,17 +381,17 @@ public class Main {
|
||||
///
|
||||
/// C L E A N U P T I M E V A R I A B L E S
|
||||
///
|
||||
if(Globals.EXPLICIT_SLEEP && Globals.timekeeper.getMostRecentRawFrametime() < 0.01f){
|
||||
if(Globals.EXPLICIT_SLEEP && Globals.engineState.timekeeper.getMostRecentRawFrametime() < 0.01f){
|
||||
Globals.profiler.beginCpuSample("sleep");
|
||||
if(Globals.timekeeper.getMostRecentRawFrametime() < targetFramePeriod){
|
||||
Main.sleep((int)(1000.0 * (targetFramePeriod - Globals.timekeeper.getMostRecentRawFrametime())));
|
||||
if(Globals.engineState.timekeeper.getMostRecentRawFrametime() < targetFramePeriod){
|
||||
Main.sleep((int)(1000.0 * (targetFramePeriod - Globals.engineState.timekeeper.getMostRecentRawFrametime())));
|
||||
} else {
|
||||
Main.sleep(1);
|
||||
}
|
||||
Globals.profiler.endCpuSample();
|
||||
}
|
||||
Globals.timekeeper.numberOfRenderedFrames++;
|
||||
if(maxFrames > 0 && Globals.timekeeper.numberOfRenderedFrames > maxFrames){
|
||||
Globals.engineState.timekeeper.numberOfRenderedFrames++;
|
||||
if(maxFrames > 0 && Globals.engineState.timekeeper.numberOfRenderedFrames > maxFrames){
|
||||
running = false;
|
||||
}
|
||||
|
||||
@ -399,7 +399,7 @@ public class Main {
|
||||
///
|
||||
/// F R A M E T I M E T R A C K I NG
|
||||
///
|
||||
ImGuiWindowMacros.addGlobalFramerateDatapoint("totalframerate", Globals.timekeeper.getMostRecentRawFrametime());
|
||||
ImGuiWindowMacros.addGlobalFramerateDatapoint("totalframerate", Globals.engineState.timekeeper.getMostRecentRawFrametime());
|
||||
|
||||
|
||||
///
|
||||
|
||||
@ -130,7 +130,7 @@ public class StateTransitionUtil {
|
||||
double animationOffset = 0.0001;
|
||||
if(this.accountForSync){
|
||||
int delay = Globals.clientState.clientConnection.getDelay();
|
||||
double simFrameTime = Globals.timekeeper.getSimFrameTime();
|
||||
double simFrameTime = Globals.engineState.timekeeper.getSimFrameTime();
|
||||
animationOffset = delay * simFrameTime;
|
||||
}
|
||||
|
||||
|
||||
@ -294,7 +294,7 @@ public class ClientAttackTree implements BehaviorTree {
|
||||
|
||||
@Override
|
||||
public void simulate(float deltaTime){
|
||||
frameCurrent = frameCurrent + (float)Globals.timekeeper.getDeltaFrames();
|
||||
frameCurrent = frameCurrent + (float)Globals.engineState.timekeeper.getDeltaFrames();
|
||||
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
|
||||
|
||||
//
|
||||
@ -320,7 +320,7 @@ public class ClientAttackTree implements BehaviorTree {
|
||||
case DRIFT:
|
||||
if(currentMove != null){
|
||||
//calculate the vector of movement
|
||||
CollisionObjUtils.getCollidable(parent).addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), currentMove.getDriftGoal() * Globals.timekeeper.getSimFrameTime(), "movement"));
|
||||
CollisionObjUtils.getCollidable(parent).addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), currentMove.getDriftGoal() * Globals.engineState.timekeeper.getSimFrameTime(), "movement"));
|
||||
if(frameCurrent > currentMove.getDriftFrameEnd()){
|
||||
this.setDriftState(AttackTreeDriftState.NO_DRIFT);
|
||||
}
|
||||
|
||||
@ -308,7 +308,7 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
|
||||
@Override
|
||||
public void simulate(float deltaTime){
|
||||
frameCurrent = frameCurrent + (float)Globals.timekeeper.getDeltaFrames();
|
||||
frameCurrent = frameCurrent + (float)Globals.engineState.timekeeper.getDeltaFrames();
|
||||
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
|
||||
|
||||
//parse attached network messages
|
||||
@ -332,7 +332,7 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
case DRIFT:
|
||||
if(currentMove != null){
|
||||
//calculate the vector of movement
|
||||
CollisionObjUtils.getCollidable(parent).addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), currentMove.getDriftGoal() * Globals.timekeeper.getSimFrameTime(), "movement"));
|
||||
CollisionObjUtils.getCollidable(parent).addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), currentMove.getDriftGoal() * Globals.engineState.timekeeper.getSimFrameTime(), "movement"));
|
||||
if(frameCurrent > currentMove.getDriftFrameEnd()){
|
||||
this.setDriftState(AttackTreeDriftState.NO_DRIFT);
|
||||
}
|
||||
|
||||
@ -43,8 +43,8 @@ public class ClientParticleEmitterComponent implements BehaviorTree {
|
||||
@Override
|
||||
public void simulate(float deltaTime) {
|
||||
Vector3d entityPos = EntityUtils.getPosition(parent);
|
||||
if((float)(Globals.timekeeper.getNumberOfRenderFramesElapsed() - lastEmittedFrame) > particleEmitter.getFrequency()){
|
||||
lastEmittedFrame = Globals.timekeeper.getNumberOfRenderFramesElapsed();
|
||||
if((float)(Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed() - lastEmittedFrame) > particleEmitter.getFrequency()){
|
||||
lastEmittedFrame = Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed();
|
||||
//create particle here
|
||||
Vector3d spawnPos = new Vector3d(entityPos);
|
||||
Quaterniond rotation = new Quaterniond(EntityUtils.getRotation(parent));
|
||||
|
||||
@ -184,7 +184,7 @@ public class ServerLifeTree implements BehaviorTree {
|
||||
CombatMessage.constructserverReportHitboxCollisionMessage(
|
||||
event.source.getId(),
|
||||
parent.getId(),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
event.sourceHitboxData.getHitboxData().getType(),
|
||||
HitboxData.HITBOX_TYPE_BLOCK_CONNECTED,
|
||||
event.position.x,
|
||||
@ -207,7 +207,7 @@ public class ServerLifeTree implements BehaviorTree {
|
||||
CombatMessage.constructserverReportHitboxCollisionMessage(
|
||||
event.source.getId(),
|
||||
parent.getId(),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
event.sourceHitboxData.getHitboxData().getType(),
|
||||
event.parentHitboxData.getHitboxData().getType(),
|
||||
event.position.x,
|
||||
|
||||
@ -143,7 +143,7 @@ public class ClientEditorMovementTree implements BehaviorTree {
|
||||
Globals.clientState.clientConnection.queueOutgoingMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -173,7 +173,7 @@ public class ClientEditorMovementTree implements BehaviorTree {
|
||||
Globals.clientState.clientConnection.queueOutgoingMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -371,7 +371,7 @@ public class ClientEditorMovementTree implements BehaviorTree {
|
||||
} break;
|
||||
case STARTUP: {
|
||||
//run startup code
|
||||
velocity = velocity + acceleration * (float)Globals.timekeeper.getSimFrameTime();
|
||||
velocity = velocity + acceleration * (float)Globals.engineState.timekeeper.getSimFrameTime();
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
} break;
|
||||
case MOVE: {
|
||||
@ -382,7 +382,7 @@ public class ClientEditorMovementTree implements BehaviorTree {
|
||||
} break;
|
||||
case SLOWDOWN: {
|
||||
//velocity stuff
|
||||
velocity = velocity - acceleration * (float)Globals.timekeeper.getSimFrameTime();
|
||||
velocity = velocity - acceleration * (float)Globals.engineState.timekeeper.getSimFrameTime();
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
} break;
|
||||
}
|
||||
|
||||
@ -99,7 +99,7 @@ public class ServerEditorMovementTree implements BehaviorTree {
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
parent.getId(),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -135,7 +135,7 @@ public class ServerEditorMovementTree implements BehaviorTree {
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
parent.getId(),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -265,7 +265,7 @@ public class ServerEditorMovementTree implements BehaviorTree {
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
parent.getId(),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -291,7 +291,7 @@ public class ServerEditorMovementTree implements BehaviorTree {
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
parent.getId(),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -332,7 +332,7 @@ public class ServerEditorMovementTree implements BehaviorTree {
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
parent.getId(),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -363,7 +363,7 @@ public class ServerEditorMovementTree implements BehaviorTree {
|
||||
} break;
|
||||
case STARTUP: {
|
||||
//run startup code
|
||||
velocity = velocity + acceleration * (float)Globals.timekeeper.getSimFrameTime();
|
||||
velocity = velocity + acceleration * (float)Globals.engineState.timekeeper.getSimFrameTime();
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
} break;
|
||||
case MOVE: {
|
||||
@ -374,7 +374,7 @@ public class ServerEditorMovementTree implements BehaviorTree {
|
||||
} break;
|
||||
case SLOWDOWN: {
|
||||
//velocity stuff
|
||||
velocity = velocity - acceleration * (float)Globals.timekeeper.getSimFrameTime();
|
||||
velocity = velocity - acceleration * (float)Globals.engineState.timekeeper.getSimFrameTime();
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
} break;
|
||||
}
|
||||
|
||||
@ -151,7 +151,7 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
||||
Globals.clientState.clientConnection.queueOutgoingMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -181,7 +181,7 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
||||
Globals.clientState.clientConnection.queueOutgoingMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
Globals.clientState.clientSceneWrapper.mapClientToServerId(parent.getId()),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -332,9 +332,9 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
||||
//actually update
|
||||
PhysicsEntityUtils.getDBody(parent).enable();
|
||||
body.setLinearVel(
|
||||
movementVector.x * velocity * Globals.timekeeper.getSimFrameTime(),
|
||||
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
|
||||
linearVelocity.get1(),
|
||||
movementVector.z * velocity * Globals.timekeeper.getSimFrameTime()
|
||||
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
|
||||
);
|
||||
body.setAngularVel(0, 0, 0);
|
||||
rotation.set(movementQuaternion);
|
||||
@ -364,9 +364,9 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
||||
float velocity = this.getModifiedVelocity();
|
||||
PhysicsEntityUtils.getDBody(parent).enable();
|
||||
body.setLinearVel(
|
||||
movementVector.x * velocity * Globals.timekeeper.getSimFrameTime(),
|
||||
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
|
||||
linearVelocity.get1(),
|
||||
movementVector.z * velocity * Globals.timekeeper.getSimFrameTime()
|
||||
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
|
||||
);
|
||||
body.setAngularVel(0, 0, 0);
|
||||
rotation.set(movementQuaternion);
|
||||
@ -414,9 +414,9 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
||||
}
|
||||
PhysicsEntityUtils.getDBody(parent).enable();
|
||||
body.setLinearVel(
|
||||
movementVector.x * velocity * Globals.timekeeper.getSimFrameTime(),
|
||||
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
|
||||
linearVelocity.get1(),
|
||||
movementVector.z * velocity * Globals.timekeeper.getSimFrameTime()
|
||||
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
|
||||
);
|
||||
body.setAngularVel(0, 0, 0);
|
||||
rotation.set(movementQuaternion);
|
||||
@ -488,7 +488,7 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
||||
} break;
|
||||
case STARTUP: {
|
||||
//run startup code
|
||||
velocity = velocity + acceleration * (float)Globals.timekeeper.getSimFrameTime();
|
||||
velocity = velocity + acceleration * (float)Globals.engineState.timekeeper.getSimFrameTime();
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
} break;
|
||||
case MOVE: {
|
||||
@ -499,7 +499,7 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
||||
} break;
|
||||
case SLOWDOWN: {
|
||||
//velocity stuff
|
||||
velocity = velocity - acceleration * (float)Globals.timekeeper.getSimFrameTime();
|
||||
velocity = velocity - acceleration * (float)Globals.engineState.timekeeper.getSimFrameTime();
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
} break;
|
||||
}
|
||||
|
||||
@ -115,7 +115,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
parent.getId(),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -151,7 +151,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
parent.getId(),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -287,9 +287,9 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
||||
}
|
||||
PhysicsEntityUtils.getDBody(parent).enable();
|
||||
PhysicsEntityUtils.getDBody(parent).setLinearVel(
|
||||
movementVector.x * velocity * Globals.timekeeper.getSimFrameTime(),
|
||||
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
|
||||
linearVelocity.get1(),
|
||||
movementVector.z * velocity * Globals.timekeeper.getSimFrameTime()
|
||||
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
|
||||
);
|
||||
body.setAngularVel(0, 0, 0);
|
||||
// position.set(newPosition);
|
||||
@ -299,7 +299,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
parent.getId(),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -333,9 +333,9 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
||||
float velocity = this.getModifiedVelocity();
|
||||
PhysicsEntityUtils.getDBody(parent).enable();
|
||||
PhysicsEntityUtils.getDBody(parent).setLinearVel(
|
||||
movementVector.x * velocity * Globals.timekeeper.getSimFrameTime(),
|
||||
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
|
||||
linearVelocity.get1(),
|
||||
movementVector.z * velocity * Globals.timekeeper.getSimFrameTime()
|
||||
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
|
||||
);
|
||||
body.setAngularVel(0, 0, 0);
|
||||
|
||||
@ -344,7 +344,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
parent.getId(),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -402,9 +402,9 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
||||
// );
|
||||
PhysicsEntityUtils.getDBody(parent).enable();
|
||||
PhysicsEntityUtils.getDBody(parent).setLinearVel(
|
||||
movementVector.x * velocity * Globals.timekeeper.getSimFrameTime(),
|
||||
movementVector.x * velocity * Globals.engineState.timekeeper.getSimFrameTime(),
|
||||
linearVelocity.get1(),
|
||||
movementVector.z * velocity * Globals.timekeeper.getSimFrameTime()
|
||||
movementVector.z * velocity * Globals.engineState.timekeeper.getSimFrameTime()
|
||||
);
|
||||
body.setAngularVel(0, 0, 0);
|
||||
// position.set(newPosition);
|
||||
@ -412,7 +412,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||
EntityMessage.constructmoveUpdateMessage(
|
||||
parent.getId(),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
@ -443,7 +443,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
||||
} break;
|
||||
case STARTUP: {
|
||||
//run startup code
|
||||
velocity = velocity + acceleration * (float)Globals.timekeeper.getSimFrameTime();
|
||||
velocity = velocity + acceleration * (float)Globals.engineState.timekeeper.getSimFrameTime();
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
} break;
|
||||
case MOVE: {
|
||||
@ -454,7 +454,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
||||
} break;
|
||||
case SLOWDOWN: {
|
||||
//velocity stuff
|
||||
velocity = velocity - acceleration * (float)Globals.timekeeper.getSimFrameTime();
|
||||
velocity = velocity - acceleration * (float)Globals.engineState.timekeeper.getSimFrameTime();
|
||||
CreatureUtils.setVelocity(parent, velocity);
|
||||
} break;
|
||||
}
|
||||
|
||||
@ -58,7 +58,7 @@ public class ServerPhysicsSyncTree implements BehaviorTree {
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(
|
||||
EntityMessage.constructsyncPhysicsMessage(
|
||||
parent.getId(),
|
||||
Globals.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
Globals.engineState.timekeeper.getNumberOfSimFramesElapsed(),
|
||||
position.x,
|
||||
position.y,
|
||||
position.z,
|
||||
|
||||
@ -348,7 +348,7 @@ public class ItemUtils {
|
||||
String idleAnim = (String)item.getData(EntityDataStrings.ANIM_IDLE);
|
||||
if(!actor.isPlayingAnimation(idleAnim)){
|
||||
actor.playAnimation(idleAnim,AnimationPriorities.getValue(AnimationPriorities.INTERACTION));
|
||||
actor.incrementAnimationTime(Globals.timekeeper.getSimFrameTime());
|
||||
actor.incrementAnimationTime(Globals.engineState.timekeeper.getSimFrameTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -487,8 +487,8 @@ public class Mesh {
|
||||
Vector3f worldPos = new Vector3f((float)parent.getWorldPos().x,(float)parent.getWorldPos().y,(float)parent.getWorldPos().z);
|
||||
openGLState.getActiveShader().setUniform(openGLState, "modelWorldPos", worldPos);
|
||||
openGLState.getActiveShader().setUniform(openGLState, "lightSpaceMatrix", Globals.lightDepthMatrix);
|
||||
openGLState.getActiveShader().setUniform(openGLState, "frame", (int)Globals.timekeeper.getNumberOfRenderFramesElapsed());
|
||||
openGLState.getActiveShader().setUniform(openGLState, "time", (float)Globals.timekeeper.getCurrentRendererTime());
|
||||
openGLState.getActiveShader().setUniform(openGLState, "frame", (int)Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed());
|
||||
openGLState.getActiveShader().setUniform(openGLState, "time", (float)Globals.engineState.timekeeper.getCurrentRendererTime());
|
||||
}
|
||||
Globals.renderingEngine.checkError();
|
||||
}
|
||||
|
||||
@ -126,7 +126,7 @@ public class ScriptEngine extends SignalServiceImpl {
|
||||
* singletons from the host that are provided to the javascript context
|
||||
*/
|
||||
public static final Object[][] hostSingletops = new Object[][]{
|
||||
{"timekeeper",Globals.timekeeper},
|
||||
{"timekeeper",Globals.engineState.timekeeper},
|
||||
{"currentPlayer",Globals.clientState.clientPlayer},
|
||||
{"loggerScripts",LoggerInterface.loggerScripts},
|
||||
};
|
||||
|
||||
@ -241,7 +241,7 @@ public class Realm {
|
||||
//
|
||||
//simulate bullet physics engine step
|
||||
if(Globals.RUN_PHYSICS){
|
||||
collisionEngine.simulatePhysics((float)Globals.timekeeper.getSimFrameTime());
|
||||
collisionEngine.simulatePhysics((float)Globals.engineState.timekeeper.getSimFrameTime());
|
||||
collisionEngine.updateDynamicObjectTransforms();
|
||||
PhysicsEntityUtils.serverRepositionEntities(this,collisionEngine);
|
||||
chemistryEngine.collide();
|
||||
|
||||
@ -45,10 +45,10 @@ public class StructureScanningService extends SignalServiceImpl {
|
||||
public void queue(Player player, Vector3d position){
|
||||
ScanningJob existing = this.playerTimeoutMap.get(player);
|
||||
if(existing == null){
|
||||
existing = new ScanningJob(Globals.timekeeper.getNumberOfRenderFramesElapsed() + StructureScanningService.FRAME_OFFSET_FOR_JOBS, position);
|
||||
existing = new ScanningJob(Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed() + StructureScanningService.FRAME_OFFSET_FOR_JOBS, position);
|
||||
} else {
|
||||
//debounce
|
||||
existing.targetFrame = Globals.timekeeper.getNumberOfRenderFramesElapsed() + StructureScanningService.FRAME_OFFSET_FOR_JOBS;
|
||||
existing.targetFrame = Globals.engineState.timekeeper.getNumberOfRenderFramesElapsed() + StructureScanningService.FRAME_OFFSET_FOR_JOBS;
|
||||
existing.position = position;
|
||||
}
|
||||
this.playerTimeoutMap.put(player,existing);
|
||||
@ -60,7 +60,7 @@ public class StructureScanningService extends SignalServiceImpl {
|
||||
public void simulate(){
|
||||
Set<Entry<Player,ScanningJob>> jobs = playerTimeoutMap.entrySet();
|
||||
for(Entry<Player,ScanningJob> job : jobs){
|
||||
if(job.getValue().targetFrame <= Globals.timekeeper.getNumberOfSimFramesElapsed()){
|
||||
if(job.getValue().targetFrame <= Globals.engineState.timekeeper.getNumberOfSimFramesElapsed()){
|
||||
//run this job
|
||||
playerTimeoutMap.remove(job.getKey());
|
||||
StructureScanningService.scanForStructure(job.getValue());
|
||||
|
||||
@ -44,7 +44,7 @@ public class MicroSimulation {
|
||||
PoseActor currentPoseActor = EntityUtils.getPoseActor(currentEntity);
|
||||
//increment animations
|
||||
if(currentPoseActor.isPlayingAnimation()){
|
||||
currentPoseActor.incrementAnimationTime(Globals.timekeeper.getSimFrameTime());
|
||||
currentPoseActor.incrementAnimationTime(Globals.engineState.timekeeper.getSimFrameTime());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -54,7 +54,7 @@ public class MicroSimulation {
|
||||
}
|
||||
//simulate behavior trees
|
||||
if(dataCell.getScene().getBehaviorTrees().size() > 0){
|
||||
dataCell.getScene().simulateBehaviorTrees((float)Globals.timekeeper.getSimFrameTime());
|
||||
dataCell.getScene().simulateBehaviorTrees((float)Globals.engineState.timekeeper.getSimFrameTime());
|
||||
}
|
||||
//update attached entity positions
|
||||
//!!This must come after simulating behavior trees!!
|
||||
@ -64,7 +64,7 @@ public class MicroSimulation {
|
||||
//sum collidable impulses
|
||||
Set<Entity> collidables = dataCell.getScene().getEntitiesWithTag(EntityTags.COLLIDABLE);
|
||||
for(Entity collidable : collidables){
|
||||
ServerCollidableTree.getServerCollidableTree(collidable).simulate((float)Globals.timekeeper.getSimFrameTime());
|
||||
ServerCollidableTree.getServerCollidableTree(collidable).simulate((float)Globals.engineState.timekeeper.getSimFrameTime());
|
||||
}
|
||||
//update actor transform caches
|
||||
poseableEntities = dataCell.getScene().getEntitiesWithTag(EntityTags.POSEABLE);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user