diff --git a/assets/Audio/weapons/swoosh-03.ogg b/assets/Audio/weapons/swoosh-03.ogg new file mode 100644 index 00000000..f4f0d70f Binary files /dev/null and b/assets/Audio/weapons/swoosh-03.ogg differ diff --git a/assets/Data/creatures/human.json b/assets/Data/creatures/human.json index 9ef5beee..84d8e6ae 100644 --- a/assets/Data/creatures/human.json +++ b/assets/Data/creatures/human.json @@ -375,20 +375,26 @@ "driftFrameStart" : 7, "driftFrameEnd" : 15, "initialMove" : true, - "animationWindup" : { - "nameFirstPerson" : "Sword1HSlash1", - "nameThirdPerson" : "Sword1HSlash1", - "priorityCategory" : "MOVEMENT_MODIFIER" + "windupState" : { + "animation" : { + "nameFirstPerson" : "Sword1HSlash1", + "nameThirdPerson" : "Sword1HSlash1", + "priorityCategory" : "MOVEMENT_MODIFIER" + } }, - "animationHold" : { - "nameFirstPerson" : "Sword1HSlash1", - "nameThirdPerson" : "Sword1HSlash1", - "priorityCategory" : "MOVEMENT_MODIFIER" + "holdState" : { + "animation" : { + "nameFirstPerson" : "Sword1HSlash1", + "nameThirdPerson" : "Sword1HSlash1", + "priorityCategory" : "MOVEMENT_MODIFIER" + } }, - "animationAttack" : { - "nameFirstPerson" : "Sword1HSlash1", - "nameThirdPerson" : "Sword1HSlash1", - "priorityCategory" : "MOVEMENT_MODIFIER" + "attackState" : { + "animation" : { + "nameFirstPerson" : "Sword1HSlash1", + "nameThirdPerson" : "Sword1HSlash1", + "priorityCategory" : "MOVEMENT_MODIFIER" + } } }, { @@ -405,20 +411,26 @@ "driftFrameStart" : 1, "driftFrameEnd" : 10, "initialMove" : false, - "animationWindup" : { - "nameFirstPerson" : "Jump", - "nameThirdPerson" : "Jump", - "priorityCategory" : "MOVEMENT_MODIFIER" + "windupState" : { + "animation" : { + "nameFirstPerson" : "Jump", + "nameThirdPerson" : "Jump", + "priorityCategory" : "MOVEMENT_MODIFIER" + } }, - "animationHold" : { - "nameFirstPerson" : "Jump", - "nameThirdPerson" : "Jump", - "priorityCategory" : "MOVEMENT_MODIFIER" + "holdState" : { + "animation" : { + "nameFirstPerson" : "Jump", + "nameThirdPerson" : "Jump", + "priorityCategory" : "MOVEMENT_MODIFIER" + } }, - "animationAttack" : { - "nameFirstPerson" : "Sword1HSlash2", - "nameThirdPerson" : "Sword1HSlash2", - "priorityCategory" : "MOVEMENT_MODIFIER" + "attackState" : { + "animation" : { + "nameFirstPerson" : "Sword1HSlash2", + "nameThirdPerson" : "Sword1HSlash2", + "priorityCategory" : "MOVEMENT_MODIFIER" + } } }, { @@ -434,10 +446,15 @@ "driftFrameStart" : 1, "driftFrameEnd" : 10, "initialMove" : true, - "animationAttack" : { - "nameFirstPerson" : "SwordR2HSlash", - "nameThirdPerson" : "SwordR2HSlash", - "priorityCategory" : "MOVEMENT_MODIFIER" + "attackState" : { + "animation" : { + "nameFirstPerson" : "SwordR2HSlash", + "nameThirdPerson" : "SwordR2HSlash", + "priorityCategory" : "MOVEMENT_MODIFIER" + }, + "audioData" : { + "audioPath" : "Audio/weapons/swoosh-03.ogg" + } } }, { @@ -453,20 +470,26 @@ "movementEnd" : 0, "movementGoal" : 0, "initialMove" : true, - "animationWindup" : { - "nameFirstPerson" : "Jump", - "nameThirdPerson" : "HoldBowString", - "priorityCategory" : "MOVEMENT_MODIFIER" + "windupState" : { + "animation" : { + "nameFirstPerson" : "Jump", + "nameThirdPerson" : "HoldBowString", + "priorityCategory" : "MOVEMENT_MODIFIER" + } }, - "animationHold" : { - "nameFirstPerson" : "Jump", - "nameThirdPerson" : "HoldBow", - "priorityCategory" : "MOVEMENT_MODIFIER" + "holdState" : { + "animation" : { + "nameFirstPerson" : "Jump", + "nameThirdPerson" : "HoldBow", + "priorityCategory" : "MOVEMENT_MODIFIER" + } }, - "animationAttack" : { - "nameFirstPerson" : "Jump", - "nameThirdPerson" : "HoldBowString", - "priorityCategory" : "MOVEMENT_MODIFIER" + "attackState" : { + "animation" : { + "nameFirstPerson" : "Sword1HSlash2", + "nameThirdPerson" : "HoldBowString", + "priorityCategory" : "MOVEMENT_MODIFIER" + } } } ], diff --git a/docs/src/progress/currenttarget.md b/docs/src/progress/currenttarget.md index ee8a39c7..bd8675a2 100644 --- a/docs/src/progress/currenttarget.md +++ b/docs/src/progress/currenttarget.md @@ -16,3 +16,12 @@ Things that feel bad: No audio Short movement bursts feel jittery Part of this may be cylinder collidable instead of capsule + + +Sound effect on hit +Sound effect on walk +Sound effect on jump +Sound effect on land +Sound effect on block +Allow block hotboxes to block damage +Server packet on damage collision diff --git a/docs/src/progress/renderertodo.md b/docs/src/progress/renderertodo.md index bd3f962f..37d48061 100644 --- a/docs/src/progress/renderertodo.md +++ b/docs/src/progress/renderertodo.md @@ -508,6 +508,7 @@ Audio on block state transitions (08/04/2024) Strafe/backpedal movement speed multipliers +Properly equipping/unequipping 2hand items # TODO diff --git a/src/main/java/electrosphere/engine/Globals.java b/src/main/java/electrosphere/engine/Globals.java index 6bde6a20..177de5d3 100644 --- a/src/main/java/electrosphere/engine/Globals.java +++ b/src/main/java/electrosphere/engine/Globals.java @@ -135,7 +135,7 @@ public class Globals { public static boolean RUN_DEMO = false; public static boolean RUN_CLIENT = true; public static boolean RUN_HIDDEN = false; //glfw session will be created with hidden window - public static boolean RUN_AUDIO = false; + public static boolean RUN_AUDIO = true; public static int clientCharacterID; // @@ -469,6 +469,7 @@ public class Globals { "/Audio/closeMenu.ogg", "/Audio/ambienceWind1SeamlessMono.ogg", "/Audio/weapons/swordUnsheath1.ogg", + "/Audio/weapons/swoosh-03.ogg", }; LoggerInterface.loggerStartup.INFO("Loading default audio resources"); for(String path : audioToInit){ diff --git a/src/main/java/electrosphere/entity/btree/StateTransitionUtil.java b/src/main/java/electrosphere/entity/btree/StateTransitionUtil.java index e5e6ae6c..f5d9931f 100644 --- a/src/main/java/electrosphere/entity/btree/StateTransitionUtil.java +++ b/src/main/java/electrosphere/entity/btree/StateTransitionUtil.java @@ -6,7 +6,6 @@ import electrosphere.audio.VirtualAudioSourceManager.VirtualAudioSourceType; import electrosphere.engine.Globals; import electrosphere.entity.Entity; import electrosphere.entity.EntityUtils; -import electrosphere.entity.state.AnimationPriorities; import electrosphere.entity.state.client.firstPerson.FirstPersonTree; import electrosphere.game.data.common.TreeDataAnimation; import electrosphere.game.data.common.TreeDataAudio; @@ -181,7 +180,7 @@ public class StateTransitionUtil { if(state.onComplete != null){ state.onComplete.run(); } - } else if(!poseActor.isPlayingAnimation() && state.onComplete != null && state.startedAnimation == true){ + } else if(!poseActor.isPlayingAnimation(animation) && state.onComplete != null && state.startedAnimation == true){ //state transition if this isn't set to loop state.onComplete.run(); state.startedAnimation = false; diff --git a/src/main/java/electrosphere/entity/state/attack/ClientAttackTree.java b/src/main/java/electrosphere/entity/state/attack/ClientAttackTree.java index 8a56056a..094b82e4 100644 --- a/src/main/java/electrosphere/entity/state/attack/ClientAttackTree.java +++ b/src/main/java/electrosphere/entity/state/attack/ClientAttackTree.java @@ -8,7 +8,8 @@ import electrosphere.entity.Entity; import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityUtils; import electrosphere.entity.btree.BehaviorTree; -import electrosphere.entity.state.client.firstPerson.FirstPersonTree; +import electrosphere.entity.btree.StateTransitionUtil; +import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem; import electrosphere.entity.state.collidable.Impulse; import electrosphere.entity.state.equip.ClientEquipState; import electrosphere.entity.state.hitbox.HitboxCollectionState; @@ -17,12 +18,12 @@ import electrosphere.entity.types.attach.AttachUtils; import electrosphere.entity.types.collision.CollisionObjUtils; import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.item.ItemUtils; +import electrosphere.game.data.common.TreeDataState; import electrosphere.game.data.creature.type.attack.AttackMove; 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 java.util.List; import java.util.concurrent.CopyOnWriteArrayList; @@ -93,11 +94,96 @@ public class ClientAttackTree implements BehaviorTree { boolean firesProjectile = false; String projectileToFire = null; String attackingPoint = null; + + //The state transition util + StateTransitionUtil stateTransitionUtil; private ClientAttackTree(Entity e, Object ... params){ setState(AttackTreeState.IDLE); setDriftState(AttackTreeDriftState.NO_DRIFT); parent = e; + this.stateTransitionUtil = StateTransitionUtil.create(parent, false, new StateTransitionUtilItem[]{ + StateTransitionUtilItem.create( + AttackTreeState.WINDUP, + () -> { + TreeDataState state = currentMove.getWindupState(); + if(state == null){ + return null; + } else { + return state.getAnimation(); + } + }, + () -> { + TreeDataState state = currentMove.getWindupState(); + if(state == null){ + return null; + } else { + return state.getAudioData(); + } + }, + null + ), + StateTransitionUtilItem.create( + AttackTreeState.HOLD, + () -> { + TreeDataState state = currentMove.getHoldState(); + if(state == null){ + return null; + } else { + return state.getAnimation(); + } + }, + () -> { + TreeDataState state = currentMove.getHoldState(); + if(state == null){ + return null; + } else { + return state.getAudioData(); + } + }, + null + ), + StateTransitionUtilItem.create( + AttackTreeState.ATTACK, + () -> { + TreeDataState state = currentMove.getAttackState(); + if(state == null){ + return null; + } else { + return state.getAnimation(); + } + }, + () -> { + TreeDataState state = currentMove.getAttackState(); + if(state == null){ + return null; + } else { + return state.getAudioData(); + } + }, + null + ), + StateTransitionUtilItem.create( + AttackTreeState.COOLDOWN, + () -> { + TreeDataState state = currentMove.getCooldownState(); + if(state == null){ + return null; + } else { + return state.getAnimation(); + } + }, + () -> { + TreeDataState state = currentMove.getCooldownState(); + if(state == null){ + return null; + } else { + return state.getAudioData(); + } + }, + null + ), + }); } /** @@ -148,7 +234,6 @@ public class ClientAttackTree implements BehaviorTree { @Override public void simulate(float deltaTime){ frameCurrent = frameCurrent + (float)Globals.timekeeper.getDeltaFrames(); - Actor entityActor = EntityUtils.getActor(parent); Vector3d movementVector = CreatureUtils.getFacingVector(parent); // @@ -237,49 +322,13 @@ public class ClientAttackTree implements BehaviorTree { if(parent.containsKey(EntityDataStrings.CLIENT_ROTATOR_TREE)){ RotatorTree.getClientRotatorTree(parent).setActive(true); } - if(currentMove != null && entityActor != null && currentMove.getAnimationWindup() != null){ - if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(currentMove.getAnimationWindup())){ - entityActor.playAnimation( - currentMove.getAnimationWindup(), - true - ); - entityActor.incrementAnimationTime(0.0001); - } - FirstPersonTree.conditionallyPlayAnimation( - parent, - currentMove.getAnimationWindup() - ); - } + this.stateTransitionUtil.simulate(AttackTreeState.WINDUP); } break; case HOLD: { - if(entityActor != null && currentMove.getAnimationHold() != null){ - if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(currentMove.getAnimationHold())){ - entityActor.playAnimation( - currentMove.getAnimationHold(), - true - ); - entityActor.incrementAnimationTime(0.0001); - } - FirstPersonTree.conditionallyPlayAnimation( - parent, - currentMove.getAnimationHold() - ); - } + this.stateTransitionUtil.simulate(AttackTreeState.HOLD); } break; case ATTACK: { - if(entityActor != null && currentMove != null){ - if(!entityActor.isPlayingAnimation() || !entityActor.isPlayingAnimation(currentMove.getAnimationAttack())){ - entityActor.playAnimation( - currentMove.getAnimationAttack(), - true - ); - entityActor.incrementAnimationTime(0.0001); - } - FirstPersonTree.conditionallyPlayAnimation( - parent, - currentMove.getAnimationAttack() - ); - } + this.stateTransitionUtil.simulate(AttackTreeState.ATTACK); //activate hitboxes List attachedEntities = AttachUtils.getChildrenList(parent); if(attachedEntities != null){ @@ -292,6 +341,7 @@ public class ClientAttackTree implements BehaviorTree { } } break; case COOLDOWN: { + this.stateTransitionUtil.simulate(AttackTreeState.COOLDOWN); //deactive hitboxes List attachedEntities = AttachUtils.getChildrenList(parent); if(attachedEntities != null){ diff --git a/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java b/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java index 8fbeb784..73a578b7 100644 --- a/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java +++ b/src/main/java/electrosphere/entity/state/attack/ServerAttackTree.java @@ -12,7 +12,8 @@ import electrosphere.entity.Entity; import electrosphere.entity.EntityDataStrings; import electrosphere.entity.EntityUtils; import electrosphere.entity.btree.BehaviorTree; -import electrosphere.entity.state.AnimationPriorities; +import electrosphere.entity.btree.StateTransitionUtil; +import electrosphere.entity.btree.StateTransitionUtil.StateTransitionUtilItem; import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeDriftState; import electrosphere.entity.state.attack.ClientAttackTree.AttackTreeState; import electrosphere.entity.state.collidable.Impulse; @@ -25,14 +26,15 @@ import electrosphere.entity.types.collision.CollisionObjUtils; import electrosphere.entity.types.creature.CreatureUtils; import electrosphere.entity.types.item.ItemUtils; import electrosphere.entity.types.projectile.ProjectileUtils; +import electrosphere.game.data.common.TreeDataState; import electrosphere.game.data.creature.type.attack.AttackMove; import electrosphere.game.data.creature.type.equip.EquipPoint; +import electrosphere.logger.LoggerInterface; 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.server.datacell.Realm; -import electrosphere.server.poseactor.PoseActor; import electrosphere.util.math.MathUtils; import java.util.List; @@ -79,11 +81,92 @@ public class ServerAttackTree implements BehaviorTree { boolean firesProjectile = false; String projectileToFire = null; String attackingPoint = null; + + //The state transition util + StateTransitionUtil stateTransitionUtil; private ServerAttackTree(Entity e, Object ... params){ state = AttackTreeState.IDLE; driftState = AttackTreeDriftState.NO_DRIFT; parent = e; + this.stateTransitionUtil = StateTransitionUtil.create(parent, true, new StateTransitionUtilItem[]{ + StateTransitionUtilItem.create( + AttackTreeState.WINDUP, + () -> { + TreeDataState state = currentMove.getWindupState(); + if(state == null){ + return null; + } else { + return state.getAnimation(); + } + }, + () -> { + TreeDataState state = currentMove.getWindupState(); + if(state == null){ + return null; + } else { + return state.getAudioData(); + } + }, + () -> { + if(currentMoveCanHold && stillHold){ + setState(AttackTreeState.HOLD); + } else { + setState(AttackTreeState.ATTACK); + } + this.stateTransitionUtil.interrupt(AttackTreeState.WINDUP); + } + ), + StateTransitionUtilItem.create( + AttackTreeState.HOLD, + () -> { + TreeDataState state = currentMove.getHoldState(); + if(state == null){ + return null; + } else { + return state.getAnimation(); + } + }, + () -> { + TreeDataState state = currentMove.getHoldState(); + if(state == null){ + return null; + } else { + return state.getAudioData(); + } + }, + null + ), + StateTransitionUtilItem.create( + AttackTreeState.ATTACK, + () -> { + TreeDataState state = currentMove.getAttackState(); + if(state == null){ + return null; + } else { + return state.getAnimation(); + } + }, + null, + () -> { + this.setState(AttackTreeState.COOLDOWN); + this.stateTransitionUtil.interrupt(AttackTreeState.ATTACK); + } + ), + StateTransitionUtilItem.create( + AttackTreeState.COOLDOWN, + () -> { + TreeDataState state = currentMove.getCooldownState(); + if(state == null){ + return null; + } else { + return state.getAnimation(); + } + }, + null, + null + ), + }); } /** @@ -122,14 +205,19 @@ public class ServerAttackTree implements BehaviorTree { projectileToFire = ItemUtils.getWeaponDataRaw(currentWeapon).getProjectileModel(); } - animationName = currentMove.getAnimationAttack().getNameThirdPerson(); - //intuit windup from presence of windup anim - currentMoveHasWindup = currentMove.getAnimationWindup() != null; - if(currentMoveHasWindup){ - animationName = currentMove.getAnimationWindup().getNameThirdPerson(); + //set initial stuff (this alerts the client as well) + setCurrentMoveId(currentMove.getAttackMoveId()); + + //start tree + if(currentMove.getWindupState() != null){ + setState(AttackTreeState.WINDUP); + } else if(currentMove.getAttackState() != null){ + setState(AttackTreeState.ATTACK); + } else { + LoggerInterface.loggerEngine.ERROR(new IllegalStateException("Trying to start attacking tree, but current move does not have windup or attack states defined!")); } //intuit can hold from presence of windup anim - currentMoveCanHold = currentMove.getAnimationHold() != null; + currentMoveCanHold = currentMove.getHoldState() != null; //stop movement tree if(parent.containsKey(EntityDataStrings.SERVER_MOVEMENT_BT)){ BehaviorTree movementTree = CreatureUtils.serverGetEntityMovementTree(parent); @@ -139,9 +227,6 @@ public class ServerAttackTree implements BehaviorTree { } Vector3d movementVector = CreatureUtils.getFacingVector(parent); EntityUtils.getRotation(parent).rotationTo(MathUtils.getOriginVector(), new Vector3d(movementVector.x,movementVector.y,movementVector.z)); - //set initial stuff (this alerts the client as well) - setCurrentMoveId(currentMove.getAttackMoveId()); - setState(AttackTreeState.WINDUP); frameCurrent = 0; } else { setState(AttackTreeState.IDLE); @@ -166,7 +251,6 @@ public class ServerAttackTree implements BehaviorTree { public void simulate(float deltaTime){ frameCurrent = frameCurrent + (float)Globals.timekeeper.getDeltaFrames(); float velocity = CreatureUtils.getVelocity(parent); - PoseActor entityPoseActor = EntityUtils.getPoseActor(parent); Vector3d position = EntityUtils.getPosition(parent); Vector3d movementVector = CreatureUtils.getFacingVector(parent); @@ -216,58 +300,31 @@ public class ServerAttackTree implements BehaviorTree { if(parent.containsKey(EntityDataStrings.SERVER_ROTATOR_TREE)){ ServerRotatorTree.getServerRotatorTree(parent).setActive(true); } - if(entityPoseActor != null){ - if(!entityPoseActor.isPlayingAnimation() || !entityPoseActor.isPlayingAnimation(animationName)){ - entityPoseActor.playAnimation( - animationName, - AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER) - ); - entityPoseActor.incrementAnimationTime(0.0001); - } - } - if(frameCurrent > currentMove.getWindupFrames()){ - if(currentMoveCanHold && stillHold){ - setState(AttackTreeState.HOLD); - } else { - setState(AttackTreeState.ATTACK); - } - } + this.stateTransitionUtil.simulate(AttackTreeState.WINDUP); Globals.server.broadcastMessage( - EntityMessage.constructattackUpdateMessage( - parent.getId(), - System.currentTimeMillis(), - (float)position.x, - (float)position.y, - (float)position.z, - movementVector.x, - movementVector.y, - movementVector.z, - velocity, - 0 - ) + EntityMessage.constructattackUpdateMessage( + parent.getId(), + System.currentTimeMillis(), + (float)position.x, + (float)position.y, + (float)position.z, + movementVector.x, + movementVector.y, + movementVector.z, + velocity, + 0 + ) ); } break; case HOLD: { - if(entityPoseActor != null){ - if(!entityPoseActor.isPlayingAnimation() || !entityPoseActor.isPlayingAnimation(animationName)){ - entityPoseActor.playAnimation( - animationName, - AnimationPriorities.getValue(AnimationPriorities.MOVEMENT_MODIFIER) - ); - entityPoseActor.incrementAnimationTime(0.0001); - } - } + this.stateTransitionUtil.simulate(AttackTreeState.HOLD); if(!stillHold){ setState(AttackTreeState.ATTACK); + this.stateTransitionUtil.interrupt(AttackTreeState.HOLD); } } break; case ATTACK: { - if(entityPoseActor != null && currentMove != null){ - if(!entityPoseActor.isPlayingAnimation() || !entityPoseActor.isPlayingAnimation(currentMove.getAnimationAttack())){ - entityPoseActor.playAnimation(currentMove.getAnimationAttack()); - entityPoseActor.incrementAnimationTime(0.0001); - } - } + this.stateTransitionUtil.simulate(AttackTreeState.ATTACK); //activate hitboxes List attachedEntities = AttachUtils.getChildrenList(parent); for(Entity currentAttached : attachedEntities){ @@ -310,9 +367,6 @@ public class ServerAttackTree implements BehaviorTree { ProjectileUtils.serverSpawnBasicProjectile(parentRealm, projectileToFire, spawnPosition, arrowRotation, 750, initialVector, 0.03f); projectileToFire = null; } - if(frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames()){ - setState(AttackTreeState.COOLDOWN); - } Globals.server.broadcastMessage( EntityMessage.constructattackUpdateMessage( parent.getId(), @@ -329,6 +383,7 @@ public class ServerAttackTree implements BehaviorTree { ); } break; case COOLDOWN: { + this.stateTransitionUtil.simulate(AttackTreeState.COOLDOWN); //deactive hitboxes List attachedEntities = AttachUtils.getChildrenList(parent); for(Entity currentAttached : attachedEntities){ @@ -339,6 +394,7 @@ public class ServerAttackTree implements BehaviorTree { } if(frameCurrent > currentMove.getWindupFrames() + currentMove.getAttackFrames() + currentMove.getCooldownFrames()){ setState(AttackTreeState.IDLE); + this.stateTransitionUtil.interrupt(AttackTreeState.COOLDOWN); frameCurrent = 0; if(parent.containsKey(EntityDataStrings.SERVER_ROTATOR_TREE)){ ServerRotatorTree.getServerRotatorTree(parent).setActive(false); 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 9b4c5ffe..ed26f9f6 100644 --- a/src/main/java/electrosphere/game/data/creature/type/CreatureDataValidator.java +++ b/src/main/java/electrosphere/game/data/creature/type/CreatureDataValidator.java @@ -84,9 +84,18 @@ public class CreatureDataValidator { List animations = new LinkedList(); if(data.getAttackMoves() != null){ for(AttackMove move : data.getAttackMoves()){ - animations.add(move.getAnimationAttack()); - animations.add(move.getAnimationHold()); - animations.add(move.getAnimationWindup()); + if(move.getWindupState() != null){ + animations.add(move.getWindupState().getAnimation()); + } + if(move.getHoldState() != null){ + animations.add(move.getHoldState().getAnimation()); + } + if(move.getAttackState() != null){ + animations.add(move.getAttackState().getAnimation()); + } + if(move.getCooldownState() != null){ + animations.add(move.getCooldownState().getAnimation()); + } } } if(data.getEquipPoints() != null){ diff --git a/src/main/java/electrosphere/game/data/creature/type/attack/AttackMove.java b/src/main/java/electrosphere/game/data/creature/type/attack/AttackMove.java index 1c461bd8..c12f3349 100644 --- a/src/main/java/electrosphere/game/data/creature/type/attack/AttackMove.java +++ b/src/main/java/electrosphere/game/data/creature/type/attack/AttackMove.java @@ -1,6 +1,6 @@ package electrosphere.game.data.creature.type.attack; -import electrosphere.game.data.common.TreeDataAnimation; +import electrosphere.game.data.common.TreeDataState; /** * Data about a single attack move this creature is capable of @@ -16,9 +16,10 @@ public class AttackMove { /* Animation stuff */ - TreeDataAnimation animationWindup; - TreeDataAnimation animationHold; - TreeDataAnimation animationAttack; + TreeDataState windupState; + TreeDataState holdState; + TreeDataState attackState; + TreeDataState cooldownState; /* Damage stuff @@ -61,27 +62,35 @@ public class AttackMove { } /** - * Gets the animation to play for the windup - * @return the animation + * Gets the state to play for the windup + * @return the state data */ - public TreeDataAnimation getAnimationWindup() { - return animationWindup; + public TreeDataState getWindupState() { + return windupState; } /** - * Gets the name of the animation to play for the hold - * @return the animation + * Gets the state to play for the hold + * @return the state data */ - public TreeDataAnimation getAnimationHold() { - return animationHold; + public TreeDataState getHoldState() { + return holdState; } /** - * Gets the animation to play for the attack - * @return the animation + * Gets the state to play for the attack + * @return the state data */ - public TreeDataAnimation getAnimationAttack() { - return animationAttack; + public TreeDataState getAttackState() { + return attackState; + } + + /** + * Gets the state to play for the cooldown + * @return the state data + */ + public TreeDataState getCooldownState() { + return cooldownState; } /**