fix ridiculous movement bug start arena skybox
This commit is contained in:
parent
41640ba543
commit
9a8ef5d586
BIN
assets/Models/cloudRing.fbx
Normal file
BIN
assets/Models/cloudRing.fbx
Normal file
Binary file not shown.
BIN
assets/Textures/cloudRing.png
Normal file
BIN
assets/Textures/cloudRing.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.4 MiB |
@ -239,6 +239,12 @@
|
|||||||
"/Textures/shirt1.png",
|
"/Textures/shirt1.png",
|
||||||
"/Textures/shirt1.png"
|
"/Textures/shirt1.png"
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
"Models/cloudRing.fbx" : {
|
||||||
|
"Sphere" : [
|
||||||
|
"/Textures/cloudRing.png",
|
||||||
|
"/Textures/cloudRing.png"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -36,6 +36,8 @@ public class ControlHandler {
|
|||||||
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD = "moveBackward";
|
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD = "moveBackward";
|
||||||
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_LEFT = "moveLeft";
|
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_LEFT = "moveLeft";
|
||||||
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT = "moveRight";
|
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_RIGHT = "moveRight";
|
||||||
|
public static final String DATA_STRING_INPUT_CODE_STRAFE_LEFT = "strafeLeft";
|
||||||
|
public static final String DATA_STRING_INPUT_CODE_STRAFE_RIGHT = "strafeRight";
|
||||||
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_JUMP = "jump";
|
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_JUMP = "jump";
|
||||||
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_FALL = "fall";
|
public static final String DATA_STRING_INPUT_CODE_MOVEMENT_FALL = "fall";
|
||||||
public static final String DATA_STRING_INPUT_CODE_ATTACK_PRIMARY = "attackPrimary";
|
public static final String DATA_STRING_INPUT_CODE_ATTACK_PRIMARY = "attackPrimary";
|
||||||
@ -122,8 +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_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_BACKWARD, new Control(true,false,GLFW_KEY_S));
|
||||||
handler.addControl(DATA_STRING_INPUT_CODE_MOVEMENT_LEFT, new Control(true,false,GLFW_KEY_A));
|
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_D));
|
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_JUMP, new Control(true,false,GLFW_KEY_SPACE));
|
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_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));
|
handler.addControl(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY, new Control(false,true,GLFW_MOUSE_BUTTON_LEFT));
|
||||||
@ -381,13 +385,75 @@ public class ControlHandler {
|
|||||||
Move up
|
Move up
|
||||||
*/
|
*/
|
||||||
if(controls.containsKey(DATA_STRING_INPUT_CODE_MOVEMENT_JUMP) && Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_JUMP).getKeyValue())){
|
if(controls.containsKey(DATA_STRING_INPUT_CODE_MOVEMENT_JUMP) && Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_JUMP).getKeyValue())){
|
||||||
EntityUtils.getPosition(Globals.playerCharacter).add(new Vector3f(0,0.6f,0).mul(1f));
|
// EntityUtils.getPosition(Globals.playerCharacter).add(new Vector3f(0,0.6f,0).mul(1f));
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Move down
|
Move down
|
||||||
*/
|
*/
|
||||||
if(controls.containsKey(DATA_STRING_INPUT_CODE_MOVEMENT_FALL) && Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FALL).getKeyValue())){
|
if(controls.containsKey(DATA_STRING_INPUT_CODE_MOVEMENT_FALL) && Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FALL).getKeyValue())){
|
||||||
EntityUtils.getPosition(Globals.playerCharacter).add(new Vector3f(0,-0.6f,0).mul(1f));
|
// EntityUtils.getPosition(Globals.playerCharacter).add(new Vector3f(0,-0.6f,0).mul(1f));
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Strafe left
|
||||||
|
*/
|
||||||
|
if(controls.containsKey(DATA_STRING_INPUT_CODE_STRAFE_LEFT)){
|
||||||
|
if(controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT).isIsKey() && Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT).getKeyValue())){
|
||||||
|
CreatureUtils.setFacingVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(Math.PI/2.0).normalize());
|
||||||
|
if(
|
||||||
|
(movementTree.getState()==MovementTreeState.IDLE || movementTree.getState()==MovementTreeState.SLOWDOWN) &&
|
||||||
|
(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD).isIsKey() && !Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD).getKeyValue())) &&
|
||||||
|
(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD).isIsKey() && !Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD).getKeyValue()))
|
||||||
|
){
|
||||||
|
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||||
|
}
|
||||||
|
controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT).setState(true);
|
||||||
|
//send to server
|
||||||
|
// Vector3f position = EntityUtils.getEntityPosition(Globals.playerCharacter);
|
||||||
|
// EntityMessage outgoingMessage = EntityMessage.constructMoveMessage(
|
||||||
|
// Globals.playerCharacter.getId(),
|
||||||
|
// System.currentTimeMillis(),
|
||||||
|
// position.x,
|
||||||
|
// position.y,
|
||||||
|
// position.z
|
||||||
|
// );
|
||||||
|
// Globals.clientConnection.queueOutgoingMessage(outgoingMessage);
|
||||||
|
} else {
|
||||||
|
if(controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT).isState() == true){
|
||||||
|
movementTree.slowdown();
|
||||||
|
}
|
||||||
|
controls.get(DATA_STRING_INPUT_CODE_STRAFE_LEFT).setState(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
Strafe right
|
||||||
|
*/
|
||||||
|
if(controls.containsKey(DATA_STRING_INPUT_CODE_STRAFE_RIGHT)){
|
||||||
|
if(controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT).isIsKey() && Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT).getKeyValue())){
|
||||||
|
CreatureUtils.setFacingVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).rotateY(-Math.PI/2.0).normalize());
|
||||||
|
if(
|
||||||
|
(movementTree.getState()==MovementTreeState.IDLE || movementTree.getState()==MovementTreeState.SLOWDOWN) &&
|
||||||
|
(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD).isIsKey() && !Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_FORWARD).getKeyValue())) &&
|
||||||
|
(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD).isIsKey() && !Globals.controlCallback.getKey(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_BACKWARD).getKeyValue()))
|
||||||
|
){
|
||||||
|
movementTree.start(MovementRelativeFacing.FORWARD);
|
||||||
|
}
|
||||||
|
controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT).setState(true);
|
||||||
|
//send to server
|
||||||
|
// Vector3f position = EntityUtils.getEntityPosition(Globals.playerCharacter);
|
||||||
|
// EntityMessage outgoingMessage = EntityMessage.constructMoveMessage(
|
||||||
|
// Globals.playerCharacter.getId(),
|
||||||
|
// System.currentTimeMillis(),
|
||||||
|
// position.x,
|
||||||
|
// position.y,
|
||||||
|
// position.z
|
||||||
|
// );
|
||||||
|
// Globals.clientConnection.queueOutgoingMessage(outgoingMessage);
|
||||||
|
} else {
|
||||||
|
if(controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT).isState() == true){
|
||||||
|
movementTree.slowdown();
|
||||||
|
}
|
||||||
|
controls.get(DATA_STRING_INPUT_CODE_STRAFE_RIGHT).setState(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
Sprint
|
Sprint
|
||||||
|
|||||||
@ -480,30 +480,51 @@ public class LoadingThread extends Thread {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void initGameGraphicalEntities(){
|
||||||
|
|
||||||
static void initArenaGraphicalEntities(){
|
|
||||||
|
|
||||||
Globals.skyboxColors.add(new Vector3f(150,200,250));
|
float skyR = 100;
|
||||||
Globals.skyboxColors.add(new Vector3f(150,200,250));
|
float skyG = 150;
|
||||||
Globals.skyboxColors.add(new Vector3f(20,20,20));
|
float skyB = 200;
|
||||||
Globals.skyboxColors.add(new Vector3f(20,20,20));
|
|
||||||
Globals.skyboxColors.add(new Vector3f(150,200,250));
|
float groundR = 50;
|
||||||
Globals.skyboxColors.add(new Vector3f(150,200,250));
|
float groundG = 100;
|
||||||
Globals.skyboxColors.add(new Vector3f(20,20,20));
|
float groundB = 150;
|
||||||
Globals.skyboxColors.add(new Vector3f(20,20,20));
|
|
||||||
|
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void initGameGraphicalEntities(){
|
|
||||||
|
|
||||||
Globals.skyboxColors.add(new Vector3f(100,150,200));
|
static void initArenaGraphicalEntities(){
|
||||||
Globals.skyboxColors.add(new Vector3f(100,150,200));
|
|
||||||
Globals.skyboxColors.add(new Vector3f(50,100,150));
|
float skyR = 150;
|
||||||
Globals.skyboxColors.add(new Vector3f(50,100,150));
|
float skyG = 200;
|
||||||
Globals.skyboxColors.add(new Vector3f(100,150,200));
|
float skyB = 250;
|
||||||
Globals.skyboxColors.add(new Vector3f(100,150,200));
|
|
||||||
Globals.skyboxColors.add(new Vector3f(50,100,150));
|
float groundR = 20;
|
||||||
Globals.skyboxColors.add(new Vector3f(50,100,150));
|
float groundG = 20;
|
||||||
|
float groundB = 20;
|
||||||
|
|
||||||
|
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(skyR,skyG,skyB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||||
|
Globals.skyboxColors.add(new Vector3f(groundR,groundG,groundB));
|
||||||
|
|
||||||
|
Entity cloudRing = EntityUtils.spawnDrawableEntity("Models/cloudRing.fbx");
|
||||||
|
EntityUtils.getRotation(cloudRing).rotateX((float)(-Math.PI/2.0f));
|
||||||
|
EntityUtils.getScale(cloudRing).mul(1000.0f);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
package electrosphere.entity;
|
package electrosphere.entity;
|
||||||
|
|
||||||
|
import electrosphere.entity.state.BehaviorTree;
|
||||||
import electrosphere.entity.types.attach.AttachUtils;
|
import electrosphere.entity.types.attach.AttachUtils;
|
||||||
import electrosphere.logger.LoggerInterface;
|
import electrosphere.logger.LoggerInterface;
|
||||||
import electrosphere.main.Globals;
|
import electrosphere.main.Globals;
|
||||||
@ -33,6 +34,8 @@ public class EntityManager {
|
|||||||
static CopyOnWriteArrayList<Entity> collidableList = new CopyOnWriteArrayList();
|
static CopyOnWriteArrayList<Entity> collidableList = new CopyOnWriteArrayList();
|
||||||
static CopyOnWriteArrayList<Entity> targetableList = new CopyOnWriteArrayList();
|
static CopyOnWriteArrayList<Entity> targetableList = new CopyOnWriteArrayList();
|
||||||
static CopyOnWriteArrayList<Entity> sprintableList = new CopyOnWriteArrayList();
|
static CopyOnWriteArrayList<Entity> sprintableList = new CopyOnWriteArrayList();
|
||||||
|
|
||||||
|
static CopyOnWriteArrayList<BehaviorTree> behaviorTreeList = new CopyOnWriteArrayList<BehaviorTree>();
|
||||||
|
|
||||||
public EntityManager(){
|
public EntityManager(){
|
||||||
|
|
||||||
|
|||||||
@ -0,0 +1,47 @@
|
|||||||
|
package electrosphere.entity.state;
|
||||||
|
|
||||||
|
import org.joml.Quaterniond;
|
||||||
|
import org.joml.Quaternionf;
|
||||||
|
|
||||||
|
import electrosphere.entity.Entity;
|
||||||
|
import electrosphere.entity.EntityUtils;
|
||||||
|
|
||||||
|
public class ApplyRotationTree implements BehaviorTree {
|
||||||
|
|
||||||
|
public static enum ApplyRotationTreeState {
|
||||||
|
ROTATE,
|
||||||
|
NO_ROTATE,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Quaternionf rotationToApply;
|
||||||
|
Entity parent;
|
||||||
|
ApplyRotationTreeState state;
|
||||||
|
|
||||||
|
public ApplyRotationTree(Entity parent, Quaternionf rotationToApply){
|
||||||
|
this.parent = parent;
|
||||||
|
this.rotationToApply = rotationToApply;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void start(){
|
||||||
|
state = ApplyRotationTreeState.ROTATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stop(){
|
||||||
|
state = ApplyRotationTreeState.NO_ROTATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void simulate(){
|
||||||
|
switch(state){
|
||||||
|
case ROTATE:
|
||||||
|
EntityUtils.getRotation(parent).slerp(rotationToApply, 1.0f);
|
||||||
|
break;
|
||||||
|
case NO_ROTATE:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@ -0,0 +1,7 @@
|
|||||||
|
package electrosphere.entity.state;
|
||||||
|
|
||||||
|
public interface BehaviorTree {
|
||||||
|
|
||||||
|
public void simulate();
|
||||||
|
|
||||||
|
}
|
||||||
@ -118,6 +118,7 @@ public class GroundMovementTree {
|
|||||||
Vector3d movementVector = new Vector3d(facingVector);
|
Vector3d movementVector = new Vector3d(facingVector);
|
||||||
switch(facing){
|
switch(facing){
|
||||||
case FORWARD:
|
case FORWARD:
|
||||||
|
movementVector.normalize();
|
||||||
break;
|
break;
|
||||||
case LEFT:
|
case LEFT:
|
||||||
movementVector.rotateY((float)(90 * Math.PI / 180)).normalize();
|
movementVector.rotateY((float)(90 * Math.PI / 180)).normalize();
|
||||||
@ -128,6 +129,7 @@ public class GroundMovementTree {
|
|||||||
case BACKWARD:
|
case BACKWARD:
|
||||||
movementVector.x = -movementVector.x;
|
movementVector.x = -movementVector.x;
|
||||||
movementVector.z = -movementVector.z;
|
movementVector.z = -movementVector.z;
|
||||||
|
movementVector.normalize();
|
||||||
break;
|
break;
|
||||||
case FORWARD_LEFT:
|
case FORWARD_LEFT:
|
||||||
movementVector.rotateY((float)(45 * Math.PI / 180)).normalize();
|
movementVector.rotateY((float)(45 * Math.PI / 180)).normalize();
|
||||||
@ -211,14 +213,12 @@ public class GroundMovementTree {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// System.out.println(movementVector + " " + velocity * Main.deltaTime);
|
||||||
|
|
||||||
//state machine
|
//state machine
|
||||||
switch(state){
|
switch(state){
|
||||||
case STARTUP:
|
case STARTUP:
|
||||||
//run startup code
|
|
||||||
velocity = velocity + acceleration * Main.deltaTime;
|
|
||||||
CreatureUtils.setVelocity(parent, velocity);
|
|
||||||
if(entityActor != null){
|
if(entityActor != null){
|
||||||
String animationToPlay = determineCorrectAnimation();
|
String animationToPlay = determineCorrectAnimation();
|
||||||
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(animationToPlay)){
|
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(animationToPlay)){
|
||||||
@ -226,11 +226,14 @@ public class GroundMovementTree {
|
|||||||
entityActor.incrementAnimationTime(0.01);
|
entityActor.incrementAnimationTime(0.01);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//run startup code
|
||||||
|
velocity = velocity + acceleration * Main.deltaTime;
|
||||||
//check if can transition state
|
//check if can transition state
|
||||||
if(velocity >= maxNaturalVelocity){
|
if(velocity >= maxNaturalVelocity){
|
||||||
velocity = maxNaturalVelocity;
|
velocity = maxNaturalVelocity;
|
||||||
state = MovementTreeState.MOVE;
|
state = MovementTreeState.MOVE;
|
||||||
}
|
}
|
||||||
|
CreatureUtils.setVelocity(parent, velocity);
|
||||||
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(new Vector3f(movementVector.x,0,movementVector.z).normalize().mul(velocity)));
|
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(new Vector3f(movementVector.x,0,movementVector.z).normalize().mul(velocity)));
|
||||||
EntityUtils.getRotation(parent).set(movementQuaternion);
|
EntityUtils.getRotation(parent).set(movementQuaternion);
|
||||||
// //move the entity
|
// //move the entity
|
||||||
@ -306,6 +309,7 @@ public class GroundMovementTree {
|
|||||||
}
|
}
|
||||||
if(velocity != maxNaturalVelocity){
|
if(velocity != maxNaturalVelocity){
|
||||||
velocity = maxNaturalVelocity;
|
velocity = maxNaturalVelocity;
|
||||||
|
CreatureUtils.setVelocity(parent, velocity);
|
||||||
}
|
}
|
||||||
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(force));
|
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(force));
|
||||||
EntityUtils.getRotation(parent).set(movementQuaternion);
|
EntityUtils.getRotation(parent).set(movementQuaternion);
|
||||||
@ -371,8 +375,6 @@ public class GroundMovementTree {
|
|||||||
break;
|
break;
|
||||||
case SLOWDOWN:
|
case SLOWDOWN:
|
||||||
//run slowdown code
|
//run slowdown code
|
||||||
velocity = velocity - acceleration * Main.deltaTime;
|
|
||||||
CreatureUtils.setVelocity(parent, velocity);
|
|
||||||
if(entityActor != null){
|
if(entityActor != null){
|
||||||
String animationToPlay = determineCorrectAnimation();
|
String animationToPlay = determineCorrectAnimation();
|
||||||
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(animationToPlay)){
|
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(animationToPlay)){
|
||||||
@ -380,11 +382,20 @@ public class GroundMovementTree {
|
|||||||
entityActor.incrementAnimationTime(0.01);
|
entityActor.incrementAnimationTime(0.01);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
//velocity stuff
|
||||||
|
velocity = velocity - acceleration * Main.deltaTime;
|
||||||
//check if can transition state
|
//check if can transition state
|
||||||
if(velocity <= 0){
|
if(velocity <= 0){
|
||||||
velocity = 0;
|
velocity = 0;
|
||||||
state = MovementTreeState.IDLE;
|
state = MovementTreeState.IDLE;
|
||||||
|
if(entityActor != null){
|
||||||
|
String animationToPlay = determineCorrectAnimation();
|
||||||
|
if(entityActor.isPlayingAnimation() && entityActor.isPlayingAnimation(animationToPlay)){
|
||||||
|
entityActor.stopAnimation(animationToPlay);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
CreatureUtils.setVelocity(parent, velocity);
|
||||||
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(new Vector3f(movementVector).mul(-1.0f).normalize().mul(velocity)));
|
// body.applyCentralForce(PhysicsUtils.jomlToVecmathVector3f(new Vector3f(movementVector).mul(-1.0f).normalize().mul(velocity)));
|
||||||
EntityUtils.getRotation(parent).rotationTo(new Vector3f(0,0,1), new Vector3f((float)movementVector.x,(float)movementVector.y,(float)movementVector.z));
|
EntityUtils.getRotation(parent).rotationTo(new Vector3f(0,0,1), new Vector3f((float)movementVector.x,(float)movementVector.y,(float)movementVector.z));
|
||||||
//move the entity
|
//move the entity
|
||||||
@ -448,12 +459,7 @@ public class GroundMovementTree {
|
|||||||
break;
|
break;
|
||||||
case IDLE:
|
case IDLE:
|
||||||
// body.clearForces();
|
// body.clearForces();
|
||||||
if(entityActor != null){
|
|
||||||
String animationToPlay = determineCorrectAnimation();
|
|
||||||
if(entityActor.isPlayingAnimation() && entityActor.isPlayingAnimation(animationToPlay)){
|
|
||||||
entityActor.stopAnimation(animationToPlay);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// if(Globals.collisionEngine.gravityCheck(Globals.commonWorldData, parent)){
|
// if(Globals.collisionEngine.gravityCheck(Globals.commonWorldData, parent)){
|
||||||
// position.set(Globals.collisionEngine.suggestMovementPosition(Globals.commonWorldData,parent,new Vector3f(position.x,position.y - 9.8f,position.z)));
|
// position.set(Globals.collisionEngine.suggestMovementPosition(Globals.commonWorldData,parent,new Vector3f(position.x,position.y - 9.8f,position.z)));
|
||||||
// }
|
// }
|
||||||
|
|||||||
@ -129,7 +129,13 @@ public class DataCellManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendNetworkMessageToChunk(NetworkMessage message, int worldX, int worldY){
|
public void sendNetworkMessageToChunk(NetworkMessage message, int worldX, int worldY){
|
||||||
if(dataCells[worldX][worldY] != null){
|
if(
|
||||||
|
//in bounds of array
|
||||||
|
worldX >= 0 && worldX < dataCells.length &&
|
||||||
|
worldY >= 0 && worldY < dataCells[0].length &&
|
||||||
|
//isn't null
|
||||||
|
dataCells[worldX][worldY] != null
|
||||||
|
){
|
||||||
dataCells[worldX][worldY].broadcastNetworkMessage(message);
|
dataCells[worldX][worldY].broadcastNetworkMessage(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -740,14 +740,14 @@ public class Mesh {
|
|||||||
temp[2] = lightLoc.z;
|
temp[2] = lightLoc.z;
|
||||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.direction"), temp);
|
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.direction"), temp);
|
||||||
|
|
||||||
|
temp[0] = 0.4f;
|
||||||
|
temp[1] = 0.4f;
|
||||||
|
temp[2] = 0.4f;
|
||||||
|
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.ambient"), temp);
|
||||||
|
|
||||||
temp[0] = 0.3f;
|
temp[0] = 0.3f;
|
||||||
temp[1] = 0.3f;
|
temp[1] = 0.3f;
|
||||||
temp[2] = 0.3f;
|
temp[2] = 0.3f;
|
||||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.ambient"), temp);
|
|
||||||
|
|
||||||
temp[0] = 0.5f;
|
|
||||||
temp[1] = 0.5f;
|
|
||||||
temp[2] = 0.5f;
|
|
||||||
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.diffuse"), temp);
|
glUniform3fv(glGetUniformLocation(Globals.renderingEngine.getActiveShader().shaderProgram, "dirLight.diffuse"), temp);
|
||||||
|
|
||||||
temp[0] = 0.1f;
|
temp[0] = 0.1f;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user