Begin work on 6.0

This commit is contained in:
Anuken
2019-11-10 14:05:29 -05:00
parent 4c0607aba8
commit 8952dd7f56
40 changed files with 2290 additions and 2055 deletions

View File

@@ -20,12 +20,13 @@ import io.anuke.mindustry.input.*;
import io.anuke.mindustry.maps.*;
import io.anuke.mindustry.mod.*;
import io.anuke.mindustry.net.Net;
import io.anuke.mindustry.type.Weather.*;
import io.anuke.mindustry.world.blocks.defense.ForceProjector.*;
import java.nio.charset.*;
import java.util.*;
import static io.anuke.arc.Core.*;
import static io.anuke.arc.Core.settings;
@SuppressWarnings("unchecked")
public class Vars implements Loadable{
@@ -178,6 +179,7 @@ public class Vars implements Loadable{
public static EntityGroup<ShieldEntity> shieldGroup;
public static EntityGroup<Puddle> puddleGroup;
public static EntityGroup<Fire> fireGroup;
public static EntityGroup<WeatherEntity> weatherGroup;
public static EntityGroup<BaseUnit>[] unitGroups;
public static Player player;
@@ -232,6 +234,7 @@ public class Vars implements Loadable{
puddleGroup = entities.add(Puddle.class).enableMapping();
shieldGroup = entities.add(ShieldEntity.class, false);
fireGroup = entities.add(Fire.class).enableMapping();
weatherGroup = entities.add(WeatherEntity.class);
unitGroups = new EntityGroup[Team.all.length];
for(Team team : Team.all){

View File

@@ -33,7 +33,7 @@ public class Blocks implements ContentList{
public static Block
//environment
air, spawn, deepwater, water, taintedWater, tar, stone, craters, charr, sand, darksand, ice, snow, darksandTaintedWater,
air, spawn, deepwater, water, taintedWater, tar, slag, stone, craters, charr, sand, darksand, ice, snow, darksandTaintedWater,
holostone, rocks, sporerocks, icerocks, cliffs, sporePine, snowPine, pine, shrubs, whiteTree, whiteTreeDead, sporeCluster,
iceSnow, sandWater, darksandWater, duneRocks, sandRocks, moss, sporeMoss, shale, shaleRocks, shaleBoulder, sandBoulder, grass, salt,
metalFloor, metalFloorDamaged, metalFloor2, metalFloor3, metalFloor5, ignarock, magmarock, hotrock, snowrocks, rock, snowrock, saltRocks,
@@ -202,6 +202,17 @@ public class Blocks implements ContentList{
cacheLayer = CacheLayer.tar;
}};
slag = new Floor("slag"){{
drownTime = 150f;
status = StatusEffects.melting;
statusDuration = 240f;
speedMultiplier = 0.19f;
variants = 0;
liquidDrop = Liquids.slag;
isLiquid = true;
cacheLayer = CacheLayer.slag;
}};
stone = new Floor("stone"){{
}};

View File

@@ -0,0 +1,14 @@
package io.anuke.mindustry.content;
import io.anuke.mindustry.ctype.*;
import io.anuke.mindustry.type.*;
public class Planets implements ContentList{
//TODO make all names
public static Planet starter;
@Override
public void load(){
}
}

View File

@@ -17,7 +17,7 @@ public class UnitTypes implements ContentList{
@Override
public void load(){
draug = new UnitType("draug", Draug::new){{
draug = new UnitType("draug", MinerDrone::new){{
flying = true;
drag = 0.01f;
speed = 0.3f;
@@ -32,7 +32,7 @@ public class UnitTypes implements ContentList{
}};
}};
spirit = new UnitType("spirit", Spirit::new){{
spirit = new UnitType("spirit", RepairDrone::new){{
flying = true;
drag = 0.01f;
speed = 0.42f;
@@ -53,7 +53,7 @@ public class UnitTypes implements ContentList{
}};
}};
phantom = new UnitType("phantom", Phantom::new){{
phantom = new UnitType("phantom", BuilderDrone::new){{
flying = true;
drag = 0.01f;
mass = 2f;
@@ -76,7 +76,7 @@ public class UnitTypes implements ContentList{
}};
}};
dagger = new UnitType("dagger", Dagger::new){{
dagger = new UnitType("dagger", GroundUnit::new){{
maxVelocity = 1.1f;
speed = 0.2f;
drag = 0.4f;
@@ -92,7 +92,7 @@ public class UnitTypes implements ContentList{
}};
}};
crawler = new UnitType("crawler", Crawler::new){{
crawler = new UnitType("crawler", GroundUnit::new){{
maxVelocity = 1.27f;
speed = 0.285f;
drag = 0.4f;
@@ -123,7 +123,7 @@ public class UnitTypes implements ContentList{
}};
}};
titan = new UnitType("titan", Titan::new){{
titan = new UnitType("titan", GroundUnit::new){{
maxVelocity = 0.8f;
speed = 0.22f;
drag = 0.4f;
@@ -145,7 +145,7 @@ public class UnitTypes implements ContentList{
}};
}};
fortress = new UnitType("fortress", Fortress::new){{
fortress = new UnitType("fortress", GroundUnit::new){{
maxVelocity = 0.78f;
speed = 0.15f;
drag = 0.4f;
@@ -167,7 +167,7 @@ public class UnitTypes implements ContentList{
}};
}};
eruptor = new UnitType("eruptor", Eruptor::new){{
eruptor = new UnitType("eruptor", GroundUnit::new){{
maxVelocity = 0.81f;
speed = 0.16f;
drag = 0.4f;
@@ -189,7 +189,7 @@ public class UnitTypes implements ContentList{
}};
}};
chaosArray = new UnitType("chaos-array", Dagger::new){{
chaosArray = new UnitType("chaos-array", GroundUnit::new){{
maxVelocity = 0.68f;
speed = 0.12f;
drag = 0.4f;
@@ -213,7 +213,7 @@ public class UnitTypes implements ContentList{
}};
}};
eradicator = new UnitType("eradicator", Dagger::new){{
eradicator = new UnitType("eradicator", GroundUnit::new){{
maxVelocity = 0.68f;
speed = 0.12f;
drag = 0.4f;
@@ -238,7 +238,7 @@ public class UnitTypes implements ContentList{
}};
}};
wraith = new UnitType("wraith", Wraith::new){{
wraith = new UnitType("wraith", FlyingUnit::new){{
speed = 0.3f;
maxVelocity = 1.9f;
drag = 0.01f;
@@ -257,7 +257,7 @@ public class UnitTypes implements ContentList{
}};
}};
ghoul = new UnitType("ghoul", Ghoul::new){{
ghoul = new UnitType("ghoul", FlyingUnit::new){{
health = 220;
speed = 0.2f;
maxVelocity = 1.4f;
@@ -281,7 +281,7 @@ public class UnitTypes implements ContentList{
}};
}};
revenant = new UnitType("revenant", Revenant::new){{
revenant = new UnitType("revenant", HoverUnit::new){{
health = 1000;
mass = 5f;
hitsize = 20f;
@@ -312,7 +312,7 @@ public class UnitTypes implements ContentList{
}};
}};
lich = new UnitType("lich", Revenant::new){{
lich = new UnitType("lich", HoverUnit::new){{
health = 6000;
mass = 20f;
hitsize = 40f;
@@ -345,7 +345,7 @@ public class UnitTypes implements ContentList{
}};
}};
reaper = new UnitType("reaper", Revenant::new){{
reaper = new UnitType("reaper", HoverUnit::new){{
health = 11000;
mass = 30f;
hitsize = 56f;

View File

@@ -0,0 +1,15 @@
package io.anuke.mindustry.content;
import io.anuke.mindustry.ctype.*;
import io.anuke.mindustry.type.*;
public class Weathers implements ContentList{
public static Weather
rain,
snow;
@Override
public void load(){
}
}

View File

@@ -10,6 +10,7 @@ import io.anuke.mindustry.type.*;
import static io.anuke.arc.collection.Array.with;
import static io.anuke.mindustry.content.Items.*;
import static io.anuke.mindustry.content.Planets.starter;
import static io.anuke.mindustry.type.ItemStack.list;
public class Zones implements ContentList{
@@ -22,7 +23,7 @@ public class Zones implements ContentList{
@Override
public void load(){
groundZero = new Zone("groundZero", new MapGenerator("groundZero", 1)){{
groundZero = new Zone("groundZero", starter, new MapGenerator("groundZero", 1)){{
baseLaunchCost = list(copper, -60);
startingItems = list(copper, 60);
alwaysUnlocked = true;
@@ -31,7 +32,7 @@ public class Zones implements ContentList{
resources = with(copper, scrap, lead);
}};
desertWastes = new Zone("desertWastes", new DesertWastesGenerator(260, 260)){{
desertWastes = new Zone("desertWastes", starter, new DesertWastesGenerator(260, 260)){{
startingItems = list(copper, 120);
conditionWave = 20;
launchPeriod = 10;
@@ -82,7 +83,7 @@ public class Zones implements ContentList{
);
}};
saltFlats = new Zone("saltFlats", new MapGenerator("saltFlats")){{
saltFlats = new Zone("saltFlats", starter, new MapGenerator("saltFlats")){{
startingItems = list(copper, 200, Items.silicon, 200, lead, 200);
loadout = Loadouts.basicFoundation;
conditionWave = 10;
@@ -98,7 +99,7 @@ public class Zones implements ContentList{
);
}};
frozenForest = new Zone("frozenForest", new MapGenerator("frozenForest", 1)
frozenForest = new Zone("frozenForest", starter, new MapGenerator("frozenForest", 1)
.decor(new Decoration(Blocks.snow, Blocks.sporeCluster, 0.02))){{
loadout = Loadouts.basicFoundation;
startingItems = list(copper, 250);
@@ -111,7 +112,7 @@ public class Zones implements ContentList{
);
}};
craters = new Zone("craters", new MapGenerator("craters", 1).decor(new Decoration(Blocks.snow, Blocks.sporeCluster, 0.004))){{
craters = new Zone("craters", starter, new MapGenerator("craters", 1).decor(new Decoration(Blocks.snow, Blocks.sporeCluster, 0.004))){{
startingItems = list(copper, 100);
conditionWave = 10;
resources = with(copper, lead, coal, sand, scrap);
@@ -122,7 +123,7 @@ public class Zones implements ContentList{
);
}};
ruinousShores = new Zone("ruinousShores", new MapGenerator("ruinousShores", 1)){{
ruinousShores = new Zone("ruinousShores", starter, new MapGenerator("ruinousShores", 1)){{
loadout = Loadouts.basicFoundation;
startingItems = list(copper, 140, lead, 50);
conditionWave = 20;
@@ -138,7 +139,7 @@ public class Zones implements ContentList{
);
}};
stainedMountains = new Zone("stainedMountains", new MapGenerator("stainedMountains", 2)
stainedMountains = new Zone("stainedMountains", starter, new MapGenerator("stainedMountains", 2)
.decor(new Decoration(Blocks.shale, Blocks.shaleBoulder, 0.02))){{
loadout = Loadouts.basicFoundation;
startingItems = list(copper, 200, lead, 50);
@@ -153,7 +154,7 @@ public class Zones implements ContentList{
);
}};
fungalPass = new Zone("fungalPass", new MapGenerator("fungalPass")){{
fungalPass = new Zone("fungalPass", starter, new MapGenerator("fungalPass")){{
startingItems = list(copper, 250, lead, 250, Items.metaglass, 100, Items.graphite, 100);
resources = with(copper, lead, coal, titanium, sand);
configureObjective = new Launched(this);
@@ -166,7 +167,7 @@ public class Zones implements ContentList{
);
}};
overgrowth = new Zone("overgrowth", new MapGenerator("overgrowth")){{
overgrowth = new Zone("overgrowth", starter, new MapGenerator("overgrowth")){{
startingItems = list(copper, 1500, lead, 1000, Items.silicon, 500, Items.metaglass, 250);
conditionWave = 12;
launchPeriod = 4;
@@ -183,7 +184,7 @@ public class Zones implements ContentList{
);
}};
tarFields = new Zone("tarFields", new MapGenerator("tarFields")
tarFields = new Zone("tarFields", starter, new MapGenerator("tarFields")
.decor(new Decoration(Blocks.shale, Blocks.shaleBoulder, 0.02))){{
loadout = Loadouts.basicFoundation;
startingItems = list(copper, 250, lead, 100);
@@ -199,7 +200,7 @@ public class Zones implements ContentList{
);
}};
desolateRift = new Zone("desolateRift", new MapGenerator("desolateRift")){{
desolateRift = new Zone("desolateRift", starter, new MapGenerator("desolateRift")){{
loadout = Loadouts.basicNucleus;
startingItems = list(copper, 1000, lead, 1000, Items.graphite, 250, titanium, 250, Items.silicon, 250);
conditionWave = 3;
@@ -224,7 +225,7 @@ public class Zones implements ContentList{
resources = Array.with(Items.copper, Items.scrap, Items.lead, Items.coal, Items.sand};
}};*/
nuclearComplex = new Zone("nuclearComplex", new MapGenerator("nuclearProductionComplex", 1)
nuclearComplex = new Zone("nuclearComplex", starter, new MapGenerator("nuclearProductionComplex", 1)
.decor(new Decoration(Blocks.snow, Blocks.sporeCluster, 0.01))){{
loadout = Loadouts.basicNucleus;
startingItems = list(copper, 1250, lead, 1500, Items.silicon, 400, Items.metaglass, 250);

View File

@@ -240,6 +240,7 @@ public class Logic implements ApplicationListener{
bulletGroup.update();
tileGroup.update();
fireGroup.update();
weatherGroup.update();
}else{
for(EntityGroup<?> group : unitGroups){
group.updateEvents();

View File

@@ -42,7 +42,9 @@ public abstract class UnlockableContent extends MappableContent{
}
/** Returns the localized name of this content. */
public abstract String localizedName();
public String localizedName(){
return localizedName;
}
//public abstract TextureRegion getContentIcon();
@@ -53,7 +55,7 @@ public abstract class UnlockableContent extends MappableContent{
public void onUnlock(){
}
/** Whether this content is always hidden in the content info dialog. */
/** Whether this content is always hidden in the content database dialog. */
public boolean isHidden(){
return false;
}

View File

@@ -1,8 +1,9 @@
package io.anuke.mindustry.entities.traits;
/**
* Marks an entity as serializable.
*/
/** Marks an entity as serializable. */
public interface SaveTrait extends Entity, TypeTrait, Saveable{
byte version();
default byte version(){
return 0;
}
}

View File

@@ -2,6 +2,7 @@ package io.anuke.mindustry.entities.traits;
import java.io.*;
/** Marks something as saveable; not necessarily used for entities. */
public interface Saveable{
void writeSave(DataOutput stream) throws IOException;
void readSave(DataInput stream, byte version) throws IOException;

View File

@@ -1,4 +0,0 @@
package io.anuke.mindustry.entities.type.base;
public class Crawler extends GroundUnit{
}

View File

@@ -1,5 +0,0 @@
package io.anuke.mindustry.entities.type.base;
public class Dagger extends GroundUnit{
}

View File

@@ -1,4 +0,0 @@
package io.anuke.mindustry.entities.type.base;
public class Draug extends MinerDrone{
}

View File

@@ -1,4 +0,0 @@
package io.anuke.mindustry.entities.type.base;
public class Eruptor extends GroundUnit{
}

View File

@@ -1,4 +0,0 @@
package io.anuke.mindustry.entities.type.base;
public class Fortress extends GroundUnit{
}

View File

@@ -1,5 +0,0 @@
package io.anuke.mindustry.entities.type.base;
public class Ghoul extends FlyingUnit{
}

View File

@@ -5,7 +5,7 @@ import io.anuke.arc.math.Angles;
import io.anuke.arc.math.Mathf;
import io.anuke.mindustry.entities.Units;
public class Revenant extends FlyingUnit{
public class HoverUnit extends FlyingUnit{
@Override
public void drawWeapons(){

View File

@@ -1,5 +0,0 @@
package io.anuke.mindustry.entities.type.base;
public class Phantom extends BuilderDrone{
}

View File

@@ -1,4 +0,0 @@
package io.anuke.mindustry.entities.type.base;
public class Spirit extends RepairDrone{
}

View File

@@ -1,5 +0,0 @@
package io.anuke.mindustry.entities.type.base;
public class Titan extends GroundUnit{
}

View File

@@ -1,5 +0,0 @@
package io.anuke.mindustry.entities.type.base;
public class Wraith extends FlyingUnit{
}

View File

@@ -31,6 +31,17 @@ public enum CacheLayer{
endShader(Shaders.tar);
}
},
slag{
@Override
public void begin(){
beginShader();
}
@Override
public void end(){
endShader(Shaders.slag);
}
},
normal,
walls;

View File

@@ -11,12 +11,11 @@ import io.anuke.arc.util.Time;
public class Shaders{
public static Shadow shadow;
public static BlockBuild blockbuild;
public static @Nullable
Shield shield;
public static @Nullable Shield shield;
public static UnitBuild build;
public static FogShader fog;
public static MenuShader menu;
public static SurfaceShader water, tar;
public static SurfaceShader water, tar, slag;
public static void init(){
shadow = new Shadow();
@@ -33,6 +32,7 @@ public class Shaders{
menu = new MenuShader();
water = new SurfaceShader("water");
tar = new SurfaceShader("tar");
slag = new SurfaceShader("slag");
}
public static class MenuShader extends LoadShader{

View File

@@ -66,54 +66,54 @@ public class LegacyTypeTable{
Player::new,
Fire::new,
Puddle::new,
Draug::new,
Spirit::new,
Phantom::new,
Dagger::new,
Crawler::new,
Titan::new,
Fortress::new,
Eruptor::new,
Wraith::new,
Ghoul::new,
Revenant::new
MinerDrone::new,
RepairDrone::new,
BuilderDrone::new,
GroundUnit::new,
GroundUnit::new,
GroundUnit::new,
GroundUnit::new,
GroundUnit::new,
FlyingUnit::new,
FlyingUnit::new,
HoverUnit::new
};
private static final Prov[] build80Table = {
Player::new,
Fire::new,
Puddle::new,
Bullet::new, //TODO reading these may crash
Bullet::new,
Lightning::new,
Draug::new,
Spirit::new,
Phantom::new,
Dagger::new,
Crawler::new,
Titan::new,
Fortress::new,
Eruptor::new,
Wraith::new,
Ghoul::new,
Revenant::new
MinerDrone::new,
RepairDrone::new,
BuilderDrone::new,
GroundUnit::new,
GroundUnit::new,
GroundUnit::new,
GroundUnit::new,
GroundUnit::new,
FlyingUnit::new,
FlyingUnit::new,
HoverUnit::new
};
private static final Prov[] build79Table = {
Player::new,
Fire::new,
Puddle::new,
Bullet::new, //TODO reading these may crash
Bullet::new,
Lightning::new,
Spirit::new,
Dagger::new,
Crawler::new,
Titan::new,
Fortress::new,
Eruptor::new,
Wraith::new,
Ghoul::new,
Phantom::new,
Revenant::new
RepairDrone::new,
GroundUnit::new,
GroundUnit::new,
GroundUnit::new,
GroundUnit::new,
GroundUnit::new,
FlyingUnit::new,
FlyingUnit::new,
BuilderDrone::new,
HoverUnit::new
};
public static Prov[] getTable(int build){

View File

@@ -15,39 +15,22 @@ import io.anuke.mindustry.world.blocks.storage.*;
import static io.anuke.mindustry.Vars.*;
//TODO:
//- limited # of enemy spawns as filter
//- spawn loadout selection as filter
//- configure map loadout, make 1 core the default
public class MapGenerator extends Generator{
private Map map;
private String mapName;
private Array<Decoration> decorations = Array.with(new Decoration(Blocks.stone, Blocks.rock, 0.003f));
/**
* The amount of final enemy spawns used. -1 to use everything in the map.
* This amount of enemy spawns is selected randomly from the map.
*/
public int enemySpawns = -1;
/** Whether floor is distorted along with blocks. */
public boolean distortFloor = false;
public MapGenerator(String mapName){
this.mapName = mapName;
}
public MapGenerator(String mapName, int enemySpawns){
this.mapName = mapName;
this.enemySpawns = enemySpawns;
}
public MapGenerator decor(Decoration... decor){
this.decorations.addAll(decor);
return this;
}
public void removePrefix(String name){
this.mapName = this.mapName.substring(name.length() + 1);
}
{
decor(new Decoration(Blocks.snow, Blocks.snowrock, 0.01), new Decoration(Blocks.ignarock, Blocks.pebbles, 0.03f));
}
public Map getMap(){
return map;
}
@@ -155,16 +138,4 @@ public class MapGenerator extends Generator{
world.prepareTiles(tiles);
world.setMap(map);
}
public static class Decoration{
public final Block floor;
public final Block wall;
public final double chance;
public Decoration(Block floor, Block wall, double chance){
this.floor = floor;
this.wall = wall;
this.chance = chance;
}
}
}

View File

@@ -13,7 +13,8 @@ public enum ContentType{
effect,
zone,
loadout,
typeid;
typeid,
planet;
public static final ContentType[] all = values();
}

View File

@@ -0,0 +1,28 @@
package io.anuke.mindustry.type;
import io.anuke.arc.scene.ui.layout.*;
import io.anuke.mindustry.ctype.*;
//TODO add full icon for this planet
public class Planet extends UnlockableContent{
public Planet(String name){
super(name);
}
/** Planets cannot be viewed in the database dialog. */
@Override
public boolean isHidden(){
return true;
}
@Override
public void displayInfo(Table table){
}
@Override
public ContentType getContentType(){
return ContentType.planet;
}
}

View File

@@ -0,0 +1,80 @@
package io.anuke.mindustry.type;
import io.anuke.annotations.Annotations.*;
import io.anuke.arc.util.ArcAnnotate.*;
import io.anuke.mindustry.ctype.*;
import io.anuke.mindustry.entities.*;
import io.anuke.mindustry.entities.traits.*;
import io.anuke.mindustry.entities.type.*;
import io.anuke.mindustry.type.Weather.*;
import java.io.*;
import static io.anuke.mindustry.Vars.*;
public abstract class Weather<T extends WeatherEntity> extends MappableContent{
protected float duration = 100f;
public Weather(String name){
super(name);
}
public abstract void update(T entity);
public abstract void draw(T entity);
@Override
public ContentType getContentType(){
return ContentType.weather;
}
/** Represents the in-game state of a weather event. */
@SuppressWarnings("unchecked")
public static class WeatherEntity extends BaseEntity implements SaveTrait, DrawTrait{
/** How long this event has been occuring in ticks. */
protected float life;
/** Type of weather that is being simulated. */
protected @NonNull Weather weather;
public WeatherEntity(Weather weather){
this.weather = weather;
}
@Override
public void update(){
weather.update(this);
}
@Override
public void draw(){
weather.draw(this);
}
@CallSuper
@Override
public void writeSave(DataOutput stream) throws IOException{
stream.writeShort(weather.id);
}
@CallSuper
@Override
public void readSave(DataInput stream, byte version) throws IOException{
weather = content.getByID(ContentType.weather, stream.readShort());
}
@Override
public byte version(){
return 0;
}
@Override
public TypeID getTypeID(){
return null;
}
@Override
public EntityGroup targetGroup(){
return weatherGroup;
}
}
}

View File

@@ -1,17 +0,0 @@
package io.anuke.mindustry.type;
import io.anuke.mindustry.ctype.Content;
//currently unimplemented, see trello for implementation plans
public class WeatherEvent extends Content{
public final String name;
public WeatherEvent(String name){
this.name = name;
}
@Override
public ContentType getContentType(){
return ContentType.weather;
}
}

View File

@@ -18,6 +18,7 @@ import static io.anuke.mindustry.Vars.*;
public class Zone extends UnlockableContent{
public @NonNull Generator generator;
public @NonNull Objective configureObjective = new ZoneWave(this, 15);
public @NonNull Planet planet;
public Array<Objective> requirements = new Array<>();
//TODO autogenerate
public Array<Item> resources = new Array<>();
@@ -35,13 +36,14 @@ public class Zone extends UnlockableContent{
private Array<ItemStack> defaultStartingItems = new Array<>();
public Zone(String name, Generator generator){
public Zone(String name, Planet planet, Generator generator){
super(name);
this.generator = generator;
this.planet = planet;
}
public Zone(String name){
this(name, new MapGenerator(name));
this(name, Planets.starter, new MapGenerator(name));
}
@Override

View File

@@ -200,7 +200,6 @@ public class FileChooser extends FloatingDialog{
files.add(upbutton).align(Align.topLeft).fillX().expandX().height(50).pad(2).colspan(2);
files.row();
ButtonGroup<TextButton> group = new ButtonGroup<>();
group.setMinCheckCount(0);