LogoTravelers Lib

Animator

Animator

Basic Animation Example

public class ExampleAnimator<T extends SmartAnimalBase> extends TravelersAnimator<T> {
// Register a base controller into the Travelers System
public static final TravelersAnimationControllers.AnimationController base_controller = TravelersAnimationControllers.register("base_controller", 10);
public static final TravelersAnimationDefinition IDLE = new TravelersAnimationDefinition("animation.idle", base_controller, PlayBehaviourType.LOOP);
public static final TravelersAnimationDefinition WALK = new TravelersAnimationDefinition("animation.walk", base_controller, PlayBehaviourType.LOOP);
public static final TravelersAnimationDefinition HURT = new TravelersAnimationDefinition("animation.hurt", base_controller, PlayBehaviourType.PLAY_ONCE);
@Override
public void animate(SmartAnimalBase smartAnimalBase, TravelersMoveAnalysis travelersMoveAnalysis, TravelersAnimalAnimationModule travelersAnimalAnimationModule) {
if(travelersMoveAnalysis.isMoving()) {
WALK.sendForEntity(smartAnimalBase);
} else {
IDLE.sendForEntity(smartAnimalBase);
}
}
@Override
public void animateServer(T base, TravelersMoveAnalysis moveAnalysis, TravelersAnimalAnimationModule animationManager) {
if(base.getLastHurtByMob() != null) {
HURT.sendForEntity(base);
}
}
}

You also have access to the TravelersAnimalAnimationModule This is for an STATE-MACHINE esk animation system:

@Override
public void animateServer(ExampleEntity base, TravelersMoveAnalysis moveAnalysis, TravelersAnimalAnimationModule animationManager) {
// The wrap tells the transition how long an animation is (if an animation should loop, you don't need to give time in ticks)
if (animationManager.playTransition(base.isSleeping(), SLEEP_IN.wrap(63), SLEEP_LOOP.wrap(), SLEEP_OUT.wrap(39))) {
return;
}
// The wrap tells the transition how long an animation is (if an animation should loop, you don't need to give time in ticks)
if (animationManager.playTransition(base.isResting(), REST_IN.wrap(36), REST_LOOP.wrap(), REST_OUT.wrap(19))) {
return;
}
if (base.isDead()) return;
if (base.curInjuredTicks > 0) {
INJURED.sendForEntity(base);
}
}

We also provide support for client animators!

Client Animators

Client animators control the neck and tail code

We'll not be making an specific example for this, but i will show you an example from Jurassic Saga

// Only run this on the CLIENT side.
public static void init() {
TravelersAnimationMap.register(JP1Animals.DILOPHOSAURUS, new DilophosaurusAnimator());
}