start work on synchronizing attack
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good
This commit is contained in:
parent
a241d97d33
commit
74b3140344
@ -5,7 +5,7 @@
|
||||
|
||||
{
|
||||
"itemId" : "Katana",
|
||||
"modelPath" : "Models/katana1alt.fbx",
|
||||
"modelPath" : "Models/items/weapons/katana1alt.fbx",
|
||||
"weaponData" : {
|
||||
"weaponClass" : "sword1h",
|
||||
"damage" : 10,
|
||||
|
||||
@ -197,6 +197,10 @@
|
||||
"treeState"
|
||||
]
|
||||
},
|
||||
{
|
||||
"messageName" : "startAttack",
|
||||
"data" : []
|
||||
},
|
||||
{
|
||||
"messageName" : "Move",
|
||||
"data" : [
|
||||
|
||||
@ -21,6 +21,10 @@
|
||||
{
|
||||
"name" : "bTreeValue",
|
||||
"type" : "FIXED_INT"
|
||||
},
|
||||
{
|
||||
"name" : "stringValue",
|
||||
"type" : "VAR_STRING"
|
||||
}
|
||||
],
|
||||
"messageTypes" : [
|
||||
@ -33,6 +37,15 @@
|
||||
"bTreeValue"
|
||||
]
|
||||
},
|
||||
{
|
||||
"messageName" : "UpdateClientStringState",
|
||||
"data" : [
|
||||
"entityId",
|
||||
"bTreeId",
|
||||
"fieldId",
|
||||
"stringValue"
|
||||
]
|
||||
},
|
||||
{
|
||||
"messageName" : "AttachTree",
|
||||
"data" : [
|
||||
|
||||
@ -79,7 +79,7 @@ import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.Main;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.attack.AttackTree;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||
import electrosphere.entity.state.attack.ShooterTree;
|
||||
import electrosphere.entity.state.equip.ClientEquipState;
|
||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||
@ -852,7 +852,7 @@ public class ControlHandler {
|
||||
controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).setOnPress(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
// Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
AttackTree attackTree = CreatureUtils.clientGetAttackTree(Globals.playerEntity);
|
||||
ClientAttackTree attackTree = CreatureUtils.clientGetAttackTree(Globals.playerEntity);
|
||||
if(attackTree != null){
|
||||
// CreatureUtils.setFacingVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize());
|
||||
attackTree.start();
|
||||
@ -874,7 +874,7 @@ public class ControlHandler {
|
||||
controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).setOnRelease(new ControlMethod(){public void execute(){
|
||||
if(Globals.playerEntity != null){
|
||||
// Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
|
||||
AttackTree attackTree = CreatureUtils.clientGetAttackTree(Globals.playerEntity);
|
||||
ClientAttackTree attackTree = CreatureUtils.clientGetAttackTree(Globals.playerEntity);
|
||||
if(attackTree != null){
|
||||
// CreatureUtils.setFacingVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize());
|
||||
attackTree.release();
|
||||
|
||||
@ -195,8 +195,8 @@ public class EntityDataStrings {
|
||||
/*
|
||||
Attack behavior tree
|
||||
*/
|
||||
public static final String CLIENT_ATTACK_TREE = "clientAttackTree";
|
||||
public static final String SERVER_ATTACK_TREE = "serverAttackTree";
|
||||
public static final String TREE_CLIENTATTACKTREE = "treeClientAttackTree";
|
||||
public static final String TREE_SERVERATTACKTREE = "treeServerAttackTree";
|
||||
|
||||
public static final String ATTACK_MOVE_TYPE_ACTIVE = "attackMoveTypeActive";
|
||||
public static final String ATTACK_MOVE_TYPE_MELEE_SWING_ONE_HAND = "MELEE_WEAPON_SWING_ONE_HAND";
|
||||
@ -254,7 +254,9 @@ public class EntityDataStrings {
|
||||
Equip state
|
||||
*/
|
||||
public static final String EQUIP_STATE = "equipState";
|
||||
public static final String TREE_CLIENTEQUIPSTATE = "treeClientEquipState";
|
||||
public static final String EQUIP_INVENTORY = "equipInventory";
|
||||
public static final String TREE_SERVEREQUIPSTATE = "treeServerEquipState";
|
||||
|
||||
/*
|
||||
Inventory in general
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package electrosphere.entity.state.attack;
|
||||
|
||||
|
||||
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
|
||||
|
||||
import electrosphere.collision.collidable.Collidable;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.Main;
|
||||
@ -21,6 +24,9 @@ import electrosphere.entity.types.projectile.ProjectileUtils;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.net.synchronization.annotation.SyncedField;
|
||||
import electrosphere.net.synchronization.annotation.SynchronizableEnum;
|
||||
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.anim.Animation;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
@ -35,8 +41,13 @@ import org.joml.Quaternionfc;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
public class AttackTree implements BehaviorTree {
|
||||
@SynchronizedBehaviorTree(name = "clientAttackTree", isServer = false, correspondingTree="serverAttackTree")
|
||||
/**
|
||||
* Client basic attack tree
|
||||
*/
|
||||
public class ClientAttackTree implements BehaviorTree {
|
||||
|
||||
@SynchronizableEnum
|
||||
public static enum AttackTreeState {
|
||||
WINDUP,
|
||||
HOLD,
|
||||
@ -46,12 +57,16 @@ public class AttackTree implements BehaviorTree {
|
||||
}
|
||||
|
||||
//the state of drifting forward during the attack
|
||||
@SynchronizableEnum
|
||||
public static enum AttackTreeDriftState {
|
||||
DRIFT,
|
||||
NO_DRIFT,
|
||||
}
|
||||
|
||||
@SyncedField
|
||||
AttackTreeState state;
|
||||
|
||||
@SyncedField
|
||||
AttackTreeDriftState driftState;
|
||||
|
||||
Entity parent;
|
||||
@ -68,6 +83,8 @@ public class AttackTree implements BehaviorTree {
|
||||
|
||||
List<AttackMove> currentMoveset = null;
|
||||
AttackMove currentMove = null;
|
||||
@SyncedField
|
||||
String currentMoveId = null;
|
||||
Entity currentWeapon = null;
|
||||
boolean currentMoveHasWindup;
|
||||
boolean currentMoveCanHold;
|
||||
@ -76,12 +93,18 @@ public class AttackTree implements BehaviorTree {
|
||||
String projectileToFire = null;
|
||||
String attackingPoint = null;
|
||||
|
||||
public AttackTree(Entity e){
|
||||
public ClientAttackTree(Entity e){
|
||||
state = AttackTreeState.IDLE;
|
||||
driftState = AttackTreeDriftState.NO_DRIFT;
|
||||
parent = e;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p> Automatically generated </p>
|
||||
* <p>
|
||||
* Gets state.
|
||||
* </p>
|
||||
*/
|
||||
public AttackTreeState getState(){
|
||||
return state;
|
||||
}
|
||||
@ -101,40 +124,7 @@ public class AttackTree implements BehaviorTree {
|
||||
parent.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, attackType);
|
||||
currentMoveset = (List<AttackMove>)parent.getData(attackType);
|
||||
if(currentMoveset != null){
|
||||
if(currentMove == null){
|
||||
currentMove = currentMoveset.get(0);
|
||||
} else {
|
||||
currentMove = getNextMove(currentMoveset,currentMove.getNextMoveId());
|
||||
}
|
||||
if(currentMove != null){
|
||||
firesProjectile = currentMove.getFiresProjectile();
|
||||
if(firesProjectile){
|
||||
projectileToFire = ItemUtils.getWeaponDataRaw(currentWeapon).getProjectileModel();
|
||||
}
|
||||
|
||||
animationName = currentMove.getAttackAnimationName();
|
||||
//intuit windup from presence of windup anim
|
||||
currentMoveHasWindup = currentMove.getWindupAnimationName() != null;
|
||||
if(currentMoveHasWindup){
|
||||
animationName = currentMove.getWindupAnimationName();
|
||||
}
|
||||
//intuit can hold from presence of windup anim
|
||||
currentMoveCanHold = currentMove.getHoldAnimationName() != null;
|
||||
//stop movement tree
|
||||
if(parent.containsKey(EntityDataStrings.CLIENT_MOVEMENT_BT)){
|
||||
BehaviorTree movementTree = CreatureUtils.clientGetEntityMovementTree(parent);
|
||||
if(movementTree instanceof GroundMovementTree){
|
||||
((GroundMovementTree)movementTree).interrupt();
|
||||
}
|
||||
}
|
||||
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
|
||||
EntityUtils.getRotation(parent).rotationTo(new Vector3d(0,0,1), new Vector3d(movementVector.x,movementVector.y,movementVector.z));
|
||||
//set initial stuff
|
||||
state = AttackTreeState.WINDUP;
|
||||
frameCurrent = 0;
|
||||
} else {
|
||||
state = AttackTreeState.IDLE;
|
||||
}
|
||||
Globals.clientConnection.queueOutgoingMessage(EntityMessage.constructstartAttackMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -158,7 +148,16 @@ public class AttackTree implements BehaviorTree {
|
||||
Actor entityActor = EntityUtils.getActor(parent);
|
||||
Vector3d position = EntityUtils.getPosition(parent);
|
||||
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
|
||||
|
||||
|
||||
//synchronize move from server
|
||||
if(this.currentMove == null && this.currentMoveId != null){
|
||||
for(AttackMove move : currentMoveset){
|
||||
if(move.getAttackMoveId().equals(currentMoveId)){
|
||||
currentMove = move;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//parse attached network messages
|
||||
for(EntityMessage message : networkMessageQueue){
|
||||
networkMessageQueue.remove(message);
|
||||
@ -246,29 +245,13 @@ public class AttackTree implements BehaviorTree {
|
||||
entityActor.incrementAnimationTime(0.0001);
|
||||
}
|
||||
}
|
||||
if(frameCurrent > currentMove.getWindupFrames()){
|
||||
if(currentMove != null && frameCurrent > currentMove.getWindupFrames()){
|
||||
if(currentMoveCanHold && stillHold){
|
||||
state = AttackTreeState.HOLD;
|
||||
} else {
|
||||
state = AttackTreeState.ATTACK;
|
||||
}
|
||||
}
|
||||
if(parent.getId() == Globals.clientCharacterID){
|
||||
Globals.clientConnection.queueOutgoingMessage(
|
||||
EntityMessage.constructattackUpdateMessage(
|
||||
Globals.clientSceneWrapper.mapClientToServerId(parent.getId()),
|
||||
System.currentTimeMillis(),
|
||||
(float)position.x,
|
||||
(float)position.y,
|
||||
(float)position.z,
|
||||
movementVector.x,
|
||||
movementVector.y,
|
||||
movementVector.z,
|
||||
velocity,
|
||||
0
|
||||
)
|
||||
);
|
||||
}
|
||||
break;
|
||||
case HOLD:
|
||||
if(entityActor != null){
|
||||
@ -326,25 +309,9 @@ public class AttackTree implements BehaviorTree {
|
||||
ProjectileUtils.clientSpawnBasicProjectile(projectileToFire, spawnPosition, arrowRotation, 750, initialVector, 0.03f);
|
||||
projectileToFire = null;
|
||||
}
|
||||
if(frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames()){
|
||||
if(currentMove != null && frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames()){
|
||||
state = AttackTreeState.COOLDOWN;
|
||||
}
|
||||
if(parent.getId() == Globals.clientCharacterID){
|
||||
Globals.clientConnection.queueOutgoingMessage(
|
||||
EntityMessage.constructattackUpdateMessage(
|
||||
Globals.clientSceneWrapper.mapClientToServerId(parent.getId()),
|
||||
System.currentTimeMillis(),
|
||||
(float)position.x,
|
||||
(float)position.y,
|
||||
(float)position.z,
|
||||
movementVector.x,
|
||||
movementVector.y,
|
||||
movementVector.z,
|
||||
velocity,
|
||||
1
|
||||
)
|
||||
);
|
||||
}
|
||||
break;
|
||||
case COOLDOWN:
|
||||
if(parent.containsKey(EntityDataStrings.ATTACH_CHILDREN_LIST)){
|
||||
@ -365,22 +332,6 @@ public class AttackTree implements BehaviorTree {
|
||||
RotatorTree.getClientRotatorTree(parent).setActive(false);
|
||||
}
|
||||
}
|
||||
if(parent.getId() == Globals.clientCharacterID){
|
||||
Globals.clientConnection.queueOutgoingMessage(
|
||||
EntityMessage.constructattackUpdateMessage(
|
||||
Globals.clientSceneWrapper.mapClientToServerId(parent.getId()),
|
||||
System.currentTimeMillis(),
|
||||
(float)position.x,
|
||||
(float)position.y,
|
||||
(float)position.z,
|
||||
movementVector.x,
|
||||
movementVector.y,
|
||||
movementVector.z,
|
||||
velocity,
|
||||
2
|
||||
)
|
||||
);
|
||||
}
|
||||
break;
|
||||
case IDLE:
|
||||
currentMove = null;
|
||||
@ -466,4 +417,178 @@ public class AttackTree implements BehaviorTree {
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* <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(AttackTreeState state){
|
||||
this.state = state;
|
||||
}
|
||||
/**
|
||||
* <p> Automatically generated </p>
|
||||
* <p>
|
||||
* Gets driftState.
|
||||
* </p>
|
||||
*/
|
||||
public AttackTreeDriftState getDriftState(){
|
||||
return driftState;
|
||||
}
|
||||
/**
|
||||
* <p> Automatically generated </p>
|
||||
* <p>
|
||||
* Sets driftState and handles the synchronization logic for it.
|
||||
* </p>
|
||||
* @param driftState The value to set driftState to.
|
||||
*/
|
||||
public void setDriftState(AttackTreeDriftState driftState){
|
||||
this.driftState = driftState;
|
||||
}
|
||||
/**
|
||||
* <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 ClientAttackTree attachTree(Entity parent){
|
||||
ClientAttackTree rVal = new ClientAttackTree(parent);
|
||||
//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_CLIENTATTACKTREE, rVal);
|
||||
Globals.clientScene.registerBehaviorTree(rVal);
|
||||
Globals.entityValueTrackingService.attachTreeToEntity(parent, BehaviorTreeIdEnums.BTREE_CLIENTATTACKTREE_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_CLIENTATTACKTREE_ID);
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
* Gets the ClientAttackTree of the entity
|
||||
* </p>
|
||||
* @param entity the entity
|
||||
* @return The ClientAttackTree
|
||||
*/
|
||||
public static ClientAttackTree getClientAttackTree(Entity entity){
|
||||
return (ClientAttackTree)entity.getData(EntityDataStrings.TREE_CLIENTATTACKTREE);
|
||||
}
|
||||
/**
|
||||
* <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 getAttackTreeStateEnumAsShort(AttackTreeState enumVal){
|
||||
switch(enumVal){
|
||||
case WINDUP:
|
||||
return 0;
|
||||
case HOLD:
|
||||
return 1;
|
||||
case ATTACK:
|
||||
return 2;
|
||||
case COOLDOWN:
|
||||
return 3;
|
||||
case IDLE:
|
||||
return 4;
|
||||
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 AttackTreeState getAttackTreeStateShortAsEnum(short shortVal){
|
||||
switch(shortVal){
|
||||
case 0:
|
||||
return AttackTreeState.WINDUP;
|
||||
case 1:
|
||||
return AttackTreeState.HOLD;
|
||||
case 2:
|
||||
return AttackTreeState.ATTACK;
|
||||
case 3:
|
||||
return AttackTreeState.COOLDOWN;
|
||||
case 4:
|
||||
return AttackTreeState.IDLE;
|
||||
default:
|
||||
return AttackTreeState.WINDUP;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <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 getAttackTreeDriftStateEnumAsShort(AttackTreeDriftState enumVal){
|
||||
switch(enumVal){
|
||||
case DRIFT:
|
||||
return 0;
|
||||
case NO_DRIFT:
|
||||
return 1;
|
||||
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 AttackTreeDriftState getAttackTreeDriftStateShortAsEnum(short shortVal){
|
||||
switch(shortVal){
|
||||
case 0:
|
||||
return AttackTreeDriftState.DRIFT;
|
||||
case 1:
|
||||
return AttackTreeDriftState.NO_DRIFT;
|
||||
default:
|
||||
return AttackTreeDriftState.DRIFT;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* <p> Automatically generated </p>
|
||||
* <p>
|
||||
* Gets currentMoveId.
|
||||
* </p>
|
||||
*/
|
||||
public String getCurrentMoveId(){
|
||||
return currentMoveId;
|
||||
}
|
||||
/**
|
||||
* <p> Automatically generated </p>
|
||||
* <p>
|
||||
* Sets currentMoveId and handles the synchronization logic for it.
|
||||
* </p>
|
||||
* @param currentMoveId The value to set currentMoveId to.
|
||||
*/
|
||||
public void setCurrentMoveId(String currentMoveId){
|
||||
this.currentMoveId = currentMoveId;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,14 @@
|
||||
package electrosphere.entity.state.attack;
|
||||
|
||||
|
||||
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.collision.collidable.Collidable;
|
||||
import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.Main;
|
||||
@ -8,6 +17,8 @@ import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.ServerEntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeDriftState;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
|
||||
import electrosphere.entity.state.collidable.Impulse;
|
||||
import electrosphere.entity.state.equip.ServerEquipState;
|
||||
import electrosphere.entity.state.movement.groundmove.GroundMovementTree;
|
||||
@ -23,6 +34,8 @@ import electrosphere.entity.types.projectile.ProjectileUtils;
|
||||
import electrosphere.game.data.creature.type.attack.AttackMove;
|
||||
import electrosphere.game.data.creature.type.equip.EquipPoint;
|
||||
import electrosphere.net.parser.net.message.EntityMessage;
|
||||
import electrosphere.net.synchronization.annotation.SyncedField;
|
||||
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
|
||||
import electrosphere.renderer.actor.Actor;
|
||||
import electrosphere.renderer.anim.Animation;
|
||||
import electrosphere.server.datacell.Realm;
|
||||
@ -38,23 +51,16 @@ import org.joml.Quaternionfc;
|
||||
import org.joml.Vector3d;
|
||||
import org.joml.Vector3f;
|
||||
|
||||
@SynchronizedBehaviorTree(name = "serverAttackTree", isServer = true, correspondingTree="clientAttackTree")
|
||||
/**
|
||||
* Server basic attack tree
|
||||
*/
|
||||
public class ServerAttackTree implements BehaviorTree {
|
||||
|
||||
public static enum AttackTreeState {
|
||||
WINDUP,
|
||||
HOLD,
|
||||
ATTACK,
|
||||
COOLDOWN,
|
||||
IDLE,
|
||||
}
|
||||
|
||||
//the state of drifting forward during the attack
|
||||
public static enum AttackTreeDriftState {
|
||||
DRIFT,
|
||||
NO_DRIFT,
|
||||
}
|
||||
|
||||
@SyncedField
|
||||
AttackTreeState state;
|
||||
|
||||
@SyncedField
|
||||
AttackTreeDriftState driftState;
|
||||
|
||||
Entity parent;
|
||||
@ -70,6 +76,8 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
int maxFrame = 60;
|
||||
|
||||
List<AttackMove> currentMoveset = null;
|
||||
@SyncedField
|
||||
String currentMoveId = null;
|
||||
AttackMove currentMove = null;
|
||||
Entity currentWeapon = null;
|
||||
boolean currentMoveHasWindup;
|
||||
@ -85,6 +93,12 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
parent = e;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p> Automatically generated </p>
|
||||
* <p>
|
||||
* Gets state.
|
||||
* </p>
|
||||
*/
|
||||
public AttackTreeState getState(){
|
||||
return state;
|
||||
}
|
||||
@ -133,10 +147,11 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
Vector3d movementVector = CreatureUtils.getFacingVector(parent);
|
||||
EntityUtils.getRotation(parent).rotationTo(new Vector3d(0,0,1), new Vector3d(movementVector.x,movementVector.y,movementVector.z));
|
||||
//set initial stuff
|
||||
state = AttackTreeState.WINDUP;
|
||||
setCurrentMoveId(currentMove.getAttackMoveId());
|
||||
setState(AttackTreeState.WINDUP);
|
||||
frameCurrent = 0;
|
||||
} else {
|
||||
state = AttackTreeState.IDLE;
|
||||
setState(AttackTreeState.IDLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -147,11 +162,11 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
}
|
||||
|
||||
public void interrupt(){
|
||||
state = AttackTreeState.IDLE;
|
||||
setState(AttackTreeState.IDLE);
|
||||
}
|
||||
|
||||
public void slowdown(){
|
||||
state = AttackTreeState.COOLDOWN;
|
||||
setState(AttackTreeState.COOLDOWN);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -173,23 +188,23 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
lastUpdateTime = updateTime;
|
||||
switch(message.gettreeState()){
|
||||
case 0:
|
||||
state = AttackTreeState.WINDUP;
|
||||
setState(AttackTreeState.WINDUP);
|
||||
frameCurrent = 0;
|
||||
// System.out.println("Set state STARTUP");
|
||||
break;
|
||||
case 1:
|
||||
frameCurrent = currentMove.getWindupFrames()+1;
|
||||
state = AttackTreeState.ATTACK;
|
||||
setState(AttackTreeState.ATTACK);
|
||||
// System.out.println("Set state MOVE");
|
||||
break;
|
||||
case 2:
|
||||
frameCurrent = currentMove.getWindupFrames()+currentMove.getAttackFrames()+1;
|
||||
state = AttackTreeState.COOLDOWN;
|
||||
setState(AttackTreeState.COOLDOWN);
|
||||
// System.out.println("Set state SLOWDOWN");
|
||||
break;
|
||||
case 3:
|
||||
frameCurrent = 60;
|
||||
state = AttackTreeState.IDLE;
|
||||
setState(AttackTreeState.IDLE);
|
||||
// System.out.println("Set state IDLE");
|
||||
break;
|
||||
}
|
||||
@ -197,17 +212,10 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
|
||||
CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ()));
|
||||
break;
|
||||
case ATTACHENTITYTOENTITY:
|
||||
case CREATE:
|
||||
case DESTROY:
|
||||
case MOVE:
|
||||
case MOVEUPDATE:
|
||||
case SETBEHAVIORTREE:
|
||||
case SETFACING:
|
||||
case SETPOSITION:
|
||||
case SETPROPERTY:
|
||||
case KILL:
|
||||
case SPAWNCREATURE:
|
||||
case STARTATTACK: {
|
||||
start();
|
||||
} break;
|
||||
default:
|
||||
//silently ignore
|
||||
break;
|
||||
}
|
||||
@ -220,14 +228,14 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
//calculate the vector of movement
|
||||
CollisionObjUtils.getCollidable(parent).addImpulse(new Impulse(new Vector3d(movementVector), new Vector3d(0,0,0), new Vector3d(0,0,0), currentMove.getDriftGoal() * Globals.timekeeper.getSimFrameTime(), "movement"));
|
||||
if(frameCurrent > currentMove.getDriftFrameEnd()){
|
||||
driftState = AttackTreeDriftState.NO_DRIFT;
|
||||
setDriftState(AttackTreeDriftState.NO_DRIFT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case NO_DRIFT:
|
||||
if(currentMove != null){
|
||||
if(frameCurrent > currentMove.getDriftFrameStart() && frameCurrent < currentMove.getDriftFrameEnd()){
|
||||
driftState = AttackTreeDriftState.DRIFT;
|
||||
setDriftState(AttackTreeDriftState.DRIFT);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@ -251,9 +259,9 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
}
|
||||
if(frameCurrent > currentMove.getWindupFrames()){
|
||||
if(currentMoveCanHold && stillHold){
|
||||
state = AttackTreeState.HOLD;
|
||||
setState(AttackTreeState.HOLD);
|
||||
} else {
|
||||
state = AttackTreeState.ATTACK;
|
||||
setState(AttackTreeState.ATTACK);
|
||||
}
|
||||
}
|
||||
Globals.server.broadcastMessage(
|
||||
@ -279,7 +287,7 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
}
|
||||
}
|
||||
if(!stillHold){
|
||||
state = AttackTreeState.ATTACK;
|
||||
setState(AttackTreeState.ATTACK);
|
||||
}
|
||||
break;
|
||||
case ATTACK:
|
||||
@ -329,7 +337,7 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
projectileToFire = null;
|
||||
}
|
||||
if(frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames()){
|
||||
state = AttackTreeState.COOLDOWN;
|
||||
setState(AttackTreeState.COOLDOWN);
|
||||
}
|
||||
Globals.server.broadcastMessage(
|
||||
EntityMessage.constructattackUpdateMessage(
|
||||
@ -359,7 +367,7 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
}
|
||||
}
|
||||
if(frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames() + currentMove.getCooldownFrames()){
|
||||
state = AttackTreeState.IDLE;
|
||||
setState(AttackTreeState.IDLE);
|
||||
frameCurrent = 0;
|
||||
if(parent.containsKey(EntityDataStrings.SERVER_ROTATOR_TREE)){
|
||||
ServerRotatorTree.getServerRotatorTree(parent).setActive(false);
|
||||
@ -464,4 +472,99 @@ public class ServerAttackTree implements BehaviorTree {
|
||||
return rVal;
|
||||
}
|
||||
|
||||
/**
|
||||
* <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(AttackTreeState state){
|
||||
this.state = state;
|
||||
int value = ClientAttackTree.getAttackTreeStateEnumAsShort(state);
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientStateMessage(parent.getId(), 1, 3, value));
|
||||
}
|
||||
/**
|
||||
* <p> Automatically generated </p>
|
||||
* <p>
|
||||
* Gets driftState.
|
||||
* </p>
|
||||
*/
|
||||
public AttackTreeDriftState getDriftState(){
|
||||
return driftState;
|
||||
}
|
||||
/**
|
||||
* <p> Automatically generated </p>
|
||||
* <p>
|
||||
* Sets driftState and handles the synchronization logic for it.
|
||||
* </p>
|
||||
* @param driftState The value to set driftState to.
|
||||
*/
|
||||
public void setDriftState(AttackTreeDriftState driftState){
|
||||
this.driftState = driftState;
|
||||
int value = ClientAttackTree.getAttackTreeDriftStateEnumAsShort(driftState);
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientStateMessage(parent.getId(), 1, 4, 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 ServerAttackTree attachTree(Entity parent){
|
||||
ServerAttackTree rVal = new ServerAttackTree(parent);
|
||||
//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_SERVERATTACKTREE, rVal);
|
||||
Globals.entityValueTrackingService.attachTreeToEntity(parent, BehaviorTreeIdEnums.BTREE_SERVERATTACKTREE_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_SERVERATTACKTREE_ID);
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
* Gets the ServerAttackTree of the entity
|
||||
* </p>
|
||||
* @param entity the entity
|
||||
* @return The ServerAttackTree
|
||||
*/
|
||||
public static ServerAttackTree getServerAttackTree(Entity entity){
|
||||
return (ServerAttackTree)entity.getData(EntityDataStrings.TREE_SERVERATTACKTREE);
|
||||
}
|
||||
/**
|
||||
* <p> Automatically generated </p>
|
||||
* <p>
|
||||
* Gets currentMoveId.
|
||||
* </p>
|
||||
*/
|
||||
public String getCurrentMoveId(){
|
||||
return currentMoveId;
|
||||
}
|
||||
/**
|
||||
* <p> Automatically generated </p>
|
||||
* <p>
|
||||
* Sets currentMoveId and handles the synchronization logic for it.
|
||||
* </p>
|
||||
* @param currentMoveId The value to set currentMoveId to.
|
||||
*/
|
||||
public void setCurrentMoveId(String currentMoveId){
|
||||
this.currentMoveId = currentMoveId;
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientStringStateMessage(parent.getId(), 1, 5, currentMoveId));
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,8 @@
|
||||
package electrosphere.entity.state.equip;
|
||||
|
||||
|
||||
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -12,6 +15,7 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.gravity.GravityUtils;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
@ -28,7 +32,7 @@ import electrosphere.renderer.actor.ActorMeshMask;
|
||||
/**
|
||||
* Client view of items equipped to a given entity
|
||||
*/
|
||||
public class ClientEquipState {
|
||||
public class ClientEquipState implements BehaviorTree {
|
||||
|
||||
Entity parent;
|
||||
|
||||
@ -265,6 +269,53 @@ public class ClientEquipState {
|
||||
public boolean hasEquippedAtPoint(String point){
|
||||
return equipMap.containsKey(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simulate(float deltaTime) {
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <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 ClientEquipState attachTree(Entity parent, List<EquipPoint> equipPoints){
|
||||
ClientEquipState rVal = new ClientEquipState(parent, equipPoints);
|
||||
//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_CLIENTEQUIPSTATE, rVal);
|
||||
Globals.clientScene.registerBehaviorTree(rVal);
|
||||
Globals.entityValueTrackingService.attachTreeToEntity(parent, BehaviorTreeIdEnums.BTREE_CLIENTEQUIPSTATE_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_CLIENTEQUIPSTATE_ID);
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
* Gets the ClientEquipState of the entity
|
||||
* </p>
|
||||
* @param entity the entity
|
||||
* @return The ClientEquipState
|
||||
*/
|
||||
public static ClientEquipState getClientEquipState(Entity entity){
|
||||
return (ClientEquipState)entity.getData(EntityDataStrings.TREE_CLIENTEQUIPSTATE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -1,5 +1,12 @@
|
||||
package electrosphere.entity.state.equip;
|
||||
|
||||
|
||||
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
|
||||
|
||||
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
||||
|
||||
import electrosphere.net.parser.net.message.SynchronizationMessage;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
@ -13,6 +20,7 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.gravity.GravityUtils;
|
||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||
import electrosphere.entity.state.inventory.RelationalInventoryState;
|
||||
@ -36,7 +44,7 @@ import electrosphere.server.datacell.utils.ServerEntityTagUtils;
|
||||
/**
|
||||
* Server view of items equipped onto an entity
|
||||
*/
|
||||
public class ServerEquipState {
|
||||
public class ServerEquipState implements BehaviorTree {
|
||||
|
||||
Entity parent;
|
||||
|
||||
@ -317,4 +325,52 @@ public class ServerEquipState {
|
||||
public boolean hasEquippedAtPoint(String point){
|
||||
return equipMap.containsKey(point);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void simulate(float deltaTime) {
|
||||
}
|
||||
|
||||
/**
|
||||
* <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 ServerEquipState attachTree(Entity parent, List<EquipPoint> equipPoints){
|
||||
ServerEquipState rVal = new ServerEquipState(parent, equipPoints);
|
||||
//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_SERVEREQUIPSTATE, rVal);
|
||||
Globals.entityValueTrackingService.attachTreeToEntity(parent, BehaviorTreeIdEnums.BTREE_SERVEREQUIPSTATE_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_SERVEREQUIPSTATE_ID);
|
||||
}
|
||||
/**
|
||||
* <p>
|
||||
* Gets the ServerEquipState of the entity
|
||||
* </p>
|
||||
* @param entity the entity
|
||||
* @return The ServerEquipState
|
||||
*/
|
||||
public static ServerEquipState getServerEquipState(Entity entity){
|
||||
return (ServerEquipState)entity.getData(EntityDataStrings.TREE_SERVEREQUIPSTATE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -215,7 +215,7 @@ public class ServerGravityTree implements BehaviorTree {
|
||||
public void setState(GravityTreeState state){
|
||||
this.state = state;
|
||||
int value = ClientGravityTree.getGravityTreeStateEnumAsShort(state);
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientStateMessage(parent.getId(), 1, 1, value));
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientStateMessage(parent.getId(), 5, 7, value));
|
||||
}
|
||||
/**
|
||||
* <p> (initially) Automatically generated </p>
|
||||
|
||||
@ -2,7 +2,7 @@ package electrosphere.entity.state.idle;
|
||||
|
||||
|
||||
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
|
||||
import electrosphere.entity.state.attack.AttackTree;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||
import electrosphere.entity.state.movement.AirplaneMovementTree;
|
||||
import electrosphere.entity.state.movement.groundmove.GroundMovementTree;
|
||||
import electrosphere.entity.state.movement.groundmove.GroundMovementTree.MovementTreeState;
|
||||
@ -68,8 +68,8 @@ public class IdleTree implements BehaviorTree {
|
||||
|
||||
boolean movementTreeIsIdle = movementTreeIsIdle();
|
||||
|
||||
boolean hasAttackTree = parent.containsKey(EntityDataStrings.CLIENT_ATTACK_TREE);
|
||||
AttackTree attackTree = null;
|
||||
boolean hasAttackTree = parent.containsKey(EntityDataStrings.TREE_CLIENTATTACKTREE);
|
||||
ClientAttackTree attackTree = null;
|
||||
if(hasAttackTree){
|
||||
attackTree = CreatureUtils.clientGetAttackTree(parent);
|
||||
}
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
package electrosphere.entity.state.idle;
|
||||
|
||||
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
|
||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
||||
import electrosphere.entity.state.attack.ServerAttackTree.AttackTreeState;
|
||||
import electrosphere.entity.state.idle.IdleTree.IdleTreeState;
|
||||
import electrosphere.entity.state.movement.AirplaneMovementTree;
|
||||
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
|
||||
@ -72,7 +72,7 @@ public class ServerIdleTree implements BehaviorTree {
|
||||
|
||||
boolean movementTreeIsIdle = movementTreeIsIdle();
|
||||
|
||||
boolean hasAttackTree = parent.containsKey(EntityDataStrings.SERVER_ATTACK_TREE);
|
||||
boolean hasAttackTree = parent.containsKey(EntityDataStrings.TREE_SERVERATTACKTREE);
|
||||
ServerAttackTree attackTree = null;
|
||||
if(hasAttackTree){
|
||||
attackTree = CreatureUtils.serverGetAttackTree(parent);
|
||||
@ -185,7 +185,7 @@ public class ServerIdleTree implements BehaviorTree {
|
||||
public void setState(IdleTreeState state){
|
||||
this.state = state;
|
||||
int value = IdleTree.getIdleTreeStateEnumAsShort(state);
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientStateMessage(parent.getId(), 3, 3, value));
|
||||
DataCellSearchUtils.getEntityDataCell(parent).broadcastNetworkMessage(SynchronizationMessage.constructUpdateClientStateMessage(parent.getId(), 7, 9, value));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -17,8 +17,8 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.attack.AttackTree;
|
||||
import electrosphere.entity.state.attack.AttackTree.AttackTreeState;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
|
||||
import electrosphere.entity.state.movement.FallTree;
|
||||
import electrosphere.entity.state.movement.JumpTree;
|
||||
import electrosphere.entity.state.movement.SprintTree;
|
||||
@ -376,7 +376,7 @@ public class GroundMovementTree implements BehaviorTree {
|
||||
|
||||
public boolean canStartMoving(){
|
||||
boolean rVal = true;
|
||||
if(parent.containsKey(EntityDataStrings.CLIENT_ATTACK_TREE) && ((AttackTree)parent.getData(EntityDataStrings.CLIENT_ATTACK_TREE)).getState() != AttackTreeState.IDLE){
|
||||
if(parent.containsKey(EntityDataStrings.TREE_CLIENTATTACKTREE) && ((ClientAttackTree)parent.getData(EntityDataStrings.TREE_CLIENTATTACKTREE)).getState() != AttackTreeState.IDLE){
|
||||
rVal = false;
|
||||
}
|
||||
return rVal;
|
||||
|
||||
@ -14,8 +14,8 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
|
||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
||||
import electrosphere.entity.state.attack.ServerAttackTree.AttackTreeState;
|
||||
import electrosphere.entity.state.movement.ServerFallTree;
|
||||
import electrosphere.entity.state.movement.ServerJumpTree;
|
||||
import electrosphere.entity.state.movement.ServerSprintTree;
|
||||
@ -411,7 +411,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
|
||||
|
||||
public boolean canStartMoving(){
|
||||
boolean rVal = true;
|
||||
if(parent.containsKey(EntityDataStrings.SERVER_ATTACK_TREE) && ((ServerAttackTree)parent.getData(EntityDataStrings.SERVER_ATTACK_TREE)).getState() != AttackTreeState.IDLE){
|
||||
if(parent.containsKey(EntityDataStrings.TREE_SERVERATTACKTREE) && ((ServerAttackTree)parent.getData(EntityDataStrings.TREE_SERVERATTACKTREE)).getState() != AttackTreeState.IDLE){
|
||||
rVal = false;
|
||||
}
|
||||
return rVal;
|
||||
|
||||
@ -20,7 +20,7 @@ import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.ServerEntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.state.attack.AttackTree;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
||||
import electrosphere.entity.state.attack.ShooterTree;
|
||||
import electrosphere.entity.state.collidable.ClientCollidableTree;
|
||||
@ -237,10 +237,8 @@ public class CreatureUtils {
|
||||
ActorUtils.applyBlenderTransformer(rVal);
|
||||
break;
|
||||
case "ATTACKER":
|
||||
AttackTree attackTree = new AttackTree(rVal);
|
||||
rVal.putData(EntityDataStrings.CLIENT_ATTACK_TREE, attackTree);
|
||||
ClientAttackTree.attachTree(rVal);
|
||||
rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, null);
|
||||
Globals.clientScene.registerBehaviorTree(attackTree);
|
||||
Globals.clientScene.registerEntityToTag(rVal, EntityTags.ATTACKER);
|
||||
//add all attack moves
|
||||
if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){
|
||||
@ -533,10 +531,8 @@ public class CreatureUtils {
|
||||
PoseActorUtils.applyBlenderTransformer(rVal);
|
||||
} break;
|
||||
case "ATTACKER": {
|
||||
ServerAttackTree attackTree = new ServerAttackTree(rVal);
|
||||
rVal.putData(EntityDataStrings.SERVER_ATTACK_TREE, attackTree);
|
||||
ServerAttackTree.attachTree(rVal);
|
||||
rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, null);
|
||||
ServerBehaviorTreeUtils.attachBTreeToEntity(rVal, attackTree);
|
||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.ATTACKER);
|
||||
//add all attack moves
|
||||
if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){
|
||||
@ -764,10 +760,6 @@ public class CreatureUtils {
|
||||
}
|
||||
}
|
||||
|
||||
public static void attachEntityMessageToAttackTree(Entity e, EntityMessage em){
|
||||
clientGetAttackTree(e).addNetworkMessage(em);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the type of creature
|
||||
* @param e the entity
|
||||
@ -801,12 +793,12 @@ public class CreatureUtils {
|
||||
return (int)e.getData(EntityDataStrings.ENTITY_TYPE) == ENTITY_TYPE_CREATURE;
|
||||
}
|
||||
|
||||
public static AttackTree clientGetAttackTree(Entity e){
|
||||
return (AttackTree)e.getData(EntityDataStrings.CLIENT_ATTACK_TREE);
|
||||
public static ClientAttackTree clientGetAttackTree(Entity e){
|
||||
return (ClientAttackTree)e.getData(EntityDataStrings.TREE_CLIENTATTACKTREE);
|
||||
}
|
||||
|
||||
public static ServerAttackTree serverGetAttackTree(Entity e){
|
||||
return (ServerAttackTree)e.getData(EntityDataStrings.SERVER_ATTACK_TREE);
|
||||
return (ServerAttackTree)e.getData(EntityDataStrings.TREE_SERVERATTACKTREE);
|
||||
}
|
||||
|
||||
public static IdleTree getIdleTree(Entity e){
|
||||
|
||||
@ -226,7 +226,7 @@ public class ItemUtils {
|
||||
|
||||
public static void updateItemActorAnimation(Entity item){
|
||||
Actor actor = EntityUtils.getActor(item);
|
||||
if(item.getData(EntityDataStrings.ANIM_IDLE) != null){
|
||||
if(actor != null && item.getData(EntityDataStrings.ANIM_IDLE) != null){
|
||||
String idleAnim = (String)item.getData(EntityDataStrings.ANIM_IDLE);
|
||||
if(!actor.isPlayingAnimation(idleAnim)){
|
||||
actor.playAnimation(idleAnim,1);
|
||||
|
||||
@ -7,6 +7,8 @@ import electrosphere.engine.Globals;
|
||||
import electrosphere.entity.ClientEntityUtils;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.creature.CreatureTemplate;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
@ -123,7 +125,7 @@ public class EntityProtocol {
|
||||
CreatureUtils.clientAttachEntityMessageToMovementTree(Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID()),message);
|
||||
} break;
|
||||
case ATTACKUPDATE: {
|
||||
CreatureUtils.attachEntityMessageToAttackTree(Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID()),message);
|
||||
ClientAttackTree.getClientAttackTree(Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID())).addNetworkMessage(message);
|
||||
} break;
|
||||
|
||||
|
||||
|
||||
@ -15,6 +15,7 @@ public class EntityMessage extends NetworkMessage {
|
||||
SETFACING,
|
||||
MOVEUPDATE,
|
||||
ATTACKUPDATE,
|
||||
STARTATTACK,
|
||||
MOVE,
|
||||
KILL,
|
||||
DESTROY,
|
||||
@ -319,6 +320,12 @@ public class EntityMessage extends NetworkMessage {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_STARTATTACK:
|
||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_STARTATTACK_SIZE){
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVE:
|
||||
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_MOVE_SIZE){
|
||||
return true;
|
||||
@ -657,6 +664,18 @@ public class EntityMessage extends NetworkMessage {
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static EntityMessage parsestartAttackMessage(CircularByteBuffer byteBuffer){
|
||||
EntityMessage rVal = new EntityMessage(EntityMessageType.STARTATTACK);
|
||||
stripPacketHeader(byteBuffer);
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static EntityMessage constructstartAttackMessage(){
|
||||
EntityMessage rVal = new EntityMessage(EntityMessageType.STARTATTACK);
|
||||
rVal.serialize();
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static EntityMessage parseMoveMessage(CircularByteBuffer byteBuffer){
|
||||
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVE);
|
||||
stripPacketHeader(byteBuffer);
|
||||
@ -1245,6 +1264,13 @@ public class EntityMessage extends NetworkMessage {
|
||||
rawBytes[70+i] = intValues[i];
|
||||
}
|
||||
break;
|
||||
case STARTATTACK:
|
||||
rawBytes = new byte[2];
|
||||
//message header
|
||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_ENTITY;
|
||||
//entity messaage header
|
||||
rawBytes[1] = TypeBytes.ENTITY_MESSAGE_TYPE_STARTATTACK;
|
||||
break;
|
||||
case MOVE:
|
||||
rawBytes = new byte[2+4+8+8+8+8];
|
||||
//message header
|
||||
|
||||
@ -76,6 +76,11 @@ SYNCHRONIZATION_MESSAGE,
|
||||
rVal = EntityMessage.parseattackUpdateMessage(byteBuffer);
|
||||
}
|
||||
break;
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_STARTATTACK:
|
||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
||||
rVal = EntityMessage.parsestartAttackMessage(byteBuffer);
|
||||
}
|
||||
break;
|
||||
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVE:
|
||||
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
|
||||
rVal = EntityMessage.parseMoveMessage(byteBuffer);
|
||||
@ -381,6 +386,11 @@ SYNCHRONIZATION_MESSAGE,
|
||||
rVal = SynchronizationMessage.parseUpdateClientStateMessage(byteBuffer);
|
||||
}
|
||||
break;
|
||||
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTSTRINGSTATE:
|
||||
if(SynchronizationMessage.canParseMessage(byteBuffer,secondByte)){
|
||||
rVal = SynchronizationMessage.parseUpdateClientStringStateMessage(byteBuffer);
|
||||
}
|
||||
break;
|
||||
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE:
|
||||
if(SynchronizationMessage.canParseMessage(byteBuffer,secondByte)){
|
||||
rVal = SynchronizationMessage.parseAttachTreeMessage(byteBuffer);
|
||||
|
||||
@ -9,6 +9,7 @@ public class SynchronizationMessage extends NetworkMessage {
|
||||
|
||||
public enum SynchronizationMessageType {
|
||||
UPDATECLIENTSTATE,
|
||||
UPDATECLIENTSTRINGSTATE,
|
||||
ATTACHTREE,
|
||||
DETATCHTREE,
|
||||
}
|
||||
@ -18,6 +19,7 @@ public class SynchronizationMessage extends NetworkMessage {
|
||||
int bTreeId;
|
||||
int fieldId;
|
||||
int bTreeValue;
|
||||
String stringValue;
|
||||
|
||||
SynchronizationMessage(SynchronizationMessageType messageType){
|
||||
this.type = MessageType.SYNCHRONIZATION_MESSAGE;
|
||||
@ -60,6 +62,14 @@ public class SynchronizationMessage extends NetworkMessage {
|
||||
this.bTreeValue = bTreeValue;
|
||||
}
|
||||
|
||||
public String getstringValue() {
|
||||
return stringValue;
|
||||
}
|
||||
|
||||
public void setstringValue(String stringValue) {
|
||||
this.stringValue = stringValue;
|
||||
}
|
||||
|
||||
static void stripPacketHeader(CircularByteBuffer byteBuffer){
|
||||
byteBuffer.read(2);
|
||||
}
|
||||
@ -72,6 +82,8 @@ public class SynchronizationMessage extends NetworkMessage {
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTSTRINGSTATE:
|
||||
return SynchronizationMessage.canParseUpdateClientStringStateMessage(byteBuffer);
|
||||
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE:
|
||||
if(byteBuffer.getRemaining() >= TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE_SIZE){
|
||||
return true;
|
||||
@ -108,6 +120,54 @@ public class SynchronizationMessage extends NetworkMessage {
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static boolean canParseUpdateClientStringStateMessage(CircularByteBuffer byteBuffer){
|
||||
int currentStreamLength = byteBuffer.getRemaining();
|
||||
List<Byte> temporaryByteQueue = new LinkedList();
|
||||
if(currentStreamLength < 6){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 10){
|
||||
return false;
|
||||
}
|
||||
if(currentStreamLength < 14){
|
||||
return false;
|
||||
}
|
||||
int stringValueSize = 0;
|
||||
if(currentStreamLength < 18){
|
||||
return false;
|
||||
} else {
|
||||
temporaryByteQueue.add(byteBuffer.peek(14 + 0));
|
||||
temporaryByteQueue.add(byteBuffer.peek(14 + 1));
|
||||
temporaryByteQueue.add(byteBuffer.peek(14 + 2));
|
||||
temporaryByteQueue.add(byteBuffer.peek(14 + 3));
|
||||
stringValueSize = ByteStreamUtils.popIntFromByteQueue(temporaryByteQueue);
|
||||
}
|
||||
if(currentStreamLength < 18 + stringValueSize){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public static SynchronizationMessage parseUpdateClientStringStateMessage(CircularByteBuffer byteBuffer){
|
||||
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.UPDATECLIENTSTRINGSTATE);
|
||||
stripPacketHeader(byteBuffer);
|
||||
rVal.setentityId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
||||
rVal.setbTreeId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
||||
rVal.setfieldId(ByteStreamUtils.popIntFromByteQueue(byteBuffer));
|
||||
rVal.setstringValue(ByteStreamUtils.popStringFromByteQueue(byteBuffer));
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static SynchronizationMessage constructUpdateClientStringStateMessage(int entityId,int bTreeId,int fieldId,String stringValue){
|
||||
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.UPDATECLIENTSTRINGSTATE);
|
||||
rVal.setentityId(entityId);
|
||||
rVal.setbTreeId(bTreeId);
|
||||
rVal.setfieldId(fieldId);
|
||||
rVal.setstringValue(stringValue);
|
||||
rVal.serialize();
|
||||
return rVal;
|
||||
}
|
||||
|
||||
public static SynchronizationMessage parseAttachTreeMessage(CircularByteBuffer byteBuffer){
|
||||
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.ATTACHTREE);
|
||||
stripPacketHeader(byteBuffer);
|
||||
@ -168,6 +228,33 @@ public class SynchronizationMessage extends NetworkMessage {
|
||||
rawBytes[14+i] = intValues[i];
|
||||
}
|
||||
break;
|
||||
case UPDATECLIENTSTRINGSTATE:
|
||||
rawBytes = new byte[2+4+4+4+4+stringValue.length()];
|
||||
//message header
|
||||
rawBytes[0] = TypeBytes.MESSAGE_TYPE_SYNCHRONIZATION;
|
||||
//entity messaage header
|
||||
rawBytes[1] = TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTSTRINGSTATE;
|
||||
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(stringValue.length());
|
||||
for(int i = 0; i < 4; i++){
|
||||
rawBytes[14+i] = intValues[i];
|
||||
}
|
||||
stringBytes = stringValue.getBytes();
|
||||
for(int i = 0; i < stringValue.length(); i++){
|
||||
rawBytes[18+i] = stringBytes[i];
|
||||
}
|
||||
break;
|
||||
case ATTACHTREE:
|
||||
rawBytes = new byte[2+4+4];
|
||||
//message header
|
||||
|
||||
@ -24,18 +24,19 @@ Message categories
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETFACING = 4;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE = 5;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE = 6;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_MOVE = 7;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_KILL = 8;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_DESTROY = 9;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE = 10;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY = 11;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT = 12;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT = 13;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE = 14;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYSTRING = 15;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM = 16;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY = 17;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED = 18;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_STARTATTACK = 7;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_MOVE = 8;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_KILL = 9;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_DESTROY = 10;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE = 11;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY = 12;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT = 13;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT = 14;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE = 15;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYSTRING = 16;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM = 17;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY = 18;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED = 19;
|
||||
/*
|
||||
Entity packet sizes
|
||||
*/
|
||||
@ -43,6 +44,7 @@ Message categories
|
||||
public static final byte ENTITY_MESSAGE_TYPE_SETFACING_SIZE = 38;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE = 82;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE_SIZE = 74;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_STARTATTACK_SIZE = 2;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_MOVE_SIZE = 38;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_KILL_SIZE = 14;
|
||||
public static final byte ENTITY_MESSAGE_TYPE_DESTROY_SIZE = 6;
|
||||
@ -161,8 +163,9 @@ Message categories
|
||||
Synchronization subcategories
|
||||
*/
|
||||
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTSTATE = 0;
|
||||
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE = 1;
|
||||
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_DETATCHTREE = 2;
|
||||
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;
|
||||
/*
|
||||
Synchronization packet sizes
|
||||
*/
|
||||
|
||||
@ -4,6 +4,7 @@ import electrosphere.engine.Globals;
|
||||
import electrosphere.engine.Main;
|
||||
import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
||||
import electrosphere.entity.types.attach.AttachUtils;
|
||||
import electrosphere.entity.types.creature.CreatureUtils;
|
||||
import electrosphere.entity.types.item.ItemUtils;
|
||||
@ -35,9 +36,15 @@ public class EntityProtocol {
|
||||
case ATTACKUPDATE:
|
||||
targetEntity = EntityLookupUtils.getEntityById(message.getentityID());
|
||||
if(targetEntity != null){
|
||||
CreatureUtils.attachEntityMessageToAttackTree(targetEntity,message);
|
||||
ServerAttackTree.getServerAttackTree(targetEntity).addNetworkMessage(message);
|
||||
}
|
||||
break;
|
||||
case STARTATTACK: {
|
||||
targetEntity = EntityLookupUtils.getEntityById(message.getentityID());
|
||||
if(targetEntity != null){
|
||||
ServerAttackTree.getServerAttackTree(targetEntity).addNetworkMessage(message);
|
||||
}
|
||||
} break;
|
||||
//ignore stack
|
||||
case KILL:
|
||||
case SPAWNCREATURE:
|
||||
|
||||
@ -5,9 +5,13 @@ package electrosphere.net.synchronization;
|
||||
*/
|
||||
public class BehaviorTreeIdEnums {
|
||||
|
||||
public static final int BTREE_GRAVITY_ID = 0;
|
||||
public static final int BTREE_SERVERGRAVITY_ID = 1;
|
||||
public static final int BTREE_IDLE_ID = 2;
|
||||
public static final int BTREE_SERVERIDLE_ID = 3;
|
||||
public static final int BTREE_CLIENTATTACKTREE_ID = 0;
|
||||
public static final int BTREE_SERVERATTACKTREE_ID = 1;
|
||||
public static final int BTREE_CLIENTEQUIPSTATE_ID = 2;
|
||||
public static final int BTREE_SERVEREQUIPSTATE_ID = 3;
|
||||
public static final int BTREE_GRAVITY_ID = 4;
|
||||
public static final int BTREE_SERVERGRAVITY_ID = 5;
|
||||
public static final int BTREE_IDLE_ID = 6;
|
||||
public static final int BTREE_SERVERIDLE_ID = 7;
|
||||
|
||||
}
|
||||
|
||||
@ -1,6 +1,11 @@
|
||||
package electrosphere.net.synchronization;
|
||||
|
||||
|
||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
||||
|
||||
import electrosphere.entity.state.equip.ServerEquipState;
|
||||
|
||||
import electrosphere.entity.state.gravity.ClientGravityTree;
|
||||
import electrosphere.entity.state.gravity.ServerGravityTree;
|
||||
|
||||
@ -47,6 +52,12 @@ public class ClientSynchronizationManager {
|
||||
Entity targetEntity = Globals.clientSceneWrapper.getEntityFromServerId(entityId);
|
||||
updateEntityState(targetEntity,bTreeId,message);
|
||||
} break;
|
||||
case UPDATECLIENTSTRINGSTATE:{
|
||||
int bTreeId = message.getbTreeId();
|
||||
int entityId = message.getentityId();
|
||||
Entity targetEntity = Globals.clientSceneWrapper.getEntityFromServerId(entityId);
|
||||
updateEntityState(targetEntity,bTreeId,message);
|
||||
} break;
|
||||
case ATTACHTREE:{
|
||||
int bTreeId = message.getbTreeId();
|
||||
int bTreeValue = message.getbTreeValue();
|
||||
@ -75,9 +86,29 @@ public class ClientSynchronizationManager {
|
||||
*/
|
||||
private void updateEntityState(Entity entity, int bTreeId, SynchronizationMessage message){
|
||||
switch(bTreeId){
|
||||
case BehaviorTreeIdEnums.BTREE_SERVERATTACKTREE_ID: {
|
||||
switch(message.getfieldId()){
|
||||
case 3:{
|
||||
ClientAttackTree tree = ClientAttackTree.getClientAttackTree(entity);
|
||||
tree.setState(ClientAttackTree.getAttackTreeStateShortAsEnum((short)message.getbTreeValue()));
|
||||
} break;
|
||||
case 4:{
|
||||
ClientAttackTree tree = ClientAttackTree.getClientAttackTree(entity);
|
||||
tree.setDriftState(ClientAttackTree.getAttackTreeDriftStateShortAsEnum((short)message.getbTreeValue()));
|
||||
} break;
|
||||
case 5:{
|
||||
ClientAttackTree tree = ClientAttackTree.getClientAttackTree(entity);
|
||||
tree.setCurrentMoveId(message.getstringValue());
|
||||
} break;
|
||||
}
|
||||
} break;
|
||||
case BehaviorTreeIdEnums.BTREE_SERVEREQUIPSTATE_ID: {
|
||||
switch(message.getfieldId()){
|
||||
}
|
||||
} break;
|
||||
case BehaviorTreeIdEnums.BTREE_SERVERGRAVITY_ID: {
|
||||
switch(message.getfieldId()){
|
||||
case 1:{
|
||||
case 7:{
|
||||
ClientGravityTree tree = ClientGravityTree.getClientGravityTree(entity);
|
||||
tree.setState(ClientGravityTree.getGravityTreeStateShortAsEnum((short)message.getbTreeValue()));
|
||||
} break;
|
||||
@ -85,7 +116,7 @@ public class ClientSynchronizationManager {
|
||||
} break;
|
||||
case BehaviorTreeIdEnums.BTREE_SERVERIDLE_ID: {
|
||||
switch(message.getfieldId()){
|
||||
case 3:{
|
||||
case 9:{
|
||||
IdleTree tree = IdleTree.getIdleTree(entity);
|
||||
tree.setState(IdleTree.getIdleTreeStateShortAsEnum((short)message.getbTreeValue()));
|
||||
} break;
|
||||
|
||||
@ -5,7 +5,7 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.attack.AttackTree;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
||||
import electrosphere.entity.state.movement.groundmove.GroundMovementTree;
|
||||
import electrosphere.entity.state.movement.groundmove.GroundMovementTree.MovementRelativeFacing;
|
||||
|
||||
@ -5,7 +5,7 @@ import electrosphere.entity.Entity;
|
||||
import electrosphere.entity.EntityDataStrings;
|
||||
import electrosphere.entity.EntityTags;
|
||||
import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.state.attack.AttackTree;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
||||
import electrosphere.entity.state.equip.ClientEquipState;
|
||||
import electrosphere.entity.state.movement.groundmove.GroundMovementTree;
|
||||
|
||||
@ -11,7 +11,7 @@ import electrosphere.entity.EntityUtils;
|
||||
import electrosphere.entity.btree.BehaviorTree;
|
||||
import electrosphere.entity.scene.EntityDescriptor;
|
||||
import electrosphere.entity.state.ParticleTree;
|
||||
import electrosphere.entity.state.attack.AttackTree;
|
||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||
import electrosphere.entity.state.collidable.ClientCollidableTree;
|
||||
import electrosphere.entity.state.collidable.ServerCollidableTree;
|
||||
import electrosphere.entity.state.idle.IdleTree;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user