87 lines
1.8 KiB
Java
Executable File
87 lines
1.8 KiB
Java
Executable File
package projectzombie.entity.particle;
|
|
|
|
import java.util.Random;
|
|
|
|
import gl_engine.MathHelpers;
|
|
import gl_engine.vec.Vec2d;
|
|
import gl_engine.vec.Vec3d;
|
|
import projectzombie.entity.Entity;
|
|
import projectzombie.entity.EntityContainer;
|
|
import projectzombie.entity.EntityHeight;
|
|
import projectzombie.entity.EntityParticle;
|
|
import projectzombie.init.Models;
|
|
import projectzombie.model.Model;
|
|
import projectzombie.util.math.random.RandomHelpers;
|
|
import projectzombie.world.chunk.Chunk;
|
|
import projectzombie.world.layer.Layer;
|
|
|
|
public class ParticleBlood extends EntityParticle implements EntityHeight
|
|
{
|
|
private boolean done = false;
|
|
private double time = 1000;
|
|
private double height = 0;
|
|
private Vec3d velocity;
|
|
|
|
@Override
|
|
public double getHeight() {
|
|
return height;
|
|
}
|
|
|
|
@Override
|
|
public void setHeight(double height) {
|
|
this.height = height;
|
|
}
|
|
|
|
public ParticleBlood(Vec2d pos) {
|
|
super(pos);
|
|
|
|
time = RandomHelpers.randrange(rand, 800, 1200);
|
|
velocity = new Vec3d(MathHelpers.moveTowards2(0.01, rand.nextDouble() * 360), rand.nextDouble() * 0.12);
|
|
}
|
|
|
|
public static EntityContainer createBloodParticles(Vec2d pos, int size)
|
|
{
|
|
Entity[] entities = new Entity[size];
|
|
|
|
for(int i=0;i<entities.length;i++) {
|
|
entities[i] = new ParticleBlood(pos.copy());
|
|
}
|
|
|
|
return new EntityContainer(pos.copy(), entities);
|
|
}
|
|
|
|
@Override
|
|
public void tick(Chunk chunk, Layer layer)
|
|
{
|
|
// Call super
|
|
super.tick(chunk, layer);
|
|
|
|
if(DISABLED || time < 0) {
|
|
kill();
|
|
return;
|
|
}
|
|
|
|
// Remove some time
|
|
time -= 1;
|
|
|
|
if(done) {
|
|
return;
|
|
}
|
|
|
|
// Move in the velocity and remove some of it
|
|
pos.x += velocity.x;
|
|
pos.y += velocity.y;
|
|
height += velocity.z;
|
|
velocity.z -= MathHelpers.FallSpeed;
|
|
if(height < 0) {
|
|
velocity = new Vec3d(0, 0, 0);
|
|
height = 0;
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public Model getModel() {
|
|
return Models.PARTICLE_BLOOD;
|
|
}
|
|
}
|