AntSim/src/antsim/entity/EntityFood.java

67 lines
872 B
Java

package antsim.entity;
import antsim.init.Models;
import antsim.model.Model;
import antsim.start.Start;
import bdf.types.BdfObject;
import gl_engine.vec.Vec2d;
public class EntityFood extends Entity implements EntityEdible
{
private int age;
public EntityFood(Vec2d pos) {
this.pos = pos;
this.age = 6000; // Stay for a minute
}
public EntityFood(BdfObject bdf) {
loadBDF(bdf);
}
@Override
public Model getModel() {
return Models.FOOD;
}
@Override
public boolean isEdible(Entity entity) {
return true;
}
@Override
public Vec2d getPos() {
return pos;
}
@Override
public void update()
{
super.update();
if(!Start.isServer) {
return;
}
age -= 1;
if(age <= 0) {
kill();
}
}
@Override
public double getWeight() {
return 1;
}
@Override
public boolean onEaten()
{
kill();
return true;
}
}