Added water check
This commit is contained in:
Binary file not shown.
@@ -302,6 +302,10 @@ public class PlanetDialog extends FloatingDialog{
|
|||||||
|
|
||||||
stable.addButton("Launch", () -> {
|
stable.addButton("Launch", () -> {
|
||||||
if(selected != null){
|
if(selected != null){
|
||||||
|
if(selected.hasAttribute(SectorAttribute.naval)){
|
||||||
|
ui.showInfo("You need a naval loadout to launch here.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
control.playSector(selected);
|
control.playSector(selected);
|
||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,10 +10,12 @@ import mindustry.*;
|
|||||||
import mindustry.content.*;
|
import mindustry.content.*;
|
||||||
import mindustry.core.*;
|
import mindustry.core.*;
|
||||||
import mindustry.ctype.*;
|
import mindustry.ctype.*;
|
||||||
|
import mindustry.game.*;
|
||||||
import mindustry.net.Net;
|
import mindustry.net.Net;
|
||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
import mindustry.type.Sector.*;
|
import mindustry.type.Sector.*;
|
||||||
import mindustry.world.*;
|
import mindustry.world.*;
|
||||||
|
import mindustry.world.blocks.storage.CoreBlock.*;
|
||||||
|
|
||||||
import static mindustry.Vars.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -50,7 +52,7 @@ public class SectorDataGenerator{
|
|||||||
ObjectSet<Content> content = new ObjectSet<>();
|
ObjectSet<Content> content = new ObjectSet<>();
|
||||||
|
|
||||||
world.loadSector(sector);
|
world.loadSector(sector);
|
||||||
int waterFloors = 0, totalFloors = 0;
|
float waterFloors = 0, totalFloors = 0;
|
||||||
state.rules.sector = sector;
|
state.rules.sector = sector;
|
||||||
|
|
||||||
for(Tile tile : world.tiles){
|
for(Tile tile : world.tiles){
|
||||||
@@ -66,7 +68,7 @@ public class SectorDataGenerator{
|
|||||||
if(!tile.block().isStatic()){
|
if(!tile.block().isStatic()){
|
||||||
totalFloors ++;
|
totalFloors ++;
|
||||||
if(liquid == Liquids.water){
|
if(liquid == Liquids.water){
|
||||||
waterFloors ++;
|
waterFloors += tile.floor().isDeep() ? 1f : 0.5f;
|
||||||
}
|
}
|
||||||
floors.increment(tile.floor());
|
floors.increment(tile.floor());
|
||||||
if(tile.overlay() != Blocks.air){
|
if(tile.overlay() != Blocks.air){
|
||||||
@@ -75,6 +77,27 @@ public class SectorDataGenerator{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CoreEntity entity = Team.sharded.core();
|
||||||
|
int cx = entity.tileX(), cy = entity.tileY();
|
||||||
|
|
||||||
|
int nearTiles = 0;
|
||||||
|
int waterCheckRad = 5;
|
||||||
|
|
||||||
|
//check for water presence
|
||||||
|
for(int rx = -waterCheckRad; rx <= waterCheckRad; rx++){
|
||||||
|
for(int ry = -waterCheckRad; ry <= waterCheckRad; ry++){
|
||||||
|
Tile tile = world.tile(cx + rx, cy + ry);
|
||||||
|
if(tile == null || tile.floor().liquidDrop != null){
|
||||||
|
nearTiles ++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//naval sector guaranteed
|
||||||
|
if(nearTiles >= 4){
|
||||||
|
waterFloors = totalFloors;
|
||||||
|
}
|
||||||
|
|
||||||
//sort counts in descending order
|
//sort counts in descending order
|
||||||
Array<ObjectIntMap.Entry<Block>> entries = floors.entries().toArray();
|
Array<ObjectIntMap.Entry<Block>> entries = floors.entries().toArray();
|
||||||
entries.sort(e -> -e.value);
|
entries.sort(e -> -e.value);
|
||||||
@@ -91,8 +114,7 @@ public class SectorDataGenerator{
|
|||||||
data.resources = content.asArray().sort(Structs.comps(Structs.comparing(Content::getContentType), Structs.comparingInt(c -> c.id))).toArray(UnlockableContent.class);
|
data.resources = content.asArray().sort(Structs.comps(Structs.comparing(Content::getContentType), Structs.comparingInt(c -> c.id))).toArray(UnlockableContent.class);
|
||||||
|
|
||||||
//50% water -> naval attribute
|
//50% water -> naval attribute
|
||||||
//TODO also select sectors with water spawns
|
if(waterFloors / totalFloors >= 0.6f){
|
||||||
if((float)waterFloors / totalFloors >= 0.6f){
|
|
||||||
data.attributes |= (1 << SectorAttribute.naval.ordinal());
|
data.attributes |= (1 << SectorAttribute.naval.ordinal());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user