mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-11 11:17:11 +07:00
Better spawn selection
This commit is contained in:
parent
196a9dd77e
commit
ad45bebbdc
@ -97,7 +97,7 @@ public class WaveSpawner{
|
||||
for(Tile tile : spawns){
|
||||
float angle = Angles.angle(tile.x, tile.y, world.width()/2, world.height()/2);
|
||||
|
||||
float trns = (world.width() + world.height()) * tilesize;
|
||||
float trns = Math.max(world.width(), world.height()) * Mathf.sqrt2 * tilesize;
|
||||
float spawnX = Mathf.clamp(world.width() * tilesize / 2f + Angles.trnsx(angle, trns), -margin, world.width() * tilesize + margin);
|
||||
float spawnY = Mathf.clamp(world.height() * tilesize / 2f + Angles.trnsy(angle, trns), -margin, world.height() * tilesize + margin);
|
||||
cons.get(spawnX, spawnY);
|
||||
|
@ -112,7 +112,8 @@ public class Blocks implements ContentList{
|
||||
{
|
||||
variants = 0;
|
||||
}
|
||||
public void draw(){}
|
||||
@Override
|
||||
public void drawBase(Tile tile){}
|
||||
};
|
||||
|
||||
cliff = new Cliff("cliff");
|
||||
|
@ -42,12 +42,13 @@ public class Fx{
|
||||
Tmp.v1.set(e.x, e.y).interpolate(Tmp.v2.set(to), e.fin(), Interpolation.pow3)
|
||||
.add(Tmp.v2.sub(e.x, e.y).nor().rotate90(1).scl(Mathf.randomSeedRange(e.id, 1f) * e.fslope() * 10f));
|
||||
float x = Tmp.v1.x, y = Tmp.v1.y;
|
||||
float size = Math.min(0.8f + e.rotation / 5f, 2);
|
||||
|
||||
stroke(e.fslope() * 2f, Pal.accent);
|
||||
Lines.circle(x, y, e.fslope() * 2f);
|
||||
stroke(e.fslope() * 2f * size, Pal.accent);
|
||||
Lines.circle(x, y, e.fslope() * 2f * size);
|
||||
|
||||
color(e.color);
|
||||
Fill.circle(x, y, e.fslope() * 1.5f);
|
||||
Fill.circle(x, y, e.fslope() * 1.5f * size);
|
||||
}),
|
||||
|
||||
lightning = new Effect(10f, 500f, e -> {
|
||||
|
@ -251,7 +251,7 @@ public class Control implements ApplicationListener, Loadable{
|
||||
ui.planet.hide();
|
||||
SaveSlot slot = sector.save;
|
||||
//TODO comment for new sector states
|
||||
//slot = null;
|
||||
slot = null;
|
||||
if(slot != null){
|
||||
try{
|
||||
net.reset();
|
||||
|
@ -69,26 +69,26 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
@Remote(called = Loc.server, unreliable = true)
|
||||
public static void transferItemEffect(Item item, float x, float y, Itemsc to){
|
||||
if(to == null) return;
|
||||
createItemTransfer(item, x, y, to, null);
|
||||
createItemTransfer(item, 1, x, y, to, null);
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server, unreliable = true)
|
||||
public static void transferItemToUnit(Item item, float x, float y, Itemsc to){
|
||||
if(to == null) return;
|
||||
createItemTransfer(item, x, y, to, () -> to.addItem(item));
|
||||
createItemTransfer(item, 1, x, y, to, () -> to.addItem(item));
|
||||
}
|
||||
|
||||
@Remote(called = Loc.server, unreliable = true)
|
||||
public static void transferItemTo(Item item, int amount, float x, float y, Tile tile){
|
||||
if(tile == null || tile.entity == null || tile.entity.items() == null) return;
|
||||
for(int i = 0; i < Mathf.clamp(amount / 3, 1, 8); i++){
|
||||
Time.run(i * 3, () -> createItemTransfer(item, x, y, tile, () -> {}));
|
||||
Time.run(i * 3, () -> createItemTransfer(item, amount, x, y, tile, () -> {}));
|
||||
}
|
||||
tile.entity.items().add(item, amount);
|
||||
}
|
||||
|
||||
public static void createItemTransfer(Item item, float x, float y, Position to, Runnable done){
|
||||
Fx.itemTransfer.at(x, y, 0, item.color, to);
|
||||
public static void createItemTransfer(Item item, int amount, float x, float y, Position to, Runnable done){
|
||||
Fx.itemTransfer.at(x, y, amount, item.color, to);
|
||||
if(done != null){
|
||||
Time.run(Fx.itemTransfer.lifetime, done);
|
||||
}
|
||||
@ -137,21 +137,17 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
int accepted = tile.acceptStack(item, amount, player.unit());
|
||||
player.unit().stack().amount -= accepted;
|
||||
|
||||
int sent = Mathf.clamp(accepted / 4, 1, 8);
|
||||
Block block = tile.block();
|
||||
|
||||
Core.app.post(() -> Events.fire(new DepositEvent(tile, player, item, accepted)));
|
||||
|
||||
for(int i = 0; i < sent; i++){
|
||||
tile.getStackOffset(item, stackTrns);
|
||||
tile.getStackOffset(item, stackTrns);
|
||||
|
||||
createItemTransfer(item, player.x() + Angles.trnsx(player.unit().rotation() + 180f, backTrns), player.y() + Angles.trnsy(player.unit().rotation() + 180f, backTrns),
|
||||
new Vec2(tile.x() + stackTrns.x, tile.y() + stackTrns.y), () -> {
|
||||
if(tile.block() != block || !tile.isValid() || tile.items() == null) return;
|
||||
|
||||
tile.handleStack(item, accepted, player.unit());
|
||||
});
|
||||
}
|
||||
createItemTransfer(
|
||||
item,
|
||||
amount,
|
||||
player.x() + Angles.trnsx(player.unit().rotation() + 180f, backTrns), player.y() + Angles.trnsy(player.unit().rotation() + 180f, backTrns),
|
||||
new Vec2(tile.x() + stackTrns.x, tile.y() + stackTrns.y),
|
||||
() -> tile.handleStack(item, accepted, player.unit())
|
||||
);
|
||||
}
|
||||
|
||||
@Remote(targets = Loc.both, called = Loc.server, forward = true)
|
||||
|
@ -125,7 +125,7 @@ public class TestPlanetGenerator extends PlanetGenerator{
|
||||
|
||||
float constraint = 1.3f;
|
||||
float radius = width / 2f / Mathf.sqrt3;
|
||||
int rooms = rand.random(2, 5);
|
||||
int rooms = rand.random(2, 5)/* - 1*/;
|
||||
Array<Room> array = new Array<>();
|
||||
|
||||
for(int i = 0; i < rooms; i++){
|
||||
@ -137,12 +137,40 @@ public class TestPlanetGenerator extends PlanetGenerator{
|
||||
array.add(new Room((int)rx, (int)ry, (int)rrad));
|
||||
}
|
||||
|
||||
//check positions on the map to place the player spawn. this needs to be in the corner of the map
|
||||
Room spawn = null;
|
||||
int offset = rand.nextInt(360);
|
||||
float length = width/2.55f - rand.random(13, 23);
|
||||
int angleStep = 5;
|
||||
int waterCheckRad = 5;
|
||||
for(int i = 0; i < 360; i+= angleStep){
|
||||
int angle = offset + i;
|
||||
int cx = (int)(width/2 + Angles.trnsx(angle, length));
|
||||
int cy = (int)(height/2 + Angles.trnsy(angle, length));
|
||||
|
||||
int waterTiles = 0;
|
||||
|
||||
//check for water presence
|
||||
for(int rx = -waterCheckRad; rx <= waterCheckRad; rx++){
|
||||
for(int ry = -waterCheckRad; ry <= waterCheckRad; ry++){
|
||||
Tile tile = tiles.get(cx + rx, cy + ry);
|
||||
if(tile == null || tile.floor().liquidDrop != null){
|
||||
waterTiles ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(waterTiles <= 4 || (i + angleStep >= 360)){
|
||||
array.add(spawn = new Room(cx, cy, rand.random(8, 15)));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for(Room room : array){
|
||||
erase(room.x, room.y, room.radius);
|
||||
}
|
||||
|
||||
int connections = rand.random(Math.max(rooms - 1, 1), rooms + 3);
|
||||
Room spawn = array.random(rand);
|
||||
for(int i = 0; i < connections; i++){
|
||||
array.random(rand).connect(array.random(rand));
|
||||
}
|
||||
@ -158,11 +186,9 @@ public class TestPlanetGenerator extends PlanetGenerator{
|
||||
|
||||
ores(ores);
|
||||
|
||||
for(Room other : array){
|
||||
if(other != spawn){
|
||||
// tiles.getn(other.x, other.y).setOverlay(Blocks.spawn);
|
||||
}
|
||||
}
|
||||
Room target = spawn;
|
||||
Room furthest = array.max(r -> Mathf.dst(r.x, r.y, target.x, target.y));
|
||||
tiles.getn(furthest.x, furthest.y).setOverlay(Blocks.spawn);
|
||||
|
||||
trimDark();
|
||||
|
||||
|
@ -89,7 +89,8 @@ public class Planet extends UnlockableContent{
|
||||
}
|
||||
}
|
||||
|
||||
sectors.get(sectors.size/2).unlocked = true;
|
||||
//for now
|
||||
sectors.each(s -> s.unlocked = true);
|
||||
}else{
|
||||
sectors = new Array<>();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user