non-functional loading screen
This commit is contained in:
@@ -28,7 +28,7 @@ import io.anuke.mindustry.ui.dialogs.FileChooser;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class AndroidLauncher extends AndroidApplication{
|
public class AndroidLauncher extends AndroidApplication{
|
||||||
public static final int PERMISSION_REQUEST_CODE = 1;
|
public static final int PERMISSION_REQUEST_CODE = 1;
|
||||||
@@ -131,7 +131,7 @@ public class AndroidLauncher extends AndroidApplication{
|
|||||||
config.hideStatusBar = true;
|
config.hideStatusBar = true;
|
||||||
Net.setClientProvider(new ArcNetClient());
|
Net.setClientProvider(new ArcNetClient());
|
||||||
Net.setServerProvider(new ArcNetServer());
|
Net.setServerProvider(new ArcNetServer());
|
||||||
initialize(new Mindustry(), config);
|
initialize(new ClientLauncher(), config);
|
||||||
checkFiles(getIntent());
|
checkFiles(getIntent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -60,10 +60,10 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
|
|||||||
|
|
||||||
void process(String classname, String path, String rtype, String loadMethod) throws Exception{
|
void process(String classname, String path, String rtype, String loadMethod) throws Exception{
|
||||||
TypeSpec.Builder type = TypeSpec.classBuilder(classname).addModifiers(Modifier.PUBLIC);
|
TypeSpec.Builder type = TypeSpec.classBuilder(classname).addModifiers(Modifier.PUBLIC);
|
||||||
MethodSpec.Builder load = MethodSpec.methodBuilder("load").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
//MethodSpec.Builder load = MethodSpec.methodBuilder("load").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
||||||
MethodSpec.Builder dispose = MethodSpec.methodBuilder("dispose").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
MethodSpec.Builder dispose = MethodSpec.methodBuilder("dispose").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
||||||
|
|
||||||
MethodSpec.Builder loadBegin = MethodSpec.methodBuilder("loadBegin").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
MethodSpec.Builder loadBegin = MethodSpec.methodBuilder("load").addModifiers(Modifier.PUBLIC, Modifier.STATIC);
|
||||||
|
|
||||||
|
|
||||||
HashSet<String> names = new HashSet<>();
|
HashSet<String> names = new HashSet<>();
|
||||||
@@ -82,13 +82,14 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
|
|||||||
name = name + "s";
|
name = name + "s";
|
||||||
}
|
}
|
||||||
|
|
||||||
load.addStatement(name + " = io.anuke.arc.Core.audio."+loadMethod+"(io.anuke.arc.Core.files.internal(io.anuke.arc.Core.app.getType() != io.anuke.arc.Application.ApplicationType.iOS ? $S : $S))",
|
String filepath = path.substring(path.lastIndexOf("/") + 1) + "/" + fname;
|
||||||
path.substring(path.lastIndexOf("/") + 1) + "/" + fname, (path.substring(path.lastIndexOf("/") + 1) + "/" + fname).replace(".ogg", ".mp3"));
|
|
||||||
|
|
||||||
|
//load.addStatement(name + " = io.anuke.arc.Core.audio."+loadMethod+"(io.anuke.arc.Core.files.internal(io.anuke.arc.Core.app.getType() != io.anuke.arc.Application.ApplicationType.iOS ? $S : $S))",
|
||||||
|
//filepath, filepath.replace(".ogg", ".mp3"));
|
||||||
|
|
||||||
loadBegin.addStatement("io.anuke.arc.Core.assets.load(io.anuke.arc.Core.app.getType() != io.anuke.arc.Application.ApplicationType.iOS ? $S : $S, "+rtype+".class)",
|
loadBegin.addStatement("io.anuke.arc.Core.assets.load(io.anuke.arc.Core.app.getType() != io.anuke.arc.Application.ApplicationType.iOS ? $S : $S, "+rtype+".class, " +
|
||||||
path.substring(path.lastIndexOf("/") + 1) + "/" + fname,
|
"new io.anuke.arc.assets.loaders."+classname.substring(0, classname.length()-1)+"Loader."+classname.substring(0, classname.length()-1)+"Parameter((m, name, type) -> " + name + " = m.get(\"" + filepath + "\")))",
|
||||||
(path.substring(path.lastIndexOf("/") + 1) + "/" + fname).replace(".ogg", ".mp3"));
|
filepath, filepath.replace(".ogg", ".mp3"));
|
||||||
|
|
||||||
|
|
||||||
dispose.addStatement(name + ".dispose()");
|
dispose.addStatement(name + ".dispose()");
|
||||||
@@ -101,7 +102,7 @@ public class AssetsAnnotationProcessor extends AbstractProcessor{
|
|||||||
type.addField(FieldSpec.builder(ClassName.bestGuess(rtype), "none", Modifier.STATIC, Modifier.PUBLIC).initializer("new io.anuke.arc.audio.mock.Mock" + rtype.substring(rtype.lastIndexOf(".") + 1)+ "()").build());
|
type.addField(FieldSpec.builder(ClassName.bestGuess(rtype), "none", Modifier.STATIC, Modifier.PUBLIC).initializer("new io.anuke.arc.audio.mock.Mock" + rtype.substring(rtype.lastIndexOf(".") + 1)+ "()").build());
|
||||||
}
|
}
|
||||||
|
|
||||||
type.addMethod(load.build());
|
//type.addMethod(load.build());
|
||||||
type.addMethod(loadBegin.build());
|
type.addMethod(loadBegin.build());
|
||||||
type.addMethod(dispose.build());
|
type.addMethod(dispose.build());
|
||||||
JavaFile.builder(packageName, type.build()).build().writeTo(Utils.filer);
|
JavaFile.builder(packageName, type.build()).build().writeTo(Utils.filer);
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public class RemoteWriteGenerator{
|
|||||||
for(VariableElement var : elem.getParameters()){
|
for(VariableElement var : elem.getParameters()){
|
||||||
//special case: calling local-only methods uses the local player
|
//special case: calling local-only methods uses the local player
|
||||||
if(index == 0 && methodEntry.where == Loc.client){
|
if(index == 0 && methodEntry.where == Loc.client){
|
||||||
results.append("io.anuke.mindustry.Vars.player");
|
results.append("io.anuke.mindustry.Min.player");
|
||||||
}else{
|
}else{
|
||||||
results.append(var.getSimpleName());
|
results.append(var.getSimpleName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,12 +11,11 @@ import io.anuke.mindustry.core.*;
|
|||||||
import io.anuke.mindustry.game.EventType.*;
|
import io.anuke.mindustry.game.EventType.*;
|
||||||
import io.anuke.mindustry.gen.*;
|
import io.anuke.mindustry.gen.*;
|
||||||
import io.anuke.mindustry.graphics.*;
|
import io.anuke.mindustry.graphics.*;
|
||||||
import io.anuke.mindustry.io.*;
|
|
||||||
|
|
||||||
import static io.anuke.arc.Core.*;
|
import static io.anuke.arc.Core.*;
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class Mindustry extends ApplicationCore{
|
public class ClientLauncher extends ApplicationCore{
|
||||||
private long lastTime;
|
private long lastTime;
|
||||||
private boolean finished = false;
|
private boolean finished = false;
|
||||||
|
|
||||||
@@ -24,7 +23,6 @@ public class Mindustry extends ApplicationCore{
|
|||||||
public void setup(){
|
public void setup(){
|
||||||
Log.setUseColors(false);
|
Log.setUseColors(false);
|
||||||
|
|
||||||
Bench.begin("load setup");
|
|
||||||
Time.setDeltaProvider(() -> {
|
Time.setDeltaProvider(() -> {
|
||||||
float result = Core.graphics.getDeltaTime() * 60f;
|
float result = Core.graphics.getDeltaTime() * 60f;
|
||||||
return (Float.isNaN(result) || Float.isInfinite(result)) ? 1f : Mathf.clamp(result, 0.0001f, 60f / 10f);
|
return (Float.isNaN(result) || Float.isInfinite(result)) ? 1f : Mathf.clamp(result, 0.0001f, 60f / 10f);
|
||||||
@@ -34,45 +32,54 @@ public class Mindustry extends ApplicationCore{
|
|||||||
assets = new AssetManager();
|
assets = new AssetManager();
|
||||||
atlas = TextureAtlas.blankAtlas();
|
atlas = TextureAtlas.blankAtlas();
|
||||||
|
|
||||||
assets.load(new Vars());
|
assets.load(new Min());
|
||||||
|
assets.load(new AssetDescriptor<>("sprites/sprites.atlas", TextureAtlas.class)).loaded = t -> atlas = (TextureAtlas)t;
|
||||||
|
|
||||||
Bench.begin("cursors");
|
|
||||||
UI.loadSystemCursors();
|
UI.loadSystemCursors();
|
||||||
|
|
||||||
Bench.begin("vars");
|
Musics.load();
|
||||||
Bench.begin("bundle");
|
Sounds.load();
|
||||||
BundleLoader.load();
|
|
||||||
|
|
||||||
Bench.begin("music");
|
add(logic = new Logic());
|
||||||
Musics.loadBegin();
|
add(control = new Control());
|
||||||
Bench.begin("sound");
|
add(renderer = new Renderer());
|
||||||
Sounds.loadBegin();
|
add(ui = new UI());
|
||||||
|
add(netServer = new NetServer());
|
||||||
|
add(netClient = new NetClient());
|
||||||
|
|
||||||
|
assets.loadRun("content::init+load", ContentLoader.class, () -> {
|
||||||
|
content.init();
|
||||||
|
content.load();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void post(){
|
private void post(){
|
||||||
Bench.begin("content");
|
for(ApplicationListener listener : modules){
|
||||||
content.load();
|
listener.init();
|
||||||
content.loadColors();
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Bench.begin("logic");
|
@Override
|
||||||
add(logic = new Logic());
|
public void add(ApplicationListener module){
|
||||||
Bench.begin("world");
|
super.add(module);
|
||||||
add(world = new World());
|
|
||||||
Bench.begin("control");
|
//autoload modules when necessary
|
||||||
add(control = new Control());
|
if(module instanceof Loadable){
|
||||||
Bench.begin("renderer");
|
assets.load((Loadable)module);
|
||||||
add(renderer = new Renderer());
|
}
|
||||||
Bench.begin("ui");
|
}
|
||||||
add(ui = new UI());
|
|
||||||
Bench.begin("net");
|
@Override
|
||||||
add(netServer = new NetServer());
|
public void resize(int width, int height){
|
||||||
add(netClient = new NetClient());
|
super.resize(width, height);
|
||||||
Bench.begin("init");
|
|
||||||
|
if(!assets.isFinished()){
|
||||||
|
Draw.proj().setOrtho(0, 0, width, height);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
//
|
|
||||||
if(!assets.update()){
|
if(!assets.update()){
|
||||||
drawLoading();
|
drawLoading();
|
||||||
}else{
|
}else{
|
||||||
@@ -104,8 +111,14 @@ public class Mindustry extends ApplicationCore{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void init(){
|
||||||
super.init();
|
setup();
|
||||||
Bench.end();
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resume(){
|
||||||
|
if(finished){
|
||||||
|
super.resume();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawLoading(){
|
void drawLoading(){
|
||||||
@@ -1,37 +1,36 @@
|
|||||||
package io.anuke.mindustry;
|
package io.anuke.mindustry;
|
||||||
|
|
||||||
|
import io.anuke.arc.Application.*;
|
||||||
import io.anuke.arc.*;
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.Application.ApplicationType;
|
|
||||||
import io.anuke.arc.assets.*;
|
import io.anuke.arc.assets.*;
|
||||||
import io.anuke.arc.files.FileHandle;
|
import io.anuke.arc.files.*;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.*;
|
||||||
import io.anuke.arc.util.Structs;
|
import io.anuke.arc.util.*;
|
||||||
|
import io.anuke.mindustry.ai.*;
|
||||||
import io.anuke.mindustry.core.*;
|
import io.anuke.mindustry.core.*;
|
||||||
import io.anuke.mindustry.entities.*;
|
import io.anuke.mindustry.entities.*;
|
||||||
import io.anuke.mindustry.entities.bullet.Bullet;
|
import io.anuke.mindustry.entities.bullet.*;
|
||||||
import io.anuke.mindustry.entities.effect.Fire;
|
import io.anuke.mindustry.entities.effect.*;
|
||||||
import io.anuke.mindustry.entities.effect.Puddle;
|
import io.anuke.mindustry.entities.impl.*;
|
||||||
import io.anuke.mindustry.entities.impl.EffectEntity;
|
import io.anuke.mindustry.entities.traits.*;
|
||||||
import io.anuke.mindustry.entities.traits.DrawTrait;
|
|
||||||
import io.anuke.mindustry.entities.traits.SyncTrait;
|
|
||||||
import io.anuke.mindustry.entities.type.*;
|
import io.anuke.mindustry.entities.type.*;
|
||||||
import io.anuke.mindustry.game.*;
|
import io.anuke.mindustry.game.*;
|
||||||
import io.anuke.mindustry.game.EventType.*;
|
import io.anuke.mindustry.gen.*;
|
||||||
import io.anuke.mindustry.gen.Serialization;
|
import io.anuke.mindustry.input.*;
|
||||||
|
import io.anuke.mindustry.maps.*;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.world.blocks.defense.ForceProjector.ShieldEntity;
|
import io.anuke.mindustry.world.blocks.defense.ForceProjector.*;
|
||||||
|
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.*;
|
||||||
import java.util.Arrays;
|
import java.util.*;
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class Vars implements Loadable{
|
public class Min implements Loadable{
|
||||||
/** Whether to load locales.*/
|
/** Whether to load locales.*/
|
||||||
public static boolean loadLocales = true;
|
public static boolean loadLocales = true;
|
||||||
/** IO buffer size. */
|
/** IO buffer size. */
|
||||||
public static final int bufferSize = 8192;
|
public static final int bufferSize = 8192;
|
||||||
/** global charset */
|
/** global charset, since Android doesn't support the Charsets class */
|
||||||
public static final Charset charset = Charset.forName("UTF-8");
|
public static final Charset charset = Charset.forName("UTF-8");
|
||||||
/** main application name, capitalized */
|
/** main application name, capitalized */
|
||||||
public static final String appName = "Mindustry";
|
public static final String appName = "Mindustry";
|
||||||
@@ -116,6 +115,8 @@ public class Vars implements Loadable{
|
|||||||
public static FileHandle screenshotDirectory;
|
public static FileHandle screenshotDirectory;
|
||||||
/** data subdirectory used for custom mmaps */
|
/** data subdirectory used for custom mmaps */
|
||||||
public static FileHandle customMapDirectory;
|
public static FileHandle customMapDirectory;
|
||||||
|
/** data subdirectory used for custom mmaps */
|
||||||
|
public static FileHandle mapPreviewDirectory;
|
||||||
/** tmp subdirectory for map conversion */
|
/** tmp subdirectory for map conversion */
|
||||||
public static FileHandle tmpDirectory;
|
public static FileHandle tmpDirectory;
|
||||||
/** data subdirectory used for saves */
|
/** data subdirectory used for saves */
|
||||||
@@ -137,11 +138,16 @@ public class Vars implements Loadable{
|
|||||||
public static DefaultWaves defaultWaves;
|
public static DefaultWaves defaultWaves;
|
||||||
public static LoopControl loops;
|
public static LoopControl loops;
|
||||||
|
|
||||||
|
public static World world;
|
||||||
|
public static Maps maps;
|
||||||
|
public static WaveSpawner spawner;
|
||||||
|
public static BlockIndexer indexer;
|
||||||
|
public static Pathfinder pathfinder;
|
||||||
|
|
||||||
public static Control control;
|
public static Control control;
|
||||||
public static Logic logic;
|
public static Logic logic;
|
||||||
public static Renderer renderer;
|
public static Renderer renderer;
|
||||||
public static UI ui;
|
public static UI ui;
|
||||||
public static World world;
|
|
||||||
public static NetServer netServer;
|
public static NetServer netServer;
|
||||||
public static NetClient netClient;
|
public static NetClient netClient;
|
||||||
|
|
||||||
@@ -160,14 +166,10 @@ public class Vars implements Loadable{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadAsync(){
|
public void loadAsync(){
|
||||||
|
loadSettings();
|
||||||
init();
|
init();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadSync(){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void init(){
|
public static void init(){
|
||||||
Serialization.init();
|
Serialization.init();
|
||||||
|
|
||||||
@@ -190,13 +192,15 @@ public class Vars implements Loadable{
|
|||||||
Version.init();
|
Version.init();
|
||||||
|
|
||||||
content = new ContentLoader();
|
content = new ContentLoader();
|
||||||
if(!headless){
|
|
||||||
content.setVerbose();
|
|
||||||
}
|
|
||||||
|
|
||||||
loops = new LoopControl();
|
loops = new LoopControl();
|
||||||
defaultWaves = new DefaultWaves();
|
defaultWaves = new DefaultWaves();
|
||||||
collisions = new EntityCollisions();
|
collisions = new EntityCollisions();
|
||||||
|
world = new World();
|
||||||
|
|
||||||
|
maps = new Maps();
|
||||||
|
spawner = new WaveSpawner();
|
||||||
|
indexer = new BlockIndexer();
|
||||||
|
pathfinder = new Pathfinder();
|
||||||
|
|
||||||
playerGroup = Entities.addGroup(Player.class).enableMapping();
|
playerGroup = Entities.addGroup(Player.class).enableMapping();
|
||||||
tileGroup = Entities.addGroup(TileEntity.class, false);
|
tileGroup = Entities.addGroup(TileEntity.class, false);
|
||||||
@@ -227,14 +231,60 @@ public class Vars implements Loadable{
|
|||||||
ios = Core.app.getType() == ApplicationType.iOS;
|
ios = Core.app.getType() == ApplicationType.iOS;
|
||||||
android = Core.app.getType() == ApplicationType.Android;
|
android = Core.app.getType() == ApplicationType.Android;
|
||||||
|
|
||||||
Core.settings.setAppName(appName);
|
|
||||||
|
|
||||||
dataDirectory = Core.settings.getDataDirectory();
|
dataDirectory = Core.settings.getDataDirectory();
|
||||||
screenshotDirectory = dataDirectory.child("screenshots/");
|
screenshotDirectory = dataDirectory.child("screenshots/");
|
||||||
customMapDirectory = dataDirectory.child("maps/");
|
customMapDirectory = dataDirectory.child("maps/");
|
||||||
|
mapPreviewDirectory = dataDirectory.child("previews/");
|
||||||
saveDirectory = dataDirectory.child("saves/");
|
saveDirectory = dataDirectory.child("saves/");
|
||||||
tmpDirectory = dataDirectory.child("tmp/");
|
tmpDirectory = dataDirectory.child("tmp/");
|
||||||
|
|
||||||
Events.fire(new AppLoadEvent());
|
maps.load();
|
||||||
|
if(!headless){
|
||||||
|
content.loadColors();
|
||||||
|
maps.loadPreviews();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void loadSettings(){
|
||||||
|
Core.settings.setAppName(appName);
|
||||||
|
Core.settings.defaults("locale", "default");
|
||||||
|
Core.keybinds.setDefaults(Binding.values());
|
||||||
|
Core.settings.load();
|
||||||
|
|
||||||
|
try{
|
||||||
|
//try loading external bundle
|
||||||
|
FileHandle handle = Core.files.local("bundle");
|
||||||
|
|
||||||
|
Locale locale = Locale.ENGLISH;
|
||||||
|
Core.bundle = I18NBundle.createBundle(handle, locale);
|
||||||
|
|
||||||
|
Log.info("NOTE: external translation bundle has been loaded.");
|
||||||
|
if(!headless){
|
||||||
|
Time.run(10f, () -> ui.showInfo("Note: You have successfully loaded an external translation bundle."));
|
||||||
|
}
|
||||||
|
}catch(Throwable e){
|
||||||
|
//no external bundle found
|
||||||
|
|
||||||
|
FileHandle handle = Core.files.internal("bundles/bundle");
|
||||||
|
|
||||||
|
Locale locale;
|
||||||
|
String loc = Core.settings.getString("locale");
|
||||||
|
if(loc.equals("default")){
|
||||||
|
locale = Locale.getDefault();
|
||||||
|
}else{
|
||||||
|
Locale lastLocale;
|
||||||
|
if(loc.contains("_")){
|
||||||
|
String[] split = loc.split("_");
|
||||||
|
lastLocale = new Locale(split[0], split[1]);
|
||||||
|
}else{
|
||||||
|
lastLocale = new Locale(loc);
|
||||||
|
}
|
||||||
|
|
||||||
|
locale = lastLocale;
|
||||||
|
}
|
||||||
|
|
||||||
|
Locale.setDefault(locale);
|
||||||
|
Core.bundle = I18NBundle.createBundle(handle, locale);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -15,7 +15,7 @@ import io.anuke.mindustry.world.*;
|
|||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
import io.anuke.mindustry.world.meta.*;
|
import io.anuke.mindustry.world.meta.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
/** Class used for indexing special target blocks for AI. */
|
/** Class used for indexing special target blocks for AI. */
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@@ -24,7 +24,7 @@ public class BlockIndexer{
|
|||||||
private final static int quadrantSize = 16;
|
private final static int quadrantSize = 16;
|
||||||
|
|
||||||
/** Set of all ores that are being scanned. */
|
/** Set of all ores that are being scanned. */
|
||||||
private final ObjectSet<Item> scanOres = ObjectSet.with(Item.getAllOres().toArray(Item.class));
|
private final ObjectSet<Item> scanOres = new ObjectSet<>();
|
||||||
private final ObjectSet<Item> itemSet = new ObjectSet<>();
|
private final ObjectSet<Item> itemSet = new ObjectSet<>();
|
||||||
/** Stores all ore quadtrants on the map. */
|
/** Stores all ore quadtrants on the map. */
|
||||||
private ObjectMap<Item, ObjectSet<Tile>> ores;
|
private ObjectMap<Item, ObjectSet<Tile>> ores;
|
||||||
@@ -57,6 +57,8 @@ public class BlockIndexer{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Events.on(WorldLoadEvent.class, event -> {
|
Events.on(WorldLoadEvent.class, event -> {
|
||||||
|
scanOres.clear();
|
||||||
|
scanOres.addAll(Item.getAllOres());
|
||||||
damagedTiles = new ObjectSet[Team.all.length];
|
damagedTiles = new ObjectSet[Team.all.length];
|
||||||
flagMap = new ObjectSet[Team.all.length][BlockFlag.all.length];
|
flagMap = new ObjectSet[Team.all.length][BlockFlag.all.length];
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,7 @@ import io.anuke.mindustry.world.Pos;
|
|||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.state;
|
import static io.anuke.mindustry.Min.*;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
|
||||||
|
|
||||||
public class Pathfinder{
|
public class Pathfinder{
|
||||||
private static final long maxUpdate = Time.millisToNanos(4);
|
private static final long maxUpdate = Time.millisToNanos(4);
|
||||||
@@ -117,7 +116,7 @@ public class Pathfinder{
|
|||||||
path.lastSearchTime = Time.millis();
|
path.lastSearchTime = Time.millis();
|
||||||
|
|
||||||
//add all targets to the frontier
|
//add all targets to the frontier
|
||||||
for(Tile other : world.indexer.getEnemy(team, BlockFlag.target)){
|
for(Tile other : indexer.getEnemy(team, BlockFlag.target)){
|
||||||
path.weights[other.x][other.y] = 0;
|
path.weights[other.x][other.y] = 0;
|
||||||
path.searches[other.x][other.y] = (short)path.search;
|
path.searches[other.x][other.y] = (short)path.search;
|
||||||
path.frontier.addFirst(other.pos());
|
path.frontier.addFirst(other.pos());
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import io.anuke.mindustry.game.SpawnGroup;
|
|||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class WaveSpawner{
|
public class WaveSpawner{
|
||||||
private static final float margin = 40f, coreMargin = tilesize * 3; //how far away from the edge flying units spawn
|
private static final float margin = 40f, coreMargin = tilesize * 3; //how far away from the edge flying units spawn
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import io.anuke.mindustry.world.consumers.*;
|
|||||||
import io.anuke.mindustry.world.meta.*;
|
import io.anuke.mindustry.world.meta.*;
|
||||||
import io.anuke.mindustry.world.modules.*;
|
import io.anuke.mindustry.world.modules.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class Blocks implements ContentList{
|
public class Blocks implements ContentList{
|
||||||
public static Block
|
public static Block
|
||||||
@@ -515,10 +515,10 @@ public class Blocks implements ContentList{
|
|||||||
Draw.alpha(entity.warmup);
|
Draw.alpha(entity.warmup);
|
||||||
|
|
||||||
Lines.lineAngleCenter(
|
Lines.lineAngleCenter(
|
||||||
tile.drawx() + Mathf.sin(entity.totalProgress, 6f, Vars.tilesize / 3f * size),
|
tile.drawx() + Mathf.sin(entity.totalProgress, 6f, Min.tilesize / 3f * size),
|
||||||
tile.drawy(),
|
tile.drawy(),
|
||||||
90,
|
90,
|
||||||
size * Vars.tilesize / 2f);
|
size * Min.tilesize / 2f);
|
||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import io.anuke.mindustry.graphics.*;
|
|||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.world;
|
||||||
|
|
||||||
public class Bullets implements ContentList{
|
public class Bullets implements ContentList{
|
||||||
public static BulletType
|
public static BulletType
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import io.anuke.mindustry.graphics.Drawf;
|
|||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.type.Item.Icon;
|
import io.anuke.mindustry.type.Item.Icon;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Min.tilesize;
|
||||||
|
|
||||||
public class Fx implements ContentList{
|
public class Fx implements ContentList{
|
||||||
public static Effect
|
public static Effect
|
||||||
|
|||||||
@@ -1,16 +1,15 @@
|
|||||||
package io.anuke.mindustry.core;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.function.Consumer;
|
import io.anuke.arc.function.*;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.*;
|
||||||
import io.anuke.arc.graphics.Pixmap;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.Log;
|
import io.anuke.mindustry.*;
|
||||||
import io.anuke.mindustry.content.*;
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.entities.bullet.BulletType;
|
import io.anuke.mindustry.entities.bullet.*;
|
||||||
import io.anuke.mindustry.game.*;
|
import io.anuke.mindustry.game.*;
|
||||||
import io.anuke.mindustry.type.*;
|
import io.anuke.mindustry.type.*;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.LegacyColorMapper;
|
|
||||||
|
|
||||||
import static io.anuke.arc.Core.files;
|
import static io.anuke.arc.Core.files;
|
||||||
|
|
||||||
@@ -21,8 +20,6 @@ import static io.anuke.arc.Core.files;
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class ContentLoader{
|
public class ContentLoader{
|
||||||
private boolean loaded = false;
|
private boolean loaded = false;
|
||||||
private boolean verbose = false;
|
|
||||||
|
|
||||||
private ObjectMap<String, MappableContent>[] contentNameMap = new ObjectMap[ContentType.values().length];
|
private ObjectMap<String, MappableContent>[] contentNameMap = new ObjectMap[ContentType.values().length];
|
||||||
private Array<Content>[] contentMap = new Array[ContentType.values().length];
|
private Array<Content>[] contentMap = new Array[ContentType.values().length];
|
||||||
private MappableContent[][] temporaryMapper;
|
private MappableContent[][] temporaryMapper;
|
||||||
@@ -45,12 +42,14 @@ public class ContentLoader{
|
|||||||
new LegacyColorMapper(),
|
new LegacyColorMapper(),
|
||||||
};
|
};
|
||||||
|
|
||||||
public void setVerbose(){
|
public ContentLoader(){
|
||||||
verbose = true;
|
//hack; allows content to initialize itself by referring to Mins.content, even though it hasn't been fully constructed yet
|
||||||
|
Min.content = this;
|
||||||
|
createContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Creates all content types. */
|
/** Creates all content types. */
|
||||||
public void load(){
|
private void createContent(){
|
||||||
if(loaded){
|
if(loaded){
|
||||||
Log.info("Content already loaded, skipping.");
|
Log.info("Content already loaded, skipping.");
|
||||||
return;
|
return;
|
||||||
@@ -65,8 +64,6 @@ public class ContentLoader{
|
|||||||
list.load();
|
list.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
int total = 0;
|
|
||||||
|
|
||||||
for(ContentType type : ContentType.values()){
|
for(ContentType type : ContentType.values()){
|
||||||
|
|
||||||
for(Content c : contentMap[type.ordinal()]){
|
for(Content c : contentMap[type.ordinal()]){
|
||||||
@@ -77,7 +74,6 @@ public class ContentLoader{
|
|||||||
}
|
}
|
||||||
contentNameMap[type.ordinal()].put(name, (MappableContent)c);
|
contentNameMap[type.ordinal()].put(name, (MappableContent)c);
|
||||||
}
|
}
|
||||||
total++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -91,25 +87,32 @@ public class ContentLoader{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(verbose){
|
|
||||||
Log.info("--- CONTENT INFO ---");
|
|
||||||
for(int k = 0; k < contentMap.length; k++){
|
|
||||||
Log.info("[{0}]: loaded {1}", ContentType.values()[k].name(), contentMap[k].size);
|
|
||||||
}
|
|
||||||
Log.info("Total content loaded: {0}", total);
|
|
||||||
Log.info("-------------------");
|
|
||||||
}
|
|
||||||
|
|
||||||
loaded = true;
|
loaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void initialize(Consumer<Content> callable){
|
/** Logs content statistics.*/
|
||||||
initialize(callable, false);
|
public void logContent(){
|
||||||
|
Log.info("--- CONTENT INFO ---");
|
||||||
|
for(int k = 0; k < contentMap.length; k++){
|
||||||
|
Log.info("[{0}]: loaded {1}", ContentType.values()[k].name(), contentMap[k].size);
|
||||||
|
}
|
||||||
|
Log.info("Total content loaded: {0}", Array.with(ContentType.values()).mapInt(c -> contentMap[c.ordinal()].size).sum());
|
||||||
|
Log.info("-------------------");
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Calls Content#init() on everything. Use only after all modules have been created.*/
|
||||||
|
public void init(){
|
||||||
|
initialize(Content::init);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Calls Content#load() on everything. Use only after all modules have been created on the client.*/
|
||||||
|
public void load(){
|
||||||
|
initialize(Content::load);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Initializes all content with the specified function. */
|
/** Initializes all content with the specified function. */
|
||||||
public void initialize(Consumer<Content> callable, boolean override){
|
private void initialize(Consumer<Content> callable){
|
||||||
if(initialization.contains(callable) && !override) return;
|
if(initialization.contains(callable)) return;
|
||||||
|
|
||||||
for(ContentType type : ContentType.values()){
|
for(ContentType type : ContentType.values()){
|
||||||
for(Content content : contentMap[type.ordinal()]){
|
for(Content content : contentMap[type.ordinal()]){
|
||||||
@@ -136,12 +139,8 @@ public class ContentLoader{
|
|||||||
pixmap.dispose();
|
pixmap.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void verbose(boolean verbose){
|
|
||||||
this.verbose = verbose;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void dispose(){
|
public void dispose(){
|
||||||
//clear all content, currently not needed
|
//clear all content, currently not used
|
||||||
}
|
}
|
||||||
|
|
||||||
public void handleContent(Content content){
|
public void handleContent(Content content){
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package io.anuke.mindustry.core;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
import io.anuke.arc.*;
|
import io.anuke.arc.*;
|
||||||
|
import io.anuke.arc.assets.*;
|
||||||
import io.anuke.arc.files.*;
|
import io.anuke.arc.files.*;
|
||||||
import io.anuke.arc.graphics.*;
|
import io.anuke.arc.graphics.*;
|
||||||
import io.anuke.arc.graphics.g2d.*;
|
import io.anuke.arc.graphics.g2d.*;
|
||||||
@@ -13,8 +14,8 @@ import io.anuke.mindustry.content.*;
|
|||||||
import io.anuke.mindustry.core.GameState.*;
|
import io.anuke.mindustry.core.GameState.*;
|
||||||
import io.anuke.mindustry.entities.*;
|
import io.anuke.mindustry.entities.*;
|
||||||
import io.anuke.mindustry.entities.type.*;
|
import io.anuke.mindustry.entities.type.*;
|
||||||
import io.anuke.mindustry.game.*;
|
|
||||||
import io.anuke.mindustry.game.EventType.*;
|
import io.anuke.mindustry.game.EventType.*;
|
||||||
|
import io.anuke.mindustry.game.*;
|
||||||
import io.anuke.mindustry.gen.*;
|
import io.anuke.mindustry.gen.*;
|
||||||
import io.anuke.mindustry.input.*;
|
import io.anuke.mindustry.input.*;
|
||||||
import io.anuke.mindustry.maps.*;
|
import io.anuke.mindustry.maps.*;
|
||||||
@@ -27,7 +28,7 @@ import io.anuke.mindustry.world.blocks.storage.*;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static io.anuke.arc.Core.*;
|
import static io.anuke.arc.Core.*;
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Control module.
|
* Control module.
|
||||||
@@ -35,10 +36,10 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
* Should <i>not</i> handle any logic-critical state.
|
* Should <i>not</i> handle any logic-critical state.
|
||||||
* This class is not created in the headless server.
|
* This class is not created in the headless server.
|
||||||
*/
|
*/
|
||||||
public class Control implements ApplicationListener{
|
public class Control implements ApplicationListener, Loadable{
|
||||||
public final Saves saves;
|
public Saves saves;
|
||||||
public final MusicControl music;
|
public MusicControl music;
|
||||||
public final Tutorial tutorial;
|
public Tutorial tutorial;
|
||||||
public InputHandler input;
|
public InputHandler input;
|
||||||
|
|
||||||
private Interval timer = new Interval(2);
|
private Interval timer = new Interval(2);
|
||||||
@@ -46,36 +47,6 @@ public class Control implements ApplicationListener{
|
|||||||
private boolean wasPaused = false;
|
private boolean wasPaused = false;
|
||||||
|
|
||||||
public Control(){
|
public Control(){
|
||||||
saves = new Saves();
|
|
||||||
tutorial = new Tutorial();
|
|
||||||
music = new MusicControl();
|
|
||||||
|
|
||||||
UnitScl.dp.setProduct(settings.getInt("uiscale", 100) / 100f);
|
|
||||||
|
|
||||||
Core.input.setCatch(KeyCode.BACK, true);
|
|
||||||
|
|
||||||
content.initialize(Content::init);
|
|
||||||
Core.atlas = new TextureAtlas("sprites/sprites.atlas");
|
|
||||||
Draw.scl = 1f / Core.atlas.find("scale_marker").getWidth();
|
|
||||||
content.initialize(Content::load, true);
|
|
||||||
|
|
||||||
data.load();
|
|
||||||
|
|
||||||
Core.settings.setAppName(appName);
|
|
||||||
Core.settings.defaults(
|
|
||||||
"ip", "localhost",
|
|
||||||
"color-0", Color.rgba8888(playerColors[8]),
|
|
||||||
"color-1", Color.rgba8888(playerColors[11]),
|
|
||||||
"color-2", Color.rgba8888(playerColors[13]),
|
|
||||||
"color-3", Color.rgba8888(playerColors[9]),
|
|
||||||
"name", "",
|
|
||||||
"lastBuild", 0
|
|
||||||
);
|
|
||||||
|
|
||||||
createPlayer();
|
|
||||||
|
|
||||||
saves.load();
|
|
||||||
|
|
||||||
Events.on(StateChangeEvent.class, event -> {
|
Events.on(StateChangeEvent.class, event -> {
|
||||||
if((event.from == State.playing && event.to == State.menu) || (event.from == State.menu && event.to != State.menu)){
|
if((event.from == State.playing && event.to == State.menu) || (event.from == State.menu && event.to != State.menu)){
|
||||||
Time.runTask(5f, Platform.instance::updateRPC);
|
Time.runTask(5f, Platform.instance::updateRPC);
|
||||||
@@ -176,9 +147,38 @@ public class Control implements ApplicationListener{
|
|||||||
Events.on(ZoneConfigureCompleteEvent.class, e -> {
|
Events.on(ZoneConfigureCompleteEvent.class, e -> {
|
||||||
ui.hudfrag.showToast(Core.bundle.format("zone.config.complete", e.zone.configureWave));
|
ui.hudfrag.showToast(Core.bundle.format("zone.config.complete", e.zone.configureWave));
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadAsync(){
|
||||||
|
saves = new Saves();
|
||||||
|
tutorial = new Tutorial();
|
||||||
|
music = new MusicControl();
|
||||||
|
|
||||||
|
Draw.scl = 1f / Core.atlas.find("scale_marker").getWidth();
|
||||||
|
|
||||||
|
UnitScl.dp.setProduct(settings.getInt("uiscale", 100) / 100f);
|
||||||
|
|
||||||
|
Core.input.setCatch(KeyCode.BACK, true);
|
||||||
|
|
||||||
|
data.load();
|
||||||
|
|
||||||
|
Core.settings.defaults(
|
||||||
|
"ip", "localhost",
|
||||||
|
"color-0", Color.rgba8888(playerColors[8]),
|
||||||
|
"name", "",
|
||||||
|
"lastBuild", 0
|
||||||
|
);
|
||||||
|
|
||||||
|
createPlayer();
|
||||||
|
|
||||||
|
saves.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadSync(){
|
||||||
if(android){
|
if(android){
|
||||||
Sounds.empty.loop(0f, 1f, 0f);
|
//Sounds.empty.loop(0f, 1f, 0f);
|
||||||
|
|
||||||
checkClassicData();
|
checkClassicData();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import io.anuke.mindustry.game.EventType.StateChangeEvent;
|
|||||||
import io.anuke.mindustry.game.*;
|
import io.anuke.mindustry.game.*;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.unitGroups;
|
import static io.anuke.mindustry.Min.unitGroups;
|
||||||
import static io.anuke.mindustry.Vars.waveTeam;
|
import static io.anuke.mindustry.Min.waveTeam;
|
||||||
|
|
||||||
public class GameState{
|
public class GameState{
|
||||||
/** Current wave number, can be anything in non-wave modes. */
|
/** Current wave number, can be anything in non-wave modes. */
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
import io.anuke.mindustry.world.blocks.BuildBlock;
|
import io.anuke.mindustry.world.blocks.BuildBlock;
|
||||||
import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity;
|
import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Logic module.
|
* Logic module.
|
||||||
@@ -109,7 +109,7 @@ public class Logic implements ApplicationListener{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void runWave(){
|
public void runWave(){
|
||||||
world.spawner.spawnEnemies();
|
spawner.spawnEnemies();
|
||||||
state.wave++;
|
state.wave++;
|
||||||
state.wavetime = world.isZone() && world.getZone().isBossWave(state.wave) ? state.rules.waveSpacing * state.rules.bossWaveMultiplier :
|
state.wavetime = world.isZone() && world.getZone().isBossWave(state.wave) ? state.rules.waveSpacing * state.rules.bossWaveMultiplier :
|
||||||
world.isZone() && world.getZone().isLaunchWave(state.wave) ? state.rules.waveSpacing * state.rules.launchWaveMultiplier : state.rules.waveSpacing;
|
world.isZone() && world.getZone().isLaunchWave(state.wave) ? state.rules.waveSpacing * state.rules.launchWaveMultiplier : state.rules.waveSpacing;
|
||||||
@@ -234,7 +234,7 @@ public class Logic implements ApplicationListener{
|
|||||||
collisions.collideGroups(bulletGroup, playerGroup);
|
collisions.collideGroups(bulletGroup, playerGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
world.pathfinder.update();
|
pathfinder.update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Net.client() && !world.isInvalidMap() && !state.isEditor()){
|
if(!Net.client() && !world.isInvalidMap() && !state.isEditor()){
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import io.anuke.arc.math.RandomXS128;
|
|||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.io.ReusableByteInStream;
|
import io.anuke.arc.util.io.ReusableByteInStream;
|
||||||
import io.anuke.arc.util.serialization.Base64Coder;
|
import io.anuke.arc.util.serialization.Base64Coder;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Min;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.entities.Entities;
|
import io.anuke.mindustry.entities.Entities;
|
||||||
import io.anuke.mindustry.entities.EntityGroup;
|
import io.anuke.mindustry.entities.EntityGroup;
|
||||||
@@ -33,7 +33,7 @@ import java.io.DataInputStream;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.zip.InflaterInputStream;
|
import java.util.zip.InflaterInputStream;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class NetClient implements ApplicationListener{
|
public class NetClient implements ApplicationListener{
|
||||||
private final static float dataTimeout = 60 * 18;
|
private final static float dataTimeout = 60 * 18;
|
||||||
@@ -126,8 +126,8 @@ public class NetClient implements ApplicationListener{
|
|||||||
//called on all clients
|
//called on all clients
|
||||||
@Remote(called = Loc.server, targets = Loc.server, variants = Variant.both)
|
@Remote(called = Loc.server, targets = Loc.server, variants = Variant.both)
|
||||||
public static void sendMessage(String message, String sender, Player playersender){
|
public static void sendMessage(String message, String sender, Player playersender){
|
||||||
if(Vars.ui != null){
|
if(Min.ui != null){
|
||||||
Vars.ui.chatfrag.addMessage(message, sender);
|
Min.ui.chatfrag.addMessage(message, sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(playersender != null){
|
if(playersender != null){
|
||||||
@@ -139,8 +139,8 @@ public class NetClient implements ApplicationListener{
|
|||||||
//equivalent to above method but there's no sender and no console log
|
//equivalent to above method but there's no sender and no console log
|
||||||
@Remote(called = Loc.server, targets = Loc.server)
|
@Remote(called = Loc.server, targets = Loc.server)
|
||||||
public static void sendMessage(String message){
|
public static void sendMessage(String message){
|
||||||
if(Vars.ui != null){
|
if(Min.ui != null){
|
||||||
Vars.ui.chatfrag.addMessage(message, null);
|
Min.ui.chatfrag.addMessage(message, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ import java.io.*;
|
|||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.util.zip.DeflaterOutputStream;
|
import java.util.zip.DeflaterOutputStream;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class NetServer implements ApplicationListener{
|
public class NetServer implements ApplicationListener{
|
||||||
public final static int maxSnapshotSize = 430;
|
public final static int maxSnapshotSize = 430;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import io.anuke.arc.math.RandomXS128;
|
|||||||
import io.anuke.arc.scene.ui.TextField;
|
import io.anuke.arc.scene.ui.TextField;
|
||||||
import io.anuke.arc.util.serialization.Base64Coder;
|
import io.anuke.arc.util.serialization.Base64Coder;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.mobile;
|
import static io.anuke.mindustry.Min.mobile;
|
||||||
|
|
||||||
public abstract class Platform{
|
public abstract class Platform{
|
||||||
/** Each separate game platform should set this instance to their own implementation. */
|
/** Each separate game platform should set this instance to their own implementation. */
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import io.anuke.mindustry.graphics.*;
|
|||||||
import io.anuke.mindustry.world.blocks.defense.ForceProjector.*;
|
import io.anuke.mindustry.world.blocks.defense.ForceProjector.*;
|
||||||
|
|
||||||
import static io.anuke.arc.Core.*;
|
import static io.anuke.arc.Core.*;
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class Renderer implements ApplicationListener{
|
public class Renderer implements ApplicationListener{
|
||||||
public final BlockRenderer blocks = new BlockRenderer();
|
public final BlockRenderer blocks = new BlockRenderer();
|
||||||
|
|||||||
@@ -3,8 +3,13 @@ package io.anuke.mindustry.core;
|
|||||||
import io.anuke.arc.*;
|
import io.anuke.arc.*;
|
||||||
import io.anuke.arc.Graphics.*;
|
import io.anuke.arc.Graphics.*;
|
||||||
import io.anuke.arc.Graphics.Cursor.*;
|
import io.anuke.arc.Graphics.Cursor.*;
|
||||||
|
import io.anuke.arc.assets.*;
|
||||||
|
import io.anuke.arc.assets.loaders.*;
|
||||||
|
import io.anuke.arc.assets.loaders.resolvers.*;
|
||||||
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.freetype.*;
|
import io.anuke.arc.freetype.*;
|
||||||
import io.anuke.arc.freetype.FreeTypeFontGenerator.*;
|
import io.anuke.arc.freetype.FreeTypeFontGenerator.*;
|
||||||
|
import io.anuke.arc.freetype.FreetypeFontLoader.*;
|
||||||
import io.anuke.arc.function.*;
|
import io.anuke.arc.function.*;
|
||||||
import io.anuke.arc.graphics.*;
|
import io.anuke.arc.graphics.*;
|
||||||
import io.anuke.arc.graphics.g2d.*;
|
import io.anuke.arc.graphics.g2d.*;
|
||||||
@@ -29,10 +34,10 @@ import io.anuke.mindustry.ui.dialogs.*;
|
|||||||
import io.anuke.mindustry.ui.fragments.*;
|
import io.anuke.mindustry.ui.fragments.*;
|
||||||
|
|
||||||
import static io.anuke.arc.scene.actions.Actions.*;
|
import static io.anuke.arc.scene.actions.Actions.*;
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class UI implements ApplicationListener{
|
public class UI implements ApplicationListener, Loadable{
|
||||||
private FreeTypeFontGenerator generator;
|
private Skin skin;
|
||||||
|
|
||||||
public MenuFragment menufrag;
|
public MenuFragment menufrag;
|
||||||
public HudFragment hudfrag;
|
public HudFragment hudfrag;
|
||||||
@@ -67,9 +72,25 @@ public class UI implements ApplicationListener{
|
|||||||
public Cursor drillCursor, unloadCursor;
|
public Cursor drillCursor, unloadCursor;
|
||||||
|
|
||||||
public UI(){
|
public UI(){
|
||||||
Skin skin = new Skin(Core.atlas);
|
FileHandleResolver resolver = new InternalFileHandleResolver();
|
||||||
generateFonts(skin);
|
Core.assets.setLoader(FreeTypeFontGenerator.class, new FreeTypeFontGeneratorLoader(resolver));
|
||||||
|
Core.assets.setLoader(BitmapFont.class, null, new FreetypeFontLoader(resolver));
|
||||||
|
skin = new Skin();
|
||||||
|
setupFonts();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadAsync(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadSync(){
|
||||||
|
//TODO type-safe skin files
|
||||||
|
skin.addRegions(Core.atlas);
|
||||||
loadExtraStyle(skin);
|
loadExtraStyle(skin);
|
||||||
|
skin.getFont("default").getData().markupEnabled = true;
|
||||||
|
skin.getFont("default").setOwnsTexture(false);
|
||||||
skin.load(Core.files.internal("sprites/uiskin.json"));
|
skin.load(Core.files.internal("sprites/uiskin.json"));
|
||||||
|
|
||||||
for(BitmapFont font : skin.getAll(BitmapFont.class).values()){
|
for(BitmapFont font : skin.getAll(BitmapFont.class).values()){
|
||||||
@@ -97,6 +118,11 @@ public class UI implements ApplicationListener{
|
|||||||
loadExtraCursors();
|
loadExtraCursors();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Array<AssetDescriptor> getDependencies(){
|
||||||
|
return Array.with(new AssetDescriptor<>(Control.class), new AssetDescriptor<>("outline", BitmapFont.class), new AssetDescriptor<>("default", BitmapFont.class), new AssetDescriptor<>("chat", BitmapFont.class));
|
||||||
|
}
|
||||||
|
|
||||||
/** Called from a static context to make the cursor appear immediately upon startup.*/
|
/** Called from a static context to make the cursor appear immediately upon startup.*/
|
||||||
public static void loadSystemCursors(){
|
public static void loadSystemCursors(){
|
||||||
SystemCursor.arrow.set(Core.graphics.newCursor("cursor"));
|
SystemCursor.arrow.set(Core.graphics.newCursor("cursor"));
|
||||||
@@ -130,8 +156,8 @@ public class UI implements ApplicationListener{
|
|||||||
unloadCursor = Core.graphics.newCursor("unload");
|
unloadCursor = Core.graphics.newCursor("unload");
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateFonts(Skin skin){
|
void setupFonts(){
|
||||||
generator = new FreeTypeFontGenerator(Core.files.internal("fonts/font.ttf"));
|
String fontName = "fonts/font.ttf";
|
||||||
|
|
||||||
FreeTypeFontParameter param = new FreeTypeFontParameter(){{
|
FreeTypeFontParameter param = new FreeTypeFontParameter(){{
|
||||||
size = (int)(UnitScl.dp.scl(18f));
|
size = (int)(UnitScl.dp.scl(18f));
|
||||||
@@ -148,11 +174,9 @@ public class UI implements ApplicationListener{
|
|||||||
incremental = true;
|
incremental = true;
|
||||||
}};
|
}};
|
||||||
|
|
||||||
skin.add("outline", generator.generateFont(outlined));
|
Core.assets.load("outline", BitmapFont.class, new FreeTypeFontLoaderParameter(fontName, outlined)).loaded = f -> skin.add("outline", f);
|
||||||
skin.add("default", generator.generateFont(param));
|
Core.assets.load("default", BitmapFont.class, new FreeTypeFontLoaderParameter(fontName, param)).loaded = f -> skin.add("default", f);
|
||||||
skin.add("chat", generator.generateFont(param));
|
Core.assets.load("chat", BitmapFont.class, new FreeTypeFontLoaderParameter(fontName, param)).loaded = f -> skin.add("chat", f);
|
||||||
skin.getFont("default").getData().markupEnabled = true;
|
|
||||||
skin.getFont("default").setOwnsTexture(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -232,7 +256,7 @@ public class UI implements ApplicationListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose(){
|
public void dispose(){
|
||||||
generator.dispose();
|
//generator.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadAnd(Runnable call){
|
public void loadAnd(Runnable call){
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import io.anuke.arc.collection.*;
|
|||||||
import io.anuke.arc.math.*;
|
import io.anuke.arc.math.*;
|
||||||
import io.anuke.arc.math.geom.*;
|
import io.anuke.arc.math.geom.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.ai.*;
|
|
||||||
import io.anuke.mindustry.content.*;
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.core.GameState.*;
|
import io.anuke.mindustry.core.GameState.*;
|
||||||
import io.anuke.mindustry.entities.*;
|
import io.anuke.mindustry.entities.*;
|
||||||
@@ -21,13 +20,9 @@ import io.anuke.mindustry.type.*;
|
|||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class World implements ApplicationListener{
|
public class World{
|
||||||
public final Maps maps = new Maps();
|
|
||||||
public final BlockIndexer indexer = new BlockIndexer();
|
|
||||||
public final WaveSpawner spawner = new WaveSpawner();
|
|
||||||
public final Pathfinder pathfinder = new Pathfinder();
|
|
||||||
public final Context context = new Context();
|
public final Context context = new Context();
|
||||||
|
|
||||||
private Map currentMap;
|
private Map currentMap;
|
||||||
@@ -36,17 +31,7 @@ public class World implements ApplicationListener{
|
|||||||
private boolean generating, invalidMap;
|
private boolean generating, invalidMap;
|
||||||
|
|
||||||
public World(){
|
public World(){
|
||||||
maps.load();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(){
|
|
||||||
maps.loadLegacyMaps();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose(){
|
|
||||||
maps.dispose();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInvalidMap(){
|
public boolean isInvalidMap(){
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import io.anuke.mindustry.world.Block;
|
|||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.Floor;
|
import io.anuke.mindustry.world.blocks.Floor;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.content;
|
import static io.anuke.mindustry.Min.content;
|
||||||
|
|
||||||
public class DrawOperation{
|
public class DrawOperation{
|
||||||
private MapEditor editor;
|
private MapEditor editor;
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
import io.anuke.mindustry.world.modules.*;
|
import io.anuke.mindustry.world.modules.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.state;
|
import static io.anuke.mindustry.Min.state;
|
||||||
import static io.anuke.mindustry.Vars.ui;
|
import static io.anuke.mindustry.Min.ui;
|
||||||
|
|
||||||
//TODO somehow remove or replace this class with a more flexible solution
|
//TODO somehow remove or replace this class with a more flexible solution
|
||||||
public class EditorTile extends Tile{
|
public class EditorTile extends Tile{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import io.anuke.arc.function.*;
|
|||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.Bresenham2;
|
import io.anuke.arc.math.geom.Bresenham2;
|
||||||
import io.anuke.arc.util.Structs;
|
import io.anuke.arc.util.Structs;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Min;
|
||||||
import io.anuke.mindustry.content.Blocks;
|
import io.anuke.mindustry.content.Blocks;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
@@ -80,7 +80,7 @@ public enum EditorTool{
|
|||||||
editor.drawCircle(x, y, tile -> {
|
editor.drawCircle(x, y, tile -> {
|
||||||
if(mode == -1){
|
if(mode == -1){
|
||||||
//erase block
|
//erase block
|
||||||
Vars.world.removeBlock(tile);
|
Min.world.removeBlock(tile);
|
||||||
}else if(mode == 0){
|
}else if(mode == 0){
|
||||||
//erase ore
|
//erase ore
|
||||||
tile.clearOverlay();
|
tile.clearOverlay();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ import io.anuke.mindustry.maps.Map;
|
|||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.blocks.BlockPart;
|
import io.anuke.mindustry.world.blocks.BlockPart;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.world;
|
||||||
|
|
||||||
public class MapEditor{
|
public class MapEditor{
|
||||||
public static final int[] brushSizes = {1, 2, 3, 4, 5, 9, 15, 20};
|
public static final int[] brushSizes = {1, 2, 3, 4, 5, 9, 15, 20};
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import io.anuke.mindustry.world.Block.*;
|
|||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
import io.anuke.mindustry.world.blocks.storage.*;
|
import io.anuke.mindustry.world.blocks.storage.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class MapEditorDialog extends Dialog implements Disposable{
|
public class MapEditorDialog extends Dialog implements Disposable{
|
||||||
public final MapEditor editor;
|
public final MapEditor editor;
|
||||||
@@ -93,11 +93,11 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
"$editor.importmap", "$editor.importmap.description", "icon-load-map", (Runnable)loadDialog::show,
|
"$editor.importmap", "$editor.importmap.description", "icon-load-map", (Runnable)loadDialog::show,
|
||||||
"$editor.importfile", "$editor.importfile.description", "icon-file", (Runnable)() ->
|
"$editor.importfile", "$editor.importfile.description", "icon-file", (Runnable)() ->
|
||||||
Platform.instance.showFileChooser("$editor.loadmap", "Map Files", file -> ui.loadAnd(() -> {
|
Platform.instance.showFileChooser("$editor.loadmap", "Map Files", file -> ui.loadAnd(() -> {
|
||||||
world.maps.tryCatchMapError(() -> {
|
maps.tryCatchMapError(() -> {
|
||||||
if(MapIO.isImage(file)){
|
if(MapIO.isImage(file)){
|
||||||
ui.showInfo("$editor.errorimage");
|
ui.showInfo("$editor.errorimage");
|
||||||
}else if(file.extension().equalsIgnoreCase(oldMapExtension)){
|
}else if(file.extension().equalsIgnoreCase(oldMapExtension)){
|
||||||
editor.beginEdit(world.maps.makeLegacyMap(file));
|
editor.beginEdit(maps.makeLegacyMap(file));
|
||||||
}else{
|
}else{
|
||||||
editor.beginEdit(MapIO.createMap(file, true));
|
editor.beginEdit(MapIO.createMap(file, true));
|
||||||
}
|
}
|
||||||
@@ -286,11 +286,11 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
infoDialog.show();
|
infoDialog.show();
|
||||||
Core.app.post(() -> ui.showError("$editor.save.noname"));
|
Core.app.post(() -> ui.showError("$editor.save.noname"));
|
||||||
}else{
|
}else{
|
||||||
Map map = world.maps.all().find(m -> m.name().equals(name));
|
Map map = maps.all().find(m -> m.name().equals(name));
|
||||||
if(map != null && !map.custom){
|
if(map != null && !map.custom){
|
||||||
handleSaveBuiltin(map);
|
handleSaveBuiltin(map);
|
||||||
}else{
|
}else{
|
||||||
world.maps.saveMap(editor.getTags());
|
maps.saveMap(editor.getTags());
|
||||||
ui.showInfoFade("$editor.saved");
|
ui.showInfoFade("$editor.saved");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -670,7 +670,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
|
|
||||||
blocksOut.clear();
|
blocksOut.clear();
|
||||||
blocksOut.addAll(Vars.content.blocks());
|
blocksOut.addAll(Min.content.blocks());
|
||||||
blocksOut.sort((b1, b2) -> {
|
blocksOut.sort((b1, b2) -> {
|
||||||
int core = -Boolean.compare(b1 instanceof CoreBlock, b2 instanceof CoreBlock);
|
int core = -Boolean.compare(b1 instanceof CoreBlock, b2 instanceof CoreBlock);
|
||||||
if(core != 0) return core;
|
if(core != 0) return core;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import io.anuke.mindustry.ui.dialogs.*;
|
|||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public class MapGenerateDialog extends FloatingDialog{
|
public class MapGenerateDialog extends FloatingDialog{
|
||||||
@@ -72,7 +72,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
|||||||
}).size(160f, 64f);
|
}).size(160f, 64f);
|
||||||
}else{
|
}else{
|
||||||
buttons.addButton("$settings.reset", () -> {
|
buttons.addButton("$settings.reset", () -> {
|
||||||
filters.set(world.maps.readFilters(""));
|
filters.set(maps.readFilters(""));
|
||||||
rebuildFilters();
|
rebuildFilters();
|
||||||
update();
|
update();
|
||||||
}).size(160f, 64f);
|
}).size(160f, 64f);
|
||||||
@@ -304,7 +304,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
|||||||
}
|
}
|
||||||
|
|
||||||
selection.cont.addButton("$filter.defaultores", () -> {
|
selection.cont.addButton("$filter.defaultores", () -> {
|
||||||
world.maps.addDefaultOres(filters);
|
maps.addDefaultOres(filters);
|
||||||
rebuildFilters();
|
rebuildFilters();
|
||||||
update();
|
update();
|
||||||
selection.hide();
|
selection.hide();
|
||||||
|
|||||||
@@ -9,8 +9,6 @@ import io.anuke.mindustry.game.*;
|
|||||||
import io.anuke.mindustry.io.*;
|
import io.anuke.mindustry.io.*;
|
||||||
import io.anuke.mindustry.ui.dialogs.*;
|
import io.anuke.mindustry.ui.dialogs.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
|
||||||
|
|
||||||
public class MapInfoDialog extends FloatingDialog{
|
public class MapInfoDialog extends FloatingDialog{
|
||||||
private final MapEditor editor;
|
private final MapEditor editor;
|
||||||
private final WaveInfoDialog waveInfo;
|
private final WaveInfoDialog waveInfo;
|
||||||
@@ -61,7 +59,7 @@ public class MapInfoDialog extends FloatingDialog{
|
|||||||
|
|
||||||
t.row();
|
t.row();
|
||||||
t.add("$editor.rules").padRight(8).left();
|
t.add("$editor.rules").padRight(8).left();
|
||||||
t.addButton("$edit", () -> ruleInfo.show(Vars.state.rules, () -> Vars.state.rules = new Rules())).left().width(200f);
|
t.addButton("$edit", () -> ruleInfo.show(Min.state.rules, () -> Min.state.rules = new Rules())).left().width(200f);
|
||||||
|
|
||||||
t.row();
|
t.row();
|
||||||
t.add("$editor.waves").padRight(8).left();
|
t.add("$editor.waves").padRight(8).left();
|
||||||
@@ -70,7 +68,7 @@ public class MapInfoDialog extends FloatingDialog{
|
|||||||
t.row();
|
t.row();
|
||||||
t.add("$editor.generation").padRight(8).left();
|
t.add("$editor.generation").padRight(8).left();
|
||||||
t.addButton("$edit",
|
t.addButton("$edit",
|
||||||
() -> generate.show(world.maps.readFilters(editor.getTags().get("genfilters", "")),
|
() -> generate.show(Min.maps.readFilters(editor.getTags().get("genfilters", "")),
|
||||||
filters -> editor.getTags().put("genfilters", JsonIO.write(filters)))
|
filters -> editor.getTags().put("genfilters", JsonIO.write(filters)))
|
||||||
).left().width(200f);
|
).left().width(200f);
|
||||||
|
|
||||||
|
|||||||
@@ -1,14 +1,14 @@
|
|||||||
package io.anuke.mindustry.editor;
|
package io.anuke.mindustry.editor;
|
||||||
|
|
||||||
import io.anuke.arc.function.Consumer;
|
import io.anuke.arc.function.*;
|
||||||
import io.anuke.arc.scene.ui.*;
|
import io.anuke.arc.scene.ui.*;
|
||||||
import io.anuke.arc.scene.ui.layout.Table;
|
import io.anuke.arc.scene.ui.layout.*;
|
||||||
import io.anuke.arc.util.Scaling;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.maps.Map;
|
import io.anuke.mindustry.maps.*;
|
||||||
import io.anuke.mindustry.ui.BorderImage;
|
import io.anuke.mindustry.ui.*;
|
||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.maps;
|
||||||
|
|
||||||
public class MapLoadDialog extends FloatingDialog{
|
public class MapLoadDialog extends FloatingDialog{
|
||||||
private Map selected = null;
|
private Map selected = null;
|
||||||
@@ -17,7 +17,6 @@ public class MapLoadDialog extends FloatingDialog{
|
|||||||
super("$editor.loadmap");
|
super("$editor.loadmap");
|
||||||
|
|
||||||
shown(this::rebuild);
|
shown(this::rebuild);
|
||||||
rebuild();
|
|
||||||
|
|
||||||
TextButton button = new TextButton("$load");
|
TextButton button = new TextButton("$load");
|
||||||
button.setDisabled(() -> selected == null);
|
button.setDisabled(() -> selected == null);
|
||||||
@@ -35,8 +34,8 @@ public class MapLoadDialog extends FloatingDialog{
|
|||||||
|
|
||||||
public void rebuild(){
|
public void rebuild(){
|
||||||
cont.clear();
|
cont.clear();
|
||||||
if(world.maps.all().size > 0){
|
if(maps.all().size > 0){
|
||||||
selected = world.maps.all().first();
|
selected = maps.all().first();
|
||||||
}
|
}
|
||||||
|
|
||||||
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
ButtonGroup<TextButton> group = new ButtonGroup<>();
|
||||||
@@ -52,7 +51,7 @@ public class MapLoadDialog extends FloatingDialog{
|
|||||||
ScrollPane pane = new ScrollPane(table, "horizontal");
|
ScrollPane pane = new ScrollPane(table, "horizontal");
|
||||||
pane.setFadeScrollBars(false);
|
pane.setFadeScrollBars(false);
|
||||||
|
|
||||||
for(Map map : world.maps.all()){
|
for(Map map : maps.all()){
|
||||||
|
|
||||||
TextButton button = new TextButton(map.name(), "toggle");
|
TextButton button = new TextButton(map.name(), "toggle");
|
||||||
button.add(new BorderImage(map.texture, 2f).setScaling(Scaling.fit)).size(16 * 4f);
|
button.add(new BorderImage(map.texture, 2f).setScaling(Scaling.fit)).size(16 * 4f);
|
||||||
@@ -64,7 +63,7 @@ public class MapLoadDialog extends FloatingDialog{
|
|||||||
if(++i % maxcol == 0) table.row();
|
if(++i % maxcol == 0) table.row();
|
||||||
}
|
}
|
||||||
|
|
||||||
if(world.maps.all().size == 0){
|
if(maps.all().size == 0){
|
||||||
table.add("$maps.none").center();
|
table.add("$maps.none").center();
|
||||||
}else{
|
}else{
|
||||||
cont.add("$editor.loadmap");
|
cont.add("$editor.loadmap");
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import io.anuke.arc.graphics.Texture;
|
|||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.util.Disposable;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.content.Blocks;
|
import io.anuke.mindustry.content.Blocks;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.graphics.IndexedRenderer;
|
import io.anuke.mindustry.graphics.IndexedRenderer;
|
||||||
@@ -16,7 +16,7 @@ import io.anuke.mindustry.world.Block;
|
|||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.BlockPart;
|
import io.anuke.mindustry.world.blocks.BlockPart;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Min.tilesize;
|
||||||
|
|
||||||
public class MapRenderer implements Disposable{
|
public class MapRenderer implements Disposable{
|
||||||
private static final int chunkSize = 64;
|
private static final int chunkSize = 64;
|
||||||
|
|||||||
@@ -1,14 +1,13 @@
|
|||||||
package io.anuke.mindustry.editor;
|
package io.anuke.mindustry.editor;
|
||||||
|
|
||||||
import io.anuke.arc.function.Consumer;
|
import io.anuke.arc.function.*;
|
||||||
import io.anuke.arc.scene.ui.TextButton;
|
import io.anuke.arc.scene.ui.*;
|
||||||
import io.anuke.arc.scene.ui.TextField;
|
import io.anuke.mindustry.*;
|
||||||
import io.anuke.mindustry.core.Platform;
|
import io.anuke.mindustry.core.*;
|
||||||
import io.anuke.mindustry.maps.Map;
|
import io.anuke.mindustry.maps.*;
|
||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.ui;
|
import static io.anuke.mindustry.Min.ui;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
|
||||||
|
|
||||||
public class MapSaveDialog extends FloatingDialog{
|
public class MapSaveDialog extends FloatingDialog{
|
||||||
private TextField field;
|
private TextField field;
|
||||||
@@ -24,7 +23,7 @@ public class MapSaveDialog extends FloatingDialog{
|
|||||||
shown(() -> {
|
shown(() -> {
|
||||||
cont.clear();
|
cont.clear();
|
||||||
cont.label(() -> {
|
cont.label(() -> {
|
||||||
Map map = world.maps.byName(field.getText());
|
Map map = Min.maps.byName(field.getText());
|
||||||
if(map != null){
|
if(map != null){
|
||||||
if(map.custom){
|
if(map.custom){
|
||||||
return "$editor.overwrite";
|
return "$editor.overwrite";
|
||||||
@@ -69,7 +68,7 @@ public class MapSaveDialog extends FloatingDialog{
|
|||||||
if(field.getText().isEmpty()){
|
if(field.getText().isEmpty()){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
Map map = world.maps.byName(field.getText());
|
Map map = Min.maps.byName(field.getText());
|
||||||
return map != null && !map.custom;
|
return map != null && !map.custom;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import io.anuke.mindustry.graphics.Pal;
|
|||||||
import io.anuke.mindustry.input.Binding;
|
import io.anuke.mindustry.input.Binding;
|
||||||
import io.anuke.mindustry.ui.GridImage;
|
import io.anuke.mindustry.ui.GridImage;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.mobile;
|
import static io.anuke.mindustry.Min.mobile;
|
||||||
import static io.anuke.mindustry.Vars.ui;
|
import static io.anuke.mindustry.Min.ui;
|
||||||
|
|
||||||
public class MapView extends Element implements GestureListener{
|
public class MapView extends Element implements GestureListener{
|
||||||
private MapEditor editor;
|
private MapEditor editor;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import io.anuke.arc.scene.ui.Label;
|
|||||||
import io.anuke.arc.scene.ui.TextField.TextFieldFilter;
|
import io.anuke.arc.scene.ui.TextField.TextFieldFilter;
|
||||||
import io.anuke.arc.scene.ui.layout.Table;
|
import io.anuke.arc.scene.ui.layout.Table;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Min;
|
||||||
import io.anuke.mindustry.content.*;
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.game.*;
|
import io.anuke.mindustry.game.*;
|
||||||
import io.anuke.mindustry.graphics.Pal;
|
import io.anuke.mindustry.graphics.Pal;
|
||||||
@@ -18,7 +18,7 @@ import io.anuke.mindustry.io.JsonIO;
|
|||||||
import io.anuke.mindustry.type.*;
|
import io.anuke.mindustry.type.*;
|
||||||
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
import io.anuke.mindustry.ui.dialogs.FloatingDialog;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
import static io.anuke.mindustry.game.SpawnGroup.never;
|
import static io.anuke.mindustry.game.SpawnGroup.never;
|
||||||
|
|
||||||
public class WaveInfoDialog extends FloatingDialog{
|
public class WaveInfoDialog extends FloatingDialog{
|
||||||
@@ -52,13 +52,13 @@ public class WaveInfoDialog extends FloatingDialog{
|
|||||||
dialog.cont.defaults().size(210f, 64f);
|
dialog.cont.defaults().size(210f, 64f);
|
||||||
dialog.cont.addButton("$waves.copy", () -> {
|
dialog.cont.addButton("$waves.copy", () -> {
|
||||||
ui.showInfoFade("$waves.copied");
|
ui.showInfoFade("$waves.copied");
|
||||||
Core.app.setClipboardText(world.maps.writeWaves(groups));
|
Core.app.setClipboardText(maps.writeWaves(groups));
|
||||||
dialog.hide();
|
dialog.hide();
|
||||||
}).disabled(b -> groups == null);
|
}).disabled(b -> groups == null);
|
||||||
dialog.cont.row();
|
dialog.cont.row();
|
||||||
dialog.cont.addButton("$waves.load", () -> {
|
dialog.cont.addButton("$waves.load", () -> {
|
||||||
try{
|
try{
|
||||||
groups = world.maps.readWaves(Core.app.getClipboardText());
|
groups = maps.readWaves(Core.app.getClipboardText());
|
||||||
buildGroups();
|
buildGroups();
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
ui.showError("$waves.invalid");
|
ui.showError("$waves.invalid");
|
||||||
@@ -242,7 +242,7 @@ public class WaveInfoDialog extends FloatingDialog{
|
|||||||
table.add((wave + 1) + "").color(Pal.accent).center().colspan(2).get().setAlignment(Align.center, Align.center);
|
table.add((wave + 1) + "").color(Pal.accent).center().colspan(2).get().setAlignment(Align.center, Align.center);
|
||||||
table.row();
|
table.row();
|
||||||
|
|
||||||
int[] spawned = new int[Vars.content.getBy(ContentType.unit).size];
|
int[] spawned = new int[Min.content.getBy(ContentType.unit).size];
|
||||||
|
|
||||||
for(SpawnGroup spawn : groups){
|
for(SpawnGroup spawn : groups){
|
||||||
spawned[spawn.type.id] += spawn.getUnitsSpawned(wave);
|
spawned[spawn.type.id] += spawn.getUnitsSpawned(wave);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import io.anuke.mindustry.gen.PropCell;
|
|||||||
import io.anuke.mindustry.graphics.Pal;
|
import io.anuke.mindustry.graphics.Pal;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
/** Utility class for damaging in an area. */
|
/** Utility class for damaging in an area. */
|
||||||
public class Damage{
|
public class Damage{
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import io.anuke.arc.math.geom.Rectangle;
|
|||||||
import io.anuke.mindustry.entities.traits.DrawTrait;
|
import io.anuke.mindustry.entities.traits.DrawTrait;
|
||||||
import io.anuke.mindustry.entities.traits.Entity;
|
import io.anuke.mindustry.entities.traits.Entity;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.collisions;
|
import static io.anuke.mindustry.Min.collisions;
|
||||||
|
|
||||||
public class Entities{
|
public class Entities{
|
||||||
private static final Array<EntityGroup<?>> groupArray = new Array<>();
|
private static final Array<EntityGroup<?>> groupArray = new Array<>();
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import io.anuke.mindustry.entities.traits.Entity;
|
|||||||
import io.anuke.mindustry.entities.traits.SolidTrait;
|
import io.anuke.mindustry.entities.traits.SolidTrait;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Min.tilesize;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.world;
|
||||||
|
|
||||||
public class EntityCollisions{
|
public class EntityCollisions{
|
||||||
//range for tile collision scanning
|
//range for tile collision scanning
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ import io.anuke.mindustry.entities.type.*;
|
|||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
/** Utility class for unit and team interactions.*/
|
/** Utility class for unit and team interactions.*/
|
||||||
public class Units{
|
public class Units{
|
||||||
@@ -68,13 +68,13 @@ public class Units{
|
|||||||
|
|
||||||
/** Returns the neareset damaged tile. */
|
/** Returns the neareset damaged tile. */
|
||||||
public static TileEntity findDamagedTile(Team team, float x, float y){
|
public static TileEntity findDamagedTile(Team team, float x, float y){
|
||||||
Tile tile = Geometry.findClosest(x, y, world.indexer.getDamaged(team));
|
Tile tile = Geometry.findClosest(x, y, indexer.getDamaged(team));
|
||||||
return tile == null ? null : tile.entity;
|
return tile == null ? null : tile.entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the neareset ally tile in a range. */
|
/** Returns the neareset ally tile in a range. */
|
||||||
public static TileEntity findAllyTile(Team team, float x, float y, float range, Predicate<Tile> pred){
|
public static TileEntity findAllyTile(Team team, float x, float y, float range, Predicate<Tile> pred){
|
||||||
return world.indexer.findTile(team, x, y, range, pred);
|
return indexer.findTile(team, x, y, range, pred);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the neareset enemy tile in a range. */
|
/** Returns the neareset enemy tile in a range. */
|
||||||
@@ -82,7 +82,7 @@ public class Units{
|
|||||||
if(team == Team.derelict) return null;
|
if(team == Team.derelict) return null;
|
||||||
|
|
||||||
for(Team enemy : state.teams.enemiesOf(team)){
|
for(Team enemy : state.teams.enemiesOf(team)){
|
||||||
TileEntity entity = world.indexer.findTile(enemy, x, y, range, pred);
|
TileEntity entity = indexer.findTile(enemy, x, y, range, pred);
|
||||||
if(entity != null){
|
if(entity != null){
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ import io.anuke.mindustry.entities.type.Unit;
|
|||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.bulletGroup;
|
import static io.anuke.mindustry.Min.bulletGroup;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.world;
|
||||||
|
|
||||||
public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Poolable, DrawTrait, VelocityTrait, TimeTrait, TeamTrait, AbsorbTrait{
|
public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Poolable, DrawTrait, VelocityTrait, TimeTrait, TeamTrait, AbsorbTrait{
|
||||||
public Interval timer = new Interval(3);
|
public Interval timer = new Interval(3);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.entities.effect.*;
|
|||||||
import io.anuke.mindustry.type.*;
|
import io.anuke.mindustry.type.*;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class LiquidBulletType extends BulletType{
|
public class LiquidBulletType extends BulletType{
|
||||||
Liquid liquid;
|
Liquid liquid;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.entities.Effects;
|
|||||||
import io.anuke.mindustry.graphics.Pal;
|
import io.anuke.mindustry.graphics.Pal;
|
||||||
import io.anuke.mindustry.world.blocks.distribution.MassDriver.DriverBulletData;
|
import io.anuke.mindustry.world.blocks.distribution.MassDriver.DriverBulletData;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.content;
|
import static io.anuke.mindustry.Min.content;
|
||||||
|
|
||||||
public class MassDriverBolt extends BulletType{
|
public class MassDriverBolt extends BulletType{
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import io.anuke.mindustry.entities.traits.BelowLiquidTrait;
|
|||||||
import io.anuke.mindustry.entities.traits.DrawTrait;
|
import io.anuke.mindustry.entities.traits.DrawTrait;
|
||||||
import io.anuke.mindustry.graphics.Pal;
|
import io.anuke.mindustry.graphics.Pal;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.groundEffectGroup;
|
import static io.anuke.mindustry.Min.groundEffectGroup;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for creating block rubble on the ground.
|
* Class for creating block rubble on the ground.
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import io.anuke.mindustry.world.*;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class Fire extends TimedEntity implements SaveTrait, SyncTrait{
|
public class Fire extends TimedEntity implements SaveTrait, SyncTrait{
|
||||||
private static final IntMap<Fire> map = new IntMap<>();
|
private static final IntMap<Fire> map = new IntMap<>();
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.anuke.mindustry.entities.effect;
|
|||||||
|
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Min;
|
||||||
import io.anuke.mindustry.entities.Effects;
|
import io.anuke.mindustry.entities.Effects;
|
||||||
import io.anuke.mindustry.entities.Effects.Effect;
|
import io.anuke.mindustry.entities.Effects.Effect;
|
||||||
import io.anuke.mindustry.entities.Effects.EffectRenderer;
|
import io.anuke.mindustry.entities.Effects.EffectRenderer;
|
||||||
@@ -27,7 +27,7 @@ public class GroundEffectEntity extends EffectEntity{
|
|||||||
if(!once && time >= lifetime()){
|
if(!once && time >= lifetime()){
|
||||||
once = true;
|
once = true;
|
||||||
time = 0f;
|
time = 0f;
|
||||||
Tile tile = Vars.world.tileWorld(x, y);
|
Tile tile = Min.world.tileWorld(x, y);
|
||||||
if(tile != null && tile.floor().isLiquid){
|
if(tile != null && tile.floor().isLiquid){
|
||||||
remove();
|
remove();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import io.anuke.mindustry.graphics.Pal;
|
|||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.effectGroup;
|
import static io.anuke.mindustry.Min.effectGroup;
|
||||||
|
|
||||||
public class ItemTransfer extends TimedEntity implements DrawTrait{
|
public class ItemTransfer extends TimedEntity implements DrawTrait{
|
||||||
private Vector2 from = new Vector2();
|
private Vector2 from = new Vector2();
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import io.anuke.mindustry.game.Team;
|
|||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
import io.anuke.mindustry.graphics.Pal;
|
import io.anuke.mindustry.graphics.Pal;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.bulletGroup;
|
import static io.anuke.mindustry.Min.bulletGroup;
|
||||||
|
|
||||||
public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{
|
public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{
|
||||||
public static final float lifetime = 10f;
|
public static final float lifetime = 10f;
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrait, SyncTrait{
|
public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrait, SyncTrait{
|
||||||
private static final IntMap<Puddle> map = new IntMap<>();
|
private static final IntMap<Puddle> map = new IntMap<>();
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import io.anuke.arc.graphics.g2d.Draw;
|
|||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.headless;
|
import static io.anuke.mindustry.Min.headless;
|
||||||
|
|
||||||
public class RubbleDecal extends Decal{
|
public class RubbleDecal extends Decal{
|
||||||
private TextureRegion region;
|
private TextureRegion region;
|
||||||
|
|||||||
@@ -7,8 +7,8 @@ import io.anuke.arc.math.Angles;
|
|||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.headless;
|
import static io.anuke.mindustry.Min.headless;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.world;
|
||||||
|
|
||||||
public class ScorchDecal extends Decal{
|
public class ScorchDecal extends Decal{
|
||||||
private static final int scorches = 5;
|
private static final int scorches = 5;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.entities.EntityGroup;
|
|||||||
import io.anuke.mindustry.entities.traits.DrawTrait;
|
import io.anuke.mindustry.entities.traits.DrawTrait;
|
||||||
import io.anuke.mindustry.entities.traits.Entity;
|
import io.anuke.mindustry.entities.traits.Entity;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.effectGroup;
|
import static io.anuke.mindustry.Min.effectGroup;
|
||||||
|
|
||||||
public class EffectEntity extends TimedEntity implements Poolable, DrawTrait{
|
public class EffectEntity extends TimedEntity implements Poolable, DrawTrait{
|
||||||
public Effect effect;
|
public Effect effect;
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import io.anuke.mindustry.world.blocks.BuildBlock.*;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
import static io.anuke.mindustry.entities.traits.BuilderTrait.BuildDataStatic.*;
|
import static io.anuke.mindustry.entities.traits.BuilderTrait.BuildDataStatic.*;
|
||||||
|
|
||||||
/** Interface for units that build things.*/
|
/** Interface for units that build things.*/
|
||||||
@@ -228,7 +228,7 @@ public interface BuilderTrait extends Entity, TeamTrait{
|
|||||||
float px = unit.x + Angles.trnsx(unit.rotation, focusLen);
|
float px = unit.x + Angles.trnsx(unit.rotation, focusLen);
|
||||||
float py = unit.y + Angles.trnsy(unit.rotation, focusLen);
|
float py = unit.y + Angles.trnsy(unit.rotation, focusLen);
|
||||||
|
|
||||||
float sz = Vars.tilesize * tile.block().size / 2f;
|
float sz = Min.tilesize * tile.block().size / 2f;
|
||||||
float ang = unit.angleTo(tile);
|
float ang = unit.angleTo(tile);
|
||||||
|
|
||||||
tmptr[0].set(tile.drawx() - sz, tile.drawy() - sz);
|
tmptr[0].set(tile.drawx() - sz, tile.drawy() - sz);
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import io.anuke.mindustry.graphics.*;
|
|||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public interface MinerTrait extends Entity{
|
public interface MinerTrait extends Entity{
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package io.anuke.mindustry.entities.traits;
|
|||||||
|
|
||||||
import io.anuke.arc.math.geom.*;
|
import io.anuke.arc.math.geom.*;
|
||||||
import io.anuke.arc.math.geom.QuadTree.QuadTreeObject;
|
import io.anuke.arc.math.geom.QuadTree.QuadTreeObject;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Min;
|
||||||
|
|
||||||
public interface SolidTrait extends QuadTreeObject, MoveTrait, VelocityTrait, Entity, Position{
|
public interface SolidTrait extends QuadTreeObject, MoveTrait, VelocityTrait, Entity, Position{
|
||||||
|
|
||||||
@@ -33,6 +33,6 @@ public interface SolidTrait extends QuadTreeObject, MoveTrait, VelocityTrait, En
|
|||||||
}
|
}
|
||||||
|
|
||||||
default void move(float x, float y){
|
default void move(float x, float y){
|
||||||
Vars.collisions.move(this, x, y);
|
Min.collisions.move(this, x, y);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import io.anuke.mindustry.world.meta.*;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
/** Base class for AI units. */
|
/** Base class for AI units. */
|
||||||
public abstract class BaseUnit extends Unit implements ShooterTrait{
|
public abstract class BaseUnit extends Unit implements ShooterTrait{
|
||||||
@@ -84,12 +84,12 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCommanded(){
|
public boolean isCommanded(){
|
||||||
return world.indexer.getAllied(team, BlockFlag.comandCenter).size != 0 && world.indexer.getAllied(team, BlockFlag.comandCenter).first().entity instanceof CommandCenterEntity;
|
return indexer.getAllied(team, BlockFlag.comandCenter).size != 0 && indexer.getAllied(team, BlockFlag.comandCenter).first().entity instanceof CommandCenterEntity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public UnitCommand getCommand(){
|
public UnitCommand getCommand(){
|
||||||
if(isCommanded()){
|
if(isCommanded()){
|
||||||
return world.indexer.getAllied(team, BlockFlag.comandCenter).first().<CommandCenterEntity>entity().command;
|
return indexer.getAllied(team, BlockFlag.comandCenter).first().<CommandCenterEntity>entity().command;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -145,12 +145,12 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void targetClosestAllyFlag(BlockFlag flag){
|
public void targetClosestAllyFlag(BlockFlag flag){
|
||||||
Tile target = Geometry.findClosest(x, y, world.indexer.getAllied(team, flag));
|
Tile target = Geometry.findClosest(x, y, indexer.getAllied(team, flag));
|
||||||
if(target != null) this.target = target.entity;
|
if(target != null) this.target = target.entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void targetClosestEnemyFlag(BlockFlag flag){
|
public void targetClosestEnemyFlag(BlockFlag flag){
|
||||||
Tile target = Geometry.findClosest(x, y, world.indexer.getEnemy(team, flag));
|
Tile target = Geometry.findClosest(x, y, indexer.getEnemy(team, flag));
|
||||||
if(target != null) this.target = target.entity;
|
if(target != null) this.target = target.entity;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -163,8 +163,8 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
|
|
||||||
public TileEntity getClosestEnemyCore(){
|
public TileEntity getClosestEnemyCore(){
|
||||||
|
|
||||||
for(Team enemy : Vars.state.teams.enemiesOf(team)){
|
for(Team enemy : Min.state.teams.enemiesOf(team)){
|
||||||
Tile tile = Geometry.findClosest(x, y, Vars.state.teams.get(enemy).cores);
|
Tile tile = Geometry.findClosest(x, y, Min.state.teams.get(enemy).cores);
|
||||||
if(tile != null){
|
if(tile != null){
|
||||||
return tile.entity;
|
return tile.entity;
|
||||||
}
|
}
|
||||||
@@ -183,7 +183,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getDamageMultipler(){
|
public float getDamageMultipler(){
|
||||||
return status.getDamageMultiplier() * Vars.state.rules.unitDamageMultiplier;
|
return status.getDamageMultiplier() * Min.state.rules.unitDamageMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -232,7 +232,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float maxHealth(){
|
public float maxHealth(){
|
||||||
return type.health * Vars.state.rules.unitHealthMultiplier;
|
return type.health * Min.state.rules.unitHealthMultiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import io.anuke.mindustry.net.*;
|
|||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.meta.*;
|
import io.anuke.mindustry.world.meta.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public abstract class FlyingUnit extends BaseUnit{
|
public abstract class FlyingUnit extends BaseUnit{
|
||||||
protected float[] weaponAngles = {0, 0};
|
protected float[] weaponAngles = {0, 0};
|
||||||
@@ -97,7 +97,7 @@ public abstract class FlyingUnit extends BaseUnit{
|
|||||||
if(retarget()){
|
if(retarget()){
|
||||||
target = getSpawner();
|
target = getSpawner();
|
||||||
|
|
||||||
Tile repair = Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair));
|
Tile repair = Geometry.findClosest(x, y, indexer.getAllied(team, BlockFlag.repair));
|
||||||
if(repair != null && damaged()) FlyingUnit.this.target = repair.entity;
|
if(repair != null && damaged()) FlyingUnit.this.target = repair.entity;
|
||||||
if(target == null) target = getClosestCore();
|
if(target == null) target = getClosestCore();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import io.anuke.mindustry.type.*;
|
|||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public abstract class GroundUnit extends BaseUnit{
|
public abstract class GroundUnit extends BaseUnit{
|
||||||
protected static Vector2 vec = new Vector2();
|
protected static Vector2 vec = new Vector2();
|
||||||
@@ -223,7 +223,7 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
protected void moveToCore(){
|
protected void moveToCore(){
|
||||||
Tile tile = world.tileWorld(x, y);
|
Tile tile = world.tileWorld(x, y);
|
||||||
if(tile == null) return;
|
if(tile == null) return;
|
||||||
Tile targetTile = world.pathfinder.getTargetTile(team, tile);
|
Tile targetTile = pathfinder.getTargetTile(team, tile);
|
||||||
|
|
||||||
if(tile == targetTile) return;
|
if(tile == targetTile) return;
|
||||||
|
|
||||||
@@ -235,8 +235,8 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
|
|
||||||
protected void moveAwayFromCore(){
|
protected void moveAwayFromCore(){
|
||||||
Team enemy = null;
|
Team enemy = null;
|
||||||
for(Team team : Vars.state.teams.enemiesOf(team)){
|
for(Team team : Min.state.teams.enemiesOf(team)){
|
||||||
if(Vars.state.teams.isActive(team)){
|
if(Min.state.teams.isActive(team)){
|
||||||
enemy = team;
|
enemy = team;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -246,7 +246,7 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
|
|
||||||
Tile tile = world.tileWorld(x, y);
|
Tile tile = world.tileWorld(x, y);
|
||||||
if(tile == null) return;
|
if(tile == null) return;
|
||||||
Tile targetTile = world.pathfinder.getTargetTile(enemy, tile);
|
Tile targetTile = pathfinder.getTargetTile(enemy, tile);
|
||||||
TileEntity core = getClosestCore();
|
TileEntity core = getClosestCore();
|
||||||
|
|
||||||
if(tile == targetTile || core == null || dst(core) < 120f) return;
|
if(tile == targetTile || core == null || dst(core) < 120f) return;
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import io.anuke.arc.math.geom.*;
|
|||||||
import io.anuke.arc.scene.ui.layout.*;
|
import io.anuke.arc.scene.ui.layout.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.pooling.Pools;
|
import io.anuke.arc.util.pooling.Pools;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Min;
|
||||||
import io.anuke.mindustry.content.*;
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.entities.*;
|
import io.anuke.mindustry.entities.*;
|
||||||
import io.anuke.mindustry.entities.traits.*;
|
import io.anuke.mindustry.entities.traits.*;
|
||||||
@@ -31,7 +31,7 @@ import io.anuke.mindustry.world.blocks.*;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
||||||
public static final int timerSync = 2;
|
public static final int timerSync = 2;
|
||||||
@@ -731,7 +731,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
|||||||
target = Units.closestTarget(team, x, y, getWeapon().bullet.range(), u -> u.getTeam() != Team.derelict, u -> u.getTeam() != Team.derelict);
|
target = Units.closestTarget(team, x, y, getWeapon().bullet.range(), u -> u.getTeam() != Team.derelict, u -> u.getTeam() != Team.derelict);
|
||||||
|
|
||||||
if(mech.canHeal && target == null){
|
if(mech.canHeal && target == null){
|
||||||
target = Geometry.findClosest(x, y, world.indexer.getDamaged(Team.sharded));
|
target = Geometry.findClosest(x, y, indexer.getDamaged(Team.sharded));
|
||||||
if(target != null && dst(target) > getWeapon().bullet.range()){
|
if(target != null && dst(target) > getWeapon().bullet.range()){
|
||||||
target = null;
|
target = null;
|
||||||
}else if(target != null){
|
}else if(target != null){
|
||||||
@@ -859,7 +859,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
|
|||||||
byte mechid = stream.readByte();
|
byte mechid = stream.readByte();
|
||||||
int spawner = stream.readInt();
|
int spawner = stream.readInt();
|
||||||
Tile stile = world.tile(spawner);
|
Tile stile = world.tile(spawner);
|
||||||
Player player = headless ? this : Vars.player;
|
Player player = headless ? this : Min.player;
|
||||||
player.readSaveSuper(stream, version);
|
player.readSaveSuper(stream, version);
|
||||||
player.mech = content.getByID(ContentType.mech, mechid);
|
player.mech = content.getByID(ContentType.mech, mechid);
|
||||||
player.dead = false;
|
player.dead = false;
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ import io.anuke.mindustry.world.modules.*;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
||||||
public static final float timeToSleep = 60f * 4; //4 seconds to fall asleep
|
public static final float timeToSleep = 60f * 4; //4 seconds to fall asleep
|
||||||
@@ -52,7 +52,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
|||||||
tile.entity.health = health;
|
tile.entity.health = health;
|
||||||
|
|
||||||
if(tile.entity.damaged()){
|
if(tile.entity.damaged()){
|
||||||
world.indexer.notifyTileDamaged(tile.entity);
|
indexer.notifyTileDamaged(tile.entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -171,7 +171,7 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(preHealth >= maxHealth() - 0.00001f && health < maxHealth() && world != null){ //when just damaged
|
if(preHealth >= maxHealth() - 0.00001f && health < maxHealth() && world != null){ //when just damaged
|
||||||
world.indexer.notifyTileDamaged(this);
|
indexer.notifyTileDamaged(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import io.anuke.mindustry.world.blocks.*;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public abstract class Unit extends DestructibleEntity implements SaveTrait, TargetTrait, SyncTrait, DrawTrait, TeamTrait{
|
public abstract class Unit extends DestructibleEntity implements SaveTrait, TargetTrait, SyncTrait, DrawTrait, TeamTrait{
|
||||||
/** Total duration of hit flash effect */
|
/** Total duration of hit flash effect */
|
||||||
@@ -256,7 +256,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
//apply knockback based on spawns
|
//apply knockback based on spawns
|
||||||
if(getTeam() != waveTeam){
|
if(getTeam() != waveTeam){
|
||||||
float relativeSize = state.rules.dropZoneRadius + getSize()/2f + 1f;
|
float relativeSize = state.rules.dropZoneRadius + getSize()/2f + 1f;
|
||||||
for(Tile spawn : world.spawner.getGroundSpawns()){
|
for(Tile spawn : spawner.getGroundSpawns()){
|
||||||
if(withinDst(spawn.worldx(), spawn.worldy(), relativeSize)){
|
if(withinDst(spawn.worldx(), spawn.worldy(), relativeSize)){
|
||||||
velocity.add(Tmp.v1.set(this).sub(spawn.worldx(), spawn.worldy()).setLength(0.1f + 1f - dst(spawn) / relativeSize).scl(0.45f * Time.delta()));
|
velocity.add(Tmp.v1.set(this).sub(spawn.worldx(), spawn.worldy()).setLength(0.1f + 1f - dst(spawn) / relativeSize).scl(0.45f * Time.delta()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import io.anuke.mindustry.entities.units.*;
|
|||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public abstract class BaseDrone extends FlyingUnit{
|
public abstract class BaseDrone extends FlyingUnit{
|
||||||
public final UnitState retreat = new UnitState(){
|
public final UnitState retreat = new UnitState(){
|
||||||
@@ -20,7 +20,7 @@ public abstract class BaseDrone extends FlyingUnit{
|
|||||||
state.set(getStartState());
|
state.set(getStartState());
|
||||||
}else if(!targetHasFlag(BlockFlag.repair)){
|
}else if(!targetHasFlag(BlockFlag.repair)){
|
||||||
if(retarget()){
|
if(retarget()){
|
||||||
Tile repairPoint = Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair));
|
Tile repairPoint = Geometry.findClosest(x, y, indexer.getAllied(team, BlockFlag.repair));
|
||||||
if(repairPoint != null){
|
if(repairPoint != null){
|
||||||
target = repairPoint;
|
target = repairPoint;
|
||||||
}else{
|
}else{
|
||||||
@@ -49,7 +49,7 @@ public abstract class BaseDrone extends FlyingUnit{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void behavior(){
|
public void behavior(){
|
||||||
if(health <= maxHealth() * type.retreatPercent && !state.is(retreat) && Geometry.findClosest(x, y, world.indexer.getAllied(team, BlockFlag.repair)) != null){
|
if(health <= maxHealth() * type.retreatPercent && !state.is(retreat) && Geometry.findClosest(x, y, indexer.getAllied(team, BlockFlag.repair)) != null){
|
||||||
setState(retreat);
|
setState(retreat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import io.anuke.arc.collection.IntIntMap;
|
|||||||
import io.anuke.arc.collection.Queue;
|
import io.anuke.arc.collection.Queue;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Min;
|
||||||
import io.anuke.mindustry.entities.EntityGroup;
|
import io.anuke.mindustry.entities.EntityGroup;
|
||||||
import io.anuke.mindustry.entities.traits.BuilderTrait;
|
import io.anuke.mindustry.entities.traits.BuilderTrait;
|
||||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||||
@@ -21,7 +21,7 @@ import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class BuilderDrone extends BaseDrone implements BuilderTrait{
|
public class BuilderDrone extends BaseDrone implements BuilderTrait{
|
||||||
private static final StaticReset reset = new StaticReset();
|
private static final StaticReset reset = new StaticReset();
|
||||||
@@ -189,7 +189,7 @@ public class BuilderDrone extends BaseDrone implements BuilderTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(isRebuild() && !isBuilding()){
|
if(isRebuild() && !isBuilding()){
|
||||||
TeamData data = Vars.state.teams.get(team);
|
TeamData data = Min.state.teams.get(team);
|
||||||
if(!data.brokenBlocks.isEmpty()){
|
if(!data.brokenBlocks.isEmpty()){
|
||||||
long block = data.brokenBlocks.removeLast();
|
long block = data.brokenBlocks.removeLast();
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
/** A drone that only mines.*/
|
/** A drone that only mines.*/
|
||||||
public class MinerDrone extends BaseDrone implements MinerTrait{
|
public class MinerDrone extends BaseDrone implements MinerTrait{
|
||||||
@@ -46,7 +46,7 @@ public class MinerDrone extends BaseDrone implements MinerTrait{
|
|||||||
setState(drop);
|
setState(drop);
|
||||||
}else{
|
}else{
|
||||||
if(retarget() && targetItem != null){
|
if(retarget() && targetItem != null){
|
||||||
target = world.indexer.findClosestOre(x, y, targetItem);
|
target = indexer.findClosestOre(x, y, targetItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(target instanceof Tile){
|
if(target instanceof Tile){
|
||||||
@@ -174,6 +174,6 @@ public class MinerDrone extends BaseDrone implements MinerTrait{
|
|||||||
if(entity == null){
|
if(entity == null){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
targetItem = Structs.findMin(type.toMine, world.indexer::hasOre, (a, b) -> -Integer.compare(entity.items.get(a), entity.items.get(b)));
|
targetItem = Structs.findMin(type.toMine, indexer::hasOre, (a, b) -> -Integer.compare(entity.items.get(a), entity.items.get(b)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.world.blocks.*;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.world;
|
||||||
|
|
||||||
public class RepairDrone extends BaseDrone{
|
public class RepairDrone extends BaseDrone{
|
||||||
public final UnitState repair = new UnitState(){
|
public final UnitState repair = new UnitState(){
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import io.anuke.mindustry.type.StatusEffect;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.content;
|
import static io.anuke.mindustry.Min.content;
|
||||||
|
|
||||||
/** Class for controlling status effects on an entity. */
|
/** Class for controlling status effects on an entity. */
|
||||||
public class Statuses implements Saveable{
|
public class Statuses implements Saveable{
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package io.anuke.mindustry.entities.units;
|
package io.anuke.mindustry.entities.units;
|
||||||
|
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Min;
|
||||||
import io.anuke.mindustry.content.Items;
|
import io.anuke.mindustry.content.Items;
|
||||||
import io.anuke.mindustry.entities.type.BaseUnit;
|
import io.anuke.mindustry.entities.type.BaseUnit;
|
||||||
import io.anuke.mindustry.entities.type.TileEntity;
|
import io.anuke.mindustry.entities.type.TileEntity;
|
||||||
@@ -13,13 +13,13 @@ public class UnitDrops{
|
|||||||
|
|
||||||
public static void dropItems(BaseUnit unit){
|
public static void dropItems(BaseUnit unit){
|
||||||
//items only dropped in waves for enemy team
|
//items only dropped in waves for enemy team
|
||||||
if(unit.getTeam() != Vars.waveTeam || !Vars.state.rules.unitDrops){
|
if(unit.getTeam() != Min.waveTeam || !Min.state.rules.unitDrops){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TileEntity core = unit.getClosestEnemyCore();
|
TileEntity core = unit.getClosestEnemyCore();
|
||||||
|
|
||||||
if(core == null || core.dst(unit) > Vars.mineTransferRange){
|
if(core == null || core.dst(unit) > Min.mineTransferRange){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,7 @@ public class UnitDrops{
|
|||||||
for(int i = 0; i < 3; i++){
|
for(int i = 0; i < 3; i++){
|
||||||
for(Item item : dropTable){
|
for(Item item : dropTable){
|
||||||
//only drop unlocked items
|
//only drop unlocked items
|
||||||
if(!Vars.headless && !Vars.data.isUnlocked(item)){
|
if(!Min.headless && !Min.data.isUnlocked(item)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package io.anuke.mindustry.game;
|
package io.anuke.mindustry.game;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Min;
|
||||||
import io.anuke.mindustry.type.ContentType;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
|
|
||||||
|
|
||||||
@@ -9,8 +9,8 @@ public abstract class Content{
|
|||||||
public final short id;
|
public final short id;
|
||||||
|
|
||||||
public Content(){
|
public Content(){
|
||||||
this.id = (short)Vars.content.getBy(getContentType()).size;
|
this.id = (short)Min.content.getBy(getContentType()).size;
|
||||||
Vars.content.handleContent(this);
|
Min.content.handleContent(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -19,7 +19,7 @@ public abstract class Content{
|
|||||||
*/
|
*/
|
||||||
public abstract ContentType getContentType();
|
public abstract ContentType getContentType();
|
||||||
|
|
||||||
/** Called after all content is created. Do not use to load regions or texture data! */
|
/** Called after all content and modules are created. Do not use to load regions or texture data! */
|
||||||
public void init(){
|
public void init(){
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.anuke.arc.*;
|
|||||||
import io.anuke.arc.function.*;
|
import io.anuke.arc.function.*;
|
||||||
import io.anuke.mindustry.maps.*;
|
import io.anuke.mindustry.maps.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.waveTeam;
|
import static io.anuke.mindustry.Min.waveTeam;
|
||||||
|
|
||||||
/** Defines preset rule sets. */
|
/** Defines preset rule sets. */
|
||||||
public enum Gamemode{
|
public enum Gamemode{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import io.anuke.mindustry.content.*;
|
|||||||
import io.anuke.mindustry.game.EventType.*;
|
import io.anuke.mindustry.game.EventType.*;
|
||||||
import io.anuke.mindustry.type.*;
|
import io.anuke.mindustry.type.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
/** Stores player unlocks. Clientside only. */
|
/** Stores player unlocks. Clientside only. */
|
||||||
public class GlobalData{
|
public class GlobalData{
|
||||||
@@ -106,7 +106,7 @@ public class GlobalData{
|
|||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
public void load(){
|
public void load(){
|
||||||
unlocked = Core.settings.getObject("unlocks", ObjectMap.class, ObjectMap::new);
|
unlocked = Core.settings.getObject("unlocks", ObjectMap.class, ObjectMap::new);
|
||||||
for(Item item : Vars.content.items()){
|
for(Item item : Min.content.items()){
|
||||||
items.put(item, Core.settings.getInt("item-" + item.name, 0));
|
items.put(item, Core.settings.getInt("item-" + item.name, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +118,7 @@ public class GlobalData{
|
|||||||
|
|
||||||
public void save(){
|
public void save(){
|
||||||
Core.settings.putObject("unlocks", unlocked);
|
Core.settings.putObject("unlocks", unlocked);
|
||||||
for(Item item : Vars.content.items()){
|
for(Item item : Min.content.items()){
|
||||||
Core.settings.put("item-" + item.name, items.get(item, 0));
|
Core.settings.put("item-" + item.name, items.get(item, 0));
|
||||||
}
|
}
|
||||||
Core.settings.save();
|
Core.settings.save();
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ public class LoopControl{
|
|||||||
private ObjectMap<Sound, SoundData> sounds = new ObjectMap<>();
|
private ObjectMap<Sound, SoundData> sounds = new ObjectMap<>();
|
||||||
|
|
||||||
public void play(Sound sound, Position pos, float volume){
|
public void play(Sound sound, Position pos, float volume){
|
||||||
if(Vars.headless) return;
|
if(Min.headless) return;
|
||||||
|
|
||||||
float baseVol = sound.calcFalloff(pos.getX(), pos.getY());
|
float baseVol = sound.calcFalloff(pos.getX(), pos.getY());
|
||||||
float vol = baseVol * volume;
|
float vol = baseVol * volume;
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import io.anuke.mindustry.core.GameState.*;
|
|||||||
import io.anuke.mindustry.game.EventType.*;
|
import io.anuke.mindustry.game.EventType.*;
|
||||||
import io.anuke.mindustry.gen.*;
|
import io.anuke.mindustry.gen.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
/** Controls playback of multiple music tracks.*/
|
/** Controls playback of multiple music tracks.*/
|
||||||
public class MusicControl{
|
public class MusicControl{
|
||||||
|
|||||||
@@ -17,8 +17,8 @@ import java.io.IOException;
|
|||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.saveExtension;
|
import static io.anuke.mindustry.Min.saveExtension;
|
||||||
import static io.anuke.mindustry.Vars.state;
|
import static io.anuke.mindustry.Min.state;
|
||||||
|
|
||||||
public class Saves{
|
public class Saves{
|
||||||
private int nextSlot;
|
private int nextSlot;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import io.anuke.arc.util.serialization.JsonValue;
|
|||||||
import io.anuke.mindustry.entities.type.BaseUnit;
|
import io.anuke.mindustry.entities.type.BaseUnit;
|
||||||
import io.anuke.mindustry.type.*;
|
import io.anuke.mindustry.type.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.content;
|
import static io.anuke.mindustry.Min.content;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A spawn group defines spawn information for a specific type of unit, with optional extra information like
|
* A spawn group defines spawn information for a specific type of unit, with optional extra information like
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.anuke.mindustry.game;
|
|||||||
|
|
||||||
import io.anuke.annotations.Annotations.Struct;
|
import io.anuke.annotations.Annotations.Struct;
|
||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Min;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
/** Class for various team-based utilities. */
|
/** Class for various team-based utilities. */
|
||||||
@@ -29,7 +29,7 @@ public class Teams{
|
|||||||
/** Returns whether a team is active, e.g. whether it has any cores remaining. */
|
/** Returns whether a team is active, e.g. whether it has any cores remaining. */
|
||||||
public boolean isActive(Team team){
|
public boolean isActive(Team team){
|
||||||
//the enemy wave team is always active
|
//the enemy wave team is always active
|
||||||
return team == Vars.waveTeam || get(team).cores.size > 0;
|
return team == Min.waveTeam || get(team).cores.size > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns a set of all teams that are enemies of this team. */
|
/** Returns a set of all teams that are enemies of this team. */
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import io.anuke.mindustry.graphics.*;
|
|||||||
import io.anuke.mindustry.type.*;
|
import io.anuke.mindustry.type.*;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
/** Handles tutorial state. */
|
/** Handles tutorial state. */
|
||||||
public class Tutorial{
|
public class Tutorial{
|
||||||
@@ -161,7 +161,7 @@ public class Tutorial{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
deposit(() -> event("deposit")),
|
deposit(() -> event("deposit")),
|
||||||
waves(() -> state.wave > 2 && state.enemies() <= 0 && !world.spawner.isSpawning()){
|
waves(() -> state.wave > 2 && state.enemies() <= 0 && !spawner.isSpawning()){
|
||||||
void begin(){
|
void begin(){
|
||||||
state.rules.waveTimer = true;
|
state.rules.waveTimer = true;
|
||||||
logic.runWave();
|
logic.runWave();
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package io.anuke.mindustry.game;
|
|||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.arc.scene.ui.layout.Table;
|
import io.anuke.arc.scene.ui.layout.Table;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Min;
|
||||||
|
|
||||||
/** Base interface for an unlockable content type. */
|
/** Base interface for an unlockable content type. */
|
||||||
public abstract class UnlockableContent extends MappableContent{
|
public abstract class UnlockableContent extends MappableContent{
|
||||||
@@ -42,7 +42,7 @@ public abstract class UnlockableContent extends MappableContent{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final boolean unlocked(){
|
public final boolean unlocked(){
|
||||||
return Vars.data.isUnlocked(this);
|
return Min.data.isUnlocked(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean locked(){
|
public final boolean locked(){
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import io.anuke.mindustry.game.Team;
|
|||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
|
|
||||||
import static io.anuke.arc.Core.camera;
|
import static io.anuke.arc.Core.camera;
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class BlockRenderer implements Disposable{
|
public class BlockRenderer implements Disposable{
|
||||||
private final static int initialRequests = 32 * 32;
|
private final static int initialRequests = 32 * 32;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import io.anuke.arc.graphics.g2d.Draw;
|
|||||||
import io.anuke.arc.graphics.glutils.Shader;
|
import io.anuke.arc.graphics.glutils.Shader;
|
||||||
|
|
||||||
import static io.anuke.arc.Core.camera;
|
import static io.anuke.arc.Core.camera;
|
||||||
import static io.anuke.mindustry.Vars.renderer;
|
import static io.anuke.mindustry.Min.renderer;
|
||||||
|
|
||||||
public enum CacheLayer{
|
public enum CacheLayer{
|
||||||
water{
|
water{
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import io.anuke.mindustry.world.blocks.Floor;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Min.tilesize;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.world;
|
||||||
|
|
||||||
public class FloorRenderer implements Disposable{
|
public class FloorRenderer implements Disposable{
|
||||||
private final static int chunksize = 64;
|
private final static int chunksize = 64;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import io.anuke.mindustry.world.*;
|
|||||||
import io.anuke.mindustry.world.blocks.Floor;
|
import io.anuke.mindustry.world.blocks.Floor;
|
||||||
import io.anuke.mindustry.world.blocks.OreBlock;
|
import io.anuke.mindustry.world.blocks.OreBlock;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class MenuRenderer implements Disposable{
|
public class MenuRenderer implements Disposable{
|
||||||
private static final float darkness = 0.3f;
|
private static final float darkness = 0.3f;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import io.anuke.mindustry.game.EventType.*;
|
|||||||
import io.anuke.mindustry.io.*;
|
import io.anuke.mindustry.io.*;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class MinimapRenderer implements Disposable{
|
public class MinimapRenderer implements Disposable{
|
||||||
private static final float baseSize = 16f;
|
private static final float baseSize = 16f;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import io.anuke.arc.math.geom.Rectangle;
|
|||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.arc.util.Tmp;
|
import io.anuke.arc.util.Tmp;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Min;
|
||||||
import io.anuke.mindustry.content.Blocks;
|
import io.anuke.mindustry.content.Blocks;
|
||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.entities.type.Player;
|
import io.anuke.mindustry.entities.type.Player;
|
||||||
@@ -18,7 +18,7 @@ import io.anuke.mindustry.input.InputHandler;
|
|||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class OverlayRenderer{
|
public class OverlayRenderer{
|
||||||
private static final float indicatorLength = 14f;
|
private static final float indicatorLength = 14f;
|
||||||
@@ -38,7 +38,7 @@ public class OverlayRenderer{
|
|||||||
|
|
||||||
if(Core.settings.getBool("indicators")){
|
if(Core.settings.getBool("indicators")){
|
||||||
for(Player player : playerGroup.all()){
|
for(Player player : playerGroup.all()){
|
||||||
if(Vars.player != player && Vars.player.getTeam() == player.getTeam()){
|
if(Min.player != player && Min.player.getTeam() == player.getTeam()){
|
||||||
if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f)
|
if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f)
|
||||||
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x, player.y)){
|
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x, player.y)){
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ public class OverlayRenderer{
|
|||||||
Lines.stroke(2f);
|
Lines.stroke(2f);
|
||||||
Draw.color(Color.GRAY, Color.LIGHT_GRAY, Mathf.absin(Time.time(), 8f, 1f));
|
Draw.color(Color.GRAY, Color.LIGHT_GRAY, Mathf.absin(Time.time(), 8f, 1f));
|
||||||
|
|
||||||
for(Tile tile : world.spawner.getGroundSpawns()){
|
for(Tile tile : spawner.getGroundSpawns()){
|
||||||
if(tile.withinDst(player.x, player.y, state.rules.dropZoneRadius + spawnerMargin)){
|
if(tile.withinDst(player.x, player.y, state.rules.dropZoneRadius + spawnerMargin)){
|
||||||
Draw.alpha(Mathf.clamp(1f - (player.dst(tile) - state.rules.dropZoneRadius) / spawnerMargin));
|
Draw.alpha(Mathf.clamp(1f - (player.dst(tile) - state.rules.dropZoneRadius) / spawnerMargin));
|
||||||
Lines.dashCircle(tile.worldx(), tile.worldy(), state.rules.dropZoneRadius);
|
Lines.dashCircle(tile.worldx(), tile.worldy(), state.rules.dropZoneRadius);
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import io.anuke.mindustry.entities.type.Player;
|
|||||||
|
|
||||||
import static io.anuke.arc.Core.camera;
|
import static io.anuke.arc.Core.camera;
|
||||||
import static io.anuke.arc.Core.graphics;
|
import static io.anuke.arc.Core.graphics;
|
||||||
import static io.anuke.mindustry.Vars.playerGroup;
|
import static io.anuke.mindustry.Min.playerGroup;
|
||||||
import static io.anuke.mindustry.Vars.renderer;
|
import static io.anuke.mindustry.Min.renderer;
|
||||||
|
|
||||||
public class Pixelator implements Disposable{
|
public class Pixelator implements Disposable{
|
||||||
private FrameBuffer buffer = new FrameBuffer(2, 2);
|
private FrameBuffer buffer = new FrameBuffer(2, 2);
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import io.anuke.mindustry.net.Net;
|
|||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
|
|
||||||
import static io.anuke.arc.Core.scene;
|
import static io.anuke.arc.Core.scene;
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
import static io.anuke.mindustry.input.PlaceMode.*;
|
import static io.anuke.mindustry.input.PlaceMode.*;
|
||||||
|
|
||||||
public class DesktopInput extends InputHandler{
|
public class DesktopInput extends InputHandler{
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import io.anuke.mindustry.type.*;
|
|||||||
import io.anuke.mindustry.ui.fragments.*;
|
import io.anuke.mindustry.ui.fragments.*;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public abstract class InputHandler implements InputProcessor{
|
public abstract class InputHandler implements InputProcessor{
|
||||||
/** Used for dropping items. */
|
/** Used for dropping items. */
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import io.anuke.mindustry.graphics.*;
|
|||||||
import io.anuke.mindustry.input.PlaceUtils.*;
|
import io.anuke.mindustry.input.PlaceUtils.*;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
import static io.anuke.mindustry.input.PlaceMode.*;
|
import static io.anuke.mindustry.input.PlaceMode.*;
|
||||||
|
|
||||||
public class MobileInput extends InputHandler implements GestureListener{
|
public class MobileInput extends InputHandler implements GestureListener{
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import io.anuke.arc.math.geom.Point2;
|
|||||||
import io.anuke.arc.util.pooling.Pools;
|
import io.anuke.arc.util.pooling.Pools;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Min.tilesize;
|
||||||
|
|
||||||
public class PlaceUtils{
|
public class PlaceUtils{
|
||||||
private static final NormalizeResult result = new NormalizeResult();
|
private static final NormalizeResult result = new NormalizeResult();
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
package io.anuke.mindustry.io;
|
|
||||||
|
|
||||||
import io.anuke.arc.Core;
|
|
||||||
import io.anuke.arc.files.FileHandle;
|
|
||||||
import io.anuke.arc.util.*;
|
|
||||||
import io.anuke.mindustry.Vars;
|
|
||||||
import io.anuke.mindustry.input.Binding;
|
|
||||||
|
|
||||||
import java.util.Locale;
|
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.headless;
|
|
||||||
|
|
||||||
public class BundleLoader{
|
|
||||||
|
|
||||||
public static void load(){
|
|
||||||
Core.settings.defaults("locale", "default");
|
|
||||||
Core.keybinds.setDefaults(Binding.values());
|
|
||||||
Core.settings.load();
|
|
||||||
loadBundle();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Locale getLocale(){
|
|
||||||
String loc = Core.settings.getString("locale");
|
|
||||||
if(loc.equals("default")){
|
|
||||||
return Locale.getDefault();
|
|
||||||
}else{
|
|
||||||
Locale lastLocale;
|
|
||||||
if(loc.contains("_")){
|
|
||||||
String[] split = loc.split("_");
|
|
||||||
lastLocale = new Locale(split[0], split[1]);
|
|
||||||
}else{
|
|
||||||
lastLocale = new Locale(loc);
|
|
||||||
}
|
|
||||||
|
|
||||||
return lastLocale;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void loadBundle(){
|
|
||||||
if(headless) return;
|
|
||||||
|
|
||||||
try{
|
|
||||||
//try loading external bundle
|
|
||||||
FileHandle handle = Core.files.local("bundle");
|
|
||||||
|
|
||||||
Locale locale = Locale.ENGLISH;
|
|
||||||
Core.bundle = I18NBundle.createBundle(handle, locale);
|
|
||||||
|
|
||||||
Log.info("NOTE: external translation bundle has been loaded.");
|
|
||||||
if(!headless){
|
|
||||||
Time.run(10f, () -> Vars.ui.showInfo("Note: You have successfully loaded an external translation bundle."));
|
|
||||||
}
|
|
||||||
}catch(Throwable e){
|
|
||||||
//no external bundle found
|
|
||||||
|
|
||||||
FileHandle handle = Core.files.internal("bundles/bundle");
|
|
||||||
|
|
||||||
Locale locale = getLocale();
|
|
||||||
Locale.setDefault(locale);
|
|
||||||
Core.bundle = I18NBundle.createBundle(handle, locale);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -50,7 +50,7 @@ public class JsonIO{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Zone read(Json json, JsonValue jsonData, Class type){
|
public Zone read(Json json, JsonValue jsonData, Class type){
|
||||||
return Vars.content.getByName(ContentType.zone, jsonData.asString());
|
return Min.content.getByName(ContentType.zone, jsonData.asString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -63,13 +63,13 @@ public class JsonIO{
|
|||||||
@Override
|
@Override
|
||||||
public Item read(Json json, JsonValue jsonData, Class type){
|
public Item read(Json json, JsonValue jsonData, Class type){
|
||||||
if(jsonData.asString() == null) return Items.copper;
|
if(jsonData.asString() == null) return Items.copper;
|
||||||
Item i = Vars.content.getByName(ContentType.item, jsonData.asString());
|
Item i = Min.content.getByName(ContentType.item, jsonData.asString());
|
||||||
return i == null ? Items.copper : i;
|
return i == null ? Items.copper : i;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//TODO extremely hacky and disgusting
|
//TODO extremely hacky and disgusting
|
||||||
for(Block block : Vars.content.blocks()){
|
for(Block block : Min.content.blocks()){
|
||||||
Class type = block.getClass();
|
Class type = block.getClass();
|
||||||
if(type.isAnonymousClass()) type = type.getSuperclass();
|
if(type.isAnonymousClass()) type = type.getSuperclass();
|
||||||
|
|
||||||
@@ -81,7 +81,7 @@ public class JsonIO{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Block read(Json json, JsonValue jsonData, Class type){
|
public Block read(Json json, JsonValue jsonData, Class type){
|
||||||
return Vars.content.getByName(ContentType.block, jsonData.asString());
|
return Min.content.getByName(ContentType.block, jsonData.asString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -94,7 +94,7 @@ public class JsonIO{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Block read(Json json, JsonValue jsonData, Class type){
|
public Block read(Json json, JsonValue jsonData, Class type){
|
||||||
return Vars.content.getByName(ContentType.block, jsonData.asString());
|
return Min.content.getByName(ContentType.block, jsonData.asString());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import io.anuke.mindustry.world.blocks.Floor;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.zip.InflaterInputStream;
|
import java.util.zip.InflaterInputStream;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
/** Map IO for the "old" .mmap format.
|
/** Map IO for the "old" .mmap format.
|
||||||
* Differentiate between legacy maps and new maps by checking the extension (or the header).*/
|
* Differentiate between legacy maps and new maps by checking the extension (or the header).*/
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ import io.anuke.mindustry.world.blocks.storage.*;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.util.zip.*;
|
import java.util.zip.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
/** Reads and writes map files. */
|
/** Reads and writes map files. */
|
||||||
//TODO does this class even need to exist??? move to Maps?
|
//TODO does this class even need to exist??? move to Maps?
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.anuke.arc.collection.*;
|
|||||||
import io.anuke.arc.files.FileHandle;
|
import io.anuke.arc.files.FileHandle;
|
||||||
import io.anuke.arc.util.io.CounterInputStream;
|
import io.anuke.arc.util.io.CounterInputStream;
|
||||||
import io.anuke.arc.util.io.FastDeflaterOutputStream;
|
import io.anuke.arc.util.io.FastDeflaterOutputStream;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Min;
|
||||||
import io.anuke.mindustry.io.versions.Save1;
|
import io.anuke.mindustry.io.versions.Save1;
|
||||||
import io.anuke.mindustry.io.versions.Save2;
|
import io.anuke.mindustry.io.versions.Save2;
|
||||||
import io.anuke.mindustry.world.WorldContext;
|
import io.anuke.mindustry.world.WorldContext;
|
||||||
@@ -13,7 +13,7 @@ import java.io.*;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.zip.InflaterInputStream;
|
import java.util.zip.InflaterInputStream;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class SaveIO{
|
public class SaveIO{
|
||||||
/** Format header. This is the string 'MSAV' in ASCII. */
|
/** Format header. This is the string 'MSAV' in ASCII. */
|
||||||
@@ -108,7 +108,7 @@ public class SaveIO{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static FileHandle fileFor(int slot){
|
public static FileHandle fileFor(int slot){
|
||||||
return saveDirectory.child(slot + "." + Vars.saveExtension);
|
return saveDirectory.child(slot + "." + Min.saveExtension);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FileHandle backupFileFor(FileHandle file){
|
public static FileHandle backupFileFor(FileHandle file){
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
package io.anuke.mindustry.io;
|
package io.anuke.mindustry.io;
|
||||||
|
|
||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.mindustry.game.Rules;
|
import io.anuke.mindustry.game.*;
|
||||||
import io.anuke.mindustry.maps.Map;
|
import io.anuke.mindustry.maps.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.maps;
|
||||||
|
|
||||||
public class SaveMeta{
|
public class SaveMeta{
|
||||||
public int version;
|
public int version;
|
||||||
@@ -21,7 +21,7 @@ public class SaveMeta{
|
|||||||
this.build = build;
|
this.build = build;
|
||||||
this.timestamp = timestamp;
|
this.timestamp = timestamp;
|
||||||
this.timePlayed = timePlayed;
|
this.timePlayed = timePlayed;
|
||||||
this.map = world.maps.all().find(m -> m.name().equals(map));
|
this.map = maps.all().find(m -> m.name().equals(map));
|
||||||
this.wave = wave;
|
this.wave = wave;
|
||||||
this.rules = rules;
|
this.rules = rules;
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import io.anuke.mindustry.world.*;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public abstract class SaveVersion extends SaveFileReader{
|
public abstract class SaveVersion extends SaveFileReader{
|
||||||
public final int version;
|
public final int version;
|
||||||
@@ -81,7 +81,7 @@ public abstract class SaveVersion extends SaveFileReader{
|
|||||||
if(state.rules.spawns.isEmpty()) state.rules.spawns = defaultWaves.get();
|
if(state.rules.spawns.isEmpty()) state.rules.spawns = defaultWaves.get();
|
||||||
lastReadBuild = map.getInt("build", -1);
|
lastReadBuild = map.getInt("build", -1);
|
||||||
|
|
||||||
Map worldmap = world.maps.byName(map.get("mapname", "\\\\\\"));
|
Map worldmap = maps.byName(map.get("mapname", "\\\\\\"));
|
||||||
world.setMap(worldmap == null ? new Map(StringMap.of(
|
world.setMap(worldmap == null ? new Map(StringMap.of(
|
||||||
"name", map.get("mapname", "Unknown"),
|
"name", map.get("mapname", "Unknown"),
|
||||||
"width", 1,
|
"width", 1,
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.io;
|
|||||||
import io.anuke.annotations.Annotations.ReadClass;
|
import io.anuke.annotations.Annotations.ReadClass;
|
||||||
import io.anuke.annotations.Annotations.WriteClass;
|
import io.anuke.annotations.Annotations.WriteClass;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.util.CommandHandler.*;
|
|
||||||
import io.anuke.mindustry.entities.Effects;
|
import io.anuke.mindustry.entities.Effects;
|
||||||
import io.anuke.mindustry.entities.Effects.Effect;
|
import io.anuke.mindustry.entities.Effects.Effect;
|
||||||
import io.anuke.mindustry.entities.Entities;
|
import io.anuke.mindustry.entities.Entities;
|
||||||
@@ -23,7 +22,7 @@ import io.anuke.mindustry.world.*;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
/** Class for specifying read/write methods for code generation. */
|
/** Class for specifying read/write methods for code generation. */
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import io.anuke.mindustry.game.*;
|
|||||||
import io.anuke.mindustry.io.*;
|
import io.anuke.mindustry.io.*;
|
||||||
import io.anuke.mindustry.maps.filters.*;
|
import io.anuke.mindustry.maps.filters.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.maps;
|
||||||
|
|
||||||
public class Map implements Comparable<Map>{
|
public class Map implements Comparable<Map>{
|
||||||
/** Whether this is a custom map. */
|
/** Whether this is a custom map. */
|
||||||
@@ -50,16 +50,20 @@ public class Map implements Comparable<Map>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Map(StringMap tags){
|
public Map(StringMap tags){
|
||||||
this(Vars.customMapDirectory.child(tags.get("name", "unknown")), 0, 0, tags, true);
|
this(Min.customMapDirectory.child(tags.get("name", "unknown")), 0, 0, tags, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getHightScore(){
|
public int getHightScore(){
|
||||||
return Core.settings.getInt("hiscore" + file.nameWithoutExtension(), 0);
|
return Core.settings.getInt("hiscore" + file.nameWithoutExtension(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public FileHandle previewFile(){
|
||||||
|
return Min.mapPreviewDirectory.child(file.nameWithoutExtension() + ".png");
|
||||||
|
}
|
||||||
|
|
||||||
public void setHighScore(int score){
|
public void setHighScore(int score){
|
||||||
Core.settings.put("hiscore" + file.nameWithoutExtension(), score);
|
Core.settings.put("hiscore" + file.nameWithoutExtension(), score);
|
||||||
Vars.data.modified();
|
Min.data.modified();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Returns the result of applying this map's rules to the specified gamemode.*/
|
/** Returns the result of applying this map's rules to the specified gamemode.*/
|
||||||
@@ -80,7 +84,7 @@ public class Map implements Comparable<Map>{
|
|||||||
public Rules rules(Rules base){
|
public Rules rules(Rules base){
|
||||||
try{
|
try{
|
||||||
Rules result = JsonIO.read(Rules.class, base, tags.get("rules", "{}"));
|
Rules result = JsonIO.read(Rules.class, base, tags.get("rules", "{}"));
|
||||||
if(result.spawns.isEmpty()) result.spawns = Vars.defaultWaves.get();
|
if(result.spawns.isEmpty()) result.spawns = Min.defaultWaves.get();
|
||||||
return result;
|
return result;
|
||||||
}catch(Exception e){
|
}catch(Exception e){
|
||||||
//error reading rules. ignore?
|
//error reading rules. ignore?
|
||||||
@@ -94,7 +98,7 @@ public class Map implements Comparable<Map>{
|
|||||||
if(tags.getInt("build", -1) < 83 && tags.getInt("build", -1) != -1 && tags.get("genfilters", "").isEmpty()){
|
if(tags.getInt("build", -1) < 83 && tags.getInt("build", -1) != -1 && tags.get("genfilters", "").isEmpty()){
|
||||||
return Array.with();
|
return Array.with();
|
||||||
}
|
}
|
||||||
return world.maps.readFilters(tags.get("genfilters", ""));
|
return maps.readFilters(tags.get("genfilters", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String author(){
|
public String author(){
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package io.anuke.mindustry.maps;
|
package io.anuke.mindustry.maps;
|
||||||
|
|
||||||
import io.anuke.arc.*;
|
import io.anuke.arc.*;
|
||||||
|
import io.anuke.arc.assets.*;
|
||||||
import io.anuke.arc.collection.*;
|
import io.anuke.arc.collection.*;
|
||||||
import io.anuke.arc.files.*;
|
import io.anuke.arc.files.*;
|
||||||
import io.anuke.arc.function.*;
|
import io.anuke.arc.function.*;
|
||||||
import io.anuke.arc.graphics.*;
|
import io.anuke.arc.graphics.*;
|
||||||
import io.anuke.arc.util.*;
|
import io.anuke.arc.util.*;
|
||||||
|
import io.anuke.arc.util.async.*;
|
||||||
import io.anuke.arc.util.serialization.*;
|
import io.anuke.arc.util.serialization.*;
|
||||||
import io.anuke.mindustry.content.*;
|
import io.anuke.mindustry.content.*;
|
||||||
import io.anuke.mindustry.game.*;
|
import io.anuke.mindustry.game.*;
|
||||||
@@ -16,9 +18,9 @@ import io.anuke.mindustry.world.blocks.storage.*;
|
|||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class Maps implements Disposable{
|
public class Maps{
|
||||||
/** List of all built-in maps. Filenames only. */
|
/** List of all built-in maps. Filenames only. */
|
||||||
private static String[] defaultMapNames = {"maze", "fortress", "labyrinth", "islands", "tendrils", "caldera", "wasteland", "shattered", "fork", "triad", "veins", "glacier"};
|
private static String[] defaultMapNames = {"maze", "fortress", "labyrinth", "islands", "tendrils", "caldera", "wasteland", "shattered", "fork", "triad", "veins", "glacier"};
|
||||||
/** All maps stored in an ordered array. */
|
/** All maps stored in an ordered array. */
|
||||||
@@ -26,6 +28,8 @@ public class Maps implements Disposable{
|
|||||||
/** Serializer for meta. */
|
/** Serializer for meta. */
|
||||||
private Json json = new Json();
|
private Json json = new Json();
|
||||||
|
|
||||||
|
private AsyncExecutor executor = new AsyncExecutor(2);
|
||||||
|
|
||||||
/** Returns a list of all maps, including custom ones. */
|
/** Returns a list of all maps, including custom ones. */
|
||||||
public Array<Map> all(){
|
public Array<Map> all(){
|
||||||
return maps;
|
return maps;
|
||||||
@@ -74,7 +78,13 @@ public class Maps implements Disposable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void reload(){
|
public void reload(){
|
||||||
dispose();
|
for(Map map : maps){
|
||||||
|
if(map.texture != null){
|
||||||
|
map.texture.dispose();
|
||||||
|
map.texture = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
maps.clear();
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +138,10 @@ public class Maps implements Disposable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
map.texture = new Texture(MapIO.generatePreview(world.getTiles()));
|
Pixmap pix = MapIO.generatePreview(world.getTiles());
|
||||||
|
executor.submit(() -> map.previewFile().writePNG(pix));
|
||||||
|
|
||||||
|
map.texture = new Texture(pix);
|
||||||
}
|
}
|
||||||
maps.add(map);
|
maps.add(map);
|
||||||
maps.sort();
|
maps.sort();
|
||||||
@@ -284,6 +297,31 @@ public class Maps implements Disposable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void loadPreviews(){
|
||||||
|
for(Map map : maps){
|
||||||
|
try{
|
||||||
|
//try to load preview
|
||||||
|
if(map.previewFile().exists()){
|
||||||
|
try{
|
||||||
|
Core.assets.load(new AssetDescriptor<>(map.previewFile(), Texture.class)).loaded = t -> map.texture = (Texture)t;
|
||||||
|
//if it works, keep going
|
||||||
|
continue;
|
||||||
|
}catch(Exception e){
|
||||||
|
Log.err("Found cached preview, but failed to load it!");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//if it's here, then the preview failed to load or doesn't exist, make it
|
||||||
|
//this has to be done synchronously!
|
||||||
|
Pixmap pix = MapIO.generatePreview(map);
|
||||||
|
Core.app.post(() -> map.texture = new Texture(pix));
|
||||||
|
executor.submit(() -> map.previewFile().writePNG(pix));
|
||||||
|
}catch(IOException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** Find a new filename to put a map to. */
|
/** Find a new filename to put a map to. */
|
||||||
private FileHandle findFile(){
|
private FileHandle findFile(){
|
||||||
//find a map name that isn't used.
|
//find a map name that isn't used.
|
||||||
@@ -301,10 +339,6 @@ public class Maps implements Disposable{
|
|||||||
throw new IOException("Map name cannot be empty! File: " + file);
|
throw new IOException("Map name cannot be empty! File: " + file);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!headless){
|
|
||||||
map.texture = new Texture(MapIO.generatePreview(map));
|
|
||||||
}
|
|
||||||
|
|
||||||
maps.add(map);
|
maps.add(map);
|
||||||
//maps.sort();
|
//maps.sort();
|
||||||
}
|
}
|
||||||
@@ -321,15 +355,4 @@ public class Maps implements Disposable{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void dispose(){
|
|
||||||
for(Map map : maps){
|
|
||||||
if(map.texture != null){
|
|
||||||
map.texture.dispose();
|
|
||||||
map.texture = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
maps.clear();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@@ -13,7 +13,7 @@ import io.anuke.mindustry.world.*;
|
|||||||
import io.anuke.mindustry.world.Block.*;
|
import io.anuke.mindustry.world.Block.*;
|
||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.updateEditorOnChange;
|
import static io.anuke.mindustry.Min.updateEditorOnChange;
|
||||||
|
|
||||||
public abstract class FilterOption{
|
public abstract class FilterOption{
|
||||||
public static final Predicate<Block> floorsOnly = b -> (b instanceof Floor && !(b instanceof OverlayFloor)) && Core.atlas.isFound(b.icon(Icon.full));
|
public static final Predicate<Block> floorsOnly = b -> (b instanceof Floor && !(b instanceof OverlayFloor)) && Core.atlas.isFound(b.icon(Icon.full));
|
||||||
@@ -81,7 +81,7 @@ public abstract class FilterOption{
|
|||||||
FloatingDialog dialog = new FloatingDialog("");
|
FloatingDialog dialog = new FloatingDialog("");
|
||||||
dialog.setFillParent(false);
|
dialog.setFillParent(false);
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(Block block : Vars.content.blocks()){
|
for(Block block : Min.content.blocks()){
|
||||||
if(!filter.test(block)) continue;
|
if(!filter.test(block)) continue;
|
||||||
|
|
||||||
dialog.cont.addImage(block == Blocks.air ? Core.atlas.find("icon-none-small") : block.icon(Icon.medium)).size(8 * 4).pad(3).get().clicked(() -> {
|
dialog.cont.addImage(block == Blocks.air ? Core.atlas.find("icon-none-small") : block.icon(Icon.medium)).size(8 * 4).pad(3).get().clicked(() -> {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import io.anuke.arc.math.*;
|
|||||||
import io.anuke.mindustry.maps.filters.FilterOption.*;
|
import io.anuke.mindustry.maps.filters.FilterOption.*;
|
||||||
import io.anuke.mindustry.world.*;
|
import io.anuke.mindustry.world.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.content;
|
import static io.anuke.mindustry.Min.content;
|
||||||
|
|
||||||
public class MedianFilter extends GenerateFilter{
|
public class MedianFilter extends GenerateFilter{
|
||||||
float radius = 2;
|
float radius = 2;
|
||||||
|
|||||||
@@ -52,6 +52,6 @@ public class OreMedianFilter extends GenerateFilter{
|
|||||||
int index = Math.min((int)(blocks.size * percentile), blocks.size - 1);
|
int index = Math.min((int)(blocks.size * percentile), blocks.size - 1);
|
||||||
int overlay = blocks.get(index);
|
int overlay = blocks.get(index);
|
||||||
|
|
||||||
in.ore = Vars.content.block(overlay);
|
in.ore = Min.content.block(overlay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import io.anuke.mindustry.world.*;
|
|||||||
import io.anuke.mindustry.world.blocks.*;
|
import io.anuke.mindustry.world.blocks.*;
|
||||||
import io.anuke.mindustry.world.blocks.storage.*;
|
import io.anuke.mindustry.world.blocks.storage.*;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Min.*;
|
||||||
|
|
||||||
public class MapGenerator extends Generator{
|
public class MapGenerator extends Generator{
|
||||||
private Map map;
|
private Map map;
|
||||||
@@ -51,7 +51,7 @@ public class MapGenerator extends Generator{
|
|||||||
@Override
|
@Override
|
||||||
public void init(Loadout loadout){
|
public void init(Loadout loadout){
|
||||||
this.loadout = loadout;
|
this.loadout = loadout;
|
||||||
map = world.maps.loadInternalMap(mapName);
|
map = maps.loadInternalMap(mapName);
|
||||||
width = map.width;
|
width = map.width;
|
||||||
height = map.height;
|
height = map.height;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import io.anuke.mindustry.maps.Map;
|
|||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Min.world;
|
||||||
|
|
||||||
public abstract class RandomGenerator extends Generator{
|
public abstract class RandomGenerator extends Generator{
|
||||||
protected Block floor;
|
protected Block floor;
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user