Fixed compile errors / Refactored sector presets
This commit is contained in:
@@ -232,7 +232,6 @@ public class World extends Module{
|
||||
/**Loads up a sector map. This does not call play(), but calls reset().*/
|
||||
public void loadSector(Sector sector){
|
||||
currentSector = sector;
|
||||
state.mode = sector.mode;
|
||||
state.difficulty = sectors.getDifficulty(sector);
|
||||
Timers.mark();
|
||||
Timers.mark();
|
||||
|
||||
55
core/src/io/anuke/mindustry/maps/SectorPresets.java
Normal file
55
core/src/io/anuke/mindustry/maps/SectorPresets.java
Normal file
@@ -0,0 +1,55 @@
|
||||
package io.anuke.mindustry.maps;
|
||||
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.Mechs;
|
||||
import io.anuke.mindustry.content.blocks.UnitBlocks;
|
||||
import io.anuke.mindustry.content.blocks.UpgradeBlocks;
|
||||
import io.anuke.mindustry.entities.units.UnitCommand;
|
||||
import io.anuke.mindustry.maps.missions.*;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.ucore.util.GridMap;
|
||||
import io.anuke.ucore.util.Structs;
|
||||
|
||||
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));
|
||||
|
||||
//water mission
|
||||
put(-2, 0, new SectorPreset(Array.with(), Array.with(Items.copper), 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));
|
||||
//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));
|
||||
//oil mission
|
||||
put(1, 0, new SectorPreset(Array.with(), Array.with(Items.copper), 1));
|
||||
}};
|
||||
|
||||
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){
|
||||
this.missions = missions;
|
||||
this.ores = ores;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
void generate(Sector sector){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,17 +5,15 @@ import com.badlogic.gdx.graphics.Pixmap.Format;
|
||||
import com.badlogic.gdx.graphics.Texture;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import io.anuke.mindustry.content.Items;
|
||||
import io.anuke.mindustry.content.Mechs;
|
||||
import io.anuke.mindustry.content.blocks.UnitBlocks;
|
||||
import io.anuke.mindustry.content.blocks.UpgradeBlocks;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||
import io.anuke.mindustry.entities.units.UnitCommand;
|
||||
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.Mission;
|
||||
import io.anuke.mindustry.maps.missions.WaveMission;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.world.ColorMapper;
|
||||
@@ -24,7 +22,10 @@ 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.*;
|
||||
|
||||
@@ -33,24 +34,7 @@ public class Sectors{
|
||||
private static final boolean checkExpansion = false;
|
||||
|
||||
private final GridMap<Sector> grid = new GridMap<>();
|
||||
|
||||
private final GridMap<SectorPreset> presets = new GridMap<SectorPreset>(){{
|
||||
put(0, 0, new SectorPreset(TutorialSector.getMissions(), Array.with(Items.copper), 1));
|
||||
|
||||
//water mission
|
||||
put(-2, 0, new SectorPreset(Array.with(), Array.with(Items.copper), 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));
|
||||
//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));
|
||||
//oil mission
|
||||
put(1, 0, new SectorPreset(Array.with(), Array.with(Items.copper), 1));
|
||||
}};
|
||||
private final SectorPresets presets = new SectorPresets();
|
||||
|
||||
public void playSector(Sector sector){
|
||||
if(sector.hasSave() && SaveIO.breakingVersions.contains(sector.getSave().getBuild())){
|
||||
@@ -310,7 +294,7 @@ public class Sectors{
|
||||
private void initSector(Sector sector){
|
||||
sector.difficulty = (int)(Mathf.dst(sector.x, sector.y));
|
||||
|
||||
if(presets.containsKey(sector.x, sector.y)){
|
||||
if(presets.get(sector.x, sector.y) != null){
|
||||
SectorPreset p = presets.get(sector.x, sector.y);
|
||||
sector.missions.addAll(p.missions);
|
||||
}else{
|
||||
@@ -370,19 +354,5 @@ public class Sectors{
|
||||
pixmap.dispose();
|
||||
}
|
||||
|
||||
private class SectorPreset{
|
||||
private final Array<Mission> missions;
|
||||
private final Array<Item> ores;
|
||||
private final int size;
|
||||
|
||||
public SectorPreset(Array<Mission> missions, Array<Item> ores, int size){
|
||||
this.missions = missions;
|
||||
this.ores = ores;
|
||||
this.size = size;
|
||||
}
|
||||
|
||||
void generate(Sector sector){
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
package io.anuke.mindustry.maps.missions;
|
||||
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.type.Mech;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
@@ -12,11 +14,16 @@ public class MechMission extends Mission{
|
||||
|
||||
@Override
|
||||
public boolean isComplete(){
|
||||
for(Player player : Vars.playerGroup.all()){
|
||||
if(player.mech == mech){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String displayString(){
|
||||
return Bundles.format("te");
|
||||
return Bundles.format("text.mission.mech", mech.localizedName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,8 +12,7 @@ import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
|
||||
import static io.anuke.mindustry.Vars.headless;
|
||||
import static io.anuke.mindustry.Vars.ui;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public abstract class Mission{
|
||||
private String extraMessage;
|
||||
@@ -90,7 +89,9 @@ public abstract class Mission{
|
||||
return Array.with();
|
||||
}
|
||||
|
||||
public void generate(Generation gen){}
|
||||
public void generate(Generation gen){
|
||||
generateCoreAt(gen, gen.width/2, gen.height/2, defaultTeam);
|
||||
}
|
||||
|
||||
public void generateCoreAt(Generation gen, int coreX, int coreY, Team team){
|
||||
gen.tiles[coreX][coreY].setBlock(StorageBlocks.core);
|
||||
|
||||
Reference in New Issue
Block a user