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 80f453f1..0253fcc8 100644 --- a/src/main/java/electrosphere/entity/state/movement/groundmove/ClientGroundMovementTree.java +++ b/src/main/java/electrosphere/entity/state/movement/groundmove/ClientGroundMovementTree.java @@ -297,7 +297,7 @@ public class ClientGroundMovementTree implements BehaviorTree { //update rotation rotation.set(movementQuaternion); //play animation - String animationToPlay = determineCorrectAnimation(); + String animationToPlay = determineCorrectAnimation(MovementTreeState.STARTUP); if(entityActor != null){ if(!entityActor.isPlayingAnimation(animationToPlay)){ entityActor.playAnimation(animationToPlay,AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); @@ -334,7 +334,7 @@ public class ClientGroundMovementTree implements BehaviorTree { //update rotation rotation.set(movementQuaternion); //play animation - String animationToPlay = determineCorrectAnimation(); + String animationToPlay = determineCorrectAnimation(MovementTreeState.MOVE); if(entityActor != null){ if(!entityActor.isPlayingAnimation(animationToPlay)){ entityActor.playAnimation(animationToPlay,AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); @@ -367,8 +367,9 @@ public class ClientGroundMovementTree implements BehaviorTree { //update rotation rotation.set(movementQuaternion); //run slowdown code - String animationToPlay = determineCorrectAnimation(); + String animationToPlay = determineCorrectAnimation(MovementTreeState.SLOWDOWN); if(entityActor != null){ + //play animations if(!entityActor.isPlayingAnimation(animationToPlay)){ entityActor.playAnimation(animationToPlay,AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); entityActor.incrementAnimationTime(0.0001); @@ -377,6 +378,9 @@ public class ClientGroundMovementTree implements BehaviorTree { this.playedFootstepSecond = false; } FirstPersonTree.conditionallyPlayAnimation(parent, groundMovementData.getAnimationWindDown().getNameFirstPerson(), AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); + if(entityActor.isPlayingAnimation(determineCorrectAnimation(MovementTreeState.MOVE))){ + entityActor.stopAnimation(determineCorrectAnimation(MovementTreeState.MOVE)); + } } //conditionally play footstep audio this.playFootstepAudio(0,entityActor.getAnimationTime(animationToPlay),position); @@ -388,7 +392,7 @@ public class ClientGroundMovementTree implements BehaviorTree { velocity = 0; state = MovementTreeState.IDLE; if(entityActor != null){ - animationToPlay = determineCorrectAnimation(); + animationToPlay = determineCorrectAnimation(MovementTreeState.SLOWDOWN); if(entityActor.isPlayingAnimation() && entityActor.isPlayingAnimation(animationToPlay)){ entityActor.stopAnimation(animationToPlay); } @@ -526,7 +530,7 @@ public class ClientGroundMovementTree implements BehaviorTree { return facing; } - public String determineCorrectAnimation(){ + public String determineCorrectAnimation(MovementTreeState state){ String rVal = ""; if(sprintTree != null){ switch(sprintTree.getState()){ 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 3fdc83cf..b8ef3d1a 100644 --- a/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java +++ b/src/main/java/electrosphere/entity/state/movement/groundmove/ServerGroundMovementTree.java @@ -256,7 +256,7 @@ public class ServerGroundMovementTree implements BehaviorTree { switch(state){ case STARTUP: { if(poseActor != null){ - String animationToPlay = determineCorrectAnimation(); + String animationToPlay = determineCorrectAnimation(MovementTreeState.STARTUP); if( !poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(animationToPlay) && (jumpTree == null || !jumpTree.isJumping()) && @@ -311,7 +311,7 @@ public class ServerGroundMovementTree implements BehaviorTree { //check if can restart animation //if yes, restart animation if(poseActor != null){ - String animationToPlay = determineCorrectAnimation(); + String animationToPlay = determineCorrectAnimation(MovementTreeState.MOVE); if( !poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(animationToPlay) && (jumpTree == null || !jumpTree.isJumping()) && @@ -363,7 +363,7 @@ public class ServerGroundMovementTree implements BehaviorTree { case SLOWDOWN: { //run slowdown code if(poseActor != null){ - String animationToPlay = determineCorrectAnimation(); + String animationToPlay = determineCorrectAnimation(MovementTreeState.SLOWDOWN); if( !poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(animationToPlay) && (jumpTree == null || !jumpTree.isJumping()) && @@ -372,6 +372,9 @@ public class ServerGroundMovementTree implements BehaviorTree { poseActor.playAnimation(animationToPlay,AnimationPriorities.getValue(AnimationPriorities.CORE_MOVEMENT)); poseActor.incrementAnimationTime(0.0001); } + if(poseActor.isPlayingAnimation(determineCorrectAnimation(MovementTreeState.MOVE))){ + poseActor.stopAnimation(determineCorrectAnimation(MovementTreeState.MOVE)); + } } //velocity stuff velocity = velocity - acceleration * (float)Globals.timekeeper.getSimFrameTime(); @@ -380,7 +383,7 @@ public class ServerGroundMovementTree implements BehaviorTree { velocity = 0; state = MovementTreeState.IDLE; if(poseActor != null){ - String animationToPlay = determineCorrectAnimation(); + String animationToPlay = determineCorrectAnimation(MovementTreeState.SLOWDOWN); if(poseActor.isPlayingAnimation() && poseActor.isPlayingAnimation(animationToPlay)){ poseActor.stopAnimation(animationToPlay); } @@ -513,7 +516,7 @@ public class ServerGroundMovementTree implements BehaviorTree { return facing; } - public String determineCorrectAnimation(){ + public String determineCorrectAnimation(MovementTreeState state){ String rVal = ""; if(sprintTree != null){ switch(sprintTree.getState()){ diff --git a/src/main/java/electrosphere/server/datacell/physics/ServerHitboxResolutionCallback.java b/src/main/java/electrosphere/server/datacell/physics/ServerHitboxResolutionCallback.java index 98d2b86d..3c16060e 100644 --- a/src/main/java/electrosphere/server/datacell/physics/ServerHitboxResolutionCallback.java +++ b/src/main/java/electrosphere/server/datacell/physics/ServerHitboxResolutionCallback.java @@ -37,28 +37,35 @@ public class ServerHitboxResolutionCallback implements CollisionResolutionCallba HitboxState receiverShapeStatus = receiverState.getShapeStatus(receiverGeom); + boolean impactorShapeStatusIsNull = impactorShapeStatus == null; + boolean receiverShapeStatusIsNull = receiverShapeStatus == null; + boolean impactorIsHit = impactorShapeStatus != null && impactorShapeStatus.getType() == HitboxType.HIT; + boolean receiverIsHurt = receiverShapeStatus != null && receiverShapeStatus.getType() == HitboxType.HURT; + boolean receiverIsBlock = receiverShapeStatus != null && (receiverShapeStatus.getType() == HitboxType.BLOCK || (receiverShapeStatus.getType() == HitboxType.HIT && receiverShapeStatus.isBlockOverride())); + boolean parentsAreDifferent = AttachUtils.getParent(impactorParent) != receiverParent; + //currently, impactor needs to be an item, and the receiver must not be an item boolean isDamageEvent = - impactorShapeStatus != null && - receiverShapeStatus != null && - impactorShapeStatus.getType() == HitboxType.HIT && - receiverShapeStatus.getType() == HitboxType.HURT && - AttachUtils.getParent(impactorParent) != receiverParent + !impactorShapeStatusIsNull && + !receiverShapeStatusIsNull && + impactorIsHit && + receiverIsHurt && + parentsAreDifferent ; boolean isBlockEvent = - impactorShapeStatus != null && - receiverShapeStatus != null && - impactorShapeStatus.getType() == HitboxType.HIT && - (receiverShapeStatus.getType() == HitboxType.BLOCK || (receiverShapeStatus.getType() == HitboxType.HIT && receiverShapeStatus.isBlockOverride())) && - AttachUtils.getParent(impactorParent) != receiverParent + !impactorShapeStatusIsNull && + !receiverShapeStatusIsNull && + impactorIsHit && + receiverIsBlock && + parentsAreDifferent ; - if(impactorShapeStatus != null){ + if(!impactorShapeStatusIsNull){ impactorShapeStatus.setHadCollision(true); } - if(receiverShapeStatus != null){ + if(!receiverShapeStatusIsNull){ receiverShapeStatus.setHadCollision(true); }