Functional presets
This commit is contained in:
@@ -9,7 +9,7 @@ import mindustry.type.*;
|
||||
public class Planets implements ContentList{
|
||||
public static Planet
|
||||
sun,
|
||||
starter;
|
||||
starter; //TODO rename
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
@@ -31,6 +31,7 @@ public class Planets implements ContentList{
|
||||
);
|
||||
}};
|
||||
|
||||
//TODO rename
|
||||
starter = new Planet("TODO", sun, 3, 1){{
|
||||
generator = new TODOPlanetGenerator();
|
||||
meshLoader = () -> new HexMesh(this, 6);
|
||||
|
||||
+7
-8
@@ -1,15 +1,13 @@
|
||||
package mindustry.content;
|
||||
|
||||
import mindustry.ctype.*;
|
||||
import mindustry.game.Objectives.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
import static arc.struct.Array.with;
|
||||
import static mindustry.content.Items.*;
|
||||
import static mindustry.content.Items.copper;
|
||||
import static mindustry.content.Planets.starter;
|
||||
import static mindustry.type.ItemStack.list;
|
||||
|
||||
public class Zones implements ContentList{
|
||||
public class SectorPresets implements ContentList{
|
||||
public static SectorPreset
|
||||
groundZero, desertWastes,
|
||||
craters, frozenForest, ruinousShores, stainedMountains, tarFields, fungalPass,
|
||||
@@ -19,7 +17,7 @@ public class Zones implements ContentList{
|
||||
@Override
|
||||
public void load(){
|
||||
|
||||
groundZero = new SectorPreset("groundZero", starter){{
|
||||
groundZero = new SectorPreset("groundZero", starter, 15){{
|
||||
baseLaunchCost = list(copper, -60);
|
||||
startingItems = list(copper, 60);
|
||||
alwaysUnlocked = true;
|
||||
@@ -80,6 +78,7 @@ public class Zones implements ContentList{
|
||||
);
|
||||
}};*/
|
||||
|
||||
/*
|
||||
saltFlats = new SectorPreset("saltFlats", starter){{
|
||||
startingItems = list(copper, 200, Items.silicon, 200, lead, 200);
|
||||
loadout = Loadouts.basicFoundation;
|
||||
@@ -194,7 +193,7 @@ public class Zones implements ContentList{
|
||||
);
|
||||
}};
|
||||
|
||||
/*
|
||||
|
||||
crags = new Zone("crags", new MapGenerator("crags").dist(2f)){{
|
||||
loadout = Loadouts.basicFoundation;
|
||||
baseLaunchCost = ItemStack.with();
|
||||
@@ -204,7 +203,7 @@ public class Zones implements ContentList{
|
||||
requirements = with(stainedMountains, 40);
|
||||
blockRequirements = new Block[]{Blocks.thermalGenerator};
|
||||
resources = Array.with(Items.copper, Items.scrap, Items.lead, Items.coal, Items.sand};
|
||||
}};*/
|
||||
}};
|
||||
|
||||
nuclearComplex = new SectorPreset("nuclearComplex", starter){{
|
||||
loadout = Loadouts.basicNucleus;
|
||||
@@ -218,7 +217,7 @@ public class Zones implements ContentList{
|
||||
);
|
||||
}};
|
||||
|
||||
/*
|
||||
|
||||
impact0078 = new SectorPreset("impact0078"){{
|
||||
loadout = Loadouts.basicNucleus;
|
||||
baseLaunchCost = ItemStack.list();
|
||||
@@ -40,7 +40,7 @@ public class ContentLoader{
|
||||
new TechTree(),
|
||||
new Weathers(),
|
||||
new Planets(),
|
||||
new Zones()
|
||||
new SectorPresets()
|
||||
};
|
||||
|
||||
public ContentLoader(){
|
||||
@@ -267,7 +267,7 @@ public class ContentLoader{
|
||||
}
|
||||
|
||||
public Array<SectorPreset> zones(){
|
||||
return getBy(ContentType.zone);
|
||||
return getBy(ContentType.sector);
|
||||
}
|
||||
|
||||
public Array<UnitType> units(){
|
||||
|
||||
@@ -427,6 +427,7 @@ public class World{
|
||||
}
|
||||
|
||||
private class Context implements WorldContext{
|
||||
|
||||
@Override
|
||||
public Tile tile(int index){
|
||||
return tiles.geti(index);
|
||||
|
||||
@@ -11,7 +11,7 @@ public enum ContentType{
|
||||
unit,
|
||||
weather,
|
||||
effect_UNUSED,
|
||||
zone,
|
||||
sector,
|
||||
loadout_UNUSED,
|
||||
typeid_UNUSED,
|
||||
error,
|
||||
|
||||
@@ -91,7 +91,7 @@ public class JsonIO{
|
||||
|
||||
@Override
|
||||
public SectorPreset read(Json json, JsonValue jsonData, Class type){
|
||||
return Vars.content.getByName(ContentType.zone, jsonData.asString());
|
||||
return Vars.content.getByName(ContentType.sector, jsonData.asString());
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -22,9 +22,10 @@ public class FileMapGenerator implements WorldGenerator{
|
||||
|
||||
@Override
|
||||
public void generate(Tiles tiles){
|
||||
tiles.fill();
|
||||
|
||||
SaveIO.load(map.file);
|
||||
world.beginMapLoad();
|
||||
|
||||
tiles = world.tiles;
|
||||
|
||||
for(Tile tile : tiles){
|
||||
if(tile.block() instanceof StorageBlock && !(tile.block() instanceof CoreBlock) && state.hasSector()){
|
||||
@@ -39,6 +40,7 @@ public class FileMapGenerator implements WorldGenerator{
|
||||
boolean anyCores = false;
|
||||
|
||||
for(Tile tile : tiles){
|
||||
|
||||
if(tile.overlay() == Blocks.spawn){
|
||||
int rad = 10;
|
||||
Geometry.circle(tile.x, tile.y, tiles.width, tiles.height, rad, (wx, wy) -> {
|
||||
@@ -48,15 +50,15 @@ public class FileMapGenerator implements WorldGenerator{
|
||||
});
|
||||
}
|
||||
|
||||
if(tile.block() instanceof CoreBlock && tile.team() == state.rules.defaultTeam){
|
||||
if(tile.block() instanceof CoreBlock && tile.team() == state.rules.defaultTeam && !anyCores){
|
||||
//TODO PLACE THE (CORRECT) LOADOUT
|
||||
Schematics.placeLoadout(Loadouts.basicFoundation, tile.x, tile.y);
|
||||
Schematics.placeLoadout(Loadouts.basicShard, tile.x, tile.y);
|
||||
anyCores = true;
|
||||
}
|
||||
}
|
||||
|
||||
if(!anyCores){
|
||||
throw new IllegalArgumentException("All zone maps must have a core.");
|
||||
throw new IllegalArgumentException("All maps must have a core.");
|
||||
}
|
||||
|
||||
state.map = map;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package mindustry.maps.generators;
|
||||
|
||||
import arc.math.geom.*;
|
||||
import mindustry.graphics.g3d.HexMesher;
|
||||
import mindustry.graphics.g3d.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
|
||||
@@ -24,10 +24,10 @@ public class TODOPlanetGenerator extends PlanetGenerator{
|
||||
{Blocks.water, Blocks.darksandWater, Blocks.darksand, Blocks.darksand, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.darksandTaintedWater, Blocks.snow, Blocks.snow, Blocks.ice},
|
||||
{Blocks.water, Blocks.darksandWater, Blocks.darksand, Blocks.sand, Blocks.salt, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.darksandTaintedWater, Blocks.snow, Blocks.ice, Blocks.ice},
|
||||
{Blocks.water, Blocks.sandWater, Blocks.sand, Blocks.salt, Blocks.salt, Blocks.salt, Blocks.sand, Blocks.sand, Blocks.iceSnow, Blocks.snow, Blocks.snow, Blocks.ice, Blocks.ice},
|
||||
{Blocks.deepwater, Blocks.water, Blocks.sandWater, Blocks.sand, Blocks.salt, Blocks.sand, Blocks.sand, Blocks.moss, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.ice},
|
||||
{Blocks.deepwater, Blocks.water, Blocks.sandWater, Blocks.sand, Blocks.salt, Blocks.sand, Blocks.sand, Blocks.ignarock, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.ice},
|
||||
{Blocks.deepwater, Blocks.water, Blocks.sandWater, Blocks.sand, Blocks.sand, Blocks.sand, Blocks.moss, Blocks.iceSnow, Blocks.snow, Blocks.snow, Blocks.ice, Blocks.snow, Blocks.ice},
|
||||
{Blocks.deepwater, Blocks.sandWater, Blocks.sand, Blocks.sand, Blocks.moss, Blocks.moss, Blocks.moss, Blocks.snow, Blocks.snow, Blocks.ice, Blocks.ice, Blocks.snow, Blocks.ice},
|
||||
{Blocks.taintedWater, Blocks.darksandTaintedWater, Blocks.darksand, Blocks.darksand, Blocks.darksandTaintedWater, Blocks.moss, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.ice, Blocks.snow, Blocks.ice, Blocks.ice},
|
||||
{Blocks.taintedWater, Blocks.darksandTaintedWater, Blocks.darksand, Blocks.darksand, Blocks.ignarock, Blocks.moss, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.ice, Blocks.snow, Blocks.ice, Blocks.ice},
|
||||
{Blocks.darksandWater, Blocks.darksand, Blocks.darksand, Blocks.darksand, Blocks.moss, Blocks.sporeMoss, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.ice, Blocks.ice},
|
||||
{Blocks.darksandWater, Blocks.darksand, Blocks.darksand, Blocks.sporeMoss, Blocks.ice, Blocks.ice, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.snow, Blocks.ice, Blocks.ice, Blocks.ice},
|
||||
{Blocks.taintedWater, Blocks.darksandTaintedWater, Blocks.darksand, Blocks.sporeMoss, Blocks.sporeMoss, Blocks.ice, Blocks.ice, Blocks.snow, Blocks.snow, Blocks.ice, Blocks.ice, Blocks.ice, Blocks.ice},
|
||||
|
||||
@@ -291,8 +291,8 @@ public class ContentParser{
|
||||
return unit;
|
||||
},
|
||||
ContentType.item, parser(ContentType.item, Item::new),
|
||||
ContentType.liquid, parser(ContentType.liquid, Liquid::new),
|
||||
ContentType.zone, parser(ContentType.zone, SectorPreset::new)
|
||||
ContentType.liquid, parser(ContentType.liquid, Liquid::new)
|
||||
//ContentType.sector, parser(ContentType.sector, SectorPreset::new)
|
||||
);
|
||||
|
||||
private String getString(JsonValue value, String key){
|
||||
|
||||
@@ -31,15 +31,19 @@ public class SectorPreset extends UnlockableContent{
|
||||
protected Array<ItemStack> launchCost;
|
||||
protected Array<ItemStack> defaultStartingItems = new Array<>();
|
||||
|
||||
public SectorPreset(String name, Planet planet){
|
||||
public SectorPreset(String name, Planet planet, int sector){
|
||||
super(name);
|
||||
this.generator = new FileMapGenerator(name);
|
||||
this.planet = planet;
|
||||
|
||||
planet.preset(sector, this);
|
||||
}
|
||||
|
||||
//TODO
|
||||
/*
|
||||
public SectorPreset(String name){
|
||||
this(name, Planets.starter);
|
||||
}
|
||||
}*/
|
||||
|
||||
public Rules getRules(){
|
||||
return generator.map.rules();
|
||||
@@ -181,7 +185,7 @@ public class SectorPreset extends UnlockableContent{
|
||||
|
||||
@Override
|
||||
public ContentType getContentType(){
|
||||
return ContentType.zone;
|
||||
return ContentType.sector;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -348,7 +348,7 @@ public class PlanetDialog extends FloatingDialog{
|
||||
|
||||
//TODO add strings to bundle after prototyping is done
|
||||
|
||||
stable.add("[accent]" + selected.id).row();
|
||||
stable.add("[accent]" + (selected.preset == null ? selected.id : selected.preset.localizedName)).row();
|
||||
stable.image().color(Pal.accent).fillX().height(3f).pad(3f).row();
|
||||
stable.add(selected.save != null ? selected.save.getPlayTime() : "[lightgray]Unexplored").row();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user