server plays blocking animation
Some checks failed
studiorailgun/Renderer/pipeline/head There was a failure building this commit

This commit is contained in:
austin 2024-07-31 18:49:18 -04:00
parent 91a84185c1
commit 92a6cefc20
4 changed files with 25 additions and 12 deletions

View File

@ -158,20 +158,24 @@ public class StateTransitionUtil {
if(state.getAnimation != null && state.getAnimation.get() != null){ if(state.getAnimation != null && state.getAnimation.get() != null){
animation = state.getAnimation.get(); animation = state.getAnimation.get();
} }
//Main simulation
if(!poseActor.isPlayingAnimation() && state.onComplete != null && state.startedAnimation == true && animation != null){ if(animation == null){
state.startedAnimation = true;
if(state.onComplete != null){
state.onComplete.run();
}
} else if(!poseActor.isPlayingAnimation() && state.onComplete != null && state.startedAnimation == true){
//state transition if this isn't set to loop //state transition if this isn't set to loop
state.onComplete.run(); state.onComplete.run();
state.startedAnimation = false; state.startedAnimation = false;
} else if(state.animation != null && (!poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(animation))){ } else if(!poseActor.isPlayingAnimation() || !poseActor.isPlayingAnimation(animation)){
//play animation for state //play animation for state
poseActor.playAnimation(animation); if(animation != null){
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){
state.onComplete.run();
state.startedAnimation = false;
} }
} }
} }

View File

@ -50,7 +50,13 @@ public class ServerBlockTree implements BehaviorTree {
this.stateTransitionUtil = StateTransitionUtil.create(parent, true, new StateTransitionUtilItem[]{ this.stateTransitionUtil = StateTransitionUtil.create(parent, true, new StateTransitionUtilItem[]{
StateTransitionUtilItem.create( StateTransitionUtilItem.create(
BlockState.WIND_UP, BlockState.WIND_UP,
() -> {return this.blockSystem.getBlockVariant(this.currentBlockVariant).getWindUpAnimation();}, () -> {
BlockVariant variant = this.blockSystem.getBlockVariant(this.currentBlockVariant);
if(variant != null){
return variant.getWindUpAnimation();
}
return null;
},
null, null,
() -> {this.setState(BlockState.BLOCKING);} () -> {this.setState(BlockState.BLOCKING);}
), ),

View File

@ -101,12 +101,15 @@ public class PoseActor {
/** /**
* Gets whether the animation is currently playing or not * Gets whether the animation is currently playing or not
* @param animationName The animation * @param animationData The animation
* @return True if the animation is playing, false otherwise * @return True if the animation is playing, false otherwise
*/ */
public boolean isPlayingAnimation(TreeDataAnimation animationName){ public boolean isPlayingAnimation(TreeDataAnimation animationData){
if(animationData == null){
return false;
}
for(ActorAnimationMask mask : animationQueue){ for(ActorAnimationMask mask : animationQueue){
if(mask.getAnimationName().contains(animationName.getNameThirdPerson())){ if(mask.getAnimationName().contains(animationData.getNameThirdPerson())){
return true; return true;
} }
} }