move tree and idle to use unified animation object
This commit is contained in:
parent
cc2ff6a93a
commit
e6fc720299
@ -429,8 +429,11 @@
|
|||||||
"onDamageIFrames" : 30
|
"onDamageIFrames" : 30
|
||||||
},
|
},
|
||||||
"idleData": {
|
"idleData": {
|
||||||
"idleAnimation" : "Idle1",
|
"animation": {
|
||||||
"firstPersonIdleAnimation" : "Idle"
|
"nameFirstPerson" : "Idle",
|
||||||
|
"nameThirdPerson" : "Idle1",
|
||||||
|
"priorityCategory" : "IDLE"
|
||||||
|
}
|
||||||
},
|
},
|
||||||
"modelPath" : "Models/creatures/person2/person2_1.glb",
|
"modelPath" : "Models/creatures/person2/person2_1.glb",
|
||||||
"viewModelData" : {
|
"viewModelData" : {
|
||||||
|
|||||||
@ -166,7 +166,7 @@ public class StateTransitionUtil {
|
|||||||
state.startedAnimation = false;
|
state.startedAnimation = false;
|
||||||
} else if(state.animation != null && (!poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(animation))){
|
} else if(state.animation != null && (!poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(animation))){
|
||||||
//play animation for state
|
//play animation for state
|
||||||
poseActor.playAnimation(animation, true);
|
poseActor.playAnimation(animation);
|
||||||
poseActor.incrementAnimationTime(0.0001);
|
poseActor.incrementAnimationTime(0.0001);
|
||||||
state.startedAnimation = true;
|
state.startedAnimation = true;
|
||||||
} else if(state.animation == null && state.onComplete != null){
|
} else if(state.animation == null && state.onComplete != null){
|
||||||
|
|||||||
@ -267,7 +267,7 @@ public class ServerAttackTree implements BehaviorTree {
|
|||||||
case ATTACK: {
|
case ATTACK: {
|
||||||
if(entityPoseActor != null && currentMove != null){
|
if(entityPoseActor != null && currentMove != null){
|
||||||
if(!entityPoseActor.isPlayingAnimation() || !entityPoseActor.isPlayingAnimation(currentMove.getAnimationAttack())){
|
if(!entityPoseActor.isPlayingAnimation() || !entityPoseActor.isPlayingAnimation(currentMove.getAnimationAttack())){
|
||||||
entityPoseActor.playAnimation(currentMove.getAnimationAttack(),true);
|
entityPoseActor.playAnimation(currentMove.getAnimationAttack());
|
||||||
entityPoseActor.incrementAnimationTime(0.0001);
|
entityPoseActor.incrementAnimationTime(0.0001);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package electrosphere.entity.state.idle;
|
|||||||
|
|
||||||
|
|
||||||
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
|
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
|
||||||
import electrosphere.entity.state.AnimationPriorities;
|
|
||||||
import electrosphere.entity.state.attack.ClientAttackTree;
|
import electrosphere.entity.state.attack.ClientAttackTree;
|
||||||
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
|
import electrosphere.entity.state.client.firstPerson.FirstPersonTree;
|
||||||
import electrosphere.entity.state.movement.AirplaneMovementTree;
|
import electrosphere.entity.state.movement.AirplaneMovementTree;
|
||||||
@ -94,14 +93,17 @@ public class ClientIdleTree implements BehaviorTree {
|
|||||||
if(entityActor != null){
|
if(entityActor != null){
|
||||||
if(
|
if(
|
||||||
idleData != null &&
|
idleData != null &&
|
||||||
(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(idleData.getIdleAnimation())) &&
|
(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(idleData.getAnimation())) &&
|
||||||
(Globals.assetManager.fetchModel(entityActor.getModelPath()) != null && Globals.assetManager.fetchModel(entityActor.getModelPath()).getAnimation(idleData.getIdleAnimation()) != null)
|
(
|
||||||
|
Globals.assetManager.fetchModel(entityActor.getModelPath()) != null &&
|
||||||
|
Globals.assetManager.fetchModel(entityActor.getModelPath()).getAnimation(idleData.getAnimation().getNameThirdPerson()) != null
|
||||||
|
)
|
||||||
|
|
||||||
){
|
){
|
||||||
entityActor.playAnimation(idleData.getIdleAnimation(),AnimationPriorities.getValue(AnimationPriorities.IDLE));
|
entityActor.playAnimation(idleData.getAnimation(),true);
|
||||||
entityActor.incrementAnimationTime(0.0001);
|
entityActor.incrementAnimationTime(0.0001);
|
||||||
}
|
}
|
||||||
FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, idleData.getFirstPersonIdleAnimation(), AnimationPriorities.getValue(AnimationPriorities.IDLE));
|
FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, idleData.getAnimation());
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case NOT_IDLE:
|
case NOT_IDLE:
|
||||||
|
|||||||
@ -2,7 +2,6 @@ package electrosphere.entity.state.idle;
|
|||||||
|
|
||||||
|
|
||||||
import electrosphere.net.synchronization.FieldIdEnums;
|
import electrosphere.net.synchronization.FieldIdEnums;
|
||||||
import electrosphere.entity.state.AnimationPriorities;
|
|
||||||
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
|
import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState;
|
||||||
import electrosphere.entity.state.attack.ServerAttackTree;
|
import electrosphere.entity.state.attack.ServerAttackTree;
|
||||||
import electrosphere.entity.state.idle.ClientIdleTree.IdleTreeState;
|
import electrosphere.entity.state.idle.ClientIdleTree.IdleTreeState;
|
||||||
@ -15,12 +14,12 @@ 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.types.creature.CreatureUtils;
|
import electrosphere.entity.types.creature.CreatureUtils;
|
||||||
|
import electrosphere.game.data.creature.type.IdleData;
|
||||||
import electrosphere.net.parser.net.message.EntityMessage;
|
import electrosphere.net.parser.net.message.EntityMessage;
|
||||||
import electrosphere.net.parser.net.message.SynchronizationMessage;
|
import electrosphere.net.parser.net.message.SynchronizationMessage;
|
||||||
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
|
import electrosphere.net.synchronization.BehaviorTreeIdEnums;
|
||||||
import electrosphere.net.synchronization.annotation.SyncedField;
|
import electrosphere.net.synchronization.annotation.SyncedField;
|
||||||
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
|
import electrosphere.net.synchronization.annotation.SynchronizedBehaviorTree;
|
||||||
import electrosphere.renderer.anim.Animation;
|
|
||||||
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
import electrosphere.server.datacell.utils.DataCellSearchUtils;
|
||||||
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
import electrosphere.server.datacell.utils.ServerBehaviorTreeUtils;
|
||||||
import electrosphere.server.poseactor.PoseActor;
|
import electrosphere.server.poseactor.PoseActor;
|
||||||
@ -39,15 +38,19 @@ public class ServerIdleTree implements BehaviorTree {
|
|||||||
|
|
||||||
Entity parent;
|
Entity parent;
|
||||||
|
|
||||||
|
//The idle data
|
||||||
|
IdleData idleData;
|
||||||
|
|
||||||
CopyOnWriteArrayList<EntityMessage> networkMessageQueue = new CopyOnWriteArrayList<EntityMessage>();
|
CopyOnWriteArrayList<EntityMessage> networkMessageQueue = new CopyOnWriteArrayList<EntityMessage>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a server idle tree
|
* Creates a server idle tree
|
||||||
* @param e The entity to attach it to
|
* @param e The entity to attach it to
|
||||||
*/
|
*/
|
||||||
public ServerIdleTree(Entity e){
|
public ServerIdleTree(Entity e, IdleData idleData){
|
||||||
state = IdleTreeState.IDLE;
|
state = IdleTreeState.IDLE;
|
||||||
parent = e;
|
parent = e;
|
||||||
|
this.idleData = idleData;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -60,19 +63,30 @@ public class ServerIdleTree implements BehaviorTree {
|
|||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts idling
|
||||||
|
*/
|
||||||
public void start(){
|
public void start(){
|
||||||
//TODO: check if can start moving
|
setState(IdleTreeState.IDLE);
|
||||||
state = IdleTreeState.IDLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Interrupts the idle animation
|
||||||
|
*/
|
||||||
public void interrupt(){
|
public void interrupt(){
|
||||||
state = IdleTreeState.NOT_IDLE;
|
setState(IdleTreeState.NOT_IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Stops the idle animation
|
||||||
|
*/
|
||||||
public void stop(){
|
public void stop(){
|
||||||
state = IdleTreeState.NOT_IDLE;
|
setState(IdleTreeState.NOT_IDLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Simulates the idle tree
|
||||||
|
*/
|
||||||
public void simulate(float deltaTime){
|
public void simulate(float deltaTime){
|
||||||
PoseActor poseActor = EntityUtils.getPoseActor(parent);
|
PoseActor poseActor = EntityUtils.getPoseActor(parent);
|
||||||
|
|
||||||
@ -91,9 +105,9 @@ public class ServerIdleTree implements BehaviorTree {
|
|||||||
case IDLE:
|
case IDLE:
|
||||||
if(poseActor != null){
|
if(poseActor != null){
|
||||||
if(
|
if(
|
||||||
(!poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(Animation.ANIMATION_IDLE_1))
|
(!poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(idleData.getAnimation()))
|
||||||
){
|
){
|
||||||
poseActor.playAnimation(Animation.ANIMATION_IDLE_1,AnimationPriorities.getValue(AnimationPriorities.IDLE));
|
poseActor.playAnimation(idleData.getAnimation());
|
||||||
poseActor.incrementAnimationTime(0.0001);
|
poseActor.incrementAnimationTime(0.0001);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,8 +170,8 @@ public class ServerIdleTree implements BehaviorTree {
|
|||||||
* @param entity The entity to attach to
|
* @param entity The entity to attach to
|
||||||
* @param tree The behavior tree to attach
|
* @param tree The behavior tree to attach
|
||||||
*/
|
*/
|
||||||
public static ServerIdleTree attachTree(Entity parent){
|
public static ServerIdleTree attachTree(Entity parent, IdleData idleData){
|
||||||
ServerIdleTree rVal = new ServerIdleTree(parent);
|
ServerIdleTree rVal = new ServerIdleTree(parent, idleData);
|
||||||
//put manual code here (setting params, etc)
|
//put manual code here (setting params, etc)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -673,7 +673,9 @@ public class CreatureUtils {
|
|||||||
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.LIFE_STATE);
|
ServerEntityTagUtils.attachTagToEntity(rVal, EntityTags.LIFE_STATE);
|
||||||
}
|
}
|
||||||
//idle tree & generic stuff all creatures have
|
//idle tree & generic stuff all creatures have
|
||||||
ServerIdleTree.attachTree(rVal);
|
if(rawType.getIdleData() != null){
|
||||||
|
ServerIdleTree.attachTree(rVal, rawType.getIdleData());
|
||||||
|
}
|
||||||
CreatureUtils.setFacingVector(rVal, MathUtils.getOriginVector());
|
CreatureUtils.setFacingVector(rVal, MathUtils.getOriginVector());
|
||||||
rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true);
|
rVal.putData(EntityDataStrings.DRAW_CAST_SHADOW, true);
|
||||||
|
|
||||||
|
|||||||
@ -18,7 +18,6 @@ import electrosphere.entity.state.gravity.ClientGravityTree;
|
|||||||
import electrosphere.entity.state.gravity.ServerGravityTree;
|
import electrosphere.entity.state.gravity.ServerGravityTree;
|
||||||
import electrosphere.entity.state.hitbox.HitboxCollectionState;
|
import electrosphere.entity.state.hitbox.HitboxCollectionState;
|
||||||
import electrosphere.entity.state.idle.ClientIdleTree;
|
import electrosphere.entity.state.idle.ClientIdleTree;
|
||||||
import electrosphere.entity.state.idle.ServerIdleTree;
|
|
||||||
import electrosphere.entity.state.inventory.ClientInventoryState;
|
import electrosphere.entity.state.inventory.ClientInventoryState;
|
||||||
import electrosphere.entity.state.inventory.InventoryUtils;
|
import electrosphere.entity.state.inventory.InventoryUtils;
|
||||||
import electrosphere.entity.state.inventory.ServerInventoryState;
|
import electrosphere.entity.state.inventory.ServerInventoryState;
|
||||||
@ -198,8 +197,6 @@ public class ObjectUtils {
|
|||||||
if(rawType.getHitboxData() != null){
|
if(rawType.getHitboxData() != null){
|
||||||
HitboxCollectionState.attachHitboxState(realm.getHitboxManager(), true, rVal, rawType.getHitboxData());
|
HitboxCollectionState.attachHitboxState(realm.getHitboxManager(), true, rVal, rawType.getHitboxData());
|
||||||
}
|
}
|
||||||
//idle tree & generic stuff all objects have
|
|
||||||
ServerIdleTree.attachTree(rVal);
|
|
||||||
|
|
||||||
|
|
||||||
//required for synchronization manager
|
//required for synchronization manager
|
||||||
|
|||||||
@ -1,30 +1,21 @@
|
|||||||
package electrosphere.game.data.creature.type;
|
package electrosphere.game.data.creature.type;
|
||||||
|
|
||||||
|
import electrosphere.game.data.common.TreeDataAnimation;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Data about how the creature will behave when in idle state
|
* Data about how the creature will behave when in idle state
|
||||||
*/
|
*/
|
||||||
public class IdleData {
|
public class IdleData {
|
||||||
|
|
||||||
//the animation that plays when the creature is idle
|
//the animation that plays when the creature is idle
|
||||||
String idleAnimation;
|
TreeDataAnimation animation;
|
||||||
|
|
||||||
//the animation that plays when the creature idles in first person
|
|
||||||
String firstPersonIdleAnimation;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* the animation that plays when the creature is idle
|
* The animation that plays when the creature is idle
|
||||||
* @return
|
* @return The animation
|
||||||
*/
|
*/
|
||||||
public String getIdleAnimation(){
|
public TreeDataAnimation getAnimation(){
|
||||||
return idleAnimation;
|
return animation;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* the animation that plays when the creature idles in first person
|
|
||||||
* @return
|
|
||||||
*/
|
|
||||||
public String getFirstPersonIdleAnimation(){
|
|
||||||
return firstPersonIdleAnimation;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -169,15 +169,10 @@ public class PoseActor {
|
|||||||
* @param animation The animation data
|
* @param animation The animation data
|
||||||
* @param isThirdPerson true if is third person, false if is first person
|
* @param isThirdPerson true if is third person, false if is first person
|
||||||
*/
|
*/
|
||||||
public void playAnimation(TreeDataAnimation animation, boolean isThirdPerson){
|
public void playAnimation(TreeDataAnimation animation){
|
||||||
|
|
||||||
//Get the animation's name
|
//Get the animation's name
|
||||||
String animationName = "";
|
String animationName = animation.getNameThirdPerson();
|
||||||
if(isThirdPerson){
|
|
||||||
animationName = animation.getNameThirdPerson();
|
|
||||||
} else {
|
|
||||||
animationName = animation.getNameFirstPerson();
|
|
||||||
}
|
|
||||||
|
|
||||||
//Get the animation's priority
|
//Get the animation's priority
|
||||||
int priority = AnimationPriorities.getValue(AnimationPriorities.DEFAULT);
|
int priority = AnimationPriorities.getValue(AnimationPriorities.DEFAULT);
|
||||||
@ -202,12 +197,9 @@ public class PoseActor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(group != null && isThirdPerson == true){
|
if(group != null){
|
||||||
boneMask.addAll(group.getBoneNamesThirdPerson());
|
boneMask.addAll(group.getBoneNamesThirdPerson());
|
||||||
}
|
}
|
||||||
if(group != null && isThirdPerson == false){
|
|
||||||
boneMask.addAll(group.getBoneNamesFirstPerson());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else if(this.boneGroups == null){
|
} else if(this.boneGroups == null){
|
||||||
LoggerInterface.loggerRenderer.WARNING("Trying to play animation on pose actor that uses bone groups, but the actor's bone group isn't defined!");
|
LoggerInterface.loggerRenderer.WARNING("Trying to play animation on pose actor that uses bone groups, but the actor's bone group isn't defined!");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user