Improved adaptability of layer generators

This commit is contained in:
josua 2019-08-28 20:27:07 +10:00
parent 230ae4846c
commit 341261f346
5 changed files with 8 additions and 18 deletions

View File

@ -104,9 +104,9 @@ public class EntityTnt extends EntityVertical
// Is this entity alive // Is this entity alive
if(e instanceof EntityAlive) if(e instanceof EntityAlive)
{ {
// Kill the entity // Add 1000 damage to the entity
killed_entities = true; killed_entities = true;
e.kill(); ((EntityAlive)e).removeHealth(10000);
} }
} }

View File

@ -126,7 +126,9 @@ public class Layer
// Create a unique seed specific to this chunk // Create a unique seed specific to this chunk
long cseed = new Random(pos.x).nextLong() + new Random(pos.y).nextLong() + seed; long cseed = new Random(pos.x).nextLong() + new Random(pos.y).nextLong() + seed;
chunks.set(pos, layergen.generateChunk(this, seed, new Random(cseed), pos)); Chunk chunk = new Chunk(this, pos, rand);
chunks.set(pos, chunk);
layergen.generateChunk(chunk, this, seed, new Random(cseed), pos);
} }
public void unloadChunk(Vec2i pos) { public void unloadChunk(Vec2i pos) {

View File

@ -9,7 +9,7 @@ import shootergame.world.layer.Layer;
public abstract class LayerGen implements IMap2D<Chunk> public abstract class LayerGen implements IMap2D<Chunk>
{ {
public abstract Chunk generateChunk(Layer layer, long seed, Random rand, Vec2i pos); public abstract void generateChunk(Chunk chunk, Layer layer, long seed, Random rand, Vec2i pos);
public abstract void spawnEntities(Layer layer, Random rand); public abstract void spawnEntities(Layer layer, Random rand);
@Override @Override

View File

@ -16,11 +16,8 @@ public class LayerGenCaves extends LayerGen
{ {
@Override @Override
public Chunk generateChunk(Layer layer, long seed, Random rand, Vec2i c_pos) public void generateChunk(Chunk chunk, Layer layer, long seed, Random rand, Vec2i c_pos)
{ {
// Create a new chunk
Chunk chunk = new Chunk(layer, c_pos, rand);
// Is there going to be a portal in this chunk // Is there going to be a portal in this chunk
boolean portal = RandomHelpers.randrange(rand, 10) == 0; boolean portal = RandomHelpers.randrange(rand, 10) == 0;
Vec2i portal_pos = null; Vec2i portal_pos = null;
@ -56,9 +53,6 @@ public class LayerGenCaves extends LayerGen
} }
} }
} }
// Send the chunk back
return chunk;
} }
@Override @Override

View File

@ -21,11 +21,8 @@ public class LayerGenEarth extends LayerGen
{ {
@Override @Override
public Chunk generateChunk(Layer layer, long seed, Random rand, Vec2i c_pos) public void generateChunk(Chunk chunk, Layer layer, long seed, Random rand, Vec2i c_pos)
{ {
// Create the new chunk
Chunk chunk = new Chunk(layer, c_pos, rand);
// Is there going to be a portal in this chunk // Is there going to be a portal in this chunk
boolean portal = RandomHelpers.randrange(rand, 10) == 0; boolean portal = RandomHelpers.randrange(rand, 10) == 0;
Vec2i portal_pos = null; Vec2i portal_pos = null;
@ -68,9 +65,6 @@ public class LayerGenEarth extends LayerGen
} }
} }
} }
// Send back the new chunk
return chunk;
} }
@Override @Override