Soul animation stages

- Kinda cursed state machine but it works, good start for future iteration
 - Adjust the timings
This commit is contained in:
JozsefA 2021-06-26 15:20:09 -07:00
parent 45fe9ba61c
commit 80f38ef05f
73 changed files with 204 additions and 29 deletions

View file

@ -14,15 +14,15 @@ import net.minecraft.util.math.vector.Vector3f;
public class CustomRotationParticle extends SimpleAnimatedParticle {
protected boolean mirror;
protected int loopTicks;
protected int loopLength;
public CustomRotationParticle(ClientWorld worldIn, double x, double y, double z, IAnimatedSprite spriteSet, float yAccel) {
super(worldIn, x, y, z, spriteSet, yAccel);
}
public void selectSpriteLoopingWithAge(IAnimatedSprite sprite) {
int loopFrame = age % loopTicks;
this.setSprite(sprite.get(loopFrame, loopTicks));
int loopFrame = age % loopLength;
this.setSprite(sprite.get(loopFrame, loopLength));
}
public Quaternion getCustomRotation(ActiveRenderInfo camera, float partialTicks) {

View file

@ -20,8 +20,8 @@ public class SoulBaseParticle extends CustomRotationParticle {
this.animatedSprite = spriteSet;
this.particleScale = 0.5f;
this.setSize(this.particleScale,this.particleScale);
this.loopTicks = 16 + (int) (this.rand.nextFloat() * 2f - 1f);
this.maxAge = (int)(64.0F / (this.rand.nextFloat() * 0.36F + 0.64F));
this.loopLength = 16 + (int) (this.rand.nextFloat() * 2f - 1f);
this.maxAge = (int)(90.0F / (this.rand.nextFloat() * 0.36F + 0.64F));
this.selectSpriteLoopingWithAge(animatedSprite);
this.field_21507 = true; // disable movement
}

View file

@ -13,26 +13,59 @@ public class SoulParticle extends CustomRotationParticle {
private final IAnimatedSprite animatedSprite;
protected int startTicks;
protected int endTicks;
protected int numLoops;
protected int firstStartFrame = 0;
protected int startFrames = 17;
protected int firstLoopFrame = 17;
protected int loopFrames = 16;
protected int firstEndFrame = 33;
protected int endFrames = 20;
protected int totalFrames = 53;
protected int ticksPerFrame = 2;
protected AnimationStage animationStage;
public SoulParticle(ClientWorld worldIn, double x, double y, double z, double vx, double vy, double vz,
IAnimatedSprite spriteSet) {
super(worldIn, x, y, z, spriteSet, 0);
this.animatedSprite = spriteSet;
this.particleScale = 0.5f;
this.setSize(this.particleScale, this.particleScale);
this.loopTicks = 16 + (int) (this.rand.nextFloat() * 4f - 2f);
this.maxAge = (int)(64.0F / (this.rand.nextFloat() * 0.36F + 0.64F));
this.selectSpriteLoopingWithAge(animatedSprite);
this.loopLength = loopFrames + (int) (this.rand.nextFloat() * 4f - 2f);
this.startTicks = startFrames + (int) (this.rand.nextFloat() * 4f - 2f);
this.endTicks = endFrames + (int) (this.rand.nextFloat() * 4f - 2f);
this.numLoops = (int)(3.0F / (this.rand.nextFloat() * 0.36F + 0.64F));
this.setFrame(0);
this.field_21507 = true; // disable movement
this.mirror = this.rand.nextBoolean();
this.animationStage = new StartAnimation(this);
}
@Override
public void tick() {
if (this.age++ >= this.maxAge) {
this.animationStage.tick();
this.animationStage = animationStage.getNext();
if (animationStage == null)
this.setExpired();
} else {
this.selectSpriteLoopingWithAge(animatedSprite);
}
public void setFrame(int frame) {
if (frame >= 0 && frame < totalFrames)
this.setSprite(animatedSprite.get(frame, totalFrames));
}
@Override
@ -50,4 +83,107 @@ public class SoulParticle extends CustomRotationParticle {
return AllParticleTypes.SOUL.get();
}
}
public static abstract class AnimationStage {
protected final SoulParticle particle;
protected int ticks;
protected int animAge;
public AnimationStage(SoulParticle particle) {
this.particle = particle;
}
public void tick() {
ticks++;
if (ticks % particle.ticksPerFrame == 0)
animAge++;
}
public float getAnimAge() {
return (float) animAge;
}
public abstract AnimationStage getNext();
}
public static class StartAnimation extends AnimationStage {
public StartAnimation(SoulParticle particle) {
super(particle);
}
@Override
public void tick() {
super.tick();
particle.setFrame(particle.firstStartFrame + (int) (getAnimAge() / (float) particle.startTicks * particle.startFrames));
}
@Override
public AnimationStage getNext() {
if (animAge < particle.startTicks)
return this;
else
return new LoopAnimation(particle);
}
}
public static class LoopAnimation extends AnimationStage {
int loops;
public LoopAnimation(SoulParticle particle) {
super(particle);
}
@Override
public void tick() {
super.tick();
int loopTick = getLoopTick();
if (loopTick == 0) loops++;
particle.setFrame(particle.firstLoopFrame + loopTick);//(int) (((float) loopTick / (float) particle.loopLength) * particle.loopFrames));
}
private int getLoopTick() {
return animAge % particle.loopFrames;
}
@Override
public AnimationStage getNext() {
if (loops <= particle.numLoops)
return this;
else
return new EndAnimation(particle);
}
}
public static class EndAnimation extends AnimationStage {
public EndAnimation(SoulParticle particle) {
super(particle);
}
@Override
public void tick() {
super.tick();
particle.setFrame(particle.firstEndFrame + (int) ((getAnimAge() / (float) particle.endTicks) * particle.endFrames));
}
@Override
public AnimationStage getNext() {
if (animAge < particle.endTicks)
return this;
else
return null;
}
}
}

View file

@ -1,20 +1,59 @@
{
"textures": [
"create:soul_particle_0",
"create:soul_particle_1",
"create:soul_particle_2",
"create:soul_particle_3",
"create:soul_particle_4",
"create:soul_particle_5",
"create:soul_particle_6",
"create:soul_particle_7",
"create:soul_particle_8",
"create:soul_particle_9",
"create:soul_particle_10",
"create:soul_particle_11",
"create:soul_particle_12",
"create:soul_particle_13",
"create:soul_particle_14",
"create:soul_particle_15"
"create:soul_sprite_start_1",
"create:soul_sprite_start_2",
"create:soul_sprite_start_3",
"create:soul_sprite_start_4",
"create:soul_sprite_start_5",
"create:soul_sprite_start_6",
"create:soul_sprite_start_7",
"create:soul_sprite_start_8",
"create:soul_sprite_start_9",
"create:soul_sprite_start_10",
"create:soul_sprite_start_11",
"create:soul_sprite_start_12",
"create:soul_sprite_start_13",
"create:soul_sprite_start_14",
"create:soul_sprite_start_15",
"create:soul_sprite_start_16",
"create:soul_sprite_start_17",
"create:soul_sprite_anim_1",
"create:soul_sprite_anim_2",
"create:soul_sprite_anim_3",
"create:soul_sprite_anim_4",
"create:soul_sprite_anim_5",
"create:soul_sprite_anim_6",
"create:soul_sprite_anim_7",
"create:soul_sprite_anim_8",
"create:soul_sprite_anim_9",
"create:soul_sprite_anim_10",
"create:soul_sprite_anim_11",
"create:soul_sprite_anim_12",
"create:soul_sprite_anim_13",
"create:soul_sprite_anim_14",
"create:soul_sprite_anim_15",
"create:soul_sprite_anim_16",
"create:soul_sprite_end_1",
"create:soul_sprite_end_2",
"create:soul_sprite_end_3",
"create:soul_sprite_end_4",
"create:soul_sprite_end_5",
"create:soul_sprite_end_6",
"create:soul_sprite_end_7",
"create:soul_sprite_end_8",
"create:soul_sprite_end_9",
"create:soul_sprite_end_10",
"create:soul_sprite_end_11",
"create:soul_sprite_end_12",
"create:soul_sprite_end_13",
"create:soul_sprite_end_14",
"create:soul_sprite_end_15",
"create:soul_sprite_end_16",
"create:soul_sprite_end_17",
"create:soul_sprite_end_18",
"create:soul_sprite_end_19",
"create:soul_sprite_end_20"
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 298 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 310 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 351 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 367 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 376 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 331 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 311 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 320 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 305 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 316 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 327 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 307 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 323 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 252 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 247 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 250 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 249 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 237 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 235 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 192 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 176 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 154 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 141 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 267 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 263 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 251 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 244 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 242 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 241 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 133 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 258 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 256 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 290 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 279 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 264 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 151 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 200 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 209 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 220 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 238 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 246 B