this.thingsToAdd.add(thing);
}
public void step(double fps) {
Vector3i tmp = Resources.vector3iResourcePool.aquire();
Vector3d tmp3d = Resources.vector3dResourcePool.aquire();
Vector2i tmp2 = Resources.vector2iResourcePool.aquire();
synchronized (this.things){
thingsToRemove.clear();
for (Thing t : this.thingsToAdd){
this.things.add(t);
if (t instanceof Player)
this.thingBridge.player = (Player)t;
}
this.thingsToAdd.clear();
Iterator<Thing> iter = this.things.iterator();
LogData.set("numberZombies", getNumberOfThingsOfType(Zombie.class));
while (iter.hasNext()) {
Thing thing = iter.next();
thing.step();
if (thing instanceof Volumetric){
if (this.thingTools.isOutOfRangeOfCamera((Volumetric)thing)){
thingsToRemove.add(thing);
continue;
}
}
if (thing instanceof Player){
Player player = (Player)thing;
player.hunger -= 1.0/(60*60*10);
if (player.isDead() && engine.camera == player){
LinearCamera fc = new LinearCamera(player.getCameraX(), player.getCameraY(), player.getCameraZ(), 0, 0,
0, 0, .01, 0, 0);
engine.addThing(fc);
engine.setCamera(fc);
}
}
else if (thing instanceof Zombie){
Zombie zombie = (Zombie)thing;
if (zombie.health <= 0){
thingsToRemove.add(zombie);
}
}
else if (thing instanceof Deer){
Deer deer = (Deer)thing;
if (deer.health <= 0){
thingsToRemove.add(deer);
}
}
if (thing instanceof Movable) {
Movable movable = (Movable) thing;
movable.accelerate(fps, 0, 0, -9.8);
Vector3d reqMoveVector = movable.getReqMoveVector(fps);
moveMovable(movable, reqMoveVector, tmp);
}
if (thing instanceof BlockManipulator) {
BlockAction action = ((BlockManipulator) thing)
.getBlockAction();
if (action instanceof AddBlock) {
AddBlock addBlockAction = (AddBlock) action;
Block original = this.chunks.getBlock(addBlockAction.x, addBlockAction.y, addBlockAction.z, tmp, (Chunk)null);
this.chunks.setBlock(addBlockAction.x, addBlockAction.y, addBlockAction.z, addBlockAction.block, tmp, tmp2, null);
if (thing instanceof Volumetric) {
if (thing instanceof Cuboid) {
Vector3d offset = Resources.vector3dResourcePool.aquire();
offset.x = 0;
offset.y = 0;
offset.z = 0;
if (this.thingTools.fixOffset((Cuboid) thing,
offset, false, this.fixOffsetTmps) != null)