Removed all references to size
This commit is contained in:
@@ -217,7 +217,7 @@ public class World extends Module{
|
||||
|
||||
beginMapLoad();
|
||||
|
||||
int width = sectorSize * sector.width, height = sectorSize * sector.height;
|
||||
int width = sectorSize, height = sectorSize;
|
||||
|
||||
Tile[][] tiles = createTiles(width, height);
|
||||
|
||||
|
||||
@@ -26,8 +26,7 @@ public class SectorPresets{
|
||||
//base tutorial mission
|
||||
add(new SectorPreset(0, 0,
|
||||
TutorialSector.getMissions(),
|
||||
Array.with(Items.copper, Items.coal, Items.lead),
|
||||
1));
|
||||
Array.with(Items.copper, Items.coal, Items.lead)));
|
||||
|
||||
//command center mission
|
||||
add(new SectorPreset(0, 1,
|
||||
@@ -39,8 +38,7 @@ public class SectorPresets{
|
||||
new CommandMission(UnitCommand.attack),
|
||||
new BattleMission()
|
||||
),
|
||||
Array.with(Items.copper, Items.lead, Items.coal),
|
||||
2));
|
||||
Array.with(Items.copper, Items.lead, Items.coal)));
|
||||
|
||||
//pad mission
|
||||
add(new SectorPreset(0, -2,
|
||||
@@ -49,8 +47,7 @@ public class SectorPresets{
|
||||
new MechMission(mobile ? Mechs.alpha : Mechs.dart),
|
||||
new WaveMission(15)
|
||||
),
|
||||
Array.with(Items.copper, Items.lead, Items.coal, Items.titanium),
|
||||
2));
|
||||
Array.with(Items.copper, Items.lead, Items.coal, Items.titanium)));
|
||||
|
||||
//oil mission
|
||||
add(new SectorPreset(-2, 0,
|
||||
@@ -61,8 +58,7 @@ public class SectorPresets{
|
||||
Missions.blockRecipe(CraftingBlocks.biomatterCompressor),
|
||||
new ContentMission(Liquids.oil)
|
||||
),
|
||||
Array.with(Items.copper, Items.lead, Items.coal, Items.titanium),
|
||||
2));
|
||||
Array.with(Items.copper, Items.lead, Items.coal, Items.titanium)));
|
||||
}
|
||||
|
||||
public Array<Item> getOres(int x, int y){
|
||||
@@ -74,12 +70,8 @@ public class SectorPresets{
|
||||
}
|
||||
|
||||
private void add(SectorPreset preset){
|
||||
for(int x = 0; x < preset.size; x++){
|
||||
for(int y = 0; y < preset.size; y++){
|
||||
presets.put(x + preset.x, y + preset.y, preset);
|
||||
orePresets.put(x + preset.x, y + preset.y, preset.ores);
|
||||
}
|
||||
}
|
||||
presets.put(preset.x, preset.y, preset);
|
||||
orePresets.put(preset.x, preset.y, preset.ores);
|
||||
}
|
||||
|
||||
public static class SectorPreset{
|
||||
@@ -87,16 +79,11 @@ public class SectorPresets{
|
||||
public final Array<Item> ores;
|
||||
public final int x, y;
|
||||
|
||||
public SectorPreset(int x, int y, Array<Mission> missions, Array<Item> ores, int size){
|
||||
public SectorPreset(int x, int y, Array<Mission> missions, Array<Item> ores){
|
||||
this.missions = missions;
|
||||
this.size = size;
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.ores = ores;
|
||||
}
|
||||
|
||||
void generate(Sector sector){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,34 +3,33 @@ package io.anuke.mindustry.maps;
|
||||
import com.badlogic.gdx.graphics.Pixmap;
|
||||
import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.game.Difficulty;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.io.SaveIO;
|
||||
import io.anuke.mindustry.maps.SectorPresets.SectorPreset;
|
||||
import io.anuke.mindustry.maps.generation.WorldGenerator.GenResult;
|
||||
import io.anuke.mindustry.maps.missions.*;
|
||||
import io.anuke.mindustry.maps.missions.BattleMission;
|
||||
import io.anuke.mindustry.maps.missions.Mission;
|
||||
import io.anuke.mindustry.maps.missions.Missions;
|
||||
import io.anuke.mindustry.maps.missions.WaveMission;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.mindustry.world.blocks.defense.Wall;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.EntityGroup;
|
||||
import io.anuke.ucore.entities.trait.Entity;
|
||||
import io.anuke.ucore.util.*;
|
||||
import io.anuke.ucore.util.Bits;
|
||||
import io.anuke.ucore.util.GridMap;
|
||||
import io.anuke.ucore.util.Log;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Sectors{
|
||||
private static final int sectorImageSize = 32;
|
||||
private static final boolean checkExpansion = true;
|
||||
|
||||
private final GridMap<Sector> grid = new GridMap<>();
|
||||
private final SectorPresets presets = new SectorPresets();
|
||||
@@ -82,18 +81,6 @@ public class Sectors{
|
||||
return grid.get(Bits.getLeftShort(position), Bits.getRightShort(position));
|
||||
}
|
||||
|
||||
/**Returns whether a sector of this size and position can be fit here.*/
|
||||
public boolean canFit(int x, int y, int width, int height){
|
||||
for(int cx = x; cx < x + width; cx++){
|
||||
for(int cy = y; cy < y + height; cy++){
|
||||
if(grid.get(cx, cy) != null){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Difficulty getDifficulty(Sector sector){
|
||||
if(sector.difficulty == 0){
|
||||
//yes, this means hard tutorial difficulty
|
||||
@@ -163,24 +150,10 @@ public class Sectors{
|
||||
Array<Sector> out = Settings.getObject("sector-data", Array.class, Array::new);
|
||||
|
||||
for(Sector sector : out){
|
||||
short x = sector.x;
|
||||
short y = sector.y;
|
||||
int w = sector.width;
|
||||
int h = sector.height;
|
||||
|
||||
createTexture(sector);
|
||||
initSector(sector);
|
||||
|
||||
sector.x = x;
|
||||
sector.y = y;
|
||||
sector.width = w;
|
||||
sector.height = h;
|
||||
|
||||
for(int cx = 0; cx < sector.width; cx++){
|
||||
for(int cy = 0; cy < sector.height; cy++){
|
||||
grid.put(sector.x + cx, sector.y + cy, sector);
|
||||
}
|
||||
}
|
||||
grid.put(sector.x, sector.y, sector);
|
||||
}
|
||||
|
||||
if(out.size == 0){
|
||||
@@ -188,6 +161,11 @@ public class Sectors{
|
||||
}
|
||||
}
|
||||
|
||||
public void clear(){
|
||||
grid.clear();
|
||||
save();
|
||||
}
|
||||
|
||||
public void save(){
|
||||
Array<Sector> out = new Array<>();
|
||||
|
||||
@@ -207,7 +185,6 @@ public class Sectors{
|
||||
if(presets.get(sector.x, sector.y) != null){
|
||||
SectorPreset p = presets.get(sector.x, sector.y);
|
||||
sector.missions.addAll(p.missions);
|
||||
sector.width = sector.height = p.size;
|
||||
sector.x = (short)p.x;
|
||||
sector.y = (short)p.y;
|
||||
}else{
|
||||
@@ -237,42 +214,12 @@ public class Sectors{
|
||||
}
|
||||
|
||||
private void generate(Sector sector){
|
||||
int width = Mathf.randomSeed(sector.getSeed()+1, 1, 3);
|
||||
int height = Mathf.randomSeed(sector.getSeed()+2, 1, 3);
|
||||
int finalWidth = 1, finalHeight = 1;
|
||||
int finalX = sector.x, finalY = sector.y;
|
||||
|
||||
for(int x = 1; x <= width; x++){
|
||||
for(int y = 1; y <= height; y++){
|
||||
for(GridPoint2 point : Geometry.d8edge){
|
||||
int shiftx = (int)(-x/2f + (point.x * (x - 1))/2f), shifty = (int)(-y/2f + (point.y * (y - 1))/2f);
|
||||
if(canFit(sector.x + shiftx, sector.y + shifty, x, y)){
|
||||
finalWidth = x;
|
||||
finalHeight = y;
|
||||
finalX = sector.x + shiftx;
|
||||
finalY = sector.y + shifty;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sector.width = finalWidth;
|
||||
sector.height = finalHeight;
|
||||
sector.x = (short)finalX;
|
||||
sector.y = (short)finalY;
|
||||
|
||||
//recipe mission
|
||||
addRecipeMission(sector, 3);
|
||||
|
||||
//expand
|
||||
addExpandMission(sector, 16);
|
||||
|
||||
if((sector.width + sector.height) <= 3){
|
||||
sector.difficulty = Math.max(sector.difficulty - 3, 0);
|
||||
}
|
||||
|
||||
//50% chance to get a wave mission
|
||||
if(Mathf.randomSeed(sector.getSeed() + 6) < 0.5 || (sector.width + sector.height) <= 3){
|
||||
if(Mathf.randomSeed(sector.getSeed() + 6) < 0.5){
|
||||
sector.missions.add(new WaveMission(sector.difficulty*5 + Mathf.randomSeed(sector.getSeed(), 1, 4)*5));
|
||||
}else{
|
||||
sector.missions.add(new BattleMission());
|
||||
@@ -283,22 +230,10 @@ public class Sectors{
|
||||
|
||||
//possibly another battle mission
|
||||
if(Mathf.randomSeed(sector.getSeed() + 3) < 0.3){
|
||||
addExpandMission(sector, 20);
|
||||
sector.missions.add(new BattleMission());
|
||||
}
|
||||
}
|
||||
|
||||
private void addExpandMission(Sector sector, int offset){
|
||||
//add 0-1 expansion mission
|
||||
if(sector.missions.size > 0){
|
||||
int ex = sector.width >= 3 ? 0 : Mathf.randomSeed(sector.getSeed() + 6 + offset, -2, 2);
|
||||
int ey = sector.height >= 3 ? 0 : Mathf.randomSeed(sector.getSeed() + 7 + offset, -2, 2);
|
||||
if(ex != 0 || ey != 0){
|
||||
sector.missions.add(new ExpandMission(ex, ey));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addRecipeMission(Sector sector, int offset){
|
||||
//build list of locked recipes to add mission for obtaining it
|
||||
if(!headless && Mathf.randomSeed(sector.getSeed() + offset) < 0.5){
|
||||
@@ -323,7 +258,7 @@ public class Sectors{
|
||||
sector.texture.dispose();
|
||||
}
|
||||
|
||||
Pixmap pixmap = new Pixmap(sectorImageSize * sector.width, sectorImageSize * sector.height, Format.RGBA8888);
|
||||
Pixmap pixmap = new Pixmap(sectorImageSize, sectorImageSize, Format.RGBA8888);
|
||||
GenResult secResult = new GenResult();
|
||||
|
||||
for(int x = 0; x < pixmap.getWidth(); x++){
|
||||
|
||||
@@ -90,13 +90,7 @@ public class TutorialSector{
|
||||
new BlockLocMission(PowerBlocks.powerNode, 62, 54),
|
||||
|
||||
new UnitMission(UnitTypes.dagger).setMessage("$tutorial.dagger"),
|
||||
new ExpandMission(1, 0){
|
||||
@Override
|
||||
public void onComplete(){
|
||||
super.onComplete();
|
||||
generateBase();
|
||||
}
|
||||
},
|
||||
new ActionMission(TutorialSector::generateBase),
|
||||
new BattleMission(){
|
||||
public void generate(Generation gen){} //no
|
||||
public void onFirstBegin(){} //also no
|
||||
|
||||
@@ -60,7 +60,6 @@ public class FortressGenerator{
|
||||
|
||||
float difficultyScl = Mathf.clamp(gen.sector.difficulty / 20f + gen.random.range(0.25f), 0f, 0.9999f);
|
||||
float dscl2 = Mathf.clamp(0.5f + gen.sector.difficulty / 20f + gen.random.range(0.1f), 0f, 1.5f);
|
||||
int coreDst = FortressGenerator.coreDst*Math.min(gen.sector.width, gen.sector.height);
|
||||
|
||||
Array<Block> turrets = find(b -> b instanceof ItemTurret);
|
||||
Array<Block> powerTurrets = find(b -> b instanceof PowerTurret);
|
||||
|
||||
@@ -31,14 +31,8 @@ public class BattleMission extends Mission{
|
||||
}
|
||||
Tile core = state.teams.get(defaultTeam).cores.first();
|
||||
Generation gen = new Generation(world.getSector(), world.getTiles(), world.width(), world.height(), new SeedRandom(world.getSector().getSeed()-1));
|
||||
int ex = world.getSector().lastExpandX;
|
||||
int ey = world.getSector().lastExpandY;
|
||||
int enx = world.width() - 1 - spacing;
|
||||
int eny = world.height() - 1 - spacing;
|
||||
if(ex < 0) enx = spacing*gen.sector.width;
|
||||
if(ex > 0) enx = world.width() - 1 - spacing*gen.sector.width;
|
||||
if(ey < 0) eny = spacing*gen.sector.height;
|
||||
if(ey > 0) eny = world.height() - 1 - spacing*gen.sector.height;
|
||||
new FortressGenerator().generate(gen, Team.red, core.x, core.y, enx, eny);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,49 +0,0 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
/**An action mission which simply expands the sector.*/
|
||||
public class ExpandMission extends ActionMission{
|
||||
private boolean done = false;
|
||||
private final int expandX, expandY;
|
||||
|
||||
public ExpandMission(int expandX, int expandY){
|
||||
this.expandX = expandX;
|
||||
this.expandY = expandY;
|
||||
|
||||
runner = () -> {
|
||||
if(headless){
|
||||
world.sectors.expandSector(world.getSector(), expandX, expandY);
|
||||
done = true;
|
||||
}else{
|
||||
ui.loadLogic(() -> {
|
||||
world.sectors.expandSector(world.getSector(), expandX, expandY);
|
||||
done = true;
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFirstBegin(){
|
||||
runner.run();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isComplete(){
|
||||
return done;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onComplete(){
|
||||
done = false;
|
||||
}
|
||||
|
||||
public int getExpandX(){
|
||||
return expandX;
|
||||
}
|
||||
|
||||
public int getExpandY(){
|
||||
return expandY;
|
||||
}
|
||||
}
|
||||
@@ -133,8 +133,8 @@ public class SectorsDialog extends FloatingDialog{
|
||||
float drawY = y + height/2f + sectorY * padSectorSize - offsetY * padSectorSize - panY % padSectorSize;
|
||||
|
||||
Sector sector = world.sectors.get(sectorX, sectorY);
|
||||
int width = (sector == null ? 1 : sector.width);
|
||||
int height = (sector == null ? 1 : sector.height);
|
||||
int width = 1;
|
||||
int height = 1;
|
||||
float paddingx = (width-1) * sectorPadding;
|
||||
float paddingy = (height-1) * sectorPadding;
|
||||
|
||||
|
||||
@@ -151,9 +151,7 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
dialog.addCloseButton();
|
||||
dialog.content().addButton("$text.settings.clearsectors", "clear", () -> {
|
||||
ui.showConfirm("$text.confirm", "$text.settings.clear.confirm", () -> {
|
||||
Settings.clearBytes("sectors");
|
||||
Settings.save();
|
||||
world.sectors.load();
|
||||
world.sectors.clear();
|
||||
dialog.hide();
|
||||
});
|
||||
});
|
||||
@@ -161,7 +159,6 @@ public class SettingsMenuDialog extends SettingsDialog{
|
||||
dialog.content().addButton("$text.settings.clearunlocks", "clear", () -> {
|
||||
ui.showConfirm("$text.confirm", "$text.settings.clear.confirm", () -> {
|
||||
control.unlocks.reset();
|
||||
Settings.save();
|
||||
dialog.hide();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user