Code cleanup

This commit is contained in:
Anuken
2018-10-06 11:56:39 -04:00
parent 0ce226d0c9
commit fd107ab5b8
48 changed files with 94 additions and 195 deletions

View File

@@ -159,7 +159,7 @@ public class Maps implements Disposable{
}
}else{
customMapNames = Settings.getObject("custom-maps", Array.class, () -> new Array<>());
customMapNames = Settings.getObject("custom-maps", Array.class, Array::new);
for(String name : customMapNames){
try{

View File

@@ -16,35 +16,42 @@ import static io.anuke.mindustry.Vars.mobile;
public class SectorPresets{
private final GridMap<SectorPreset> presets = new GridMap<SectorPreset>(){{
//base tutorial mission
put(0, 0, new SectorPreset(TutorialSector.getMissions(), Array.with(Items.copper), 1));
put(0, 0, new SectorPreset(TutorialSector.getMissions(), 1));
//water mission
put(-2, 0, new SectorPreset(Array.with(), Array.with(Items.copper), 1));
put(-2, 0, new SectorPreset(Array.with(), 1));
//command center mission
//TODO generate enemy base
//TODO make 2x2
//TODO more gen info
put(0, 1, new SectorPreset(Structs.array(new BlockMission(UnitBlocks.daggerFactory), Missions.blockRecipe(UnitBlocks.commandCenter),
new CommandMission(UnitCommand.retreat), new CommandMission(UnitCommand.attack), new BattleMission()), Array.with(Items.copper), 1));
new CommandMission(UnitCommand.retreat), new CommandMission(UnitCommand.attack), new BattleMission()), 2));
//reconstructor mission
put(0, -1, new SectorPreset(Structs.array(Missions.blockRecipe(mobile ? UpgradeBlocks.tridentPad : UpgradeBlocks.deltaPad),
new MechMission(Mechs.delta)), Array.with(Items.copper), 1));
new MechMission(Mechs.delta)), 1));
//oil mission
put(1, 0, new SectorPreset(Array.with(), Array.with(Items.copper), 1));
put(1, 0, new SectorPreset(Array.with(), 1));
}};
private final GridMap<Array<Item>> orePresets = new GridMap<Array<Item>>(){{
put(0, 0, Array.with(Items.copper));
put(1, 0, Array.with(Items.copper, Items.lead, Items.coal));
}};
public Array<Item> getOres(int x, int y){
return orePresets.get(x, y);
}
public SectorPreset get(int x, int y){
return presets.get(x, y);
}
public static class SectorPreset{
public final Array<Mission> missions;
public final Array<Item> ores;
public final int size;
public SectorPreset(Array<Mission> missions, Array<Item> ores, int size){
public SectorPreset(Array<Mission> missions, int size){
this.missions = missions;
this.ores = ores;
this.size = size;
}

View File

@@ -207,12 +207,7 @@ public class Sectors{
}
public Array<Item> getOres(int x, int y){
if(x == 0 && y == 0){
return Array.with(Items.copper);
}else if(x == 1 && y == 0){
return Array.with(Items.copper, Items.lead, Items.coal);
}
return Array.with(Items.copper);
return presets.getOres(x, y) == null ? Array.with(Items.copper) : presets.getOres(x, y);
}
/**Unlocks a sector. This shows nearby sectors.*/
@@ -263,7 +258,7 @@ public class Sectors{
}
grid.clear();
Array<Sector> out = Settings.getObject("sectors", Array.class, () -> new Array<>());
Array<Sector> out = Settings.getObject("sectors", Array.class, Array::new);
for(Sector sector : out){
createTexture(sector);
@@ -297,6 +292,7 @@ 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;
}else{
genMissions(sector);
}