server sync sprint tree

This commit is contained in:
austin 2024-09-03 22:36:30 -04:00
parent c783550ee5
commit ebcf0865ee
15 changed files with 424 additions and 97 deletions

View File

@ -151,7 +151,7 @@
"priorityCategory" : "CORE_MOVEMENT" "priorityCategory" : "CORE_MOVEMENT"
}, },
"sprintSystem" : { "sprintSystem" : {
"maxVelocity" : 0.058, "modifier" : 1.4,
"staminaMax" : 500, "staminaMax" : 500,
"animationStartUp" : { "animationStartUp" : {
"nameThirdPerson" : "Sprint", "nameThirdPerson" : "Sprint",

View File

@ -671,6 +671,13 @@ Fix level editor entity tree not re-rendering when an entity is deleted
Fix server entity not rotation when first person camera rotates Fix server entity not rotation when first person camera rotates
Entity details debug menu Data View Entity details debug menu Data View
(09/03/2024)
Documentation reorganization
Better jenkins documentation
Include jenkins dockerfile in repo
Better model for gameobjects
Server synchronization of sprint tree
# TODO # TODO

View File

@ -824,7 +824,7 @@ public class ControlHandler {
mainGameControlList.add(controls.get(INPUT_CODE_SPRINT)); mainGameControlList.add(controls.get(INPUT_CODE_SPRINT));
controls.get(INPUT_CODE_SPRINT).setOnPress(new ControlMethod(){public void execute(){ controls.get(INPUT_CODE_SPRINT).setOnPress(new ControlMethod(){public void execute(){
if(Globals.playerEntity != null){ if(Globals.playerEntity != null){
ClientSprintTree sprintTree = CreatureUtils.clientGetSprintTree(Globals.playerEntity); ClientSprintTree sprintTree = ClientSprintTree.getClientSprintTree(Globals.playerEntity);
if(sprintTree != null){ if(sprintTree != null){
sprintTree.start(); sprintTree.start();
} }
@ -832,9 +832,9 @@ public class ControlHandler {
}}); }});
controls.get(INPUT_CODE_SPRINT).setOnRelease(new ControlMethod(){public void execute(){ controls.get(INPUT_CODE_SPRINT).setOnRelease(new ControlMethod(){public void execute(){
if(Globals.playerEntity != null){ if(Globals.playerEntity != null){
ClientSprintTree sprintTree = CreatureUtils.clientGetSprintTree(Globals.playerEntity); ClientSprintTree sprintTree = ClientSprintTree.getClientSprintTree(Globals.playerEntity);
if(sprintTree != null){ if(sprintTree != null){
sprintTree.stop(); sprintTree.interrupt();
} }
} }
}}); }});

View File

@ -56,8 +56,8 @@ public class EntityDataStrings {
public static final String SERVER_MOVEMENT_BT = "serverMovementBT"; public static final String SERVER_MOVEMENT_BT = "serverMovementBT";
public static final String TREE_CLIENTGROUNDMOVEMENTTREE = "treeClientGroundMovementTree"; public static final String TREE_CLIENTGROUNDMOVEMENTTREE = "treeClientGroundMovementTree";
public static final String TREE_SERVERGROUNDMOVEMENTTREE = "treeServerGroundMovementTree"; public static final String TREE_SERVERGROUNDMOVEMENTTREE = "treeServerGroundMovementTree";
public static final String CLIENT_SPRINT_TREE = "clientSprintBT"; public static final String TREE_CLIENTSPRINTTREE = "treeClientSprintTree";
public static final String SERVER_SPRINT_TREE = "serverSprintBT"; public static final String TREE_SERVERSPRINTTREE = "treeServerSprintTree";
public static final String DATA_STRING_FACING_VECTOR = "facingVector"; public static final String DATA_STRING_FACING_VECTOR = "facingVector";
public static final String DATA_STRING_VELOCITY = "velocity"; public static final String DATA_STRING_VELOCITY = "velocity";
public static final String DATA_STRING_ACCELERATION = "acceleration"; public static final String DATA_STRING_ACCELERATION = "acceleration";

View File

@ -503,6 +503,9 @@ public class ClientGroundMovementTree implements BehaviorTree {
if(ClientWalkTree.getClientWalkTree(parent) != null && ClientWalkTree.getClientWalkTree(parent).isWalking()){ if(ClientWalkTree.getClientWalkTree(parent) != null && ClientWalkTree.getClientWalkTree(parent).isWalking()){
walkModifier = ClientWalkTree.getClientWalkTree(parent).getModifier(); walkModifier = ClientWalkTree.getClientWalkTree(parent).getModifier();
} }
if(ClientSprintTree.getClientSprintTree(parent) != null && ClientSprintTree.getClientSprintTree(parent).isSprinting()){
sprintModifier = ClientSprintTree.getClientSprintTree(parent).getSprintSystem().getModifier();
}
return velocity * sprintModifier * walkModifier; return velocity * sprintModifier * walkModifier;
} }

View File

@ -454,6 +454,9 @@ public class ServerGroundMovementTree implements BehaviorTree {
if(ServerWalkTree.getServerWalkTree(parent) != null && ServerWalkTree.getServerWalkTree(parent).isWalking()){ if(ServerWalkTree.getServerWalkTree(parent) != null && ServerWalkTree.getServerWalkTree(parent).isWalking()){
walkModifier = ServerWalkTree.getServerWalkTree(parent).getModifier(); walkModifier = ServerWalkTree.getServerWalkTree(parent).getModifier();
} }
if(ServerSprintTree.getServerSprintTree(parent) != null && ServerSprintTree.getServerSprintTree(parent).isSprinting()){
sprintModifier = ServerSprintTree.getServerSprintTree(parent).getSprintSystem().getModifier();
}
return velocity * sprintModifier * walkModifier; return velocity * sprintModifier * walkModifier;
} }

View File

@ -1,82 +1,217 @@
package electrosphere.entity.state.movement.sprint; package electrosphere.entity.state.movement.sprint;
import electrosphere.engine.Globals;
import electrosphere.entity.EntityDataStrings;
import electrosphere.net.synchronization.server.ServerSynchronizationManager;
import electrosphere.net.parser.net.message.SynchronizationMessage;
import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree; import electrosphere.game.data.creature.type.SprintSystem;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementTreeState; import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizableEnum;
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
/** /**
* Client sprint tree * Client sprint tree
*/ */
@SynchronizedBehaviorTree(
name = "clientSprintTree",
isServer = false,
correspondingTree = "serverSprintTree",
genStartInt = true
)
public class ClientSprintTree implements BehaviorTree { public class ClientSprintTree implements BehaviorTree {
@SynchronizableEnum
public static enum SprintTreeState { public static enum SprintTreeState {
SPRINTING, SPRINTING,
NOT_SPRINTING, NOT_SPRINTING,
} }
SprintTreeState state;
@SyncedField
ClientGroundMovementTree groundMovementTree; SprintTreeState state = SprintTreeState.NOT_SPRINTING;
/**
* The data for the sprint system
*/
SprintSystem sprintData;
/**
* The parent entity
*/
Entity parent; Entity parent;
int staminaCurrent = 0; /**
int staminaMax = 1; * Gets the state of the tree
* @return The state
float maxVelocity; */
public ClientSprintTree(Entity e, float maxVelocity, int staminaMax){
state = SprintTreeState.NOT_SPRINTING;
parent = e;
this.maxVelocity = maxVelocity;
this.staminaMax = staminaMax;
}
public SprintTreeState getState(){ public SprintTreeState getState(){
return state; return state;
} }
/**
* <p> Automatically generated </p>
* <p>
* Requests that the server start this btree
* </p>
*/
public void start(){ public void start(){
if(staminaCurrent > 0){ Globals.clientConnection.queueOutgoingMessage(
// System.out.println("Starting sprinting"); SynchronizationMessage.constructClientRequestBTreeActionMessage(
state = SprintTreeState.SPRINTING; Globals.clientSceneWrapper.mapClientToServerId(parent.getId()),
} BehaviorTreeIdEnums.BTREE_CLIENTSPRINTTREE_ID,
} ServerSynchronizationManager.SERVER_SYNC_START
)
public void stop(){ );
state = SprintTreeState.NOT_SPRINTING;
} }
@Override @Override
public void simulate(float deltaTime){ public void simulate(float deltaTime){
switch(state){ }
case SPRINTING:
if(groundMovementTree != null && groundMovementTree.getState() != MovementTreeState.IDLE){ /**
staminaCurrent--; * Gets the sprint system
if(staminaCurrent < 1){ * @return The sprint system
state = SprintTreeState.NOT_SPRINTING; */
} public SprintSystem getSprintSystem(){
} return sprintData;
break; }
case NOT_SPRINTING:
staminaCurrent++; /**
if(staminaCurrent > staminaMax){ * Checks if the entity is sprinting
staminaCurrent = staminaMax; * @return true if it is sprinting, false otherwise
} */
break; public boolean isSprinting(){
return this.state == SprintTreeState.SPRINTING;
}
/**
* <p> (initially) Automatically generated </p>
* <p> Private constructor to enforce using the attach methods </p>
* <p>
* Constructor
* </p>
* @param parent The parent entity of this tree
* @param params Optional parameters that can be provided when attaching the tree. All custom data required for creating this tree should be passed in this varargs.
*/
private ClientSprintTree(Entity parent, Object ... params){
if(params.length < 1 || (params[0] instanceof SprintSystem) == false){
throw new IllegalArgumentException("Trying to create client walk tree with invalid arguments!");
}
this.parent = parent;
this.sprintData = (SprintSystem)params[0];
}
/**
* <p> (initially) Automatically generated </p>
* <p>
* Attaches this tree to the entity.
* </p>
* @param entity The entity to attach to
* @param tree The behavior tree to attach
* @param params Optional parameters that will be provided to the constructor
*/
public static ClientSprintTree attachTree(Entity parent, Object ... params){
ClientSprintTree rVal = new ClientSprintTree(parent,params);
//!!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_CLIENTSPRINTTREE, rVal);
Globals.clientSceneWrapper.getScene().registerBehaviorTree(rVal);
Globals.entityValueTrackingService.attachTreeToEntity(parent, BehaviorTreeIdEnums.BTREE_CLIENTSPRINTTREE_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_CLIENTSPRINTTREE_ID);
}
/**
* <p>
* Gets the ClientSprintTree of the entity
* </p>
* @param entity the entity
* @return The ClientSprintTree
*/
public static ClientSprintTree getClientSprintTree(Entity entity){
return (ClientSprintTree)entity.getData(EntityDataStrings.TREE_CLIENTSPRINTTREE);
}
/**
* <p> Automatically generated </p>
* <p>
* Requests that the server start this btree
* </p>
*/
public void interrupt(){
Globals.clientConnection.queueOutgoingMessage(
SynchronizationMessage.constructClientRequestBTreeActionMessage(
Globals.clientSceneWrapper.mapClientToServerId(parent.getId()),
BehaviorTreeIdEnums.BTREE_CLIENTSPRINTTREE_ID,
ServerSynchronizationManager.SERVER_SYNC_INTERRUPT
)
);
}
/**
* <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 SprintTreeState getSprintTreeStateShortAsEnum(short shortVal){
switch(shortVal){
case 0:
return SprintTreeState.SPRINTING;
case 1:
return SprintTreeState.NOT_SPRINTING;
default:
return SprintTreeState.SPRINTING;
} }
} }
public void setGroundMovementTree(ClientGroundMovementTree groundMovementTree){ /**
this.groundMovementTree = groundMovementTree; * <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 getSprintTreeStateEnumAsShort(SprintTreeState enumVal){
switch(enumVal){
case SPRINTING:
return 0;
case NOT_SPRINTING:
return 1;
default:
return 0;
}
} }
//get max velocity /**
public float getMaxVelocity() { * <p> Automatically generated </p>
return maxVelocity; * <p>
* Sets state and handles the synchronization logic for it.
* </p>
* @param state The value to set state to.
*/
public void setState(SprintTreeState state){
this.state = state;
} }
} }

View File

@ -1,51 +1,78 @@
package electrosphere.entity.state.movement.sprint; package electrosphere.entity.state.movement.sprint;
import electrosphere.net.synchronization.enums.FieldIdEnums;
import electrosphere.server.datacell.utils.DataCellSearchUtils;
import electrosphere.net.parser.net.message.SynchronizationMessage;
import electrosphere.engine.Globals;
import electrosphere.entity.EntityDataStrings;
import electrosphere.net.synchronization.enums.BehaviorTreeIdEnums;
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementTreeState; import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementTreeState;
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree; import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
import electrosphere.entity.state.movement.sprint.ClientSprintTree.SprintTreeState;
import electrosphere.game.data.creature.type.SprintSystem;
import electrosphere.net.synchronization.annotation.SyncedField;
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
/** /**
* Server sprint tree * Server sprint tree
*/ */
@SynchronizedBehaviorTree(
name = "serverSprintTree",
isServer = true,
correspondingTree = "clientSprintTree"
)
public class ServerSprintTree implements BehaviorTree { public class ServerSprintTree implements BehaviorTree {
public static enum SprintTreeState { @SyncedField
SPRINTING, SprintTreeState state = SprintTreeState.NOT_SPRINTING;
NOT_SPRINTING,
}
SprintTreeState state;
/**
* The data for the sprint system
*/
SprintSystem sprintData;
/**
* Gets the ground movement tree associated with this sprint tree
*/
ServerGroundMovementTree groundMovementTree; ServerGroundMovementTree groundMovementTree;
/**
* Gets the parent entity
*/
Entity parent; Entity parent;
/**
* The current stamina for the tree
*/
int staminaCurrent = 0; int staminaCurrent = 0;
int staminaMax = 1;
float maxVelocity;
public ServerSprintTree(Entity e, float maxVelocity, int staminaMax){
state = SprintTreeState.NOT_SPRINTING;
parent = e;
this.maxVelocity = maxVelocity;
this.staminaMax = staminaMax;
}
/**
* Gets the state of the tree
* @return The state of the tree
*/
public SprintTreeState getState(){ public SprintTreeState getState(){
return state; return state;
} }
/**
* Starts the sprint component
*/
public void start(){ public void start(){
if(staminaCurrent > 0){ if(staminaCurrent > 0){
// System.out.println("Starting sprinting"); // System.out.println("Starting sprinting");
state = SprintTreeState.SPRINTING; this.setState(SprintTreeState.SPRINTING);
} }
} }
public void stop(){ /**
state = SprintTreeState.NOT_SPRINTING; * Interrupts the sprint component
*/
public void interrupt(){
this.setState(SprintTreeState.NOT_SPRINTING);
} }
@Override @Override
@ -61,22 +88,108 @@ public class ServerSprintTree implements BehaviorTree {
break; break;
case NOT_SPRINTING: case NOT_SPRINTING:
staminaCurrent++; staminaCurrent++;
if(staminaCurrent > staminaMax){ if(staminaCurrent > sprintData.getStaminaMax()){
staminaCurrent = staminaMax; staminaCurrent = sprintData.getStaminaMax();
} }
break; break;
} }
} }
/**
* Gets the sprint system
* @return The sprint system
*/
public SprintSystem getSprintSystem(){
return sprintData;
}
/**
* Sets the ground movement tree associated with this sprint tree
* @param groundMovementTree The ground movement tree
*/
public void setServerGroundMovementTree(ServerGroundMovementTree groundMovementTree){ public void setServerGroundMovementTree(ServerGroundMovementTree groundMovementTree){
this.groundMovementTree = groundMovementTree; this.groundMovementTree = groundMovementTree;
} }
//get max velocity /**
public float getMaxVelocity() { * Checks if the entity is sprinting
return maxVelocity; * @return true if it is sprinting, false otherwise
*/
public boolean isSprinting(){
return this.state == SprintTreeState.SPRINTING;
}
/**
* <p> (initially) Automatically generated </p>
* <p> Private constructor to enforce using the attach methods </p>
* <p>
* Constructor
* </p>
* @param parent The parent entity of this tree
* @param params Optional parameters that can be provided when attaching the tree. All custom data required for creating this tree should be passed in this varargs.
*/
private ServerSprintTree(Entity parent, Object ... params){
if(params.length < 1 || (params[0] instanceof SprintSystem) == false){
throw new IllegalArgumentException("Trying to create client walk tree with invalid arguments!");
}
this.parent = parent;
this.sprintData = (SprintSystem)params[0];
} }
/**
* <p> (initially) Automatically generated </p>
* <p>
* Attaches this tree to the entity.
* </p>
* @param entity The entity to attach to
* @param tree The behavior tree to attach
* @param params Optional parameters that will be provided to the constructor
*/
public static ServerSprintTree attachTree(Entity parent, Object ... params){
ServerSprintTree rVal = new ServerSprintTree(parent,params);
//!!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_SERVERSPRINTTREE, rVal);
Globals.entityValueTrackingService.attachTreeToEntity(parent, BehaviorTreeIdEnums.BTREE_SERVERSPRINTTREE_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_SERVERSPRINTTREE_ID);
}
/**
* <p>
* Gets the ServerSprintTree of the entity
* </p>
* @param entity the entity
* @return The ServerSprintTree
*/
public static ServerSprintTree getServerSprintTree(Entity entity){
return (ServerSprintTree)entity.getData(EntityDataStrings.TREE_SERVERSPRINTTREE);
}
/**
* <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(SprintTreeState state){
this.state = state;
int value = ClientSprintTree.getSprintTreeStateEnumAsShort(state);
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientStateMessage(parent.getId(), BehaviorTreeIdEnums.BTREE_SERVERSPRINTTREE_ID, FieldIdEnums.TREE_SERVERSPRINTTREE_SYNCEDFIELD_STATE_ID, value));
}
} }

View File

@ -148,7 +148,7 @@ public class CreatureUtils {
//sprint system //sprint system
if(groundMovementSystem.getSprintSystem() != null){ if(groundMovementSystem.getSprintSystem() != null){
SprintSystem sprintSystem = groundMovementSystem.getSprintSystem(); SprintSystem sprintSystem = groundMovementSystem.getSprintSystem();
ClientSprintTree sprintTree = new ClientSprintTree(rVal,sprintSystem.getMaxVelocity(),sprintSystem.getStaminaMax()); ClientSprintTree sprintTree = ClientSprintTree.attachTree(rVal, sprintSystem);
if(sprintSystem.getAnimationStartUp()!= null){ if(sprintSystem.getAnimationStartUp()!= null){
moveTree.setAnimationSprintStartUp(sprintSystem.getAnimationStartUp().getNameThirdPerson()); moveTree.setAnimationSprintStartUp(sprintSystem.getAnimationStartUp().getNameThirdPerson());
} }
@ -158,10 +158,7 @@ public class CreatureUtils {
if(sprintSystem.getAnimationWindDown()!= null){ if(sprintSystem.getAnimationWindDown()!= null){
moveTree.setAnimationSprintWindDown(sprintSystem.getAnimationWindDown().getNameThirdPerson()); moveTree.setAnimationSprintWindDown(sprintSystem.getAnimationWindDown().getNameThirdPerson());
} }
sprintTree.setGroundMovementTree(moveTree);
moveTree.setSprintTree(sprintTree); moveTree.setSprintTree(sprintTree);
rVal.putData(EntityDataStrings.CLIENT_SPRINT_TREE,sprintTree);
Globals.clientScene.registerBehaviorTree(sprintTree);
Globals.clientScene.registerEntityToTag(rVal, EntityTags.SPRINTABLE); Globals.clientScene.registerEntityToTag(rVal, EntityTags.SPRINTABLE);
} }
//round out end of move system //round out end of move system
@ -420,7 +417,7 @@ public class CreatureUtils {
//sprint system //sprint system
if(groundMovementSystem.getSprintSystem() != null){ if(groundMovementSystem.getSprintSystem() != null){
SprintSystem sprintSystem = groundMovementSystem.getSprintSystem(); SprintSystem sprintSystem = groundMovementSystem.getSprintSystem();
ServerSprintTree sprintTree = new ServerSprintTree(rVal,sprintSystem.getMaxVelocity(),sprintSystem.getStaminaMax()); ServerSprintTree sprintTree = ServerSprintTree.attachTree(rVal, sprintSystem);
if(sprintSystem.getAnimationStartUp()!= null){ if(sprintSystem.getAnimationStartUp()!= null){
moveTree.setAnimationSprintStartUp(sprintSystem.getAnimationStartUp().getNameThirdPerson()); moveTree.setAnimationSprintStartUp(sprintSystem.getAnimationStartUp().getNameThirdPerson());
} }
@ -432,8 +429,6 @@ public class CreatureUtils {
} }
sprintTree.setServerGroundMovementTree(moveTree); sprintTree.setServerGroundMovementTree(moveTree);
moveTree.setServerSprintTree(sprintTree); moveTree.setServerSprintTree(sprintTree);
rVal.putData(EntityDataStrings.SERVER_SPRINT_TREE,sprintTree);
ServerBehaviorTreeUtils.attachBTreeToEntity(rVal, sprintTree);
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.SPRINTABLE); ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.SPRINTABLE);
} }
//round out end of move system //round out end of move system
@ -843,14 +838,6 @@ public class CreatureUtils {
public static ClientIdleTree getIdleTree(Entity e){ public static ClientIdleTree getIdleTree(Entity e){
return (ClientIdleTree)e.getData(EntityDataStrings.TREE_IDLE); return (ClientIdleTree)e.getData(EntityDataStrings.TREE_IDLE);
} }
public static ClientSprintTree clientGetSprintTree(Entity e){
return (ClientSprintTree)e.getData(EntityDataStrings.CLIENT_SPRINT_TREE);
}
public static ServerSprintTree serverGetSprintTree(Entity e){
return (ServerSprintTree)e.getData(EntityDataStrings.SERVER_SPRINT_TREE);
}
public static void setCreatureTemplate(Entity e, CreatureTemplate template){ public static void setCreatureTemplate(Entity e, CreatureTemplate template){
e.putData(EntityDataStrings.CREATURE_TEMPLATE, template); e.putData(EntityDataStrings.CREATURE_TEMPLATE, template);

View File

@ -6,28 +6,68 @@ import electrosphere.game.data.common.TreeDataAnimation;
* Sprint data * Sprint data
*/ */
public class SprintSystem { public class SprintSystem {
/**
* The animation to play on starting to sprint
*/
TreeDataAnimation animationStartUp; TreeDataAnimation animationStartUp;
/**
* The main animation to play while sprinting
*/
TreeDataAnimation animationMain; TreeDataAnimation animationMain;
/**
* The animation to play while winding down from sprinting
*/
TreeDataAnimation animationWindDown; TreeDataAnimation animationWindDown;
float maxVelocity;
/**
* The modifier applied to the movement speed while sprinting
*/
float modifier;
/**
* The maximum stamina
*/
int staminaMax; int staminaMax;
/**
* Gets The animation to play on starting to sprint
* @return The animation to play on starting to sprint
*/
public TreeDataAnimation getAnimationStartUp() { public TreeDataAnimation getAnimationStartUp() {
return animationStartUp; return animationStartUp;
} }
/**
* Gets The main animation to play while sprinting
* @return The main animation to play while sprinting
*/
public TreeDataAnimation getAnimationMain() { public TreeDataAnimation getAnimationMain() {
return animationMain; return animationMain;
} }
/**
* Gets The animation to play while winding down from sprinting
* @return The animation to play while winding down from sprinting
*/
public TreeDataAnimation getAnimationWindDown() { public TreeDataAnimation getAnimationWindDown() {
return animationWindDown; return animationWindDown;
} }
public float getMaxVelocity() { /**
return maxVelocity; * Gets The modifier applied to the movement speed while sprinting
* @return The modifier applied to the movement speed while sprinting
*/
public float getModifier() {
return modifier;
} }
/**
* Gets The maximum stamina
* @return The maximum stamina
*/
public int getStaminaMax() { public int getStaminaMax() {
return staminaMax; return staminaMax;
} }

View File

@ -1,6 +1,7 @@
package electrosphere.net.synchronization.client; package electrosphere.net.synchronization.client;
import electrosphere.entity.state.movement.sprint.ClientSprintTree;
import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.state.movement.jump.ClientJumpTree; import electrosphere.entity.state.movement.jump.ClientJumpTree;
import electrosphere.entity.state.movement.walk.ClientWalkTree; import electrosphere.entity.state.movement.walk.ClientWalkTree;
@ -226,6 +227,14 @@ public class ClientSynchronizationManager {
} break; } break;
} }
} break; } break;
case BehaviorTreeIdEnums.BTREE_SERVERSPRINTTREE_ID: {
switch(message.getfieldId()){
case FieldIdEnums.TREE_SERVERSPRINTTREE_SYNCEDFIELD_STATE_ID:{
ClientSprintTree tree = ClientSprintTree.getClientSprintTree(entity);
tree.setState(ClientSprintTree.getSprintTreeStateShortAsEnum((short)message.getbTreeValue()));
} break;
}
} break;
case BehaviorTreeIdEnums.BTREE_SERVERWALKTREE_ID: { case BehaviorTreeIdEnums.BTREE_SERVERWALKTREE_ID: {
switch(message.getfieldId()){ switch(message.getfieldId()){
case FieldIdEnums.TREE_SERVERWALKTREE_SYNCEDFIELD_STATE_ID:{ case FieldIdEnums.TREE_SERVERWALKTREE_SYNCEDFIELD_STATE_ID:{

View File

@ -21,6 +21,8 @@ public class BehaviorTreeIdEnums {
public static final int BTREE_SERVERGROUNDMOVEMENTTREE_ID = 11; public static final int BTREE_SERVERGROUNDMOVEMENTTREE_ID = 11;
public static final int BTREE_CLIENTJUMPTREE_ID = 14; public static final int BTREE_CLIENTJUMPTREE_ID = 14;
public static final int BTREE_SERVERJUMPTREE_ID = 15; public static final int BTREE_SERVERJUMPTREE_ID = 15;
public static final int BTREE_CLIENTSPRINTTREE_ID = 18;
public static final int BTREE_SERVERSPRINTTREE_ID = 19;
public static final int BTREE_CLIENTWALKTREE_ID = 16; public static final int BTREE_CLIENTWALKTREE_ID = 16;
public static final int BTREE_SERVERWALKTREE_ID = 17; public static final int BTREE_SERVERWALKTREE_ID = 17;

View File

@ -29,6 +29,8 @@ public class FieldIdEnums {
public static final int TREE_SERVERJUMPTREE_SYNCEDFIELD_STATE_ID = 19; 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_CURRENTFRAME_ID = 20;
public static final int TREE_SERVERJUMPTREE_SYNCEDFIELD_CURRENTJUMPFORCE_ID = 21; public static final int TREE_SERVERJUMPTREE_SYNCEDFIELD_CURRENTJUMPFORCE_ID = 21;
public static final int TREE_CLIENTSPRINTTREE_SYNCEDFIELD_STATE_ID = 26;
public static final int TREE_SERVERSPRINTTREE_SYNCEDFIELD_STATE_ID = 27;
public static final int TREE_CLIENTWALKTREE_SYNCEDFIELD_STATE_ID = 24; public static final int TREE_CLIENTWALKTREE_SYNCEDFIELD_STATE_ID = 24;
public static final int TREE_SERVERWALKTREE_SYNCEDFIELD_STATE_ID = 25; public static final int TREE_SERVERWALKTREE_SYNCEDFIELD_STATE_ID = 25;

View File

@ -1,6 +1,7 @@
package electrosphere.net.synchronization.server; package electrosphere.net.synchronization.server;
import electrosphere.entity.state.movement.sprint.ServerSprintTree;
import electrosphere.logger.LoggerInterface; import electrosphere.logger.LoggerInterface;
import java.util.LinkedList; import java.util.LinkedList;
@ -99,6 +100,17 @@ public class ServerSynchronizationManager {
} break; } break;
} }
} break; } break;
case BehaviorTreeIdEnums.BTREE_CLIENTSPRINTTREE_ID: {
ServerSprintTree tree = ServerSprintTree.getServerSprintTree(entity);
switch(message.getbTreeValue()){
case ServerSynchronizationManager.SERVER_SYNC_START: {
tree.start();
} break;
case ServerSynchronizationManager.SERVER_SYNC_INTERRUPT: {
tree.interrupt();
} break;
}
} break;
case BehaviorTreeIdEnums.BTREE_CLIENTWALKTREE_ID: { case BehaviorTreeIdEnums.BTREE_CLIENTWALKTREE_ID: {
ServerWalkTree tree = ServerWalkTree.getServerWalkTree(entity); ServerWalkTree tree = ServerWalkTree.getServerWalkTree(entity);
switch(message.getbTreeValue()){ switch(message.getbTreeValue()){

View File

@ -1,6 +1,8 @@
package electrosphere.net.synchronization.transport; package electrosphere.net.synchronization.transport;
import electrosphere.entity.state.movement.sprint.ServerSprintTree;
import electrosphere.entity.state.movement.sprint.ClientSprintTree;
import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.equip.ClientEquipState;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -102,6 +104,10 @@ public class StateCollection {
collection.setValue(new SynchronizedFieldValue(BehaviorTreeIdEnums.BTREE_SERVERJUMPTREE_ID,FieldIdEnums.TREE_SERVERJUMPTREE_SYNCEDFIELD_CURRENTFRAME_ID,tree.getCurrentFrame())); collection.setValue(new SynchronizedFieldValue(BehaviorTreeIdEnums.BTREE_SERVERJUMPTREE_ID,FieldIdEnums.TREE_SERVERJUMPTREE_SYNCEDFIELD_CURRENTFRAME_ID,tree.getCurrentFrame()));
collection.setValue(new SynchronizedFieldValue(BehaviorTreeIdEnums.BTREE_SERVERJUMPTREE_ID,FieldIdEnums.TREE_SERVERJUMPTREE_SYNCEDFIELD_CURRENTJUMPFORCE_ID,tree.getCurrentJumpForce())); collection.setValue(new SynchronizedFieldValue(BehaviorTreeIdEnums.BTREE_SERVERJUMPTREE_ID,FieldIdEnums.TREE_SERVERJUMPTREE_SYNCEDFIELD_CURRENTJUMPFORCE_ID,tree.getCurrentJumpForce()));
} break; } break;
case BehaviorTreeIdEnums.BTREE_SERVERSPRINTTREE_ID: {
ServerSprintTree tree = ServerSprintTree.getServerSprintTree(entity);
collection.setValue(new SynchronizedFieldValue(BehaviorTreeIdEnums.BTREE_SERVERSPRINTTREE_ID,FieldIdEnums.TREE_SERVERSPRINTTREE_SYNCEDFIELD_STATE_ID,ClientSprintTree.getSprintTreeStateEnumAsShort(tree.getState())));
} break;
case BehaviorTreeIdEnums.BTREE_SERVERWALKTREE_ID: { case BehaviorTreeIdEnums.BTREE_SERVERWALKTREE_ID: {
ServerWalkTree tree = ServerWalkTree.getServerWalkTree(entity); ServerWalkTree tree = ServerWalkTree.getServerWalkTree(entity);
collection.setValue(new SynchronizedFieldValue(BehaviorTreeIdEnums.BTREE_SERVERWALKTREE_ID,FieldIdEnums.TREE_SERVERWALKTREE_SYNCEDFIELD_STATE_ID,ClientWalkTree.getWalkStateEnumAsShort(tree.getState()))); collection.setValue(new SynchronizedFieldValue(BehaviorTreeIdEnums.BTREE_SERVERWALKTREE_ID,FieldIdEnums.TREE_SERVERWALKTREE_SYNCEDFIELD_STATE_ID,ClientWalkTree.getWalkStateEnumAsShort(tree.getState())));
@ -199,6 +205,14 @@ public class StateCollection {
} break; } break;
} }
} break; } break;
case BehaviorTreeIdEnums.BTREE_SERVERSPRINTTREE_ID: {
ClientSprintTree tree = ClientSprintTree.getClientSprintTree(entity);
switch(syncedValue.getFieldId()){
case(FieldIdEnums.TREE_SERVERSPRINTTREE_SYNCEDFIELD_STATE_ID): {
tree.setState(ClientSprintTree.getSprintTreeStateShortAsEnum(((Double)syncedValue.getValue()).shortValue()));
} break;
}
} break;
case BehaviorTreeIdEnums.BTREE_SERVERWALKTREE_ID: { case BehaviorTreeIdEnums.BTREE_SERVERWALKTREE_ID: {
ClientWalkTree tree = ClientWalkTree.getClientWalkTree(entity); ClientWalkTree tree = ClientWalkTree.getClientWalkTree(entity);
switch(syncedValue.getFieldId()){ switch(syncedValue.getFieldId()){