Skip to content

Commit

Permalink
WIP push
Browse files Browse the repository at this point in the history
  • Loading branch information
Trainguy9512 committed Mar 31, 2024
1 parent 07637f5 commit c417c21
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 12 deletions.
Expand Up @@ -104,7 +104,7 @@ public enum FPPlayerLocators {
public static final AnimationPoseSamplerKey<AnimationSequencePlayer> IDLE_SEQUENCE_PLAYER_ALT = AnimationPoseSamplerKey.of(() -> AnimationSequencePlayer.of(ANIMATION_FP_PLAYER_IDLE)
.setPlayRate(1)
.setStartTime(20)
.addPlayFromStartOnActiveStates(TEST_STATE_MACHINE, TestStates.MOVING)
.addProgressTimeOnActiveStates(TEST_STATE_MACHINE, TestStates.MOVING)
.build()).setIdentifier("idle_sequence_player").build();


Expand Down
Expand Up @@ -104,25 +104,39 @@ public float getTimeElapsed(){
}


//TODO: Make this part of the configuration

public void playFromStartOnStateActive(){
boolean statesActive = false;
for(AnimationPoseSamplerKey<? extends AnimationStateMachine<?>> animationStateMachineKey : this.playFromStartOnActiveStates.keySet()){
AnimationStateMachine<?> animationStateMachine = this.getAnimationDataContainer().getPoseSampler(animationStateMachineKey);

for(AnimationStateMachine.StateEnum stateEnum : this.playFromStartOnActiveStates.get(animationStateMachineKey)){
if(animationStateMachine.getActiveStates().contains(stateEnum)){
statesActive = true;
break;
public void playFromStartOnStateActive(){
if(!this.playFromStartOnActiveStates.isEmpty()) {
for (AnimationPoseSamplerKey<? extends AnimationStateMachine<?>> animationStateMachineKey : this.playFromStartOnActiveStates.keySet()) {
AnimationStateMachine<?> animationStateMachine = this.getAnimationDataContainer().getPoseSampler(animationStateMachineKey);

for (AnimationStateMachine.StateEnum stateEnum : this.playFromStartOnActiveStates.get(animationStateMachineKey)) {
if (animationStateMachine.getActiveStates().contains(stateEnum)) {
return;
}
}
}
}
if(!statesActive){
this.resetTime();
}
}

public void progressTimeIfStateActive(){
if(!this.progressTimeOnActiveStates.isEmpty()){
for(AnimationPoseSamplerKey<? extends AnimationStateMachine<?>> animationStateMachineKey : this.progressTimeOnActiveStates.keySet()){
AnimationStateMachine<?> animationStateMachine = this.getAnimationDataContainer().getPoseSampler(animationStateMachineKey);

for(AnimationStateMachine.StateEnum stateEnum : this.progressTimeOnActiveStates.get(animationStateMachineKey)){
if(animationStateMachine.getActiveStates().contains(stateEnum)){
this.playing = true;
return;
}
}
}
this.playing = false;
}
}

public <S extends AnimationStateMachine.StateEnum> void progressTimeIfStateActive(AnimationPoseSamplerKey<AnimationStateMachine<S>> animationStateMachineKey, S stateIdentifier){
this.progressTimeIfStateActive(animationStateMachineKey, List.of(stateIdentifier));
}
Expand All @@ -144,6 +158,7 @@ public <S extends AnimationStateMachine.StateEnum> void progressTimeIfStateActiv

@Override
public void tick(){
progressTimeIfStateActive();
if(this.getIsPlaying()){
this.timeElapsed += this.playRate;
}
Expand Down

0 comments on commit c417c21

Please sign in to comment.