diff --git a/src/main/java/electrosphere/controls/ControlHandler.java b/src/main/java/electrosphere/controls/ControlHandler.java index 36e9a824..aa0a4bd3 100644 --- a/src/main/java/electrosphere/controls/ControlHandler.java +++ b/src/main/java/electrosphere/controls/ControlHandler.java @@ -124,10 +124,10 @@ public class ControlHandler { */ handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD, new Control(true,false,GLFW_KEY_W)); handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD, new Control(true,false,GLFW_KEY_S)); - handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_LEFT, new Control(true,false,GLFW_KEY_F24)); - handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT, new Control(true,false,GLFW_KEY_F24)); - handler.addControl(DATA_STRING_INPUT_CODE_STRAFE_LEFT, new Control(true,false,GLFW_KEY_A)); - handler.addControl(DATA_STRING_INPUT_CODE_STRAFE_RIGHT, new Control(true,false,GLFW_KEY_D)); + handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_LEFT, new Control(true,false,GLFW_KEY_A)); + handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT, new Control(true,false,GLFW_KEY_D)); + handler.addControl(DATA_STRING_INPUT_CODE_STRAFE_LEFT, new Control(true,false,GLFW_KEY_F24)); + handler.addControl(DATA_STRING_INPUT_CODE_STRAFE_RIGHT, new Control(true,false,GLFW_KEY_F24)); handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_JUMP, new Control(true,false,GLFW_KEY_SPACE)); handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_FALL, new Control(true,false,GLFW_KEY_LEFT_CONTROL)); handler.addControl(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY, new Control(false,true,GLFW_MOUSE_BUTTON_LEFT)); diff --git a/src/main/java/electrosphere/engine/LoadingThread.java b/src/main/java/electrosphere/engine/LoadingThread.java index 89d8f574..a049b019 100644 --- a/src/main/java/electrosphere/engine/LoadingThread.java +++ b/src/main/java/electrosphere/engine/LoadingThread.java @@ -5,6 +5,7 @@ import electrosphere.controls.ControlHandler; import electrosphere.entity.CameraEntityUtils; import electrosphere.entity.Entity; import electrosphere.entity.EntityUtils; +import electrosphere.entity.state.ApplyRotationTree; import electrosphere.game.collision.CollisionEngine; import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.item.ItemUtils; @@ -522,9 +523,11 @@ public class LoadingThread extends Thread { Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB)); Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB)); + //cloud ring pseudo skybox Entity cloudRing = EntityUtils.spawnDrawableEntity("Models/cloudRing.fbx"); EntityUtils.getRotation(cloudRing).rotateX((float)(-Math.PI/2.0f)); EntityUtils.getScale(cloudRing).mul(1000.0f); + Globals.entityManager.registerBehaviorTree(new ApplyRotationTree(cloudRing,new Quaternionf().rotationZ(0.0001f))); } diff --git a/src/main/java/electrosphere/entity/EntityManager.java b/src/main/java/electrosphere/entity/EntityManager.java index 7882d2bc..f88db094 100644 --- a/src/main/java/electrosphere/entity/EntityManager.java +++ b/src/main/java/electrosphere/entity/EntityManager.java @@ -157,6 +157,20 @@ public class EntityManager { public CopyOnWriteArrayList getSprintables(){ return sprintableList; } + + public void registerBehaviorTree(BehaviorTree tree){ + behaviorTreeList.add(tree); + } + + public void removeBehaviorTree(BehaviorTree tree){ + behaviorTreeList.remove(tree); + } + + public void simulateBehaviorTrees(){ + for(BehaviorTree tree : behaviorTreeList){ + tree.simulate(); + } + } public void deregisterEntity(Entity e){ if(lightList.contains(e)){ diff --git a/src/main/java/electrosphere/entity/state/ApplyRotationTree.java b/src/main/java/electrosphere/entity/state/ApplyRotationTree.java index a3d68327..4b0cae70 100644 --- a/src/main/java/electrosphere/entity/state/ApplyRotationTree.java +++ b/src/main/java/electrosphere/entity/state/ApplyRotationTree.java @@ -16,7 +16,7 @@ public class ApplyRotationTree implements BehaviorTree { Quaternionf rotationToApply; Entity parent; - ApplyRotationTreeState state; + ApplyRotationTreeState state = ApplyRotationTreeState.ROTATE; public ApplyRotationTree(Entity parent, Quaternionf rotationToApply){ this.parent = parent; @@ -35,7 +35,7 @@ public class ApplyRotationTree implements BehaviorTree { public void simulate(){ switch(state){ case ROTATE: - EntityUtils.getRotation(parent).slerp(rotationToApply, 1.0f); + EntityUtils.getRotation(parent).mul(rotationToApply).normalize(); break; case NO_ROTATE: break; diff --git a/src/main/java/electrosphere/game/simulation/MicroSimulation.java b/src/main/java/electrosphere/game/simulation/MicroSimulation.java index e6ff74ad..cdcbd7d5 100644 --- a/src/main/java/electrosphere/game/simulation/MicroSimulation.java +++ b/src/main/java/electrosphere/game/simulation/MicroSimulation.java @@ -123,6 +123,8 @@ public class MicroSimulation { if(Globals.RUN_CLIENT){ Globals.entityManager.clearOutOfBoundsEntities(); } + //simulate behavior trees + Globals.entityManager.simulateBehaviorTrees(); //data cell manager update if(Globals.dataCellManager != null){ boolean playerHasChangedChunk = Globals.dataCellManager.updatePlayerPositions();