server sync sprint tree
This commit is contained in:
parent
c783550ee5
commit
ebcf0865ee
@ -151,7 +151,7 @@
|
||||
"priorityCategory" : "CORE_MOVEMENT"
|
||||
},
|
||||
"sprintSystem" : {
|
||||
"maxVelocity" : 0.058,
|
||||
"modifier" : 1.4,
|
||||
"staminaMax" : 500,
|
||||
"animationStartUp" : {
|
||||
"nameThirdPerson" : "Sprint",
|
||||
|
||||
@ -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
|
||||
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
|
||||
|
||||
|
||||
@ -824,7 +824,7 @@ public class ControlHandler {
|
||||
mainGameControlList.add(controls.get(INPUT_CODE_SPRINT));
|
||||
controls.get(INPUT_CODE_SPRINT).setOnPress(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
ClientSprintTree sprintTree = CreatureUtils.clientGetSprintTree(Globals.playerEntity);
|
||||
ClientSprintTree sprintTree = ClientSprintTree.getClientSprintTree(Globals.playerEntity);
|
||||
if(sprintTree != null){
|
||||
sprintTree.start();
|
||||
}
|
||||
@ -832,9 +832,9 @@ public class ControlHandler {
|
||||
}});
|
||||
controls.get(INPUT_CODE_SPRINT).setOnRelease(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
ClientSprintTree sprintTree = CreatureUtils.clientGetSprintTree(Globals.playerEntity);
|
||||
ClientSprintTree sprintTree = ClientSprintTree.getClientSprintTree(Globals.playerEntity);
|
||||
if(sprintTree != null){
|
||||
sprintTree.stop();
|
||||
sprintTree.interrupt();
|
||||
}
|
||||
}
|
||||
}});
|
||||
|
||||
@ -56,8 +56,8 @@ public class EntityDataStrings {
|
||||
public static final String SERVER_MOVEMENT_BT = "serverMovementBT";
|
||||
public static final String TREE_CLIENTGROUNDMOVEMENTTREE = "treeClientGroundMovementTree";
|
||||
public static final String TREE_SERVERGROUNDMOVEMENTTREE = "treeServerGroundMovementTree";
|
||||
public static final String CLIENT_SPRINT_TREE = "clientSprintBT";
|
||||
public static final String SERVER_SPRINT_TREE = "serverSprintBT";
|
||||
public static final String TREE_CLIENTSPRINTTREE = "treeClientSprintTree";
|
||||
public static final String TREE_SERVERSPRINTTREE = "treeServerSprintTree";
|
||||
public static final String DATA_STRING_FACING_VECTOR = "facingVector";
|
||||
public static final String DATA_STRING_VELOCITY = "velocity";
|
||||
public static final String DATA_STRING_ACCELERATION = "acceleration";
|
||||
|
||||
@ -503,6 +503,9 @@ public class ClientGroundMovementTree implements BehaviorTree {
|
||||
if(ClientWalkTree.getClientWalkTree(parent) != null && ClientWalkTree.getClientWalkTree(parent).isWalking()){
|
||||
walkModifier = ClientWalkTree.getClientWalkTree(parent).getModifier();
|
||||
}
|
||||
if(ClientSprintTree.getClientSprintTree(parent) != null && ClientSprintTree.getClientSprintTree(parent).isSprinting()){
|
||||
sprintModifier = ClientSprintTree.getClientSprintTree(parent).getSprintSystem().getModifier();
|
||||
}
|
||||
return velocity * sprintModifier * walkModifier;
|
||||
}
|
||||
|
||||
|
||||
@ -454,6 +454,9 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
||||
if(ServerWalkTree.getServerWalkTree(parent) != null && ServerWalkTree.getServerWalkTree(parent).isWalking()){
|
||||
walkModifier = ServerWalkTree.getServerWalkTree(parent).getModifier();
|
||||
}
|
||||
if(ServerSprintTree.getServerSprintTree(parent) != null && ServerSprintTree.getServerSprintTree(parent).isSprinting()){
|
||||
sprintModifier = ServerSprintTree.getServerSprintTree(parent).getSprintSystem().getModifier();
|
||||
}
|
||||
return velocity * sprintModifier * walkModifier;
|
||||
}
|
||||
|
||||
|
||||
@ -1,82 +1,217 @@
|
||||
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.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree;
|
||||
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementTreeState;
|
||||
import electrosphere.game.data.creature.type.SprintSystem;
|
||||
import electrosphere.net.synchronization.annotation.SyncedField;
|
||||
import electrosphere.net.synchronization.annotation.SynchronizableEnum;
|
||||
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
|
||||
|
||||
/**
|
||||
* Client sprint tree
|
||||
*/
|
||||
@SynchronizedBehaviorTree(
|
||||
name = "clientSprintTree",
|
||||
isServer = false,
|
||||
correspondingTree = "serverSprintTree",
|
||||
genStartInt = true
|
||||
)
|
||||
public class ClientSprintTree implements BehaviorTree {
|
||||
|
||||
@SynchronizableEnum
|
||||
public static enum SprintTreeState {
|
||||
SPRINTING,
|
||||
NOT_SPRINTING,
|
||||
}
|
||||
|
||||
SprintTreeState state;
|
||||
|
||||
ClientGroundMovementTree groundMovementTree;
|
||||
|
||||
@SyncedField
|
||||
SprintTreeState state = SprintTreeState.NOT_SPRINTING;
|
||||
|
||||
/**
|
||||
* The data for the sprint system
|
||||
*/
|
||||
SprintSystem sprintData;
|
||||
|
||||
/**
|
||||
* The parent entity
|
||||
*/
|
||||
Entity parent;
|
||||
|
||||
int staminaCurrent = 0;
|
||||
int staminaMax = 1;
|
||||
|
||||
float maxVelocity;
|
||||
|
||||
public ClientSprintTree(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
|
||||
*/
|
||||
public SprintTreeState getState(){
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p> Automatically generated </p>
|
||||
* <p>
|
||||
* Requests that the server start this btree
|
||||
* </p>
|
||||
*/
|
||||
public void start(){
|
||||
if(staminaCurrent > 0){
|
||||
// System.out.println("Starting sprinting");
|
||||
state = SprintTreeState.SPRINTING;
|
||||
}
|
||||
}
|
||||
|
||||
public void stop(){
|
||||
state = SprintTreeState.NOT_SPRINTING;
|
||||
Globals.clientConnection.queueOutgoingMessage(
|
||||
SynchronizationMessage.constructClientRequestBTreeActionMessage(
|
||||
Globals.clientSceneWrapper.mapClientToServerId(parent.getId()),
|
||||
BehaviorTreeIdEnums.BTREE_CLIENTSPRINTTREE_ID,
|
||||
ServerSynchronizationManager.SERVER_SYNC_START
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simulate(float deltaTime){
|
||||
switch(state){
|
||||
case SPRINTING:
|
||||
if(groundMovementTree != null && groundMovementTree.getState() != MovementTreeState.IDLE){
|
||||
staminaCurrent--;
|
||||
if(staminaCurrent < 1){
|
||||
state = SprintTreeState.NOT_SPRINTING;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NOT_SPRINTING:
|
||||
staminaCurrent++;
|
||||
if(staminaCurrent > staminaMax){
|
||||
staminaCurrent = staminaMax;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the sprint system
|
||||
* @return The sprint system
|
||||
*/
|
||||
public SprintSystem getSprintSystem(){
|
||||
return sprintData;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if the entity is sprinting
|
||||
* @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 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() {
|
||||
return maxVelocity;
|
||||
/**
|
||||
* <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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,51 +1,78 @@
|
||||
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.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.movement.groundmove.ClientGroundMovementTree.MovementTreeState;
|
||||
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
|
||||
*/
|
||||
@SynchronizedBehaviorTree(
|
||||
name = "serverSprintTree",
|
||||
isServer = true,
|
||||
correspondingTree = "clientSprintTree"
|
||||
)
|
||||
public class ServerSprintTree implements BehaviorTree {
|
||||
|
||||
public static enum SprintTreeState {
|
||||
SPRINTING,
|
||||
NOT_SPRINTING,
|
||||
}
|
||||
|
||||
SprintTreeState state;
|
||||
@SyncedField
|
||||
SprintTreeState state = SprintTreeState.NOT_SPRINTING;
|
||||
|
||||
/**
|
||||
* The data for the sprint system
|
||||
*/
|
||||
SprintSystem sprintData;
|
||||
|
||||
/**
|
||||
* Gets the ground movement tree associated with this sprint tree
|
||||
*/
|
||||
ServerGroundMovementTree groundMovementTree;
|
||||
|
||||
/**
|
||||
* Gets the parent entity
|
||||
*/
|
||||
Entity parent;
|
||||
|
||||
/**
|
||||
* The current stamina for the tree
|
||||
*/
|
||||
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(){
|
||||
return state;
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts the sprint component
|
||||
*/
|
||||
public void start(){
|
||||
if(staminaCurrent > 0){
|
||||
// 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
|
||||
@ -61,22 +88,108 @@ public class ServerSprintTree implements BehaviorTree {
|
||||
break;
|
||||
case NOT_SPRINTING:
|
||||
staminaCurrent++;
|
||||
if(staminaCurrent > staminaMax){
|
||||
staminaCurrent = staminaMax;
|
||||
if(staminaCurrent > sprintData.getStaminaMax()){
|
||||
staminaCurrent = sprintData.getStaminaMax();
|
||||
}
|
||||
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){
|
||||
this.groundMovementTree = groundMovementTree;
|
||||
}
|
||||
|
||||
//get max velocity
|
||||
public float getMaxVelocity() {
|
||||
return maxVelocity;
|
||||
/**
|
||||
* Checks if the entity is sprinting
|
||||
* @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));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ public class CreatureUtils {
|
||||
//sprint system
|
||||
if(groundMovementSystem.getSprintSystem() != null){
|
||||
SprintSystem sprintSystem = groundMovementSystem.getSprintSystem();
|
||||
ClientSprintTree sprintTree = new ClientSprintTree(rVal,sprintSystem.getMaxVelocity(),sprintSystem.getStaminaMax());
|
||||
ClientSprintTree sprintTree = ClientSprintTree.attachTree(rVal, sprintSystem);
|
||||
if(sprintSystem.getAnimationStartUp()!= null){
|
||||
moveTree.setAnimationSprintStartUp(sprintSystem.getAnimationStartUp().getNameThirdPerson());
|
||||
}
|
||||
@ -158,10 +158,7 @@ public class CreatureUtils {
|
||||
if(sprintSystem.getAnimationWindDown()!= null){
|
||||
moveTree.setAnimationSprintWindDown(sprintSystem.getAnimationWindDown().getNameThirdPerson());
|
||||
}
|
||||
sprintTree.setGroundMovementTree(moveTree);
|
||||
moveTree.setSprintTree(sprintTree);
|
||||
rVal.putData(EntityDataStrings.CLIENT_SPRINT_TREE,sprintTree);
|
||||
Globals.clientScene.registerBehaviorTree(sprintTree);
|
||||
Globals.clientScene.registerEntityToTag(rVal, EntityTags.SPRINTABLE);
|
||||
}
|
||||
//round out end of move system
|
||||
@ -420,7 +417,7 @@ public class CreatureUtils {
|
||||
//sprint system
|
||||
if(groundMovementSystem.getSprintSystem() != null){
|
||||
SprintSystem sprintSystem = groundMovementSystem.getSprintSystem();
|
||||
ServerSprintTree sprintTree = new ServerSprintTree(rVal,sprintSystem.getMaxVelocity(),sprintSystem.getStaminaMax());
|
||||
ServerSprintTree sprintTree = ServerSprintTree.attachTree(rVal, sprintSystem);
|
||||
if(sprintSystem.getAnimationStartUp()!= null){
|
||||
moveTree.setAnimationSprintStartUp(sprintSystem.getAnimationStartUp().getNameThirdPerson());
|
||||
}
|
||||
@ -432,8 +429,6 @@ public class CreatureUtils {
|
||||
}
|
||||
sprintTree.setServerGroundMovementTree(moveTree);
|
||||
moveTree.setServerSprintTree(sprintTree);
|
||||
rVal.putData(EntityDataStrings.SERVER_SPRINT_TREE,sprintTree);
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(rVal, sprintTree);
|
||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.SPRINTABLE);
|
||||
}
|
||||
//round out end of move system
|
||||
@ -843,14 +838,6 @@ public class CreatureUtils {
|
||||
public static ClientIdleTree getIdleTree(Entity e){
|
||||
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){
|
||||
e.putData(EntityDataStrings.CREATURE_TEMPLATE, template);
|
||||
|
||||
@ -6,28 +6,68 @@ import electrosphere.game.data.common.TreeDataAnimation;
|
||||
* Sprint data
|
||||
*/
|
||||
public class SprintSystem {
|
||||
|
||||
/**
|
||||
* The animation to play on starting to sprint
|
||||
*/
|
||||
TreeDataAnimation animationStartUp;
|
||||
|
||||
/**
|
||||
* The main animation to play while sprinting
|
||||
*/
|
||||
TreeDataAnimation animationMain;
|
||||
|
||||
/**
|
||||
* The animation to play while winding down from sprinting
|
||||
*/
|
||||
TreeDataAnimation animationWindDown;
|
||||
float maxVelocity;
|
||||
|
||||
/**
|
||||
* The modifier applied to the movement speed while sprinting
|
||||
*/
|
||||
float modifier;
|
||||
|
||||
/**
|
||||
* The maximum stamina
|
||||
*/
|
||||
int staminaMax;
|
||||
|
||||
/**
|
||||
* Gets The animation to play on starting to sprint
|
||||
* @return The animation to play on starting to sprint
|
||||
*/
|
||||
public TreeDataAnimation getAnimationStartUp() {
|
||||
return animationStartUp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets The main animation to play while sprinting
|
||||
* @return The main animation to play while sprinting
|
||||
*/
|
||||
public TreeDataAnimation getAnimationMain() {
|
||||
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() {
|
||||
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() {
|
||||
return staminaMax;
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package electrosphere.net.synchronization.client;
|
||||
|
||||
|
||||
import electrosphere.entity.state.movement.sprint.ClientSprintTree;
|
||||
import electrosphere.entity.state.equip.ClientEquipState;
|
||||
import electrosphere.entity.state.movement.jump.ClientJumpTree;
|
||||
import electrosphere.entity.state.movement.walk.ClientWalkTree;
|
||||
@ -226,6 +227,14 @@ public class ClientSynchronizationManager {
|
||||
} 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: {
|
||||
switch(message.getfieldId()){
|
||||
case FieldIdEnums.TREE_SERVERWALKTREE_SYNCEDFIELD_STATE_ID:{
|
||||
|
||||
@ -21,6 +21,8 @@ public class BehaviorTreeIdEnums {
|
||||
public static final int BTREE_SERVERGROUNDMOVEMENTTREE_ID = 11;
|
||||
public static final int BTREE_CLIENTJUMPTREE_ID = 14;
|
||||
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_SERVERWALKTREE_ID = 17;
|
||||
|
||||
|
||||
@ -29,6 +29,8 @@ public class FieldIdEnums {
|
||||
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;
|
||||
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_SERVERWALKTREE_SYNCEDFIELD_STATE_ID = 25;
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package electrosphere.net.synchronization.server;
|
||||
|
||||
|
||||
import electrosphere.entity.state.movement.sprint.ServerSprintTree;
|
||||
import electrosphere.logger.LoggerInterface;
|
||||
|
||||
import java.util.LinkedList;
|
||||
@ -99,6 +100,17 @@ public class ServerSynchronizationManager {
|
||||
} 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: {
|
||||
ServerWalkTree tree = ServerWalkTree.getServerWalkTree(entity);
|
||||
switch(message.getbTreeValue()){
|
||||
|
||||
@ -1,6 +1,8 @@
|
||||
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 java.util.LinkedList;
|
||||
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_CURRENTJUMPFORCE_ID,tree.getCurrentJumpForce()));
|
||||
} 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: {
|
||||
ServerWalkTree tree = ServerWalkTree.getServerWalkTree(entity);
|
||||
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;
|
||||
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: {
|
||||
ClientWalkTree tree = ClientWalkTree.getClientWalkTree(entity);
|
||||
switch(syncedValue.getFieldId()){
|
||||
|
||||
Loading…
Reference in New Issue
Block a user