import Hexel.util.Util;
public class SpawnRules {
public static void addRules(final Engine engine, ArrayList<BlockRule> woodRules, ArrayList<BlockRule> dirtRules){
woodRules.add(new SpawnBlockRule(engine, 100){
@Override
public boolean blockMatches(int x, int y, int z, Block b, Chunk c, HighestBlockChunk hbc, Chunks chunks, int steps) {
return true;
}
@Override
public void spawn(double x, double y, double z, int bx, int by, int bz, int step, Chunk c, Chunks chunks) {
if (engine.thingSimulator.getNumberOfThingsOfType(Wanderer.class) < 10 && Math.random() < .001){
Wanderer wanderer = new Wanderer(x, y, z, engine.getThingBridge());
engine.addThing(wanderer);
}
}
});
dirtRules.add(new SpawnBlockRule(engine, 100){
private Vector3i tmp = new Vector3i();
@Override
public boolean blockMatches(int x, int y, int z, Block b, Chunk c, HighestBlockChunk hbc, Chunks chunks, int steps) {
Block ab = chunks.getBlock(x, y, z+1, tmp, c);
return ab instanceof BlockEmpty;
}
@Override
public void spawn(double x, double y, double z, int bx, int by, int bz, int step, Chunk c, Chunks chunks) {
if (engine.thingSimulator.getNumberOfThingsOfType(Deer.class) < 10){
Deer deer = new Deer(x, y, z, engine.getThingBridge());
engine.addThing(deer);
}
}
});
dirtRules.add(new SpawnBlockRule(engine, 100){
private Vector3i tmp = new Vector3i();
@Override
public boolean blockMatches(int x, int y, int z, Block b, Chunk c, HighestBlockChunk hbc, Chunks chunks, int steps) {