synchronization work
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-07-31 10:29:05 -04:00
parent 8fafdf4cb7
commit 4eaad3a6dd
20 changed files with 884 additions and 163 deletions

View File

@ -25,12 +25,28 @@
{
"name" : "stringValue",
"type" : "VAR_STRING"
},
{
"name" : "intValue",
"type" : "FIXED_INT"
},
{
"name" : "longValue",
"type" : "FIXED_LONG"
},
{
"name" : "floatValue",
"type" : "FIXED_FLOAT"
},
{
"name" : "doubleValue",
"type" : "FIXED_DOUBLE"
}
],
"messageTypes" : [
{
"messageName" : "UpdateClientState",
"description" : "Updates an integer on the client",
"description" : "Updates a btree state variable on the client",
"data" : [
"entityId",
"bTreeId",
@ -48,6 +64,55 @@
"stringValue"
]
},
{
"messageName" : "UpdateClientIntState",
"description" : "Updates an int on the client",
"data" : [
"entityId",
"bTreeId",
"fieldId",
"intValue"
]
},
{
"messageName" : "UpdateClientLongState",
"description" : "Updates a long on the client",
"data" : [
"entityId",
"bTreeId",
"fieldId",
"longValue"
]
},
{
"messageName" : "UpdateClientFloatState",
"description" : "Updates a float on the client",
"data" : [
"entityId",
"bTreeId",
"fieldId",
"floatValue"
]
},
{
"messageName" : "UpdateClientDoubleState",
"description" : "Updates a double on the client",
"data" : [
"entityId",
"bTreeId",
"fieldId",
"doubleValue"
]
},
{
"messageName" : "ClientRequestBTreeAction",
"description" : "Client requests a btree on the server performs an action (ie start, interrupt, etc)",
"data" : [
"entityId",
"bTreeId",
"bTreeValue"
]
},
{
"messageName" : "AttachTree",
"description" : "Attaches a btree to an entity on the client",

View File

@ -91,7 +91,7 @@ import electrosphere.entity.state.movement.SprintTree;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementRelativeFacing;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementTreeState;
import electrosphere.entity.state.movement.jump.JumpTree;
import electrosphere.entity.state.movement.jump.ClientJumpTree;
import electrosphere.entity.types.camera.CameraEntityUtils;
import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.logger.LoggerInterface;
@ -821,7 +821,7 @@ public class ControlHandler {
mainGameControlList.add(controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_JUMP));
controls.get(DATA_STRING_INPUT_CODE_MOVEMENT_JUMP).setOnPress(new ControlMethod(){public void execute(){
if(Globals.playerEntity != null){
JumpTree jumpTree = JumpTree.getClientJumpTree(Globals.playerEntity);
ClientJumpTree jumpTree = ClientJumpTree.getClientJumpTree(Globals.playerEntity);
if(jumpTree != null){
jumpTree.start();
}

View File

@ -65,8 +65,8 @@ public class EntityDataStrings {
public static final String CREATURE_ATTRIBUTE_VARIANT = "creatureAttributeVariant";
public static final String CLIENT_ROTATOR_TREE = "clientRotatorTree";
public static final String SERVER_ROTATOR_TREE = "serverRotatorTree";
public static final String CLIENT_JUMP_TREE = "clientJumpTree";
public static final String SERVER_JUMP_TREE = "serverJumpTree";
public static final String TREE_CLIENTJUMPTREE = "treeClientJumpTree";
public static final String TREE_SERVERJUMPTREE = "treeServerJumpTree";
public static final String FALL_TREE = "fallTree";
public static final String CREATURE_TEMPLATE = "creatureTemplate";
public static final String FIRST_PERSON_TREE = "firstPersonTree";

View File

@ -20,7 +20,7 @@ import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.collidable.ClientCollidableTree;
import electrosphere.entity.state.collidable.Impulse;
import electrosphere.entity.state.movement.FallTree;
import electrosphere.entity.state.movement.jump.JumpTree;
import electrosphere.entity.state.movement.jump.ClientJumpTree;
import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizableEnum;
@ -116,8 +116,8 @@ public class ClientGravityTree implements BehaviorTree {
if(!hadStructureCollision()){
// position.set(new Vector3d(position.x,Globals.commonWorldData.getElevationAtPoint(position) + 0.0001f,position.z));
}
JumpTree jumpTree;
if((jumpTree = JumpTree.getClientJumpTree(parent))!=null){
ClientJumpTree jumpTree;
if((jumpTree = ClientJumpTree.getClientJumpTree(parent))!=null){
jumpTree.land();
}
FallTree fallTree;

View File

@ -9,7 +9,7 @@ import electrosphere.entity.btree.StateTransitionUtil;
import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem;
import electrosphere.entity.state.AnimationPriorities;
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
import electrosphere.entity.state.movement.jump.JumpTree;
import electrosphere.entity.state.movement.jump.ClientJumpTree;
import electrosphere.game.data.creature.type.movement.FallMovementSystem;
import electrosphere.renderer.actor.Actor;
@ -36,7 +36,7 @@ public class FallTree implements BehaviorTree {
Entity parent;
//the related jump tree
JumpTree jumpTree;
ClientJumpTree jumpTree;
//The state transition util
StateTransitionUtil stateTransitionUtil;
@ -115,7 +115,7 @@ public class FallTree implements BehaviorTree {
* Sets the related jump tree
* @param jumpTree the jump tree that is related to this fall tree (on the same entity)
*/
public void setJumpTree(JumpTree jumpTree){
public void setJumpTree(ClientJumpTree jumpTree){
this.jumpTree = jumpTree;
}

View File

@ -21,7 +21,7 @@ import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
import electrosphere.entity.state.movement.FallTree;
import electrosphere.entity.state.movement.SprintTree;
import electrosphere.entity.state.movement.SprintTree.SprintTreeState;
import electrosphere.entity.state.movement.jump.JumpTree;
import electrosphere.entity.state.movement.jump.ClientJumpTree;
import electrosphere.net.parser.net.message.EntityMessage;
import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizableEnum;
@ -87,7 +87,7 @@ public class ClientGroundMovementTree implements BehaviorTree {
MovementRelativeFacing facing = MovementRelativeFacing.FORWARD;
SprintTree sprintTree;
JumpTree jumpTree;
ClientJumpTree jumpTree;
FallTree fallTree;
GroundMovementSystem groundMovementData;
@ -431,7 +431,7 @@ public class ClientGroundMovementTree implements BehaviorTree {
this.sprintTree = sprintTree;
}
public void setClientJumpTree(JumpTree jumpTree){
public void setClientJumpTree(ClientJumpTree jumpTree){
this.jumpTree = jumpTree;
}

View File

@ -1,6 +1,7 @@
package electrosphere.entity.state.movement.groundmove;
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import electrosphere.net.synchronization.FieldIdEnums;
import electrosphere.net.parser.net.message.SynchronizationMessage;

View File

@ -0,0 +1,276 @@
package electrosphere.entity.state.movement.jump;
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
import org.ode4j.math.DVector3C;
import org.ode4j.ode.DBody;
import electrosphere.collision.PhysicsEntityUtils;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.AnimationPriorities;
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
import electrosphere.entity.state.gravity.GravityUtils;
import electrosphere.game.data.creature.type.movement.JumpMovementSystem;
import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizableEnum;
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
import electrosphere.renderer.actor.Actor;
@SynchronizedBehaviorTree(name = "clientJumpTree", isServer = false, correspondingTree="serverJumpTree")
/*
Behavior tree for jumping
*/
public class ClientJumpTree implements BehaviorTree {
/**
* States for the jump tree
*/
@SynchronizableEnum
public static enum JumpState {
INACTIVE,
ACTIVE,
AWAITING_LAND,
}
@SyncedField
JumpState state = JumpState.INACTIVE;
@SyncedField
int currentFrame = 0;
@SyncedField
float currentJumpForce = 0;
String animationJump = "Armature|Jump";
JumpMovementSystem jumpData;
Entity parent;
int jumpFrames = 0;
float jumpForce = 10.0f;
static final float jumpFalloff = 0.99f;
public ClientJumpTree(Entity parent, JumpMovementSystem jumpData){
this.parent = parent;
this.jumpFrames = jumpData.getJumpFrames();
this.jumpForce = jumpData.getJumpForce();
this.jumpData = jumpData;
}
public void start(){
// if(state == JumpState.INACTIVE){
state = JumpState.ACTIVE;
currentFrame = 0;
currentJumpForce = jumpForce;
GravityUtils.clientAttemptActivateGravity(parent);
// }
}
@Override
public void simulate(float deltaTime) {
Actor entityActor = EntityUtils.getActor(parent);
switch(state){
case ACTIVE:
if(entityActor != null){
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(jumpData.getAnimationJump().getNameThirdPerson())){
entityActor.playAnimation(jumpData.getAnimationJump().getNameThirdPerson(),AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER));
entityActor.incrementAnimationTime(0.0001);
}
FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, jumpData.getAnimationJump());
}
currentFrame++;
currentJumpForce = currentJumpForce * jumpFalloff;
//stop body falling if it is
DBody body = PhysicsEntityUtils.getDBody(parent);
DVector3C linearVelocity = body.getLinearVel();
body.setLinearVel(linearVelocity.get0(), 0, linearVelocity.get2());
//push parent up
body.addForce(0, currentJumpForce, 0);
//potentially disable
if(currentFrame >= jumpFrames){
state = JumpState.AWAITING_LAND;
GravityUtils.clientAttemptActivateGravity(parent);
}
break;
case INACTIVE:
break;
case AWAITING_LAND:
break;
}
}
/**
* <p>
* Gets the ClientJumpTree of the entity
* </p>
* @param entity the entity
* @return The ClientJumpTree
*/
public static ClientJumpTree getClientJumpTree(Entity entity){
return (ClientJumpTree)entity.getData(EntityDataStrings.TREE_CLIENTJUMPTREE);
}
public void land(){
if(state != JumpState.INACTIVE && currentFrame > 2){
state = JumpState.INACTIVE;
}
}
public boolean isJumping(){
return state == JumpState.ACTIVE;
}
String determineCorrectAnimation(){
return animationJump;
}
public void setAnimationJump(String animationName){
animationJump = animationName;
}
/**
* <p> Automatically generated </p>
* <p>
* Gets state.
* </p>
*/
public JumpState getState(){
return state;
}
/**
* <p> Automatically generated </p>
* <p>
* Sets state and handles the synchronization logic for it.
* </p>
* @param state The value to set state to.
*/
public void setState(JumpState state){
this.state = state;
}
/**
* <p> (initially) Automatically generated </p>
* <p> More parameters can be safely added to this method</p>
* <p>
* Attaches this tree to the entity.
* </p>
* @param entity The entity to attach to
* @param tree The behavior tree to attach
*/
public static ClientJumpTree attachTree(Entity parent, JumpMovementSystem jumpData){
ClientJumpTree rVal = new ClientJumpTree(parent, jumpData);
//put manual code here (setting params, etc)
//!!WARNING!! from here below should not be touched
//This was generated automatically to properly alert various systems that the btree exists and should be tracked
parent.putData(EntityDataStrings.TREE_CLIENTJUMPTREE, rVal);
Globals.clientSceneWrapper.getScene().registerBehaviorTree(rVal);
Globals.entityValueTrackingService.attachTreeToEntity(parent, BehaviorTreeIdEnums.BTREE_CLIENTJUMPTREE_ID);
return rVal;
}
/**
* <p> Automatically generated </p>
* <p>
* Detatches this tree from the entity.
* </p>
* @param entity The entity to detach to
* @param tree The behavior tree to detach
*/
public static void detachTree(Entity entity, BehaviorTree tree){
Globals.entityValueTrackingService.detatchTreeFromEntity(entity, BehaviorTreeIdEnums.BTREE_CLIENTJUMPTREE_ID);
}
/**
* <p> Automatically generated </p>
* <p>
* Converts this enum type to an equivalent short value
* </p>
* @param enumVal The enum value
* @return The short value
*/
public static short getJumpStateEnumAsShort(JumpState enumVal){
switch(enumVal){
case INACTIVE:
return 0;
case ACTIVE:
return 1;
case AWAITING_LAND:
return 2;
default:
return 0;
}
}
/**
* <p> Automatically generated </p>
* <p>
* Converts a short to the equivalent enum value
* </p>
* @param shortVal The short value
* @return The enum value
*/
public static JumpState getJumpStateShortAsEnum(short shortVal){
switch(shortVal){
case 0:
return JumpState.INACTIVE;
case 1:
return JumpState.ACTIVE;
case 2:
return JumpState.AWAITING_LAND;
default:
return JumpState.INACTIVE;
}
}
/**
* <p> Automatically generated </p>
* <p>
* Gets currentFrame.
* </p>
*/
public int getCurrentFrame(){
return currentFrame;
}
/**
* <p> Automatically generated </p>
* <p>
* Sets currentFrame and handles the synchronization logic for it.
* </p>
* @param currentFrame The value to set currentFrame to.
*/
public void setCurrentFrame(int currentFrame){
this.currentFrame = currentFrame;
}
/**
* <p> Automatically generated </p>
* <p>
* Gets currentJumpForce.
* </p>
*/
public float getCurrentJumpForce(){
return currentJumpForce;
}
/**
* <p> Automatically generated </p>
* <p>
* Sets currentJumpForce and handles the synchronization logic for it.
* </p>
* @param currentJumpForce The value to set currentJumpForce to.
*/
public void setCurrentJumpForce(float currentJumpForce){
this.currentJumpForce = currentJumpForce;
}
}

View File

@ -1,112 +0,0 @@
package electrosphere.entity.state.movement.jump;
import org.ode4j.math.DVector3C;
import org.ode4j.ode.DBody;
import electrosphere.collision.PhysicsEntityUtils;
import electrosphere.engine.Globals;
import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.AnimationPriorities;
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
import electrosphere.entity.state.gravity.GravityUtils;
import electrosphere.game.data.creature.type.movement.JumpMovementSystem;
import electrosphere.renderer.actor.Actor;
public class JumpTree implements BehaviorTree {
public static enum JumpState {
INACTIVE,
ACTIVE,
AWAITING_LAND,
}
JumpState state = JumpState.INACTIVE;
String animationJump = "Armature|Jump";
JumpMovementSystem jumpData;
Entity parent;
int jumpFrames = 0;
int currentFrame = 0;
float jumpForce = 10.0f;
float currentJumpForce = jumpForce;
static final float jumpFalloff = 0.99f;
public JumpTree(Entity parent, int jumpFrames, float jumpForce, JumpMovementSystem jumpData){
this.parent = parent;
this.jumpFrames = jumpFrames;
this.jumpForce = jumpForce;
this.jumpData = jumpData;
}
public void start(){
// if(state == JumpState.INACTIVE){
state = JumpState.ACTIVE;
currentFrame = 0;
currentJumpForce = jumpForce;
GravityUtils.clientAttemptActivateGravity(parent);
// }
}
@Override
public void simulate(float deltaTime) {
Actor entityActor = EntityUtils.getActor(parent);
switch(state){
case ACTIVE:
if(entityActor != null){
if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(jumpData.getAnimationJump().getNameThirdPerson())){
entityActor.playAnimation(jumpData.getAnimationJump().getNameThirdPerson(),AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER));
entityActor.incrementAnimationTime(0.0001);
}
FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, jumpData.getAnimationJump());
}
currentFrame++;
currentJumpForce = currentJumpForce * jumpFalloff;
//stop body falling if it is
DBody body = PhysicsEntityUtils.getDBody(parent);
DVector3C linearVelocity = body.getLinearVel();
body.setLinearVel(linearVelocity.get0(), 0, linearVelocity.get2());
//push parent up
body.addForce(0, currentJumpForce, 0);
//potentially disable
if(currentFrame >= jumpFrames){
state = JumpState.AWAITING_LAND;
GravityUtils.clientAttemptActivateGravity(parent);
}
break;
case INACTIVE:
break;
case AWAITING_LAND:
break;
}
}
public static JumpTree getClientJumpTree(Entity parent){
return (JumpTree)parent.getData(EntityDataStrings.CLIENT_JUMP_TREE);
}
public void land(){
if(state != JumpState.INACTIVE && currentFrame > 2){
state = JumpState.INACTIVE;
}
}
public boolean isJumping(){
return state == JumpState.ACTIVE;
}
String determineCorrectAnimation(){
return animationJump;
}
public void setAnimationJump(String animationName){
animationJump = animationName;
}
}

View File

@ -1,5 +1,12 @@
package electrosphere.entity.state.movement.jump;
import electrosphere.net.synchronization.FieldIdEnums;
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import electrosphere.net.parser.net.message.SynchronizationMessage;
import electrosphere.server.datacell.utils.DataCellSearchUtils;
import electrosphere.engine.Globals;
import org.ode4j.math.DVector3C;
import org.ode4j.ode.DBody;
@ -10,38 +17,47 @@ import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.AnimationPriorities;
import electrosphere.entity.state.gravity.GravityUtils;
import electrosphere.entity.state.movement.jump.ClientJumpTree.JumpState;
import electrosphere.game.data.creature.type.movement.JumpMovementSystem;
import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
import electrosphere.server.poseactor.PoseActor;
@SynchronizedBehaviorTree(name = "serverJumpTree", isServer = true, correspondingTree="clientJumpTree")
/*
Behavior tree for movement in an entity
*/
public class ServerJumpTree implements BehaviorTree {
static enum JumpState {
INACTIVE,
ACTIVE,
AWAITING_LAND,
}
@SyncedField
JumpState state = JumpState.INACTIVE;
@SyncedField
int currentFrame = 0;
@SyncedField
float currentJumpForce = 0;
String animationJump = "Armature|Jump";
Entity parent;
int jumpFrames = 0;
int currentFrame = 0;
float jumpForce = 10.0f;
float currentJumpForce = jumpForce;
JumpMovementSystem jumpData;
static final float jumpFalloff = 0.99f;
public ServerJumpTree(Entity parent, int jumpFrames, float jumpForce){
public ServerJumpTree(Entity parent, JumpMovementSystem jumpData){
this.parent = parent;
this.jumpFrames = jumpFrames;
this.jumpForce = jumpForce;
this.jumpFrames = jumpData.getJumpFrames();
this.jumpForce = jumpData.getJumpForce();
this.jumpData = jumpData;
}
public void start(){
if(state == JumpState.INACTIVE){
state = JumpState.ACTIVE;
this.setState(JumpState.ACTIVE);
currentFrame = 0;
currentJumpForce = jumpForce;
GravityUtils.serverAttemptActivateGravity(parent);
@ -81,8 +97,15 @@ public class ServerJumpTree implements BehaviorTree {
}
}
public static ServerJumpTree getServerJumpTree(Entity parent){
return (ServerJumpTree)parent.getData(EntityDataStrings.SERVER_JUMP_TREE);
/**
* <p>
* Gets the ServerJumpTree of the entity
* </p>
* @param entity the entity
* @return The ServerJumpTree
*/
public static ServerJumpTree getServerJumpTree(Entity entity){
return (ServerJumpTree)entity.getData(EntityDataStrings.TREE_SERVERJUMPTREE);
}
public void land(){
@ -103,4 +126,105 @@ public class ServerJumpTree implements BehaviorTree {
animationJump = animationName;
}
/**
* <p> Automatically generated </p>
* <p>
* Gets state.
* </p>
*/
public JumpState getState(){
return state;
}
/**
* <p> Automatically generated </p>
* <p>
* Sets state and handles the synchronization logic for it.
* </p>
* @param state The value to set state to.
*/
public void setState(JumpState state){
this.state = state;
int value = ClientJumpTree.getJumpStateEnumAsShort(state);
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientStateMessage(parent.getId(), BehaviorTreeIdEnums.BTREE_SERVERJUMPTREE_ID, FieldIdEnums.TREE_SERVERJUMPTREE_SYNCEDFIELD_STATE_ID, value));
}
/**
* <p> (initially) Automatically generated </p>
* <p> More parameters can be safely added to this method</p>
* <p>
* Attaches this tree to the entity.
* </p>
* @param entity The entity to attach to
* @param tree The behavior tree to attach
*/
public static ServerJumpTree attachTree(Entity parent, JumpMovementSystem jumpData){
ServerJumpTree rVal = new ServerJumpTree(parent, jumpData);
//put manual code here (setting params, etc)
//!!WARNING!! from here below should not be touched
//This was generated automatically to properly alert various systems that the btree exists and should be tracked
ServerBehaviorTreeUtils.attachBTreeToEntity(parent, rVal);
parent.putData(EntityDataStrings.TREE_SERVERJUMPTREE, rVal);
Globals.entityValueTrackingService.attachTreeToEntity(parent, BehaviorTreeIdEnums.BTREE_SERVERJUMPTREE_ID);
return rVal;
}
/**
* <p> Automatically generated </p>
* <p>
* Detatches this tree from the entity.
* </p>
* @param entity The entity to detach to
* @param tree The behavior tree to detach
*/
public static void detachTree(Entity entity, BehaviorTree tree){
Globals.entityValueTrackingService.detatchTreeFromEntity(entity, BehaviorTreeIdEnums.BTREE_SERVERJUMPTREE_ID);
}
/**
* <p> Automatically generated </p>
* <p>
* Gets currentFrame.
* </p>
*/
public int getCurrentFrame(){
return currentFrame;
}
/**
* <p> Automatically generated </p>
* <p>
* Sets currentFrame and handles the synchronization logic for it.
* </p>
* @param currentFrame The value to set currentFrame to.
*/
public void setCurrentFrame(int currentFrame){
this.currentFrame = currentFrame;
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientIntStateMessage(parent.getId(), BehaviorTreeIdEnums.BTREE_SERVERJUMPTREE_ID, FieldIdEnums.TREE_SERVERJUMPTREE_SYNCEDFIELD_CURRENTFRAME_ID, currentFrame));
}
/**
* <p> Automatically generated </p>
* <p>
* Gets currentJumpForce.
* </p>
*/
public float getCurrentJumpForce(){
return currentJumpForce;
}
/**
* <p> Automatically generated </p>
* <p>
* Sets currentJumpForce and handles the synchronization logic for it.
* </p>
* @param currentJumpForce The value to set currentJumpForce to.
*/
public void setCurrentJumpForce(float currentJumpForce){
this.currentJumpForce = currentJumpForce;
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientFloatStateMessage(parent.getId(), BehaviorTreeIdEnums.BTREE_SERVERJUMPTREE_ID, FieldIdEnums.TREE_SERVERJUMPTREE_SYNCEDFIELD_CURRENTJUMPFORCE_ID, currentJumpForce));
}
}

View File

@ -39,7 +39,7 @@ import electrosphere.entity.state.movement.ServerSprintTree;
import electrosphere.entity.state.movement.SprintTree;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree;
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
import electrosphere.entity.state.movement.jump.JumpTree;
import electrosphere.entity.state.movement.jump.ClientJumpTree;
import electrosphere.entity.state.movement.jump.ServerJumpTree;
import electrosphere.entity.state.rotator.RotatorHierarchyNode;
import electrosphere.entity.state.rotator.RotatorTree;
@ -170,7 +170,7 @@ public class CreatureUtils {
// Jump
case JumpMovementSystem.JUMP_MOVEMENT_SYSTEM:
JumpMovementSystem jumpMovementSystem = (JumpMovementSystem)movementSystem;
JumpTree jumpTree = new JumpTree(rVal, jumpMovementSystem.getJumpFrames(), jumpMovementSystem.getJumpForce(), jumpMovementSystem);
ClientJumpTree jumpTree = ClientJumpTree.attachTree(rVal, jumpMovementSystem);
if(jumpMovementSystem.getAnimationJump() != null){
jumpTree.setAnimationJump(jumpMovementSystem.getAnimationJump().getNameThirdPerson());
}
@ -180,8 +180,6 @@ public class CreatureUtils {
if(FallTree.getFallTree(rVal)!=null){
FallTree.getFallTree(rVal).setJumpTree(jumpTree);
}
rVal.putData(EntityDataStrings.CLIENT_JUMP_TREE, jumpTree);
Globals.clientScene.registerBehaviorTree(jumpTree);
break;
//
// Falling
@ -191,8 +189,8 @@ public class CreatureUtils {
if(CreatureUtils.clientGetEntityMovementTree(rVal) != null && CreatureUtils.clientGetEntityMovementTree(rVal) instanceof ClientGroundMovementTree){
((ClientGroundMovementTree)CreatureUtils.clientGetEntityMovementTree(rVal)).setClientFallTree(fallTree);
}
if(JumpTree.getClientJumpTree(rVal)!=null){
fallTree.setJumpTree(JumpTree.getClientJumpTree(rVal));
if(ClientJumpTree.getClientJumpTree(rVal)!=null){
fallTree.setJumpTree(ClientJumpTree.getClientJumpTree(rVal));
}
rVal.putData(EntityDataStrings.FALL_TREE, fallTree);
Globals.clientScene.registerBehaviorTree(fallTree);
@ -443,7 +441,7 @@ public class CreatureUtils {
// Jump
case JumpMovementSystem.JUMP_MOVEMENT_SYSTEM:
JumpMovementSystem jumpMovementSystem = (JumpMovementSystem)movementSystem;
ServerJumpTree jumpTree = new ServerJumpTree(rVal, jumpMovementSystem.getJumpFrames(), jumpMovementSystem.getJumpForce());
ServerJumpTree jumpTree = ServerJumpTree.attachTree(rVal, jumpMovementSystem);
if(jumpMovementSystem.getAnimationJump() != null){
jumpTree.setAnimationJump(jumpMovementSystem.getAnimationJump().getNameThirdPerson());
}
@ -453,8 +451,6 @@ public class CreatureUtils {
if(ServerFallTree.getFallTree(rVal)!=null){
ServerFallTree.getFallTree(rVal).setServerJumpTree(jumpTree);
}
rVal.putData(EntityDataStrings.SERVER_JUMP_TREE, jumpTree);
ServerBehaviorTreeUtils.attachBTreeToEntity(rVal, jumpTree);
break;
//
// Falling

View File

@ -18,13 +18,18 @@ public class SynchronizationProtocol implements ClientProtocolTemplate<Synchroni
public void handleSyncMessage(SynchronizationMessage message) {
Globals.profiler.beginCpuSample("SynchronizationProtocol.handleSynchronizationMessage");
switch(message.getMessageSubtype()){
case CLIENTREQUESTBTREEACTION:
case UPDATECLIENTSTATE:
case UPDATECLIENTSTRINGSTATE:
case UPDATECLIENTDOUBLESTATE:
case UPDATECLIENTFLOATSTATE:
case UPDATECLIENTINTSTATE:
case UPDATECLIENTLONGSTATE:
case ATTACHTREE:
case DETATCHTREE:
Globals.clientSynchronizationManager.pushMessage(message);
Globals.clientSynchronizationManager.pushMessage(message);
break;
default:
case LOADSCENE:
throw new UnsupportedOperationException("Received synchronization message on the client of unsupported type: " + message.getMessageSubtype());
}
Globals.profiler.endCpuSample();

View File

@ -346,6 +346,31 @@ SYNCHRONIZATION_MESSAGE,
rVal = SynchronizationMessage.parseUpdateClientStringStateMessage(byteBuffer);
}
break;
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTINTSTATE:
if(SynchronizationMessage.canParseMessage(byteBuffer,secondByte)){
rVal = SynchronizationMessage.parseUpdateClientIntStateMessage(byteBuffer);
}
break;
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTLONGSTATE:
if(SynchronizationMessage.canParseMessage(byteBuffer,secondByte)){
rVal = SynchronizationMessage.parseUpdateClientLongStateMessage(byteBuffer);
}
break;
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTFLOATSTATE:
if(SynchronizationMessage.canParseMessage(byteBuffer,secondByte)){
rVal = SynchronizationMessage.parseUpdateClientFloatStateMessage(byteBuffer);
}
break;
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTDOUBLESTATE:
if(SynchronizationMessage.canParseMessage(byteBuffer,secondByte)){
rVal = SynchronizationMessage.parseUpdateClientDoubleStateMessage(byteBuffer);
}
break;
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_CLIENTREQUESTBTREEACTION:
if(SynchronizationMessage.canParseMessage(byteBuffer,secondByte)){
rVal = SynchronizationMessage.parseClientRequestBTreeActionMessage(byteBuffer);
}
break;
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE:
if(SynchronizationMessage.canParseMessage(byteBuffer,secondByte)){
rVal = SynchronizationMessage.parseAttachTreeMessage(byteBuffer);

View File

@ -10,6 +10,11 @@ public class SynchronizationMessage extends NetworkMessage {
public enum SynchronizationMessageType {
UPDATECLIENTSTATE,
UPDATECLIENTSTRINGSTATE,
UPDATECLIENTINTSTATE,
UPDATECLIENTLONGSTATE,
UPDATECLIENTFLOATSTATE,
UPDATECLIENTDOUBLESTATE,
CLIENTREQUESTBTREEACTION,
ATTACHTREE,
DETATCHTREE,
LOADSCENE,
@ -21,6 +26,10 @@ public class SynchronizationMessage extends NetworkMessage {
int fieldId;
int bTreeValue;
String stringValue;
int intValue;
long longValue;
float floatValue;
double doubleValue;
SynchronizationMessage(SynchronizationMessageType messageType){
this.type = MessageType.SYNCHRONIZATION_MESSAGE;
@ -71,6 +80,38 @@ public class SynchronizationMessage extends NetworkMessage {
this.stringValue = stringValue;
}
public int getintValue() {
return intValue;
}
public void setintValue(int intValue) {
this.intValue = intValue;
}
public long getlongValue() {
return longValue;
}
public void setlongValue(long longValue) {
this.longValue = longValue;
}
public float getfloatValue() {
return floatValue;
}
public void setfloatValue(float floatValue) {
this.floatValue = floatValue;
}
public double getdoubleValue() {
return doubleValue;
}
public void setdoubleValue(double doubleValue) {
this.doubleValue = doubleValue;
}
static void stripPacketHeader(CircularByteBuffer byteBuffer){
byteBuffer.read(2);
}
@ -85,6 +126,36 @@ public class SynchronizationMessage extends NetworkMessage {
}
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTSTRINGSTATE:
return SynchronizationMessage.canParseUpdateClientStringStateMessage(byteBuffer);
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTINTSTATE:
if(byteBuffer.getRemaining() >= TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTINTSTATE_SIZE){
return true;
} else {
return false;
}
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTLONGSTATE:
if(byteBuffer.getRemaining() >= TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTLONGSTATE_SIZE){
return true;
} else {
return false;
}
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTFLOATSTATE:
if(byteBuffer.getRemaining() >= TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTFLOATSTATE_SIZE){
return true;
} else {
return false;
}
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTDOUBLESTATE:
if(byteBuffer.getRemaining() >= TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTDOUBLESTATE_SIZE){
return true;
} else {
return false;
}
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_CLIENTREQUESTBTREEACTION:
if(byteBuffer.getRemaining() >= TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_CLIENTREQUESTBTREEACTION_SIZE){
return true;
} else {
return false;
}
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE:
if(byteBuffer.getRemaining() >= TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE_SIZE){
return true;
@ -171,6 +242,104 @@ public class SynchronizationMessage extends NetworkMessage {
return rVal;
}
public static SynchronizationMessage parseUpdateClientIntStateMessage(CircularByteBuffer byteBuffer){
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.UPDATECLIENTINTSTATE);
stripPacketHeader(byteBuffer);
rVal.setentityId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setbTreeId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setfieldId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setintValue(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
return rVal;
}
public static SynchronizationMessage constructUpdateClientIntStateMessage(int entityId,int bTreeId,int fieldId,int intValue){
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.UPDATECLIENTINTSTATE);
rVal.setentityId(entityId);
rVal.setbTreeId(bTreeId);
rVal.setfieldId(fieldId);
rVal.setintValue(intValue);
rVal.serialize();
return rVal;
}
public static SynchronizationMessage parseUpdateClientLongStateMessage(CircularByteBuffer byteBuffer){
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.UPDATECLIENTLONGSTATE);
stripPacketHeader(byteBuffer);
rVal.setentityId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setbTreeId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setfieldId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setlongValue(ByteStreamUtils.popLongFromByteQueue(byteBuffer));
return rVal;
}
public static SynchronizationMessage constructUpdateClientLongStateMessage(int entityId,int bTreeId,int fieldId,long longValue){
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.UPDATECLIENTLONGSTATE);
rVal.setentityId(entityId);
rVal.setbTreeId(bTreeId);
rVal.setfieldId(fieldId);
rVal.setlongValue(longValue);
rVal.serialize();
return rVal;
}
public static SynchronizationMessage parseUpdateClientFloatStateMessage(CircularByteBuffer byteBuffer){
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.UPDATECLIENTFLOATSTATE);
stripPacketHeader(byteBuffer);
rVal.setentityId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setbTreeId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setfieldId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setfloatValue(ByteStreamUtils.popFloatFromByteQueue(byteBuffer));
return rVal;
}
public static SynchronizationMessage constructUpdateClientFloatStateMessage(int entityId,int bTreeId,int fieldId,float floatValue){
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.UPDATECLIENTFLOATSTATE);
rVal.setentityId(entityId);
rVal.setbTreeId(bTreeId);
rVal.setfieldId(fieldId);
rVal.setfloatValue(floatValue);
rVal.serialize();
return rVal;
}
public static SynchronizationMessage parseUpdateClientDoubleStateMessage(CircularByteBuffer byteBuffer){
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.UPDATECLIENTDOUBLESTATE);
stripPacketHeader(byteBuffer);
rVal.setentityId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setbTreeId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setfieldId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setdoubleValue(ByteStreamUtils.popDoubleFromByteQueue(byteBuffer));
return rVal;
}
public static SynchronizationMessage constructUpdateClientDoubleStateMessage(int entityId,int bTreeId,int fieldId,double doubleValue){
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.UPDATECLIENTDOUBLESTATE);
rVal.setentityId(entityId);
rVal.setbTreeId(bTreeId);
rVal.setfieldId(fieldId);
rVal.setdoubleValue(doubleValue);
rVal.serialize();
return rVal;
}
public static SynchronizationMessage parseClientRequestBTreeActionMessage(CircularByteBuffer byteBuffer){
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.CLIENTREQUESTBTREEACTION);
stripPacketHeader(byteBuffer);
rVal.setentityId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setbTreeId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
rVal.setbTreeValue(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
return rVal;
}
public static SynchronizationMessage constructClientRequestBTreeActionMessage(int entityId,int bTreeId,int bTreeValue){
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.CLIENTREQUESTBTREEACTION);
rVal.setentityId(entityId);
rVal.setbTreeId(bTreeId);
rVal.setbTreeValue(bTreeValue);
rVal.serialize();
return rVal;
}
public static SynchronizationMessage parseAttachTreeMessage(CircularByteBuffer byteBuffer){
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.ATTACHTREE);
stripPacketHeader(byteBuffer);
@ -291,6 +460,116 @@ public class SynchronizationMessage extends NetworkMessage {
rawBytes[18+i] = stringBytes[i];
}
break;
case UPDATECLIENTINTSTATE:
rawBytes = new byte[2+4+4+4+4];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_SYNCHRONIZATION;
//entity messaage header
rawBytes[1] = TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTINTSTATE;
intValues = ByteStreamUtils.serializeIntToBytes(entityId);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(bTreeId);
for(int i = 0; i < 4; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(fieldId);
for(int i = 0; i < 4; i++){
rawBytes[10+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(intValue);
for(int i = 0; i < 4; i++){
rawBytes[14+i] = intValues[i];
}
break;
case UPDATECLIENTLONGSTATE:
rawBytes = new byte[2+4+4+4+8];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_SYNCHRONIZATION;
//entity messaage header
rawBytes[1] = TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTLONGSTATE;
intValues = ByteStreamUtils.serializeIntToBytes(entityId);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(bTreeId);
for(int i = 0; i < 4; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(fieldId);
for(int i = 0; i < 4; i++){
rawBytes[10+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeLongToBytes(longValue);
for(int i = 0; i < 8; i++){
rawBytes[14+i] = intValues[i];
}
break;
case UPDATECLIENTFLOATSTATE:
rawBytes = new byte[2+4+4+4+4];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_SYNCHRONIZATION;
//entity messaage header
rawBytes[1] = TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTFLOATSTATE;
intValues = ByteStreamUtils.serializeIntToBytes(entityId);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(bTreeId);
for(int i = 0; i < 4; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(fieldId);
for(int i = 0; i < 4; i++){
rawBytes[10+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeFloatToBytes(floatValue);
for(int i = 0; i < 4; i++){
rawBytes[14+i] = intValues[i];
} break;
case UPDATECLIENTDOUBLESTATE:
rawBytes = new byte[2+4+4+4+8];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_SYNCHRONIZATION;
//entity messaage header
rawBytes[1] = TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTDOUBLESTATE;
intValues = ByteStreamUtils.serializeIntToBytes(entityId);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(bTreeId);
for(int i = 0; i < 4; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(fieldId);
for(int i = 0; i < 4; i++){
rawBytes[10+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeDoubleToBytes(doubleValue);
for(int i = 0; i < 8; i++){
rawBytes[14+i] = intValues[i];
}
break;
case CLIENTREQUESTBTREEACTION:
rawBytes = new byte[2+4+4+4];
//message header
rawBytes[0] = TypeBytes.MESSAGE_TYPE_SYNCHRONIZATION;
//entity messaage header
rawBytes[1] = TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_CLIENTREQUESTBTREEACTION;
intValues = ByteStreamUtils.serializeIntToBytes(entityId);
for(int i = 0; i < 4; i++){
rawBytes[2+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(bTreeId);
for(int i = 0; i < 4; i++){
rawBytes[6+i] = intValues[i];
}
intValues = ByteStreamUtils.serializeIntToBytes(bTreeValue);
for(int i = 0; i < 4; i++){
rawBytes[10+i] = intValues[i];
}
break;
case ATTACHTREE:
rawBytes = new byte[2+4+4];
//message header

View File

@ -147,13 +147,23 @@ Message categories
*/
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTSTATE = 0;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTSTRINGSTATE = 1;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE = 2;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_DETATCHTREE = 3;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_LOADSCENE = 4;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTINTSTATE = 2;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTLONGSTATE = 3;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTFLOATSTATE = 4;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTDOUBLESTATE = 5;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_CLIENTREQUESTBTREEACTION = 6;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE = 7;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_DETATCHTREE = 8;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_LOADSCENE = 9;
/*
Synchronization packet sizes
*/
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTSTATE_SIZE = 18;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTINTSTATE_SIZE = 18;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTLONGSTATE_SIZE = 22;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTFLOATSTATE_SIZE = 18;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTDOUBLESTATE_SIZE = 22;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_CLIENTREQUESTBTREEACTION_SIZE = 14;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE_SIZE = 10;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_DETATCHTREE_SIZE = 10;
}

View File

@ -12,11 +12,18 @@ public class SynchronizationProtocol implements ServerProtocolTemplate<Synchroni
@Override
public SynchronizationMessage handleAsyncMessage(ServerConnectionHandler connectionHandler, SynchronizationMessage message) {
switch(message.getMessageSubtype()){
case CLIENTREQUESTBTREEACTION:
return message;
case UPDATECLIENTSTATE:
case UPDATECLIENTSTRINGSTATE:
case UPDATECLIENTDOUBLESTATE:
case UPDATECLIENTFLOATSTATE:
case UPDATECLIENTINTSTATE:
case UPDATECLIENTLONGSTATE:
case ATTACHTREE:
case DETATCHTREE:
case LOADSCENE:
//silently ignore
break;
}
return null;
@ -25,11 +32,18 @@ public class SynchronizationProtocol implements ServerProtocolTemplate<Synchroni
@Override
public void handleSyncMessage(ServerConnectionHandler connectionHandler, SynchronizationMessage message) {
switch(message.getMessageSubtype()){
case CLIENTREQUESTBTREEACTION:
throw new UnsupportedOperationException("Not implemented yet!");
case UPDATECLIENTSTATE:
case UPDATECLIENTSTRINGSTATE:
case UPDATECLIENTDOUBLESTATE:
case UPDATECLIENTFLOATSTATE:
case UPDATECLIENTINTSTATE:
case UPDATECLIENTLONGSTATE:
case ATTACHTREE:
case DETATCHTREE:
case LOADSCENE:
//silently ignore
break;
}
}

View File

@ -19,5 +19,7 @@ public class BehaviorTreeIdEnums {
public static final int BTREE_SERVERLIFETREE_ID = 13;
public static final int BTREE_CLIENTGROUNDMOVEMENTTREE_ID = 10;
public static final int BTREE_SERVERGROUNDMOVEMENTTREE_ID = 11;
public static final int BTREE_CLIENTJUMPTREE_ID = 14;
public static final int BTREE_SERVERJUMPTREE_ID = 15;
}

View File

@ -1,6 +1,7 @@
package electrosphere.net.synchronization;
import electrosphere.entity.state.movement.jump.ClientJumpTree;
import electrosphere.entity.state.life.ClientLifeTree;
import electrosphere.entity.state.block.ClientBlockTree;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree;
@ -60,12 +61,11 @@ public class ClientSynchronizationManager {
messagesToClear.add(message);
messageBounceCount.remove(message);
switch(message.getMessageSubtype()){
case UPDATECLIENTSTATE:{
int bTreeId = message.getbTreeId();
int entityId = message.getentityId();
Entity targetEntity = Globals.clientSceneWrapper.getEntityFromServerId(entityId);
updateEntityState(targetEntity,bTreeId,message);
} break;
case UPDATECLIENTSTATE:
case UPDATECLIENTDOUBLESTATE:
case UPDATECLIENTFLOATSTATE:
case UPDATECLIENTINTSTATE:
case UPDATECLIENTLONGSTATE:
case UPDATECLIENTSTRINGSTATE:{
int bTreeId = message.getbTreeId();
int entityId = message.getentityId();
@ -76,13 +76,19 @@ public class ClientSynchronizationManager {
// int bTreeId = message.getbTreeId();
// int bTreeValue = message.getbTreeValue();
// int entityId = message.getentityId();
} break;
throw new UnsupportedOperationException("Not implemented yet!");
}
case DETATCHTREE:{
// int bTreeId = message.getbTreeId();
// int entityId = message.getentityId();
} break;
throw new UnsupportedOperationException("Not implemented yet!");
}
case LOADSCENE: {
} break;
throw new UnsupportedOperationException("Not implemented yet!");
}
case CLIENTREQUESTBTREEACTION:
//silently ignore
break;
}
} else if(Globals.clientSceneWrapper.containsServerId(message.getentityId()) && Globals.clientSceneWrapper.getEntityFromServerId(message.getentityId()) == null){
String errorMessage =
@ -190,6 +196,22 @@ public class ClientSynchronizationManager {
} break;
}
} break;
case BehaviorTreeIdEnums.BTREE_SERVERJUMPTREE_ID: {
switch(message.getfieldId()){
case FieldIdEnums.TREE_SERVERJUMPTREE_SYNCEDFIELD_STATE_ID:{
ClientJumpTree tree = ClientJumpTree.getClientJumpTree(entity);
tree.setState(ClientJumpTree.getJumpStateShortAsEnum((short)message.getbTreeValue()));
} break;
case FieldIdEnums.TREE_SERVERJUMPTREE_SYNCEDFIELD_CURRENTFRAME_ID:{
ClientJumpTree tree = ClientJumpTree.getClientJumpTree(entity);
tree.setCurrentFrame(message.getintValue());
} break;
case FieldIdEnums.TREE_SERVERJUMPTREE_SYNCEDFIELD_CURRENTJUMPFORCE_ID:{
ClientJumpTree tree = ClientJumpTree.getClientJumpTree(entity);
tree.setCurrentJumpForce(message.getfloatValue());
} break;
}
} break;
}
}

View File

@ -23,5 +23,11 @@ public class FieldIdEnums {
public static final int TREE_SERVERLIFETREE_SYNCEDFIELD_STATE_ID = 17;
public static final int TREE_CLIENTGROUNDMOVEMENTTREE_SYNCEDFIELD_FACING_ID = 14;
public static final int TREE_SERVERGROUNDMOVEMENTTREE_SYNCEDFIELD_FACING_ID = 15;
public static final int TREE_CLIENTJUMPTREE_SYNCEDFIELD_STATE_ID = 18;
public static final int TREE_CLIENTJUMPTREE_SYNCEDFIELD_CURRENTFRAME_ID = 22;
public static final int TREE_CLIENTJUMPTREE_SYNCEDFIELD_CURRENTJUMPFORCE_ID = 23;
public static final int TREE_SERVERJUMPTREE_SYNCEDFIELD_STATE_ID = 19;
public static final int TREE_SERVERJUMPTREE_SYNCEDFIELD_CURRENTFRAME_ID = 20;
public static final int TREE_SERVERJUMPTREE_SYNCEDFIELD_CURRENTJUMPFORCE_ID = 21;
}

View File

@ -0,0 +1,8 @@
package electrosphere.net.synchronization;
/**
* Server service to handle synchronization packets from client (principally, requesting to start btrees)
*/
public class ServerSynchronizationManager {
}