start work on synchronizing attack
All checks were successful
studiorailgun/Renderer/pipeline/head This commit looks good

This commit is contained in:
austin 2024-05-05 16:52:03 -04:00
parent a241d97d33
commit 74b3140344
27 changed files with 703 additions and 187 deletions

View File

@ -5,7 +5,7 @@
{ {
"itemId" : "Katana", "itemId" : "Katana",
"modelPath" : "Models/katana1alt.fbx", "modelPath" : "Models/items/weapons/katana1alt.fbx",
"weaponData" : { "weaponData" : {
"weaponClass" : "sword1h", "weaponClass" : "sword1h",
"damage" : 10, "damage" : 10,

View File

@ -197,6 +197,10 @@
"treeState" "treeState"
] ]
}, },
{
"messageName" : "startAttack",
"data" : []
},
{ {
"messageName" : "Move", "messageName" : "Move",
"data" : [ "data" : [

View File

@ -21,6 +21,10 @@
{ {
"name" : "bTreeValue", "name" : "bTreeValue",
"type" : "FIXED_INT" "type" : "FIXED_INT"
},
{
"name" : "stringValue",
"type" : "VAR_STRING"
} }
], ],
"messageTypes" : [ "messageTypes" : [
@ -33,6 +37,15 @@
"bTreeValue" "bTreeValue"
] ]
}, },
{
"messageName" : "UpdateClientStringState",
"data" : [
"entityId",
"bTreeId",
"fieldId",
"stringValue"
]
},
{ {
"messageName" : "AttachTree", "messageName" : "AttachTree",
"data" : [ "data" : [

View File

@ -79,7 +79,7 @@ import electrosphere.engine.Globals;
import electrosphere.engine.Main; import electrosphere.engine.Main;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.btree.BehaviorTree; 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.attack.ShooterTree;
import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.state.inventory.InventoryUtils; 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(){ controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).setOnPress(new ControlMethod(){public void execute(){
if(Globals.playerEntity != null){ if(Globals.playerEntity != null){
// Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera); // Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
AttackTree attackTree = CreatureUtils.clientGetAttackTree(Globals.playerEntity); ClientAttackTree attackTree = CreatureUtils.clientGetAttackTree(Globals.playerEntity);
if(attackTree != null){ if(attackTree != null){
// CreatureUtils.setFacingVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize()); // CreatureUtils.setFacingVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize());
attackTree.start(); attackTree.start();
@ -874,7 +874,7 @@ public class ControlHandler {
controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).setOnRelease(new ControlMethod(){public void execute(){ controls.get(DATA_STRING_INPUT_CODE_ATTACK_PRIMARY).setOnRelease(new ControlMethod(){public void execute(){
if(Globals.playerEntity != null){ if(Globals.playerEntity != null){
// Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera); // Vector3f cameraEyeVector = CameraEntityUtils.getCameraEye(Globals.playerCamera);
AttackTree attackTree = CreatureUtils.clientGetAttackTree(Globals.playerEntity); ClientAttackTree attackTree = CreatureUtils.clientGetAttackTree(Globals.playerEntity);
if(attackTree != null){ if(attackTree != null){
// CreatureUtils.setFacingVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize()); // CreatureUtils.setFacingVector(Globals.playerCharacter, new Vector3d(-cameraEyeVector.x,0,-cameraEyeVector.z).normalize());
attackTree.release(); attackTree.release();

View File

@ -195,8 +195,8 @@ public class EntityDataStrings {
/* /*
Attack behavior tree Attack behavior tree
*/ */
public static final String CLIENT_ATTACK_TREE = "clientAttackTree"; public static final String TREE_CLIENTATTACKTREE = "treeClientAttackTree";
public static final String SERVER_ATTACK_TREE = "serverAttackTree"; public static final String TREE_SERVERATTACKTREE = "treeServerAttackTree";
public static final String ATTACK_MOVE_TYPE_ACTIVE = "attackMoveTypeActive"; 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"; 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 Equip state
*/ */
public static final String EQUIP_STATE = "equipState"; 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 EQUIP_INVENTORY = "equipInventory";
public static final String TREE_SERVEREQUIPSTATE = "treeServerEquipState";
/* /*
Inventory in general Inventory in general

View File

@ -1,5 +1,8 @@
package electrosphere.entity.state.attack; package electrosphere.entity.state.attack;
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
import electrosphere.collision.collidable.Collidable; import electrosphere.collision.collidable.Collidable;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.Main; 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.attack.AttackMove;
import electrosphere.game.data.creature.type.equip.EquipPoint; import electrosphere.game.data.creature.type.equip.EquipPoint;
import electrosphere.net.parser.net.message.EntityMessage; 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.actor.Actor;
import electrosphere.renderer.anim.Animation; import electrosphere.renderer.anim.Animation;
import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.Realm;
@ -35,8 +41,13 @@ import org.joml.Quaternionfc;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.joml.Vector3f; 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 { public static enum AttackTreeState {
WINDUP, WINDUP,
HOLD, HOLD,
@ -46,12 +57,16 @@ public class AttackTree implements BehaviorTree {
} }
//the state of drifting forward during the attack //the state of drifting forward during the attack
@SynchronizableEnum
public static enum AttackTreeDriftState { public static enum AttackTreeDriftState {
DRIFT, DRIFT,
NO_DRIFT, NO_DRIFT,
} }
@SyncedField
AttackTreeState state; AttackTreeState state;
@SyncedField
AttackTreeDriftState driftState; AttackTreeDriftState driftState;
Entity parent; Entity parent;
@ -68,6 +83,8 @@ public class AttackTree implements BehaviorTree {
List<AttackMove> currentMoveset = null; List<AttackMove> currentMoveset = null;
AttackMove currentMove = null; AttackMove currentMove = null;
@SyncedField
String currentMoveId = null;
Entity currentWeapon = null; Entity currentWeapon = null;
boolean currentMoveHasWindup; boolean currentMoveHasWindup;
boolean currentMoveCanHold; boolean currentMoveCanHold;
@ -76,12 +93,18 @@ public class AttackTree implements BehaviorTree {
String projectileToFire = null; String projectileToFire = null;
String attackingPoint = null; String attackingPoint = null;
public AttackTree(Entity e){ public ClientAttackTree(Entity e){
state = AttackTreeState.IDLE; state = AttackTreeState.IDLE;
driftState = AttackTreeDriftState.NO_DRIFT; driftState = AttackTreeDriftState.NO_DRIFT;
parent = e; parent = e;
} }
/**
* <p> Automatically generated </p>
* <p>
* Gets state.
* </p>
*/
public AttackTreeState getState(){ public AttackTreeState getState(){
return state; return state;
} }
@ -101,40 +124,7 @@ public class AttackTree implements BehaviorTree {
parent.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, attackType); parent.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, attackType);
currentMoveset = (List<AttackMove>)parent.getData(attackType); currentMoveset = (List<AttackMove>)parent.getData(attackType);
if(currentMoveset != null){ if(currentMoveset != null){
if(currentMove == null){ Globals.clientConnection.queueOutgoingMessage(EntityMessage.constructstartAttackMessage());
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;
}
} }
} }
} }
@ -159,6 +149,15 @@ public class AttackTree implements BehaviorTree {
Vector3d position = EntityUtils.getPosition(parent); Vector3d position = EntityUtils.getPosition(parent);
Vector3d movementVector = CreatureUtils.getFacingVector(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 //parse attached network messages
for(EntityMessage message : networkMessageQueue){ for(EntityMessage message : networkMessageQueue){
networkMessageQueue.remove(message); networkMessageQueue.remove(message);
@ -246,29 +245,13 @@ public class AttackTree implements BehaviorTree {
entityActor.incrementAnimationTime(0.0001); entityActor.incrementAnimationTime(0.0001);
} }
} }
if(frameCurrent > currentMove.getWindupFrames()){ if(currentMove != null && frameCurrent > currentMove.getWindupFrames()){
if(currentMoveCanHold && stillHold){ if(currentMoveCanHold && stillHold){
state = AttackTreeState.HOLD; state = AttackTreeState.HOLD;
} else { } else {
state = AttackTreeState.ATTACK; 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; break;
case HOLD: case HOLD:
if(entityActor != null){ if(entityActor != null){
@ -326,25 +309,9 @@ public class AttackTree implements BehaviorTree {
ProjectileUtils.clientSpawnBasicProjectile(projectileToFire, spawnPosition, arrowRotation, 750, initialVector, 0.03f); ProjectileUtils.clientSpawnBasicProjectile(projectileToFire, spawnPosition, arrowRotation, 750, initialVector, 0.03f);
projectileToFire = null; projectileToFire = null;
} }
if(frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames()){ if(currentMove != null && frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames()){
state = AttackTreeState.COOLDOWN; 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; break;
case COOLDOWN: case COOLDOWN:
if(parent.containsKey(EntityDataStrings.ATTACH_CHILDREN_LIST)){ if(parent.containsKey(EntityDataStrings.ATTACH_CHILDREN_LIST)){
@ -365,22 +332,6 @@ public class AttackTree implements BehaviorTree {
RotatorTree.getClientRotatorTree(parent).setActive(false); 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; break;
case IDLE: case IDLE:
currentMove = null; currentMove = null;
@ -466,4 +417,178 @@ public class AttackTree implements BehaviorTree {
return rVal; 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;
}
} }

View File

@ -1,5 +1,14 @@
package electrosphere.entity.state.attack; 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.collision.collidable.Collidable;
import electrosphere.engine.Globals; import electrosphere.engine.Globals;
import electrosphere.engine.Main; import electrosphere.engine.Main;
@ -8,6 +17,8 @@ import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.ServerEntityUtils; import electrosphere.entity.ServerEntityUtils;
import electrosphere.entity.btree.BehaviorTree; 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.collidable.Impulse;
import electrosphere.entity.state.equip.ServerEquipState; import electrosphere.entity.state.equip.ServerEquipState;
import electrosphere.entity.state.movement.groundmove.GroundMovementTree; 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.attack.AttackMove;
import electrosphere.game.data.creature.type.equip.EquipPoint; import electrosphere.game.data.creature.type.equip.EquipPoint;
import electrosphere.net.parser.net.message.EntityMessage; 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.actor.Actor;
import electrosphere.renderer.anim.Animation; import electrosphere.renderer.anim.Animation;
import electrosphere.server.datacell.Realm; import electrosphere.server.datacell.Realm;
@ -38,23 +51,16 @@ import org.joml.Quaternionfc;
import org.joml.Vector3d; import org.joml.Vector3d;
import org.joml.Vector3f; import org.joml.Vector3f;
@SynchronizedBehaviorTree(name = "serverAttackTree", isServer = true, correspondingTree="clientAttackTree")
/**
* Server basic attack tree
*/
public class ServerAttackTree implements BehaviorTree { public class ServerAttackTree implements BehaviorTree {
public static enum AttackTreeState { @SyncedField
WINDUP,
HOLD,
ATTACK,
COOLDOWN,
IDLE,
}
//the state of drifting forward during the attack
public static enum AttackTreeDriftState {
DRIFT,
NO_DRIFT,
}
AttackTreeState state; AttackTreeState state;
@SyncedField
AttackTreeDriftState driftState; AttackTreeDriftState driftState;
Entity parent; Entity parent;
@ -70,6 +76,8 @@ public class ServerAttackTree implements BehaviorTree {
int maxFrame = 60; int maxFrame = 60;
List<AttackMove> currentMoveset = null; List<AttackMove> currentMoveset = null;
@SyncedField
String currentMoveId = null;
AttackMove currentMove = null; AttackMove currentMove = null;
Entity currentWeapon = null; Entity currentWeapon = null;
boolean currentMoveHasWindup; boolean currentMoveHasWindup;
@ -85,6 +93,12 @@ public class ServerAttackTree implements BehaviorTree {
parent = e; parent = e;
} }
/**
* <p> Automatically generated </p>
* <p>
* Gets state.
* </p>
*/
public AttackTreeState getState(){ public AttackTreeState getState(){
return state; return state;
} }
@ -133,10 +147,11 @@ public class ServerAttackTree implements BehaviorTree {
Vector3d movementVector = CreatureUtils.getFacingVector(parent); Vector3d movementVector = CreatureUtils.getFacingVector(parent);
EntityUtils.getRotation(parent).rotationTo(new Vector3d(0,0,1), new Vector3d(movementVector.x,movementVector.y,movementVector.z)); EntityUtils.getRotation(parent).rotationTo(new Vector3d(0,0,1), new Vector3d(movementVector.x,movementVector.y,movementVector.z));
//set initial stuff //set initial stuff
state = AttackTreeState.WINDUP; setCurrentMoveId(currentMove.getAttackMoveId());
setState(AttackTreeState.WINDUP);
frameCurrent = 0; frameCurrent = 0;
} else { } else {
state = AttackTreeState.IDLE; setState(AttackTreeState.IDLE);
} }
} }
} }
@ -147,11 +162,11 @@ public class ServerAttackTree implements BehaviorTree {
} }
public void interrupt(){ public void interrupt(){
state = AttackTreeState.IDLE; setState(AttackTreeState.IDLE);
} }
public void slowdown(){ public void slowdown(){
state = AttackTreeState.COOLDOWN; setState(AttackTreeState.COOLDOWN);
} }
@Override @Override
@ -173,23 +188,23 @@ public class ServerAttackTree implements BehaviorTree {
lastUpdateTime = updateTime; lastUpdateTime = updateTime;
switch(message.gettreeState()){ switch(message.gettreeState()){
case 0: case 0:
state = AttackTreeState.WINDUP; setState(AttackTreeState.WINDUP);
frameCurrent = 0; frameCurrent = 0;
// System.out.println("Set state STARTUP"); // System.out.println("Set state STARTUP");
break; break;
case 1: case 1:
frameCurrent = currentMove.getWindupFrames()+1; frameCurrent = currentMove.getWindupFrames()+1;
state = AttackTreeState.ATTACK; setState(AttackTreeState.ATTACK);
// System.out.println("Set state MOVE"); // System.out.println("Set state MOVE");
break; break;
case 2: case 2:
frameCurrent = currentMove.getWindupFrames()+currentMove.getAttackFrames()+1; frameCurrent = currentMove.getWindupFrames()+currentMove.getAttackFrames()+1;
state = AttackTreeState.COOLDOWN; setState(AttackTreeState.COOLDOWN);
// System.out.println("Set state SLOWDOWN"); // System.out.println("Set state SLOWDOWN");
break; break;
case 3: case 3:
frameCurrent = 60; frameCurrent = 60;
state = AttackTreeState.IDLE; setState(AttackTreeState.IDLE);
// System.out.println("Set state IDLE"); // System.out.println("Set state IDLE");
break; break;
} }
@ -197,17 +212,10 @@ public class ServerAttackTree implements BehaviorTree {
EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ()); EntityUtils.getPosition(parent).set(message.getpositionX(),message.getpositionY(),message.getpositionZ());
CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ())); CreatureUtils.setFacingVector(parent, new Vector3d(message.getrotationX(),message.getrotationY(),message.getrotationZ()));
break; break;
case ATTACHENTITYTOENTITY: case STARTATTACK: {
case CREATE: start();
case DESTROY: } break;
case MOVE: default:
case MOVEUPDATE:
case SETBEHAVIORTREE:
case SETFACING:
case SETPOSITION:
case SETPROPERTY:
case KILL:
case SPAWNCREATURE:
//silently ignore //silently ignore
break; break;
} }
@ -220,14 +228,14 @@ public class ServerAttackTree implements BehaviorTree {
//calculate the vector of movement //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")); 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()){ if(frameCurrent > currentMove.getDriftFrameEnd()){
driftState = AttackTreeDriftState.NO_DRIFT; setDriftState(AttackTreeDriftState.NO_DRIFT);
} }
} }
break; break;
case NO_DRIFT: case NO_DRIFT:
if(currentMove != null){ if(currentMove != null){
if(frameCurrent > currentMove.getDriftFrameStart() && frameCurrent < currentMove.getDriftFrameEnd()){ if(frameCurrent > currentMove.getDriftFrameStart() && frameCurrent < currentMove.getDriftFrameEnd()){
driftState = AttackTreeDriftState.DRIFT; setDriftState(AttackTreeDriftState.DRIFT);
} }
} }
break; break;
@ -251,9 +259,9 @@ public class ServerAttackTree implements BehaviorTree {
} }
if(frameCurrent > currentMove.getWindupFrames()){ if(frameCurrent > currentMove.getWindupFrames()){
if(currentMoveCanHold && stillHold){ if(currentMoveCanHold && stillHold){
state = AttackTreeState.HOLD; setState(AttackTreeState.HOLD);
} else { } else {
state = AttackTreeState.ATTACK; setState(AttackTreeState.ATTACK);
} }
} }
Globals.server.broadcastMessage( Globals.server.broadcastMessage(
@ -279,7 +287,7 @@ public class ServerAttackTree implements BehaviorTree {
} }
} }
if(!stillHold){ if(!stillHold){
state = AttackTreeState.ATTACK; setState(AttackTreeState.ATTACK);
} }
break; break;
case ATTACK: case ATTACK:
@ -329,7 +337,7 @@ public class ServerAttackTree implements BehaviorTree {
projectileToFire = null; projectileToFire = null;
} }
if(frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames()){ if(frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames()){
state = AttackTreeState.COOLDOWN; setState(AttackTreeState.COOLDOWN);
} }
Globals.server.broadcastMessage( Globals.server.broadcastMessage(
EntityMessage.constructattackUpdateMessage( EntityMessage.constructattackUpdateMessage(
@ -359,7 +367,7 @@ public class ServerAttackTree implements BehaviorTree {
} }
} }
if(frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames() + currentMove.getCooldownFrames()){ if(frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames() + currentMove.getCooldownFrames()){
state = AttackTreeState.IDLE; setState(AttackTreeState.IDLE);
frameCurrent = 0; frameCurrent = 0;
if(parent.containsKey(EntityDataStrings.SERVER_ROTATOR_TREE)){ if(parent.containsKey(EntityDataStrings.SERVER_ROTATOR_TREE)){
ServerRotatorTree.getServerRotatorTree(parent).setActive(false); ServerRotatorTree.getServerRotatorTree(parent).setActive(false);
@ -464,4 +472,99 @@ public class ServerAttackTree implements BehaviorTree {
return rVal; 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));
}
} }

View File

@ -1,5 +1,8 @@
package electrosphere.entity.state.equip; package electrosphere.entity.state.equip;
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -12,6 +15,7 @@ import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityTags; import electrosphere.entity.EntityTags;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.gravity.GravityUtils; import electrosphere.entity.state.gravity.GravityUtils;
import electrosphere.entity.types.attach.AttachUtils; import electrosphere.entity.types.attach.AttachUtils;
import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.creature.CreatureUtils;
@ -28,7 +32,7 @@ import electrosphere.renderer.actor.ActorMeshMask;
/** /**
* Client view of items equipped to a given entity * Client view of items equipped to a given entity
*/ */
public class ClientEquipState { public class ClientEquipState implements BehaviorTree {
Entity parent; Entity parent;
@ -266,5 +270,52 @@ public class ClientEquipState {
return equipMap.containsKey(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);
}
} }

View File

@ -1,5 +1,12 @@
package electrosphere.entity.state.equip; 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.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -13,6 +20,7 @@ import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityTags; import electrosphere.entity.EntityTags;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.gravity.GravityUtils; import electrosphere.entity.state.gravity.GravityUtils;
import electrosphere.entity.state.inventory.InventoryUtils; import electrosphere.entity.state.inventory.InventoryUtils;
import electrosphere.entity.state.inventory.RelationalInventoryState; import electrosphere.entity.state.inventory.RelationalInventoryState;
@ -36,7 +44,7 @@ import electrosphere.server.datacell.utils.ServerEntityTagUtils;
/** /**
* Server view of items equipped onto an entity * Server view of items equipped onto an entity
*/ */
public class ServerEquipState { public class ServerEquipState implements BehaviorTree {
Entity parent; Entity parent;
@ -317,4 +325,52 @@ public class ServerEquipState {
public boolean hasEquippedAtPoint(String point){ public boolean hasEquippedAtPoint(String point){
return equipMap.containsKey(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);
}
} }

View File

@ -215,7 +215,7 @@ public class ServerGravityTree implements BehaviorTree {
public void setState(GravityTreeState state){ public void setState(GravityTreeState state){
this.state = state; this.state = state;
int value = ClientGravityTree.getGravityTreeStateEnumAsShort(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> * <p> (initially) Automatically generated </p>

View File

@ -2,7 +2,7 @@ package electrosphere.entity.state.idle;
import electrosphere.net.synchronization.BehaviorTreeIdEnums; 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.AirplaneMovementTree;
import electrosphere.entity.state.movement.groundmove.GroundMovementTree; import electrosphere.entity.state.movement.groundmove.GroundMovementTree;
import electrosphere.entity.state.movement.groundmove.GroundMovementTree.MovementTreeState; import electrosphere.entity.state.movement.groundmove.GroundMovementTree.MovementTreeState;
@ -68,8 +68,8 @@ public class IdleTree implements BehaviorTree {
boolean movementTreeIsIdle = movementTreeIsIdle(); boolean movementTreeIsIdle = movementTreeIsIdle();
boolean hasAttackTree = parent.containsKey(EntityDataStrings.CLIENT_ATTACK_TREE); boolean hasAttackTree = parent.containsKey(EntityDataStrings.TREE_CLIENTATTACKTREE);
AttackTree attackTree = null; ClientAttackTree attackTree = null;
if(hasAttackTree){ if(hasAttackTree){
attackTree = CreatureUtils.clientGetAttackTree(parent); attackTree = CreatureUtils.clientGetAttackTree(parent);
} }

View File

@ -1,7 +1,7 @@
package electrosphere.entity.state.idle; package electrosphere.entity.state.idle;
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
import electrosphere.entity.state.attack.ServerAttackTree; import electrosphere.entity.state.attack.ServerAttackTree;
import electrosphere.entity.state.attack.ServerAttackTree.AttackTreeState;
import electrosphere.entity.state.idle.IdleTree.IdleTreeState; import electrosphere.entity.state.idle.IdleTree.IdleTreeState;
import electrosphere.entity.state.movement.AirplaneMovementTree; import electrosphere.entity.state.movement.AirplaneMovementTree;
import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree; import electrosphere.entity.state.movement.groundmove.ServerGroundMovementTree;
@ -72,7 +72,7 @@ public class ServerIdleTree implements BehaviorTree {
boolean movementTreeIsIdle = movementTreeIsIdle(); boolean movementTreeIsIdle = movementTreeIsIdle();
boolean hasAttackTree = parent.containsKey(EntityDataStrings.SERVER_ATTACK_TREE); boolean hasAttackTree = parent.containsKey(EntityDataStrings.TREE_SERVERATTACKTREE);
ServerAttackTree attackTree = null; ServerAttackTree attackTree = null;
if(hasAttackTree){ if(hasAttackTree){
attackTree = CreatureUtils.serverGetAttackTree(parent); attackTree = CreatureUtils.serverGetAttackTree(parent);
@ -185,7 +185,7 @@ public class ServerIdleTree implements BehaviorTree {
public void setState(IdleTreeState state){ public void setState(IdleTreeState state){
this.state = state; this.state = state;
int value = IdleTree.getIdleTreeStateEnumAsShort(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));
} }
/** /**

View File

@ -17,8 +17,8 @@ import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.attack.AttackTree; import electrosphere.entity.state.attack.ClientAttackTree;
import electrosphere.entity.state.attack.AttackTree.AttackTreeState; import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
import electrosphere.entity.state.movement.FallTree; import electrosphere.entity.state.movement.FallTree;
import electrosphere.entity.state.movement.JumpTree; import electrosphere.entity.state.movement.JumpTree;
import electrosphere.entity.state.movement.SprintTree; import electrosphere.entity.state.movement.SprintTree;
@ -376,7 +376,7 @@ public class GroundMovementTree implements BehaviorTree {
public boolean canStartMoving(){ public boolean canStartMoving(){
boolean rVal = true; 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; rVal = false;
} }
return rVal; return rVal;

View File

@ -14,8 +14,8 @@ import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
import electrosphere.entity.state.attack.ServerAttackTree; import electrosphere.entity.state.attack.ServerAttackTree;
import electrosphere.entity.state.attack.ServerAttackTree.AttackTreeState;
import electrosphere.entity.state.movement.ServerFallTree; import electrosphere.entity.state.movement.ServerFallTree;
import electrosphere.entity.state.movement.ServerJumpTree; import electrosphere.entity.state.movement.ServerJumpTree;
import electrosphere.entity.state.movement.ServerSprintTree; import electrosphere.entity.state.movement.ServerSprintTree;
@ -411,7 +411,7 @@ public class ServerGroundMovementTree implements BehaviorTree {
public boolean canStartMoving(){ public boolean canStartMoving(){
boolean rVal = true; 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; rVal = false;
} }
return rVal; return rVal;

View File

@ -20,7 +20,7 @@ import electrosphere.entity.EntityTags;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.ServerEntityUtils; import electrosphere.entity.ServerEntityUtils;
import electrosphere.entity.btree.BehaviorTree; 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.ServerAttackTree;
import electrosphere.entity.state.attack.ShooterTree; import electrosphere.entity.state.attack.ShooterTree;
import electrosphere.entity.state.collidable.ClientCollidableTree; import electrosphere.entity.state.collidable.ClientCollidableTree;
@ -237,10 +237,8 @@ public class CreatureUtils {
ActorUtils.applyBlenderTransformer(rVal); ActorUtils.applyBlenderTransformer(rVal);
break; break;
case "ATTACKER": case "ATTACKER":
AttackTree attackTree = new AttackTree(rVal); ClientAttackTree.attachTree(rVal);
rVal.putData(EntityDataStrings.CLIENT_ATTACK_TREE, attackTree);
rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, null); rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, null);
Globals.clientScene.registerBehaviorTree(attackTree);
Globals.clientScene.registerEntityToTag(rVal, EntityTags.ATTACKER); Globals.clientScene.registerEntityToTag(rVal, EntityTags.ATTACKER);
//add all attack moves //add all attack moves
if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){ if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){
@ -533,10 +531,8 @@ public class CreatureUtils {
PoseActorUtils.applyBlenderTransformer(rVal); PoseActorUtils.applyBlenderTransformer(rVal);
} break; } break;
case "ATTACKER": { case "ATTACKER": {
ServerAttackTree attackTree = new ServerAttackTree(rVal); ServerAttackTree.attachTree(rVal);
rVal.putData(EntityDataStrings.SERVER_ATTACK_TREE, attackTree);
rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, null); rVal.putData(EntityDataStrings.ATTACK_MOVE_TYPE_ACTIVE, null);
ServerBehaviorTreeUtils.attachBTreeToEntity(rVal, attackTree);
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.ATTACKER); ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.ATTACKER);
//add all attack moves //add all attack moves
if(rawType.getAttackMoves() != null && rawType.getAttackMoves().size() > 0){ 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 * Gets the type of creature
* @param e the entity * @param e the entity
@ -801,12 +793,12 @@ public class CreatureUtils {
return (int)e.getData(EntityDataStrings.ENTITY_TYPE) == ENTITY_TYPE_CREATURE; return (int)e.getData(EntityDataStrings.ENTITY_TYPE) == ENTITY_TYPE_CREATURE;
} }
public static AttackTree clientGetAttackTree(Entity e){ public static ClientAttackTree clientGetAttackTree(Entity e){
return (AttackTree)e.getData(EntityDataStrings.CLIENT_ATTACK_TREE); return (ClientAttackTree)e.getData(EntityDataStrings.TREE_CLIENTATTACKTREE);
} }
public static ServerAttackTree serverGetAttackTree(Entity e){ 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){ public static IdleTree getIdleTree(Entity e){

View File

@ -226,7 +226,7 @@ public class ItemUtils {
public static void updateItemActorAnimation(Entity item){ public static void updateItemActorAnimation(Entity item){
Actor actor = EntityUtils.getActor(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); String idleAnim = (String)item.getData(EntityDataStrings.ANIM_IDLE);
if(!actor.isPlayingAnimation(idleAnim)){ if(!actor.isPlayingAnimation(idleAnim)){
actor.playAnimation(idleAnim,1); actor.playAnimation(idleAnim,1);

View File

@ -7,6 +7,8 @@ import electrosphere.engine.Globals;
import electrosphere.entity.ClientEntityUtils; import electrosphere.entity.ClientEntityUtils;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils; 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.attach.AttachUtils;
import electrosphere.entity.types.creature.CreatureTemplate; import electrosphere.entity.types.creature.CreatureTemplate;
import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.creature.CreatureUtils;
@ -123,7 +125,7 @@ public class EntityProtocol {
CreatureUtils.clientAttachEntityMessageToMovementTree(Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID()),message); CreatureUtils.clientAttachEntityMessageToMovementTree(Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID()),message);
} break; } break;
case ATTACKUPDATE: { case ATTACKUPDATE: {
CreatureUtils.attachEntityMessageToAttackTree(Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID()),message); ClientAttackTree.getClientAttackTree(Globals.clientSceneWrapper.getEntityFromServerId(message.getentityID())).addNetworkMessage(message);
} break; } break;

View File

@ -15,6 +15,7 @@ public class EntityMessage extends NetworkMessage {
SETFACING, SETFACING,
MOVEUPDATE, MOVEUPDATE,
ATTACKUPDATE, ATTACKUPDATE,
STARTATTACK,
MOVE, MOVE,
KILL, KILL,
DESTROY, DESTROY,
@ -319,6 +320,12 @@ public class EntityMessage extends NetworkMessage {
} else { } else {
return false; 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: case TypeBytes.ENTITY_MESSAGE_TYPE_MOVE:
if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_MOVE_SIZE){ if(byteBuffer.getRemaining() >= TypeBytes.ENTITY_MESSAGE_TYPE_MOVE_SIZE){
return true; return true;
@ -657,6 +664,18 @@ public class EntityMessage extends NetworkMessage {
return rVal; 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){ public static EntityMessage parseMoveMessage(CircularByteBuffer byteBuffer){
EntityMessage rVal = new EntityMessage(EntityMessageType.MOVE); EntityMessage rVal = new EntityMessage(EntityMessageType.MOVE);
stripPacketHeader(byteBuffer); stripPacketHeader(byteBuffer);
@ -1245,6 +1264,13 @@ public class EntityMessage extends NetworkMessage {
rawBytes[70+i] = intValues[i]; rawBytes[70+i] = intValues[i];
} }
break; 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: case MOVE:
rawBytes = new byte[2+4+8+8+8+8]; rawBytes = new byte[2+4+8+8+8+8];
//message header //message header

View File

@ -76,6 +76,11 @@ SYNCHRONIZATION_MESSAGE,
rVal = EntityMessage.parseattackUpdateMessage(byteBuffer); rVal = EntityMessage.parseattackUpdateMessage(byteBuffer);
} }
break; break;
case TypeBytes.ENTITY_MESSAGE_TYPE_STARTATTACK:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parsestartAttackMessage(byteBuffer);
}
break;
case TypeBytes.ENTITY_MESSAGE_TYPE_MOVE: case TypeBytes.ENTITY_MESSAGE_TYPE_MOVE:
if(EntityMessage.canParseMessage(byteBuffer,secondByte)){ if(EntityMessage.canParseMessage(byteBuffer,secondByte)){
rVal = EntityMessage.parseMoveMessage(byteBuffer); rVal = EntityMessage.parseMoveMessage(byteBuffer);
@ -381,6 +386,11 @@ SYNCHRONIZATION_MESSAGE,
rVal = SynchronizationMessage.parseUpdateClientStateMessage(byteBuffer); rVal = SynchronizationMessage.parseUpdateClientStateMessage(byteBuffer);
} }
break; break;
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTSTRINGSTATE:
if(SynchronizationMessage.canParseMessage(byteBuffer,secondByte)){
rVal = SynchronizationMessage.parseUpdateClientStringStateMessage(byteBuffer);
}
break;
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE: case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE:
if(SynchronizationMessage.canParseMessage(byteBuffer,secondByte)){ if(SynchronizationMessage.canParseMessage(byteBuffer,secondByte)){
rVal = SynchronizationMessage.parseAttachTreeMessage(byteBuffer); rVal = SynchronizationMessage.parseAttachTreeMessage(byteBuffer);

View File

@ -9,6 +9,7 @@ public class SynchronizationMessage extends NetworkMessage {
public enum SynchronizationMessageType { public enum SynchronizationMessageType {
UPDATECLIENTSTATE, UPDATECLIENTSTATE,
UPDATECLIENTSTRINGSTATE,
ATTACHTREE, ATTACHTREE,
DETATCHTREE, DETATCHTREE,
} }
@ -18,6 +19,7 @@ public class SynchronizationMessage extends NetworkMessage {
int bTreeId; int bTreeId;
int fieldId; int fieldId;
int bTreeValue; int bTreeValue;
String stringValue;
SynchronizationMessage(SynchronizationMessageType messageType){ SynchronizationMessage(SynchronizationMessageType messageType){
this.type = MessageType.SYNCHRONIZATION_MESSAGE; this.type = MessageType.SYNCHRONIZATION_MESSAGE;
@ -60,6 +62,14 @@ public class SynchronizationMessage extends NetworkMessage {
this.bTreeValue = bTreeValue; this.bTreeValue = bTreeValue;
} }
public String getstringValue() {
return stringValue;
}
public void setstringValue(String stringValue) {
this.stringValue = stringValue;
}
static void stripPacketHeader(CircularByteBuffer byteBuffer){ static void stripPacketHeader(CircularByteBuffer byteBuffer){
byteBuffer.read(2); byteBuffer.read(2);
} }
@ -72,6 +82,8 @@ public class SynchronizationMessage extends NetworkMessage {
} else { } else {
return false; return false;
} }
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTSTRINGSTATE:
return SynchronizationMessage.canParseUpdateClientStringStateMessage(byteBuffer);
case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE: case TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE:
if(byteBuffer.getRemaining() >= TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE_SIZE){ if(byteBuffer.getRemaining() >= TypeBytes.SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE_SIZE){
return true; return true;
@ -108,6 +120,54 @@ public class SynchronizationMessage extends NetworkMessage {
return rVal; 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){ public static SynchronizationMessage parseAttachTreeMessage(CircularByteBuffer byteBuffer){
SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.ATTACHTREE); SynchronizationMessage rVal = new SynchronizationMessage(SynchronizationMessageType.ATTACHTREE);
stripPacketHeader(byteBuffer); stripPacketHeader(byteBuffer);
@ -168,6 +228,33 @@ public class SynchronizationMessage extends NetworkMessage {
rawBytes[14+i] = intValues[i]; rawBytes[14+i] = intValues[i];
} }
break; 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: case ATTACHTREE:
rawBytes = new byte[2+4+4]; rawBytes = new byte[2+4+4];
//message header //message header

View File

@ -24,18 +24,19 @@ Message categories
public static final byte ENTITY_MESSAGE_TYPE_SETFACING = 4; 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_MOVEUPDATE = 5;
public static final byte ENTITY_MESSAGE_TYPE_ATTACKUPDATE = 6; 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_STARTATTACK = 7;
public static final byte ENTITY_MESSAGE_TYPE_KILL = 8; public static final byte ENTITY_MESSAGE_TYPE_MOVE = 8;
public static final byte ENTITY_MESSAGE_TYPE_DESTROY = 9; public static final byte ENTITY_MESSAGE_TYPE_KILL = 9;
public static final byte ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE = 10; public static final byte ENTITY_MESSAGE_TYPE_DESTROY = 10;
public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY = 11; public static final byte ENTITY_MESSAGE_TYPE_SETBEHAVIORTREE = 11;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT = 12; public static final byte ENTITY_MESSAGE_TYPE_SETPROPERTY = 12;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT = 13; public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYINT = 13;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE = 14; public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYFLOAT = 14;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYSTRING = 15; public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYDOUBLE = 15;
public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM = 16; public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYSTRING = 16;
public static final byte ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY = 17; public static final byte ENTITY_MESSAGE_TYPE_SETBTREEPROPERTYENUM = 17;
public static final byte ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED = 18; public static final byte ENTITY_MESSAGE_TYPE_ATTACHENTITYTOENTITY = 18;
public static final byte ENTITY_MESSAGE_TYPE_SPAWNFOLIAGESEED = 19;
/* /*
Entity packet sizes 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_SETFACING_SIZE = 38;
public static final byte ENTITY_MESSAGE_TYPE_MOVEUPDATE_SIZE = 82; 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_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_MOVE_SIZE = 38;
public static final byte ENTITY_MESSAGE_TYPE_KILL_SIZE = 14; public static final byte ENTITY_MESSAGE_TYPE_KILL_SIZE = 14;
public static final byte ENTITY_MESSAGE_TYPE_DESTROY_SIZE = 6; public static final byte ENTITY_MESSAGE_TYPE_DESTROY_SIZE = 6;
@ -161,8 +163,9 @@ Message categories
Synchronization subcategories Synchronization subcategories
*/ */
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_UPDATECLIENTSTATE = 0; 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_UPDATECLIENTSTRINGSTATE = 1;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_DETATCHTREE = 2; public static final byte SYNCHRONIZATION_MESSAGE_TYPE_ATTACHTREE = 2;
public static final byte SYNCHRONIZATION_MESSAGE_TYPE_DETATCHTREE = 3;
/* /*
Synchronization packet sizes Synchronization packet sizes
*/ */

View File

@ -4,6 +4,7 @@ import electrosphere.engine.Globals;
import electrosphere.engine.Main; import electrosphere.engine.Main;
import electrosphere.entity.Entity; import electrosphere.entity.Entity;
import electrosphere.entity.EntityUtils; import electrosphere.entity.EntityUtils;
import electrosphere.entity.state.attack.ServerAttackTree;
import electrosphere.entity.types.attach.AttachUtils; import electrosphere.entity.types.attach.AttachUtils;
import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.creature.CreatureUtils;
import electrosphere.entity.types.item.ItemUtils; import electrosphere.entity.types.item.ItemUtils;
@ -35,9 +36,15 @@ public class EntityProtocol {
case ATTACKUPDATE: case ATTACKUPDATE:
targetEntity = EntityLookupUtils.getEntityById(message.getentityID()); targetEntity = EntityLookupUtils.getEntityById(message.getentityID());
if(targetEntity != null){ if(targetEntity != null){
CreatureUtils.attachEntityMessageToAttackTree(targetEntity,message); ServerAttackTree.getServerAttackTree(targetEntity).addNetworkMessage(message);
} }
break; break;
case STARTATTACK: {
targetEntity = EntityLookupUtils.getEntityById(message.getentityID());
if(targetEntity != null){
ServerAttackTree.getServerAttackTree(targetEntity).addNetworkMessage(message);
}
} break;
//ignore stack //ignore stack
case KILL: case KILL:
case SPAWNCREATURE: case SPAWNCREATURE:

View File

@ -5,9 +5,13 @@ package electrosphere.net.synchronization;
*/ */
public class BehaviorTreeIdEnums { public class BehaviorTreeIdEnums {
public static final int BTREE_GRAVITY_ID = 0; public static final int BTREE_CLIENTATTACKTREE_ID = 0;
public static final int BTREE_SERVERGRAVITY_ID = 1; public static final int BTREE_SERVERATTACKTREE_ID = 1;
public static final int BTREE_IDLE_ID = 2; public static final int BTREE_CLIENTEQUIPSTATE_ID = 2;
public static final int BTREE_SERVERIDLE_ID = 3; 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;
} }

View File

@ -1,6 +1,11 @@
package electrosphere.net.synchronization; 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.ClientGravityTree;
import electrosphere.entity.state.gravity.ServerGravityTree; import electrosphere.entity.state.gravity.ServerGravityTree;
@ -47,6 +52,12 @@ public class ClientSynchronizationManager {
Entity targetEntity = Globals.clientSceneWrapper.getEntityFromServerId(entityId); Entity targetEntity = Globals.clientSceneWrapper.getEntityFromServerId(entityId);
updateEntityState(targetEntity,bTreeId,message); updateEntityState(targetEntity,bTreeId,message);
} break; } break;
case UPDATECLIENTSTRINGSTATE:{
int bTreeId = message.getbTreeId();
int entityId = message.getentityId();
Entity targetEntity = Globals.clientSceneWrapper.getEntityFromServerId(entityId);
updateEntityState(targetEntity,bTreeId,message);
} break;
case ATTACHTREE:{ case ATTACHTREE:{
int bTreeId = message.getbTreeId(); int bTreeId = message.getbTreeId();
int bTreeValue = message.getbTreeValue(); int bTreeValue = message.getbTreeValue();
@ -75,9 +86,29 @@ public class ClientSynchronizationManager {
*/ */
private void updateEntityState(Entity entity, int bTreeId, SynchronizationMessage message){ private void updateEntityState(Entity entity, int bTreeId, SynchronizationMessage message){
switch(bTreeId){ 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: { case BehaviorTreeIdEnums.BTREE_SERVERGRAVITY_ID: {
switch(message.getfieldId()){ switch(message.getfieldId()){
case 1:{ case 7:{
ClientGravityTree tree = ClientGravityTree.getClientGravityTree(entity); ClientGravityTree tree = ClientGravityTree.getClientGravityTree(entity);
tree.setState(ClientGravityTree.getGravityTreeStateShortAsEnum((short)message.getbTreeValue())); tree.setState(ClientGravityTree.getGravityTreeStateShortAsEnum((short)message.getbTreeValue()));
} break; } break;
@ -85,7 +116,7 @@ public class ClientSynchronizationManager {
} break; } break;
case BehaviorTreeIdEnums.BTREE_SERVERIDLE_ID: { case BehaviorTreeIdEnums.BTREE_SERVERIDLE_ID: {
switch(message.getfieldId()){ switch(message.getfieldId()){
case 3:{ case 9:{
IdleTree tree = IdleTree.getIdleTree(entity); IdleTree tree = IdleTree.getIdleTree(entity);
tree.setState(IdleTree.getIdleTreeStateShortAsEnum((short)message.getbTreeValue())); tree.setState(IdleTree.getIdleTreeStateShortAsEnum((short)message.getbTreeValue()));
} break; } break;

View File

@ -5,7 +5,7 @@ import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityTags; import electrosphere.entity.EntityTags;
import electrosphere.entity.EntityUtils; 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.attack.ServerAttackTree;
import electrosphere.entity.state.movement.groundmove.GroundMovementTree; import electrosphere.entity.state.movement.groundmove.GroundMovementTree;
import electrosphere.entity.state.movement.groundmove.GroundMovementTree.MovementRelativeFacing; import electrosphere.entity.state.movement.groundmove.GroundMovementTree.MovementRelativeFacing;

View File

@ -5,7 +5,7 @@ import electrosphere.entity.Entity;
import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityDataStrings;
import electrosphere.entity.EntityTags; import electrosphere.entity.EntityTags;
import electrosphere.entity.EntityUtils; 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.attack.ServerAttackTree;
import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.equip.ClientEquipState;
import electrosphere.entity.state.movement.groundmove.GroundMovementTree; import electrosphere.entity.state.movement.groundmove.GroundMovementTree;

View File

@ -11,7 +11,7 @@ import electrosphere.entity.EntityUtils;
import electrosphere.entity.btree.BehaviorTree; import electrosphere.entity.btree.BehaviorTree;
import electrosphere.entity.scene.EntityDescriptor; import electrosphere.entity.scene.EntityDescriptor;
import electrosphere.entity.state.ParticleTree; 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.ClientCollidableTree;
import electrosphere.entity.state.collidable.ServerCollidableTree; import electrosphere.entity.state.collidable.ServerCollidableTree;
import electrosphere.entity.state.idle.IdleTree; import electrosphere.entity.state.idle.IdleTree;