diff --git a/assets/Data/creatures.json b/assets/Data/creatures.json index 0bec3fad..20d73ec7 100644 --- a/assets/Data/creatures.json +++ b/assets/Data/creatures.json @@ -43,9 +43,8 @@ ], "files" : [ "Data/creatures/human.json", - "Data/creatures/elf.json", - "Data/creatures/goblin.json", "Data/creatures/animals.json", "Data/creatures/test.json" ] } + diff --git a/assets/Data/creatures/human.json b/assets/Data/creatures/human.json index c637e40b..649bfafb 100644 --- a/assets/Data/creatures/human.json +++ b/assets/Data/creatures/human.json @@ -131,32 +131,38 @@ "maxVelocity" : 500.5, "animationStartup" : { "nameThirdPerson" : "Jog", - "length" : 1, - "loops" : false + "priorityCategory" : "CORE_MOVEMENT" }, "animationFirstPersonStartup" : { - "nameFirstPerson" : "Jog" + "nameFirstPerson" : "Jog", + "priorityCategory" : "CORE_MOVEMENT" }, "animationLoop" : { - "nameThirdPerson" : "Jog" + "nameThirdPerson" : "Jog", + "priorityCategory" : "CORE_MOVEMENT" }, "animationFirstPersonLoop" : { - "nameFirstPerson" : "Jog" + "nameFirstPerson" : "Jog", + "priorityCategory" : "CORE_MOVEMENT" }, "animationWindDown" : { - "nameThirdPerson" : "Jog" + "nameThirdPerson" : "Jog", + "priorityCategory" : "CORE_MOVEMENT" }, "animationFirstPersonWindDown" : { - "nameFirstPerson" : "Jog" + "nameFirstPerson" : "Jog", + "priorityCategory" : "CORE_MOVEMENT" }, "sprintSystem" : { "maxVelocity" : 0.058, "staminaMax" : 500, "animationStartUp" : { - "nameThirdPerson" : "Sprint" + "nameThirdPerson" : "Sprint", + "priorityCategory" : "MOVEMENT_MODIFIER" }, "animationMain" : { - "nameThirdPerson" : "Sprint" + "nameThirdPerson" : "Sprint", + "priorityCategory" : "MOVEMENT_MODIFIER" } } }, @@ -165,10 +171,12 @@ "jumpFrames" : 3, "jumpForce" : 500, "animationJump" : { - "nameThirdPerson" : "Jump" + "nameThirdPerson" : "Jump", + "priorityCategory" : "MOVEMENT_MODIFIER" }, "animationFirstPersonJump" : { - "nameFirstPerson" : "Jump" + "nameFirstPerson" : "Jump", + "priorityCategory" : "MOVEMENT_MODIFIER" } }, { @@ -177,14 +185,14 @@ "animation" : { "nameThirdPerson" : "Fall", "nameFirstPerson" : "Fall", - "priority": 4 + "priorityCategory" : "MOVEMENT_MODIFIER" } }, "landState" : { "animation" : { "nameThirdPerson" : "Land", "nameFirstPerson" : "Land", - "priority": 4 + "priorityCategory" : "MOVEMENT_MODIFIER" } } } @@ -256,9 +264,9 @@ "item" ], "equippedAnimation" : { - "nameThirdPerson" : "", - "nameFirstPerson" : "", - "priority" : 4, + "nameThirdPerson" : "Idle1", + "nameFirstPerson" : "Idle", + "priorityCategory" : "MODIFIER_MAX", "boneGroups" : ["handRight"] } }, @@ -334,13 +342,16 @@ "driftFrameEnd" : 15, "initialMove" : true, "animationFirstPersonWindup" : { - "nameFirstPerson" : "Jump" + "nameFirstPerson" : "Jump", + "priorityCategory" : "MOVEMENT_MODIFIER" }, "animationFirstPersonHold" : { - "nameFirstPerson" : "Jump" + "nameFirstPerson" : "Jump", + "priorityCategory" : "MOVEMENT_MODIFIER" }, "animationFirstPersonAttack" : { - "nameFirstPerson" : "Sword1HSlash1" + "nameFirstPerson" : "Sword1HSlash1", + "priorityCategory" : "MOVEMENT_MODIFIER" } }, { @@ -359,13 +370,16 @@ "driftFrameEnd" : 10, "initialMove" : false, "animationFirstPersonWindup" : { - "nameFirstPerson" : "Jump" + "nameFirstPerson" : "Jump", + "priorityCategory" : "MOVEMENT_MODIFIER" }, "animationFirstPersonHold" : { - "nameFirstPerson" : "Jump" + "nameFirstPerson" : "Jump", + "priorityCategory" : "MOVEMENT_MODIFIER" }, "animationFirstPersonAttack" : { - "nameFirstPerson" : "Sword1HSlash2" + "nameFirstPerson" : "Sword1HSlash2", + "priorityCategory" : "MOVEMENT_MODIFIER" } }, { @@ -383,13 +397,16 @@ "driftFrameEnd" : 10, "initialMove" : true, "animationFirstPersonWindup" : { - "nameFirstPerson" : "HoldItemR2H" + "nameFirstPerson" : "HoldItemR2H", + "priorityCategory" : "MOVEMENT_MODIFIER" }, "animationFirstPersonHold" : { - "nameFirstPerson" : "HoldItemR2H" + "nameFirstPerson" : "HoldItemR2H", + "priorityCategory" : "MOVEMENT_MODIFIER" }, "animationFirstPersonAttack" : { - "nameFirstPerson" : "SwordR2HSlash" + "nameFirstPerson" : "SwordR2HSlash", + "priorityCategory" : "MOVEMENT_MODIFIER" } }, { @@ -409,13 +426,16 @@ "movementGoal" : 0, "initialMove" : true, "animationFirstPersonWindup" : { - "nameFirstPerson" : "Jump" + "nameFirstPerson" : "Jump", + "priorityCategory" : "MOVEMENT_MODIFIER" }, "animationFirstPersonHold" : { - "nameFirstPerson" : "Jump" + "nameFirstPerson" : "Jump", + "priorityCategory" : "MOVEMENT_MODIFIER" }, "animationFirstPersonAttack" : { - "nameFirstPerson" : "Jump" + "nameFirstPerson" : "Jump", + "priorityCategory" : "MOVEMENT_MODIFIER" } } ], diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index 66afa721..2b814af7 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -470,6 +470,8 @@ Attach utils fixes for first person handling (07/28/2024) Tear out first person rendering pipeline Partially fix first person attachment to viewmodel +Creature data validation +Unify animation format data on disk # TODO diff --git a/src/main/java/electrosphere/entity/state/AnimationPriorities.java b/src/main/java/electrosphere/entity/state/AnimationPriorities.java index a7c63dec..0a6b8900 100644 --- a/src/main/java/electrosphere/entity/state/AnimationPriorities.java +++ b/src/main/java/electrosphere/entity/state/AnimationPriorities.java @@ -1,5 +1,7 @@ package electrosphere.entity.state; +import electrosphere.logger.LoggerInterface; + /** * The list of animation priorities */ @@ -9,43 +11,88 @@ public class AnimationPriorities { // //1 // - public static final int DEATH = 1; + private static final int STATE_FINAL_VALUE = 1; + public static final String STATE_FINAL = "STATE_FINAL"; //A final state for the entity (ie dying/death) // //2 // - public static final int ATTACK = 2; - public static final int BLOCK = 2; + private static final int MODIFIER_MAX_VALUE = 2; + public static final String MODIFIER_MAX = "MODIFIER_MAX"; //A modifier to a bone group that is maximum priority (ie if holding an item, the animation to hold the item is top priority) // //4 // - public static final int FALL = 4; - public static final int JUMP = 4; - public static final int LAND = 4; // //5 // - public static final int GROUND_MOVE = 5; + private static final int MOVEMENT_MODIFIER_VALUE = 5; + public static final String MOVEMENT_MODIFIER = "MOVEMENT_MODIFIER"; //When a state is modifying the core movement tree active currently (think sprinting, jumping, landing, etc) + + // + //6 + // + private static final int MODIFIER_HIGH_VALUE = 6; + public static final String MODIFIER_HIGH = "MODIFIER_HIGH"; //A modifier to a bone group that is high priority (think holding the arm upright when a sword is equipped) // //7 // - public static final int ITEM_INTERACTION = 7; + private static final int CORE_MOVEMENT_VALUE = 7; + public static final String CORE_MOVEMENT = "CORE_MOVEMENT"; //A core movement tree (ie base ground movement) + + + // + //8 + // + private static final int INTERACTION_VALUE = 8; + public static final String INTERACTION = "INTERACTION"; //An interaction animation (ie grabbing an item, dropping an item, etc) // //10 // - public static final int IDLE = 10; + private static final int IDLE_VALUE = 10; + public static final String IDLE = "IDLE"; //An idle animation // //50 // - public static final int DEFAULT = 50; + private static final int DEFAULT_VALUE = 50; + public static final String DEFAULT = "DEFAULT"; //The default (low) priority + + /** + * Gets the value of animation category + * @param type The animation category + * @return the priority + */ + public static int getValue(String category){ + switch(category){ + case STATE_FINAL: + return STATE_FINAL_VALUE; + case MODIFIER_MAX: + return MODIFIER_MAX_VALUE; + case MOVEMENT_MODIFIER: + return MOVEMENT_MODIFIER_VALUE; + case MODIFIER_HIGH: + return MODIFIER_HIGH_VALUE; + case CORE_MOVEMENT: + return CORE_MOVEMENT_VALUE; + case INTERACTION: + return INTERACTION_VALUE; + case IDLE: + return IDLE_VALUE; + case DEFAULT: + return DEFAULT_VALUE; + default: { + LoggerInterface.loggerEngine.WARNING("Trying to get priority of animation category that doesn't exist! " + category); + return DEFAULT_VALUE; + } + } + } } diff --git a/src/main/java/electrosphere/entity/state/attack/ClientAttackTree.java b/src/main/java/electrosphere/entity/state/attack/ClientAttackTree.java index 1f0b7b44..1b16f956 100644 --- a/src/main/java/electrosphere/entity/state/attack/ClientAttackTree.java +++ b/src/main/java/electrosphere/entity/state/attack/ClientAttackTree.java @@ -241,29 +241,50 @@ public class ClientAttackTree implements BehaviorTree { if(currentMove != null){ if(entityActor != null){ if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(currentMove.getWindupAnimationName())){ - entityActor.playAnimation(currentMove.getWindupAnimationName(),AnimationPriorities.ATTACK); + entityActor.playAnimation( + currentMove.getWindupAnimationName(), + AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER) + ); entityActor.incrementAnimationTime(0.0001); } - FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, currentMove.getAnimationFirstPersonWindup().getNameFirstPerson(), AnimationPriorities.ATTACK); + FirstPersonTree.conditionallyPlayAnimation( + Globals.firstPersonEntity, + currentMove.getAnimationFirstPersonWindup().getNameFirstPerson(), + AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER) + ); } } } break; case HOLD: { if(entityActor != null){ if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(currentMove.getHoldAnimationName())){ - entityActor.playAnimation(currentMove.getHoldAnimationName(),AnimationPriorities.ATTACK); + entityActor.playAnimation( + currentMove.getHoldAnimationName(), + AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER) + ); entityActor.incrementAnimationTime(0.0001); } - FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, currentMove.getAnimationFirstPersonHold().getNameFirstPerson(), AnimationPriorities.ATTACK); + FirstPersonTree.conditionallyPlayAnimation( + Globals.firstPersonEntity, + currentMove.getAnimationFirstPersonHold().getNameFirstPerson(), + AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER) + ); } } break; case ATTACK: { if(entityActor != null && currentMove != null){ if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(currentMove.getAttackAnimationName())){ - entityActor.playAnimation(currentMove.getAttackAnimationName(),AnimationPriorities.ATTACK); + entityActor.playAnimation( + currentMove.getAttackAnimationName(), + AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER) + ); entityActor.incrementAnimationTime(0.0001); } - FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, currentMove.getAnimationFirstPersonAttack().getNameFirstPerson(), AnimationPriorities.ATTACK); + FirstPersonTree.conditionallyPlayAnimation( + Globals.firstPersonEntity, + currentMove.getAnimationFirstPersonAttack().getNameFirstPerson(), + AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER) + ); } //activate hitboxes List attachedEntities = AttachUtils.getChildrenList(parent); diff --git a/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java b/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java index 0127817e..d32f4509 100644 --- a/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java +++ b/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java @@ -221,7 +221,10 @@ public class ServerAttackTree implements BehaviorTree { } if(entityPoseActor != null){ if(!entityPoseActor.isPlayingAnimation() || !entityPoseActor.isPlayingAnimation(animationName)){ - entityPoseActor.playAnimation(animationName,AnimationPriorities.ATTACK); + entityPoseActor.playAnimation( + animationName, + AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER) + ); entityPoseActor.incrementAnimationTime(0.0001); } } @@ -250,7 +253,10 @@ public class ServerAttackTree implements BehaviorTree { case HOLD: { if(entityPoseActor != null){ if(!entityPoseActor.isPlayingAnimation() || !entityPoseActor.isPlayingAnimation(animationName)){ - entityPoseActor.playAnimation(animationName,AnimationPriorities.ATTACK); + entityPoseActor.playAnimation( + animationName, + AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER) + ); entityPoseActor.incrementAnimationTime(0.0001); } } diff --git a/src/main/java/electrosphere/entity/state/block/ClientBlockTree.java b/src/main/java/electrosphere/entity/state/block/ClientBlockTree.java index 3e53acba..4e1674da 100644 --- a/src/main/java/electrosphere/entity/state/block/ClientBlockTree.java +++ b/src/main/java/electrosphere/entity/state/block/ClientBlockTree.java @@ -56,7 +56,7 @@ public class ClientBlockTree implements BehaviorTree { this.stateTransitionUtil = StateTransitionUtil.create(parent, false, new StateTransitionUtilItem[]{ StateTransitionUtilItem.create( BlockState.WIND_UP, - AnimationPriorities.BLOCK, + AnimationPriorities.getValue(AnimationPriorities.MODIFIER_HIGH), () -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getWindUpFirstPersonAnimation();}, () -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getWindUpAnimation();}, null, @@ -64,7 +64,7 @@ public class ClientBlockTree implements BehaviorTree { ), StateTransitionUtilItem.create( BlockState.BLOCKING, - AnimationPriorities.BLOCK, + AnimationPriorities.getValue(AnimationPriorities.MODIFIER_HIGH), () -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getMainFirstPersonAnimation();}, () -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getMainAnimation();}, null, @@ -72,7 +72,7 @@ public class ClientBlockTree implements BehaviorTree { ), StateTransitionUtilItem.create( BlockState.COOLDOWN, - AnimationPriorities.BLOCK, + AnimationPriorities.getValue(AnimationPriorities.MODIFIER_HIGH), () -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getCooldownFirstPersonAnimation();}, () -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getCooldownAnimation();}, null, diff --git a/src/main/java/electrosphere/entity/state/block/ServerBlockTree.java b/src/main/java/electrosphere/entity/state/block/ServerBlockTree.java index d22d672e..b6826025 100644 --- a/src/main/java/electrosphere/entity/state/block/ServerBlockTree.java +++ b/src/main/java/electrosphere/entity/state/block/ServerBlockTree.java @@ -50,7 +50,7 @@ public class ServerBlockTree implements BehaviorTree { this.stateTransitionUtil = StateTransitionUtil.create(parent, true, new StateTransitionUtilItem[]{ StateTransitionUtilItem.create( BlockState.WIND_UP, - AnimationPriorities.BLOCK, + AnimationPriorities.getValue(AnimationPriorities.MODIFIER_HIGH), null, () -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getWindUpAnimation();}, null, @@ -58,7 +58,7 @@ public class ServerBlockTree implements BehaviorTree { ), StateTransitionUtilItem.create( BlockState.BLOCKING, - AnimationPriorities.BLOCK, + AnimationPriorities.getValue(AnimationPriorities.MODIFIER_HIGH), null, () -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getMainAnimation();}, null, @@ -66,7 +66,7 @@ public class ServerBlockTree implements BehaviorTree { ), StateTransitionUtilItem.create( BlockState.COOLDOWN, - AnimationPriorities.BLOCK, + AnimationPriorities.getValue(AnimationPriorities.MODIFIER_HIGH), null, () -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getCooldownAnimation();}, null, diff --git a/src/main/java/electrosphere/entity/state/idle/ClientIdleTree.java b/src/main/java/electrosphere/entity/state/idle/ClientIdleTree.java index 24665eb8..78ed47a9 100644 --- a/src/main/java/electrosphere/entity/state/idle/ClientIdleTree.java +++ b/src/main/java/electrosphere/entity/state/idle/ClientIdleTree.java @@ -98,10 +98,10 @@ public class ClientIdleTree implements BehaviorTree { (Globals.assetManager.fetchModel(entityActor.getModelPath()) != null && Globals.assetManager.fetchModel(entityActor.getModelPath()).getAnimation(idleData.getIdleAnimation()) != null) ){ - entityActor.playAnimation(idleData.getIdleAnimation(),AnimationPriorities.IDLE); + entityActor.playAnimation(idleData.getIdleAnimation(),AnimationPriorities.getValue(AnimationPriorities.IDLE)); entityActor.incrementAnimationTime(0.0001); } - FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, idleData.getFirstPersonIdleAnimation(), AnimationPriorities.IDLE); + FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, idleData.getFirstPersonIdleAnimation(), AnimationPriorities.getValue(AnimationPriorities.IDLE)); } break; case NOT_IDLE: diff --git a/src/main/java/electrosphere/entity/state/idle/ServerIdleTree.java b/src/main/java/electrosphere/entity/state/idle/ServerIdleTree.java index bd8732cb..99e0c1f3 100644 --- a/src/main/java/electrosphere/entity/state/idle/ServerIdleTree.java +++ b/src/main/java/electrosphere/entity/state/idle/ServerIdleTree.java @@ -93,7 +93,7 @@ public class ServerIdleTree implements BehaviorTree { if( (!poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(Animation.ANIMATION_IDLE_1)) ){ - poseActor.playAnimation(Animation.ANIMATION_IDLE_1,AnimationPriorities.IDLE); + poseActor.playAnimation(Animation.ANIMATION_IDLE_1,AnimationPriorities.getValue(AnimationPriorities.IDLE)); poseActor.incrementAnimationTime(0.0001); } } diff --git a/src/main/java/electrosphere/entity/state/movement/FallTree.java b/src/main/java/electrosphere/entity/state/movement/FallTree.java index dd9a1790..1ae3d688 100644 --- a/src/main/java/electrosphere/entity/state/movement/FallTree.java +++ b/src/main/java/electrosphere/entity/state/movement/FallTree.java @@ -93,10 +93,10 @@ public class FallTree implements BehaviorTree { if( !entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(fallMovementSystem.getLandState().getAnimation().getNameThirdPerson()) ){ - entityActor.playAnimation(fallMovementSystem.getLandState().getAnimation().getNameThirdPerson(),AnimationPriorities.LAND); + entityActor.playAnimation(fallMovementSystem.getLandState().getAnimation().getNameThirdPerson(),AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER)); entityActor.incrementAnimationTime(0.0001); } - FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, fallMovementSystem.getLandState().getAnimation().getNameFirstPerson(), AnimationPriorities.LAND); + FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, fallMovementSystem.getLandState().getAnimation().getNameFirstPerson(), AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER)); } } } diff --git a/src/main/java/electrosphere/entity/state/movement/JumpTree.java b/src/main/java/electrosphere/entity/state/movement/JumpTree.java index 19da7c0d..203e48fb 100644 --- a/src/main/java/electrosphere/entity/state/movement/JumpTree.java +++ b/src/main/java/electrosphere/entity/state/movement/JumpTree.java @@ -61,10 +61,10 @@ public class JumpTree implements BehaviorTree { case ACTIVE: if(entityActor != null){ if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(jumpData.getAnimationJump().getNameThirdPerson())){ - entityActor.playAnimation(jumpData.getAnimationJump().getNameThirdPerson(),AnimationPriorities.JUMP); + entityActor.playAnimation(jumpData.getAnimationJump().getNameThirdPerson(),AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER)); entityActor.incrementAnimationTime(0.0001); } - FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, jumpData.getAnimationFirstPersonJump().getNameFirstPerson(), AnimationPriorities.JUMP); + FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, jumpData.getAnimationFirstPersonJump().getNameFirstPerson(), AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER)); } currentFrame++; currentJumpForce = currentJumpForce * jumpFalloff; diff --git a/src/main/java/electrosphere/entity/state/movement/ServerFallTree.java b/src/main/java/electrosphere/entity/state/movement/ServerFallTree.java index 73c39cd1..c0aac64f 100644 --- a/src/main/java/electrosphere/entity/state/movement/ServerFallTree.java +++ b/src/main/java/electrosphere/entity/state/movement/ServerFallTree.java @@ -39,7 +39,7 @@ public class ServerFallTree implements BehaviorTree { !poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(animationToPlay) && (jumpTree == null || !jumpTree.isJumping()) ){ - poseActor.playAnimation(animationToPlay,AnimationPriorities.FALL); + poseActor.playAnimation(animationToPlay,AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER)); poseActor.incrementAnimationTime(0.0001); } } @@ -66,7 +66,7 @@ public class ServerFallTree implements BehaviorTree { if( !poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(animationToPlay) ){ - poseActor.playAnimation(animationToPlay,AnimationPriorities.LAND); + poseActor.playAnimation(animationToPlay,AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER)); poseActor.incrementAnimationTime(0.0001); } } diff --git a/src/main/java/electrosphere/entity/state/movement/ServerJumpTree.java b/src/main/java/electrosphere/entity/state/movement/ServerJumpTree.java index c1811ed3..c11734b8 100644 --- a/src/main/java/electrosphere/entity/state/movement/ServerJumpTree.java +++ b/src/main/java/electrosphere/entity/state/movement/ServerJumpTree.java @@ -56,7 +56,7 @@ public class ServerJumpTree implements BehaviorTree { if(poseActor != null){ String animationToPlay = determineCorrectAnimation(); if(!poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(animationToPlay)){ - poseActor.playAnimation(animationToPlay,AnimationPriorities.JUMP); + poseActor.playAnimation(animationToPlay,AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER)); poseActor.incrementAnimationTime(0.0001); } } diff --git a/src/main/java/electrosphere/entity/state/movement/groundmove/ClientGroundMovementTree.java b/src/main/java/electrosphere/entity/state/movement/groundmove/ClientGroundMovementTree.java index 6fcc2bf1..e89594ed 100644 --- a/src/main/java/electrosphere/entity/state/movement/groundmove/ClientGroundMovementTree.java +++ b/src/main/java/electrosphere/entity/state/movement/groundmove/ClientGroundMovementTree.java @@ -291,10 +291,10 @@ public class ClientGroundMovementTree implements BehaviorTree { (jumpTree == null || !jumpTree.isJumping()) && (fallTree == null || !fallTree.isFalling()) ){ - entityActor.playAnimation(animationToPlay,AnimationPriorities.GROUND_MOVE); + entityActor.playAnimation(animationToPlay,AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); entityActor.incrementAnimationTime(0.0001); } - FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, groundMovementData.getAnimationFirstPersonStartup().getNameThirdPerson(), AnimationPriorities.GROUND_MOVE); + FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, groundMovementData.getAnimationFirstPersonStartup().getNameThirdPerson(), AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); } //run startup code velocity = velocity + acceleration * (float)Globals.timekeeper.getSimFrameTime(); @@ -325,10 +325,10 @@ public class ClientGroundMovementTree implements BehaviorTree { (jumpTree == null || !jumpTree.isJumping()) && (fallTree == null || !fallTree.isFalling()) ){ - entityActor.playAnimation(animationToPlay,AnimationPriorities.GROUND_MOVE); + entityActor.playAnimation(animationToPlay,AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); entityActor.incrementAnimationTime(0.0001); } - FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, groundMovementData.getAnimationFirstPersonLoop().getNameThirdPerson(), AnimationPriorities.GROUND_MOVE); + FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, groundMovementData.getAnimationFirstPersonLoop().getNameThirdPerson(), AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); } if(velocity != maxNaturalVelocity){ velocity = maxNaturalVelocity; @@ -353,10 +353,10 @@ public class ClientGroundMovementTree implements BehaviorTree { (jumpTree == null || !jumpTree.isJumping()) && (fallTree == null || !fallTree.isFalling()) ){ - entityActor.playAnimation(animationToPlay,AnimationPriorities.GROUND_MOVE); + entityActor.playAnimation(animationToPlay,AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); entityActor.incrementAnimationTime(0.0001); } - FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, groundMovementData.getAnimationFirstPersonWindDown().getNameThirdPerson(), AnimationPriorities.GROUND_MOVE); + FirstPersonTree.conditionallyPlayAnimation(Globals.firstPersonEntity, groundMovementData.getAnimationFirstPersonWindDown().getNameThirdPerson(), AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); } //velocity stuff velocity = velocity - acceleration * (float)Globals.timekeeper.getSimFrameTime(); diff --git a/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java b/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java index 0881cb3d..63f545a9 100644 --- a/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java +++ b/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java @@ -253,7 +253,7 @@ public class ServerGroundMovementTree implements BehaviorTree { (jumpTree == null || !jumpTree.isJumping()) && (fallTree == null || !fallTree.isFalling()) ){ - poseActor.playAnimation(animationToPlay,AnimationPriorities.GROUND_MOVE); + poseActor.playAnimation(animationToPlay,AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); poseActor.incrementAnimationTime(0.0001); } } @@ -308,7 +308,7 @@ public class ServerGroundMovementTree implements BehaviorTree { (jumpTree == null || !jumpTree.isJumping()) && (fallTree == null || !fallTree.isFalling()) ){ - poseActor.playAnimation(animationToPlay,AnimationPriorities.GROUND_MOVE); + poseActor.playAnimation(animationToPlay,AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); poseActor.incrementAnimationTime(0.0001); } } @@ -360,7 +360,7 @@ public class ServerGroundMovementTree implements BehaviorTree { (jumpTree == null || !jumpTree.isJumping()) && (fallTree == null || !fallTree.isFalling()) ){ - poseActor.playAnimation(animationToPlay,AnimationPriorities.GROUND_MOVE); + poseActor.playAnimation(animationToPlay,AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); poseActor.incrementAnimationTime(0.0001); } } diff --git a/src/main/java/electrosphere/entity/types/item/ItemUtils.java b/src/main/java/electrosphere/entity/types/item/ItemUtils.java index 94843e96..c1d396d2 100644 --- a/src/main/java/electrosphere/entity/types/item/ItemUtils.java +++ b/src/main/java/electrosphere/entity/types/item/ItemUtils.java @@ -241,7 +241,7 @@ public class ItemUtils { if(actor != null && item.getData(EntityDataStrings.ANIM_IDLE) != null){ String idleAnim = (String)item.getData(EntityDataStrings.ANIM_IDLE); if(!actor.isPlayingAnimation(idleAnim)){ - actor.playAnimation(idleAnim,AnimationPriorities.ITEM_INTERACTION); + actor.playAnimation(idleAnim,AnimationPriorities.getValue(AnimationPriorities.INTERACTION)); actor.incrementAnimationTime(0.0001); } } @@ -256,7 +256,7 @@ public class ItemUtils { if(actor != null && item.getData(EntityDataStrings.ANIM_IDLE) != null){ String idleAnim = (String)item.getData(EntityDataStrings.ANIM_IDLE); if(!actor.isPlayingAnimation(idleAnim)){ - actor.playAnimation(idleAnim,AnimationPriorities.ITEM_INTERACTION); + actor.playAnimation(idleAnim,AnimationPriorities.getValue(AnimationPriorities.INTERACTION)); actor.incrementAnimationTime(0.0001); } } diff --git a/src/main/java/electrosphere/game/data/common/TreeDataAnimation.java b/src/main/java/electrosphere/game/data/common/TreeDataAnimation.java index 6ad2dd2b..b84dcf59 100644 --- a/src/main/java/electrosphere/game/data/common/TreeDataAnimation.java +++ b/src/main/java/electrosphere/game/data/common/TreeDataAnimation.java @@ -32,6 +32,11 @@ public class TreeDataAnimation { */ Integer priority; + /** + * The priority category this animation is in + */ + String priorityCategory; + /** * The list of bone groups this animation applies to */ @@ -77,6 +82,14 @@ public class TreeDataAnimation { return priority; } + /** + * Gets the priority category of this animation + * @return The priority category + */ + public String getPriorityCategory(){ + return priorityCategory; + } + /** * Gets the bone groups this animation applies to * @return The list of bone groups this animation applies to diff --git a/src/main/java/electrosphere/game/data/creature/type/CreatureDataValidator.java b/src/main/java/electrosphere/game/data/creature/type/CreatureDataValidator.java index d00f8098..a735ea55 100644 --- a/src/main/java/electrosphere/game/data/creature/type/CreatureDataValidator.java +++ b/src/main/java/electrosphere/game/data/creature/type/CreatureDataValidator.java @@ -3,7 +3,14 @@ package electrosphere.game.data.creature.type; import java.util.LinkedList; import java.util.List; +import electrosphere.game.data.common.TreeDataAnimation; +import electrosphere.game.data.creature.type.attack.AttackMove; import electrosphere.game.data.creature.type.bonegroups.BoneGroup; +import electrosphere.game.data.creature.type.equip.EquipPoint; +import electrosphere.game.data.creature.type.movement.FallMovementSystem; +import electrosphere.game.data.creature.type.movement.GroundMovementSystem; +import electrosphere.game.data.creature.type.movement.JumpMovementSystem; +import electrosphere.game.data.creature.type.movement.MovementSystem; import electrosphere.logger.LoggerInterface; /** @@ -17,6 +24,7 @@ public class CreatureDataValidator { */ public static void validate(CreatureData data){ CreatureDataValidator.validateBoneGroups(data); + CreatureDataValidator.validateAnimations(data); } @@ -68,4 +76,65 @@ public class CreatureDataValidator { } } + /** + * Validates the bone groups + * @param data The creature data + */ + static void validateAnimations(CreatureData data){ + List animations = new LinkedList(); + if(data.getAttackMoves() != null){ + for(AttackMove move : data.getAttackMoves()){ + animations.add(move.getAnimationFirstPersonAttack()); + animations.add(move.getAnimationFirstPersonHold()); + animations.add(move.getAnimationFirstPersonWindup()); + } + } + if(data.getEquipPoints() != null){ + for(EquipPoint point : data.getEquipPoints()){ + animations.add(point.getEquippedAnimation()); + } + } + if(data.getHealthSystem() != null && data.getHealthSystem().getDyingState() != null){ + animations.add(data.getHealthSystem().getDyingState().getAnimation()); + } + for(MovementSystem system : data.getMovementSystems()){ + if(system instanceof GroundMovementSystem){ + GroundMovementSystem groundMovementSystem = (GroundMovementSystem)system; + animations.add(groundMovementSystem.getAnimationFirstPersonLoop()); + animations.add(groundMovementSystem.getAnimationFirstPersonStartup()); + animations.add(groundMovementSystem.getAnimationFirstPersonWindDown()); + animations.add(groundMovementSystem.getAnimationLoop()); + animations.add(groundMovementSystem.getAnimationStartup()); + animations.add(groundMovementSystem.getAnimationWindDown()); + } + if(system instanceof JumpMovementSystem){ + JumpMovementSystem jumpMovementSystem = (JumpMovementSystem)system; + animations.add(jumpMovementSystem.getAnimationFirstPersonJump()); + animations.add(jumpMovementSystem.getAnimationJump()); + } + if(system instanceof FallMovementSystem){ + FallMovementSystem fallMovementSystem = (FallMovementSystem)system; + if(fallMovementSystem.getFallState() != null){ + animations.add(fallMovementSystem.getFallState().getAnimation()); + } + if(fallMovementSystem.getLandState() != null){ + animations.add(fallMovementSystem.getLandState().getAnimation()); + } + } + } + for(TreeDataAnimation animation : animations){ + if(animation != null){ + if(animation.getPriority() == null && animation.getPriorityCategory() == null){ + //same bone used in multiple groups + String message = "Animation does not have priority defined!\n" + + "Creature name: " + data.getCreatureId() + "\n" + + "Animation first person name: " + animation.getNameFirstPerson() + "\n" + + "Animation third person name: " + animation.getNameThirdPerson() + "\n" + ; + LoggerInterface.loggerEngine.WARNING(message); + } + } + } + } + } diff --git a/src/main/java/electrosphere/renderer/actor/Actor.java b/src/main/java/electrosphere/renderer/actor/Actor.java index 97f89520..eb6cec96 100644 --- a/src/main/java/electrosphere/renderer/actor/Actor.java +++ b/src/main/java/electrosphere/renderer/actor/Actor.java @@ -173,10 +173,13 @@ public class Actor { } //Get the animation's priority - int priority = AnimationPriorities.DEFAULT; + int priority = AnimationPriorities.getValue(AnimationPriorities.DEFAULT); if(animation.getPriority() != null){ priority = animation.getPriority(); } + if(animation.getPriorityCategory() != null){ + priority = AnimationPriorities.getValue(animation.getPriorityCategory()); + } //Gets the mask List boneMask = null; diff --git a/src/main/java/electrosphere/server/poseactor/PoseActor.java b/src/main/java/electrosphere/server/poseactor/PoseActor.java index 8647d67e..9d7a98d9 100644 --- a/src/main/java/electrosphere/server/poseactor/PoseActor.java +++ b/src/main/java/electrosphere/server/poseactor/PoseActor.java @@ -161,10 +161,13 @@ public class PoseActor { } //Get the animation's priority - int priority = AnimationPriorities.DEFAULT; + int priority = AnimationPriorities.getValue(AnimationPriorities.DEFAULT); if(animation.getPriority() != null){ priority = animation.getPriority(); } + if(animation.getPriorityCategory() != null){ + priority = AnimationPriorities.getValue(animation.getPriorityCategory()); + } //Gets the mask List boneMask = null;