Skip to content

Commit

Permalink
restart a TimedAnimationEntry if it is past its length and resumed.
Browse files Browse the repository at this point in the history
  • Loading branch information
birsy committed Nov 22, 2024
1 parent 141504c commit b120482
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,13 +89,16 @@ private TimedAnimationEntry(Animation<P, T> animation, int priority, int lengthI
}

public void begin() { this.time = 0; this.resume(); }
public void resume() { this.playing = true; }
public void resume() {
if (!this.playing && this.time > this.lengthInTicks) this.time = 0; // restart an animation if it is past its length and resumed.
this.playing = true;
}
public void rewind() { this.rewinding = true; }
public void stop() { this.playing = false; this.rewinding = false; }

private void updateTime(P parent, T skeleton) {
if (this.playing && this.animation.running(parent, skeleton, mixFactor, time)) this.time += (this.rewinding ? -1.0F : 1.0F) / lengthInTicks;
if ((this.time > 1 && !rewinding) || (time < 0 && rewinding)) this.stop();
if (this.playing && this.animation.running(parent, skeleton, mixFactor, time)) this.time += (this.rewinding ? -1.0F : 1.0F);
if ((this.time > lengthInTicks && !rewinding) || (time < 0 && rewinding)) this.stop();
}

@Override
Expand Down

0 comments on commit b120482

Please sign in to comment.