diff --git a/android/AndroidManifest.xml b/android/AndroidManifest.xml index a4202d4364..a29bcea7c3 100644 --- a/android/AndroidManifest.xml +++ b/android/AndroidManifest.xml @@ -13,6 +13,7 @@ android:icon="@mipmap/ic_launcher" android:roundIcon="@mipmap/ic_launcher_round" android:isGame="true" + android:usesCleartextTraffic="true" android:appCategory="game" android:label="@string/app_name" android:theme="@style/GdxTheme" android:fullBackupContent="@xml/backup_rules"> diff --git a/android/src/io/anuke/mindustry/AndroidLauncher.java b/android/src/io/anuke/mindustry/AndroidLauncher.java index 96f99dcd5f..627a782dd3 100644 --- a/android/src/io/anuke/mindustry/AndroidLauncher.java +++ b/android/src/io/anuke/mindustry/AndroidLauncher.java @@ -12,7 +12,7 @@ import android.telephony.*; import io.anuke.arc.*; import io.anuke.arc.backends.android.surfaceview.*; import io.anuke.arc.files.*; -import io.anuke.arc.function.*; +import io.anuke.arc.func.Cons; import io.anuke.arc.scene.ui.layout.*; import io.anuke.arc.util.*; import io.anuke.arc.util.serialization.*; @@ -70,7 +70,7 @@ public class AndroidLauncher extends AndroidApplication{ } @Override - public void showFileChooser(boolean open, String extension, Consumer cons){ + public void showFileChooser(boolean open, String extension, Cons cons){ if(VERSION.SDK_INT >= VERSION_CODES.Q){ Intent intent = new Intent(open ? Intent.ACTION_OPEN_DOCUMENT : Intent.ACTION_CREATE_DOCUMENT); intent.addCategory(Intent.CATEGORY_OPENABLE); @@ -81,7 +81,7 @@ public class AndroidLauncher extends AndroidApplication{ if(uri.getPath().contains("(invalid)")) return; - Core.app.post(() -> Core.app.post(() -> cons.accept(new FileHandle(uri.getPath()){ + Core.app.post(() -> Core.app.post(() -> cons.get(new FileHandle(uri.getPath()){ @Override public InputStream read(){ try{ @@ -106,9 +106,9 @@ public class AndroidLauncher extends AndroidApplication{ checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE) == PackageManager.PERMISSION_GRANTED)){ chooser = new FileChooser(open ? "$open" : "$save", file -> file.extension().equalsIgnoreCase(extension), open, file -> { if(!open){ - cons.accept(file.parent().child(file.nameWithoutExtension() + "." + extension)); + cons.get(file.parent().child(file.nameWithoutExtension() + "." + extension)); }else{ - cons.accept(file); + cons.get(file); } }); diff --git a/core/assets/bundles/bundle.properties b/core/assets/bundles/bundle.properties index 4a5b0dd56a..4dd936f376 100644 --- a/core/assets/bundles/bundle.properties +++ b/core/assets/bundles/bundle.properties @@ -84,6 +84,7 @@ uploadingcontent = Uploading Content uploadingpreviewfile = Uploading Preview File committingchanges = Comitting Changes done = Done +feature.unsupported = Your device does not support this feature. mods.alphainfo = Keep in mind that mods are in alpha, and[scarlet] may be very buggy[].\nReport any issues you find to the Mindustry Github or Discord. mods.alpha = [accent](Alpha) diff --git a/core/src/io/anuke/mindustry/ai/BlockIndexer.java b/core/src/io/anuke/mindustry/ai/BlockIndexer.java index 77e2b05707..e43957785b 100644 --- a/core/src/io/anuke/mindustry/ai/BlockIndexer.java +++ b/core/src/io/anuke/mindustry/ai/BlockIndexer.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.ai; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.math.*; import io.anuke.arc.math.geom.*; @@ -163,11 +164,11 @@ public class BlockIndexer{ set.add(entity.tile); } - public TileEntity findTile(Team team, float x, float y, float range, Predicate pred){ + public TileEntity findTile(Team team, float x, float y, float range, Boolf pred){ return findTile(team, x, y, range, pred, false); } - public TileEntity findTile(Team team, float x, float y, float range, Predicate pred, boolean usePriority){ + public TileEntity findTile(Team team, float x, float y, float range, Boolf pred, boolean usePriority){ TileEntity closest = null; float dst = 0; @@ -182,7 +183,7 @@ public class BlockIndexer{ if(other == null) continue; - if(other.entity == null || other.getTeam() != team || !pred.test(other) || !other.block().targetable) + if(other.entity == null || other.getTeam() != team || !pred.get(other) || !other.block().targetable) continue; TileEntity e = other.entity; diff --git a/core/src/io/anuke/mindustry/ai/Pathfinder.java b/core/src/io/anuke/mindustry/ai/Pathfinder.java index 03ca073a08..f9099ba991 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfinder.java +++ b/core/src/io/anuke/mindustry/ai/Pathfinder.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.ai; import io.anuke.annotations.Annotations.*; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.math.geom.*; import io.anuke.arc.util.*; @@ -317,15 +318,15 @@ public class Pathfinder implements Runnable{ public static final PathTarget[] all = values(); - private final BiConsumer targeter; + private final Cons2 targeter; - PathTarget(BiConsumer targeter){ + PathTarget(Cons2 targeter){ this.targeter = targeter; } /** Get targets. This must run on the main thread.*/ public IntArray getTargets(Team team, IntArray out){ - targeter.accept(team, out); + targeter.get(team, out); return out; } } diff --git a/core/src/io/anuke/mindustry/ai/WaveSpawner.java b/core/src/io/anuke/mindustry/ai/WaveSpawner.java index b4dadcd59a..ca50e36b13 100644 --- a/core/src/io/anuke/mindustry/ai/WaveSpawner.java +++ b/core/src/io/anuke/mindustry/ai/WaveSpawner.java @@ -2,7 +2,7 @@ package io.anuke.mindustry.ai; import io.anuke.arc.Events; import io.anuke.arc.collection.Array; -import io.anuke.arc.function.PositionConsumer; +import io.anuke.arc.func.Floatc2; import io.anuke.arc.math.Angles; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Time; @@ -99,17 +99,17 @@ public class WaveSpawner{ } } - private void eachFlyerSpawn(PositionConsumer cons){ + private void eachFlyerSpawn(Floatc2 cons){ for(FlyerSpawn spawn : flySpawns){ float trns = (world.width() + world.height()) * tilesize; float spawnX = Mathf.clamp(world.width() * tilesize / 2f + Angles.trnsx(spawn.angle, trns), -margin, world.width() * tilesize + margin); float spawnY = Mathf.clamp(world.height() * tilesize / 2f + Angles.trnsy(spawn.angle, trns), -margin, world.height() * tilesize + margin); - cons.accept(spawnX, spawnY); + cons.get(spawnX, spawnY); } if(state.rules.attackMode && state.teams.isActive(waveTeam)){ for(Tile core : state.teams.get(waveTeam).cores){ - cons.accept(core.worldx(), core.worldy()); + cons.get(core.worldx(), core.worldy()); } } } diff --git a/core/src/io/anuke/mindustry/core/ContentLoader.java b/core/src/io/anuke/mindustry/core/ContentLoader.java index 99c50e111e..bfc853a13c 100644 --- a/core/src/io/anuke/mindustry/core/ContentLoader.java +++ b/core/src/io/anuke/mindustry/core/ContentLoader.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.core; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.util.*; @@ -24,7 +25,7 @@ public class ContentLoader{ private ObjectMap[] contentNameMap = new ObjectMap[ContentType.values().length]; private Array[] contentMap = new Array[ContentType.values().length]; private MappableContent[][] temporaryMapper; - private ObjectSet> initialization = new ObjectSet<>(); + private ObjectSet> initialization = new ObjectSet<>(); private ContentList[] content = { new Fx(), new Items(), @@ -105,13 +106,13 @@ public class ContentLoader{ } /** Initializes all content with the specified function. */ - private void initialize(Consumer callable){ + private void initialize(Cons callable){ if(initialization.contains(callable)) return; for(ContentType type : ContentType.values()){ for(Content content : contentMap[type.ordinal()]){ try{ - callable.accept(content); + callable.get(content); }catch(Throwable e){ if(content.mod != null){ mods.handleError(new ModLoadException(content, e), content.mod); diff --git a/core/src/io/anuke/mindustry/core/Control.java b/core/src/io/anuke/mindustry/core/Control.java index e5d5b2b9ce..b38cc63297 100644 --- a/core/src/io/anuke/mindustry/core/Control.java +++ b/core/src/io/anuke/mindustry/core/Control.java @@ -254,7 +254,7 @@ public class Control implements ApplicationListener, Loadable{ logic.reset(); net.reset(); world.loadGenerator(zone.generator); - zone.rules.accept(state.rules); + zone.rules.get(state.rules); state.rules.zone = zone; for(Tile core : state.teams.get(defaultTeam).cores){ for(ItemStack stack : zone.getStartingItems()){ @@ -302,7 +302,7 @@ public class Control implements ApplicationListener, Loadable{ world.endMapLoad(); - zone.rules.accept(state.rules); + zone.rules.get(state.rules); state.rules.zone = zone; for(Tile core : state.teams.get(defaultTeam).cores){ for(ItemStack stack : zone.getStartingItems()){ diff --git a/core/src/io/anuke/mindustry/core/Platform.java b/core/src/io/anuke/mindustry/core/Platform.java index 588e5081f1..f30ef754a8 100644 --- a/core/src/io/anuke/mindustry/core/Platform.java +++ b/core/src/io/anuke/mindustry/core/Platform.java @@ -4,6 +4,7 @@ import io.anuke.arc.*; import io.anuke.arc.Input.*; import io.anuke.arc.collection.*; import io.anuke.arc.files.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.math.*; import io.anuke.arc.scene.ui.*; @@ -96,12 +97,12 @@ public interface Platform{ * @param open Whether to open or save files * @param extension File extension to filter */ - default void showFileChooser(boolean open, String extension, Consumer cons){ + default void showFileChooser(boolean open, String extension, Cons cons){ new FileChooser(open ? "$open" : "$save", file -> file.extension().toLowerCase().equals(extension), open, file -> { if(!open){ - cons.accept(file.parent().child(file.nameWithoutExtension() + "." + extension)); + cons.get(file.parent().child(file.nameWithoutExtension() + "." + extension)); }else{ - cons.accept(file); + cons.get(file); } }).show(); } diff --git a/core/src/io/anuke/mindustry/core/Renderer.java b/core/src/io/anuke/mindustry/core/Renderer.java index fd9c577179..b279025743 100644 --- a/core/src/io/anuke/mindustry/core/Renderer.java +++ b/core/src/io/anuke/mindustry/core/Renderer.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.core; import io.anuke.arc.*; import io.anuke.arc.files.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.g2d.*; @@ -333,19 +334,19 @@ public class Renderer implements ApplicationListener{ Draw.color(0, 0, 0, 0.4f); float rad = 1.6f; - Consumer draw = u -> { + Cons draw = u -> { float size = Math.max(u.getIconRegion().getWidth(), u.getIconRegion().getHeight()) * Draw.scl; Draw.rect("circle-shadow", u.x, u.y, size * rad, size * rad); }; for(EntityGroup group : unitGroups){ if(!group.isEmpty()){ - group.draw(unit -> !unit.isDead(), draw::accept); + group.draw(unit -> !unit.isDead(), draw::get); } } if(!playerGroup.isEmpty()){ - playerGroup.draw(unit -> !unit.isDead(), draw::accept); + playerGroup.draw(unit -> !unit.isDead(), draw::get); } Draw.color(); diff --git a/core/src/io/anuke/mindustry/core/UI.java b/core/src/io/anuke/mindustry/core/UI.java index ffea7f4a4e..ce6981604f 100644 --- a/core/src/io/anuke/mindustry/core/UI.java +++ b/core/src/io/anuke/mindustry/core/UI.java @@ -12,6 +12,7 @@ import io.anuke.arc.files.*; import io.anuke.arc.freetype.*; import io.anuke.arc.freetype.FreeTypeFontGenerator.*; import io.anuke.arc.freetype.FreetypeFontLoader.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.Texture.*; @@ -279,7 +280,7 @@ public class UI implements ApplicationListener, Loadable{ }); } - public void showTextInput(String titleText, String dtext, int textLength, String def, boolean inumeric, Consumer confirmed){ + public void showTextInput(String titleText, String dtext, int textLength, String def, boolean inumeric, Cons confirmed){ if(mobile){ Core.input.getTextInput(new TextInput(){{ this.title = (titleText.startsWith("$") ? Core.bundle.get(titleText.substring(1)) : titleText); @@ -296,7 +297,7 @@ public class UI implements ApplicationListener, Loadable{ field.setFilter((f, c) -> field.getText().length() < textLength && filter.acceptChar(f, c)); buttons.defaults().size(120, 54).pad(4); buttons.addButton("$ok", () -> { - confirmed.accept(field.getText()); + confirmed.get(field.getText()); hide(); }).disabled(b -> field.getText().isEmpty()); buttons.addButton("$cancel", this::hide); @@ -304,11 +305,11 @@ public class UI implements ApplicationListener, Loadable{ } } - public void showTextInput(String title, String text, String def, Consumer confirmed){ + public void showTextInput(String title, String text, String def, Cons confirmed){ showTextInput(title, text, 32, def, confirmed); } - public void showTextInput(String titleText, String text, int textLength, String def, Consumer confirmed){ + public void showTextInput(String titleText, String text, int textLength, String def, Cons confirmed){ showTextInput(titleText, text, textLength, def, false, confirmed); } @@ -404,7 +405,7 @@ public class UI implements ApplicationListener, Loadable{ showConfirm(title, text, null, confirmed); } - public void showConfirm(String title, String text, BooleanProvider hide, Runnable confirmed){ + public void showConfirm(String title, String text, Boolp hide, Runnable confirmed){ FloatingDialog dialog = new FloatingDialog(title); dialog.cont.add(text).width(mobile ? 400f : 500f).wrap().pad(4f).get().setAlignment(Align.center, Align.center); dialog.buttons.defaults().size(200f, 54f).pad(2f); diff --git a/core/src/io/anuke/mindustry/editor/EditorTool.java b/core/src/io/anuke/mindustry/editor/EditorTool.java index 9da41ad7f2..3a363de688 100644 --- a/core/src/io/anuke/mindustry/editor/EditorTool.java +++ b/core/src/io/anuke/mindustry/editor/EditorTool.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.editor; import io.anuke.arc.collection.IntArray; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Bresenham2; @@ -113,8 +114,8 @@ public enum EditorTool{ return; } - Predicate tester; - Consumer setter; + Boolf tester; + Cons setter; if(editor.drawBlock.isOverlay()){ Block dest = tile.overlay(); @@ -146,7 +147,7 @@ public enum EditorTool{ } } - void fill(MapEditor editor, int x, int y, boolean replace, Predicate tester, Consumer filler){ + void fill(MapEditor editor, int x, int y, boolean replace, Boolf tester, Cons filler){ int width = editor.width(), height = editor.height(); if(replace){ @@ -154,8 +155,8 @@ public enum EditorTool{ for(int cx = 0; cx < width; cx++){ for(int cy = 0; cy < height; cy++){ Tile tile = editor.tile(cx, cy); - if(tester.test(tile)){ - filler.accept(tile); + if(tester.get(tile)){ + filler.get(tile); } } } @@ -173,23 +174,23 @@ public enum EditorTool{ y = Pos.y(popped); x1 = x; - while(x1 >= 0 && tester.test(editor.tile(x1, y))) x1--; + while(x1 >= 0 && tester.get(editor.tile(x1, y))) x1--; x1++; boolean spanAbove = false, spanBelow = false; - while(x1 < width && tester.test(editor.tile(x1, y))){ - filler.accept(editor.tile(x1, y)); + while(x1 < width && tester.get(editor.tile(x1, y))){ + filler.get(editor.tile(x1, y)); - if(!spanAbove && y > 0 && tester.test(editor.tile(x1, y - 1))){ + if(!spanAbove && y > 0 && tester.get(editor.tile(x1, y - 1))){ stack.add(Pos.get(x1, y - 1)); spanAbove = true; - }else if(spanAbove && !tester.test(editor.tile(x1, y - 1))){ + }else if(spanAbove && !tester.get(editor.tile(x1, y - 1))){ spanAbove = false; } - if(!spanBelow && y < height - 1 && tester.test(editor.tile(x1, y + 1))){ + if(!spanBelow && y < height - 1 && tester.get(editor.tile(x1, y + 1))){ stack.add(Pos.get(x1, y + 1)); spanBelow = true; - }else if(spanBelow && y < height - 1 && !tester.test(editor.tile(x1, y + 1))){ + }else if(spanBelow && y < height - 1 && !tester.get(editor.tile(x1, y + 1))){ spanBelow = false; } x1++; diff --git a/core/src/io/anuke/mindustry/editor/MapEditor.java b/core/src/io/anuke/mindustry/editor/MapEditor.java index ec32a94594..d8e8d60206 100644 --- a/core/src/io/anuke/mindustry/editor/MapEditor.java +++ b/core/src/io/anuke/mindustry/editor/MapEditor.java @@ -2,8 +2,8 @@ package io.anuke.mindustry.editor; import io.anuke.arc.collection.StringMap; import io.anuke.arc.files.FileHandle; -import io.anuke.arc.function.Consumer; -import io.anuke.arc.function.Predicate; +import io.anuke.arc.func.Cons; +import io.anuke.arc.func.Boolf; import io.anuke.arc.graphics.Pixmap; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.Structs; @@ -144,11 +144,11 @@ public class MapEditor{ drawBlocks(x, y, false, tile -> true); } - public void drawBlocks(int x, int y, Predicate tester){ + public void drawBlocks(int x, int y, Boolf tester){ drawBlocks(x, y, false, tester); } - public void drawBlocks(int x, int y, boolean square, Predicate tester){ + public void drawBlocks(int x, int y, boolean square, Boolf tester){ if(drawBlock.isMultiblock()){ x = Mathf.clamp(x, (drawBlock.size - 1) / 2, width() - drawBlock.size / 2 - 1); y = Mathf.clamp(y, (drawBlock.size - 1) / 2, height() - drawBlock.size / 2 - 1); @@ -180,8 +180,8 @@ public class MapEditor{ }else{ boolean isFloor = drawBlock.isFloor() && drawBlock != Blocks.air; - Consumer drawer = tile -> { - if(!tester.test(tile)) return; + Cons drawer = tile -> { + if(!tester.get(tile)) return; //remove linked tiles blocking the way if(!isFloor && (tile.isLinked() || tile.block().isMultiblock())){ @@ -209,7 +209,7 @@ public class MapEditor{ } } - public void drawCircle(int x, int y, Consumer drawer){ + public void drawCircle(int x, int y, Cons drawer){ for(int rx = -brushSize; rx <= brushSize; rx++){ for(int ry = -brushSize; ry <= brushSize; ry++){ if(Mathf.dst2(rx, ry) <= (brushSize - 0.5f) * (brushSize - 0.5f)){ @@ -219,13 +219,13 @@ public class MapEditor{ continue; } - drawer.accept(tile(wx, wy)); + drawer.get(tile(wx, wy)); } } } } - public void drawSquare(int x, int y, Consumer drawer){ + public void drawSquare(int x, int y, Cons drawer){ for(int rx = -brushSize; rx <= brushSize; rx++){ for(int ry = -brushSize; ry <= brushSize; ry++){ int wx = x + rx, wy = y + ry; @@ -234,7 +234,7 @@ public class MapEditor{ continue; } - drawer.accept(tile(wx, wy)); + drawer.get(tile(wx, wy)); } } } diff --git a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java index 0bcd4fa80b..6427cc15c9 100644 --- a/core/src/io/anuke/mindustry/editor/MapEditorDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapEditorDialog.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.editor; import io.anuke.arc.*; import io.anuke.arc.collection.*; import io.anuke.arc.files.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.g2d.*; @@ -425,7 +426,7 @@ public class MapEditorDialog extends Dialog implements Disposable{ ButtonGroup group = new ButtonGroup<>(); Table[] lastTable = {null}; - Consumer addTool = tool -> { + Cons addTool = tool -> { ImageButton button = new ImageButton(Core.atlas.drawable("icon-" + tool.name() + "-small"), Styles.clearTogglei); button.clicked(() -> { @@ -507,14 +508,14 @@ public class MapEditorDialog extends Dialog implements Disposable{ ImageButton grid = tools.addImageButton(Icon.gridSmall, Styles.clearTogglei, () -> view.setGrid(!view.isGrid())).get(); - addTool.accept(EditorTool.zoom); + addTool.get(EditorTool.zoom); tools.row(); ImageButton undo = tools.addImageButton(Icon.undoSmall, Styles.cleari, editor::undo).get(); ImageButton redo = tools.addImageButton(Icon.redoSmall, Styles.cleari, editor::redo).get(); - addTool.accept(EditorTool.pick); + addTool.get(EditorTool.pick); tools.row(); @@ -525,14 +526,14 @@ public class MapEditorDialog extends Dialog implements Disposable{ redo.update(() -> redo.getImage().setColor(redo.isDisabled() ? Color.gray : Color.white)); grid.update(() -> grid.setChecked(view.isGrid())); - addTool.accept(EditorTool.line); - addTool.accept(EditorTool.pencil); - addTool.accept(EditorTool.eraser); + addTool.get(EditorTool.line); + addTool.get(EditorTool.pencil); + addTool.get(EditorTool.eraser); tools.row(); - addTool.accept(EditorTool.fill); - addTool.accept(EditorTool.spray); + addTool.get(EditorTool.fill); + addTool.get(EditorTool.spray); ImageButton rotate = tools.addImageButton(Icon.arrow16Small, Styles.cleari, () -> editor.rotation = (editor.rotation + 1) % 4).get(); rotate.getImage().update(() -> { diff --git a/core/src/io/anuke/mindustry/editor/MapGenerateDialog.java b/core/src/io/anuke/mindustry/editor/MapGenerateDialog.java index dd1f77811e..bc469ad3a6 100644 --- a/core/src/io/anuke/mindustry/editor/MapGenerateDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapGenerateDialog.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.editor; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.Pixmap.*; @@ -27,7 +28,7 @@ import static io.anuke.mindustry.Vars.*; @SuppressWarnings("unchecked") public class MapGenerateDialog extends FloatingDialog{ - private final Supplier[] filterTypes = new Supplier[]{ + private final Prov[] filterTypes = new Prov[]{ NoiseFilter::new, ScatterFilter::new, TerrainFilter::new, DistortFilter::new, RiverNoiseFilter::new, OreFilter::new, OreMedianFilter::new, MedianFilter::new, BlendFilter::new, MirrorFilter::new, ClearFilter::new @@ -48,7 +49,7 @@ public class MapGenerateDialog extends FloatingDialog{ private GenTile returnTile = new GenTile(); private GenTile[][] buffer1, buffer2; - private Consumer> applier; + private Cons> applier; private CachedTile ctile = new CachedTile(){ //nothing. @Override @@ -95,13 +96,13 @@ public class MapGenerateDialog extends FloatingDialog{ onResize(this::rebuildFilters); } - public void show(Array filters, Consumer> applier){ + public void show(Array filters, Cons> applier){ this.filters = filters; this.applier = applier; show(); } - public void show(Consumer> applier){ + public void show(Cons> applier){ show(this.filters, applier); } @@ -289,7 +290,7 @@ public class MapGenerateDialog extends FloatingDialog{ selection.setFillParent(false); selection.cont.defaults().size(210f, 60f); int i = 0; - for(Supplier gen : filterTypes){ + for(Prov gen : filterTypes){ GenerateFilter filter = gen.get(); if(!applied && filter.buffered) continue; @@ -334,7 +335,7 @@ public class MapGenerateDialog extends FloatingDialog{ texture = null; } - applier.accept(filters); + applier.get(filters); } void update(){ diff --git a/core/src/io/anuke/mindustry/editor/MapLoadDialog.java b/core/src/io/anuke/mindustry/editor/MapLoadDialog.java index c0567a724c..4cad68bc32 100644 --- a/core/src/io/anuke/mindustry/editor/MapLoadDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapLoadDialog.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.editor; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.scene.ui.*; import io.anuke.arc.scene.ui.layout.*; @@ -13,7 +14,7 @@ import static io.anuke.mindustry.Vars.maps; public class MapLoadDialog extends FloatingDialog{ private Map selected = null; - public MapLoadDialog(Consumer loader){ + public MapLoadDialog(Cons loader){ super("$editor.loadmap"); shown(this::rebuild); @@ -22,7 +23,7 @@ public class MapLoadDialog extends FloatingDialog{ button.setDisabled(() -> selected == null); button.clicked(() -> { if(selected != null){ - loader.accept(selected); + loader.get(selected); hide(); } }); diff --git a/core/src/io/anuke/mindustry/editor/MapResizeDialog.java b/core/src/io/anuke/mindustry/editor/MapResizeDialog.java index 3284feda19..e9abddc964 100644 --- a/core/src/io/anuke/mindustry/editor/MapResizeDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapResizeDialog.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.editor; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.math.*; import io.anuke.arc.scene.ui.layout.*; @@ -10,7 +11,7 @@ public class MapResizeDialog extends FloatingDialog{ private static final int minSize = 50, maxSize = 500, increment = 50; int width, height; - public MapResizeDialog(MapEditor editor, IntPositionConsumer cons){ + public MapResizeDialog(MapEditor editor, Intc2 cons){ super("$editor.resizemap"); shown(() -> { cont.clear(); @@ -47,7 +48,7 @@ public class MapResizeDialog extends FloatingDialog{ buttons.defaults().size(200f, 50f); buttons.addButton("$cancel", this::hide); buttons.addButton("$ok", () -> { - cons.accept(width, height); + cons.get(width, height); hide(); }); } diff --git a/core/src/io/anuke/mindustry/editor/MapSaveDialog.java b/core/src/io/anuke/mindustry/editor/MapSaveDialog.java index d0f8ce77ae..44b118b408 100644 --- a/core/src/io/anuke/mindustry/editor/MapSaveDialog.java +++ b/core/src/io/anuke/mindustry/editor/MapSaveDialog.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.editor; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.scene.ui.*; import io.anuke.mindustry.*; @@ -10,9 +11,9 @@ import static io.anuke.mindustry.Vars.ui; public class MapSaveDialog extends FloatingDialog{ private TextField field; - private Consumer listener; + private Cons listener; - public MapSaveDialog(Consumer cons){ + public MapSaveDialog(Cons cons){ super("$editor.savemap"); field = new TextField(); listener = cons; @@ -43,7 +44,7 @@ public class MapSaveDialog extends FloatingDialog{ TextButton button = new TextButton("$save"); button.clicked(() -> { if(!invalid()){ - cons.accept(field.getText()); + cons.get(field.getText()); hide(); } }); @@ -53,7 +54,7 @@ public class MapSaveDialog extends FloatingDialog{ public void save(){ if(!invalid()){ - listener.accept(field.getText()); + listener.get(field.getText()); }else{ ui.showErrorMessage("$editor.failoverwrite"); } diff --git a/core/src/io/anuke/mindustry/entities/Damage.java b/core/src/io/anuke/mindustry/entities/Damage.java index dfe339bb44..149bb9b4d8 100644 --- a/core/src/io/anuke/mindustry/entities/Damage.java +++ b/core/src/io/anuke/mindustry/entities/Damage.java @@ -1,26 +1,22 @@ package io.anuke.mindustry.entities; -import io.anuke.annotations.Annotations.Struct; +import io.anuke.annotations.Annotations.*; import io.anuke.arc.*; import io.anuke.arc.collection.*; -import io.anuke.arc.function.*; -import io.anuke.arc.graphics.Color; -import io.anuke.arc.math.Mathf; +import io.anuke.arc.func.*; +import io.anuke.arc.graphics.*; +import io.anuke.arc.math.*; import io.anuke.arc.math.geom.*; import io.anuke.arc.util.*; -import io.anuke.mindustry.content.Bullets; -import io.anuke.mindustry.content.Fx; -import io.anuke.mindustry.entities.Effects.Effect; -import io.anuke.mindustry.entities.type.Bullet; -import io.anuke.mindustry.entities.effect.Fire; -import io.anuke.mindustry.entities.effect.Lightning; -import io.anuke.mindustry.entities.type.Unit; +import io.anuke.mindustry.content.*; +import io.anuke.mindustry.entities.Effects.*; +import io.anuke.mindustry.entities.effect.*; +import io.anuke.mindustry.entities.type.*; import io.anuke.mindustry.game.EventType.*; -import io.anuke.mindustry.game.Team; -import io.anuke.mindustry.gen.Call; -import io.anuke.mindustry.gen.PropCell; -import io.anuke.mindustry.graphics.Pal; -import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.game.*; +import io.anuke.mindustry.gen.*; +import io.anuke.mindustry.graphics.*; +import io.anuke.mindustry.world.*; import static io.anuke.mindustry.Vars.*; @@ -90,7 +86,7 @@ public class Damage{ public static void collideLine(Bullet hitter, Team team, Effect effect, float x, float y, float angle, float length, boolean large){ collidedBlocks.clear(); tr.trns(angle, length); - IntPositionConsumer collider = (cx, cy) -> { + Intc2 collider = (cx, cy) -> { Tile tile = world.ltile(cx, cy); if(tile != null && !collidedBlocks.contains(tile.pos()) && tile.entity != null && tile.getTeamID() != team.ordinal() && tile.entity.collide(hitter)){ tile.entity.collision(hitter); @@ -100,10 +96,10 @@ public class Damage{ }; world.raycastEachWorld(x, y, x + tr.x, y + tr.y, (cx, cy) -> { - collider.accept(cx, cy); + collider.get(cx, cy); if(large){ for(Point2 p : Geometry.d4){ - collider.accept(cx + p.x, cy + p.y); + collider.get(cx + p.x, cy + p.y); } } return false; @@ -129,7 +125,7 @@ public class Damage{ rect.width += expand * 2; rect.height += expand * 2; - Consumer cons = e -> { + Cons cons = e -> { e.hitbox(hitrect); Rectangle other = hitrect; other.y -= expand; @@ -150,16 +146,16 @@ public class Damage{ } /** Damages all entities and blocks in a radius that are enemies of the team. */ - public static void damageUnits(Team team, float x, float y, float size, float damage, Predicate predicate, Consumer acceptor){ - Consumer cons = entity -> { - if(!predicate.test(entity)) return; + public static void damageUnits(Team team, float x, float y, float size, float damage, Boolf predicate, Cons acceptor){ + Cons cons = entity -> { + if(!predicate.get(entity)) return; entity.hitbox(hitrect); if(!hitrect.overlaps(rect)){ return; } entity.damage(damage); - acceptor.accept(entity); + acceptor.get(entity); }; rect.setSize(size * 2).setCenter(x, y); @@ -182,7 +178,7 @@ public class Damage{ /** Damages all entities and blocks in a radius that are enemies of the team. */ public static void damage(Team team, float x, float y, float radius, float damage, boolean complete){ - Consumer cons = entity -> { + Cons cons = entity -> { if(entity.getTeam() == team || entity.dst(x, y) > radius){ return; } diff --git a/core/src/io/anuke/mindustry/entities/Effects.java b/core/src/io/anuke/mindustry/entities/Effects.java index 62bcd9a3ce..2647fc2427 100644 --- a/core/src/io/anuke/mindustry/entities/Effects.java +++ b/core/src/io/anuke/mindustry/entities/Effects.java @@ -2,7 +2,7 @@ package io.anuke.mindustry.entities; import io.anuke.arc.Core; import io.anuke.arc.collection.Array; -import io.anuke.arc.function.Consumer; +import io.anuke.arc.func.Cons; import io.anuke.arc.graphics.Color; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Position; @@ -142,11 +142,11 @@ public class Effects{ this.data = data; } - public void scaled(float lifetime, Consumer cons){ + public void scaled(float lifetime, Cons cons){ if(innerContainer == null) innerContainer = new EffectContainer(); if(time <= lifetime){ innerContainer.set(id, color, time, lifetime, rotation, x, y, data); - cons.accept(innerContainer); + cons.get(innerContainer); } } diff --git a/core/src/io/anuke/mindustry/entities/EntityGroup.java b/core/src/io/anuke/mindustry/entities/EntityGroup.java index 07057d0436..3ce94ac968 100644 --- a/core/src/io/anuke/mindustry/entities/EntityGroup.java +++ b/core/src/io/anuke/mindustry/entities/EntityGroup.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.entities; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.math.geom.*; @@ -22,8 +23,8 @@ public class EntityGroup{ private final Rectangle intersectRect = new Rectangle(); private IntMap map; private QuadTree tree; - private Consumer removeListener; - private Consumer addListener; + private Cons removeListener; + private Cons addListener; private final Rectangle viewport = new Rectangle(); private int count = 0; @@ -60,20 +61,20 @@ public class EntityGroup{ draw(e -> true); } - public void draw(Predicate toDraw){ + public void draw(Boolf toDraw){ draw(toDraw, t -> ((DrawTrait)t).draw()); } - public void draw(Predicate toDraw, Consumer cons){ + public void draw(Boolf toDraw, Cons cons){ Camera cam = Core.camera; viewport.set(cam.position.x - cam.width / 2, cam.position.y - cam.height / 2, cam.width, cam.height); for(Entity e : all()){ - if(!(e instanceof DrawTrait) || !toDraw.test((T)e) || !e.isAdded()) continue; + if(!(e instanceof DrawTrait) || !toDraw.get((T)e) || !e.isAdded()) continue; DrawTrait draw = (DrawTrait)e; if(viewport.overlaps(draw.getX() - draw.drawSize()/2f, draw.getY() - draw.drawSize()/2f, draw.drawSize(), draw.drawSize())){ - cons.accept((T)e); + cons.get((T)e); } } } @@ -82,11 +83,11 @@ public class EntityGroup{ return useTree; } - public void setRemoveListener(Consumer removeListener){ + public void setRemoveListener(Cons removeListener){ this.removeListener = removeListener; } - public void setAddListener(Consumer addListener){ + public void setAddListener(Cons addListener){ this.addListener = addListener; } @@ -148,7 +149,7 @@ public class EntityGroup{ if(check.getID() == id){ //if it is indeed queued, remove it entitiesToAdd.removeValue(check, true); if(removeListener != null){ - removeListener.accept(check); + removeListener.get(check); } break; } @@ -157,7 +158,7 @@ public class EntityGroup{ } @SuppressWarnings("unchecked") - public void intersect(float x, float y, float width, float height, Consumer out){ + public void intersect(float x, float y, float width, float height, Cons out){ //don't waste time for empty groups if(isEmpty()) return; tree().getIntersect(out, x, y, width, height); @@ -192,10 +193,10 @@ public class EntityGroup{ return entityArray.size; } - public int count(Predicate pred){ + public int count(Boolf pred){ int count = 0; for(int i = 0; i < entityArray.size; i++){ - if(pred.test(entityArray.get(i))) count++; + if(pred.get(entityArray.get(i))) count++; } return count; } @@ -211,7 +212,7 @@ public class EntityGroup{ } if(addListener != null){ - addListener.accept(type); + addListener.get(type); } } @@ -221,7 +222,7 @@ public class EntityGroup{ entitiesToRemove.add(type); if(removeListener != null){ - removeListener.accept(type); + removeListener.get(type); } } @@ -244,10 +245,10 @@ public class EntityGroup{ map.clear(); } - public T find(Predicate pred){ + public T find(Boolf pred){ for(int i = 0; i < entityArray.size; i++){ - if(pred.test(entityArray.get(i))) return entityArray.get(i); + if(pred.get(entityArray.get(i))) return entityArray.get(i); } return null; diff --git a/core/src/io/anuke/mindustry/entities/Units.java b/core/src/io/anuke/mindustry/entities/Units.java index c9d0073998..df4ba980df 100644 --- a/core/src/io/anuke/mindustry/entities/Units.java +++ b/core/src/io/anuke/mindustry/entities/Units.java @@ -1,8 +1,8 @@ package io.anuke.mindustry.entities; import io.anuke.arc.collection.EnumSet; -import io.anuke.arc.function.Consumer; -import io.anuke.arc.function.Predicate; +import io.anuke.arc.func.Cons; +import io.anuke.arc.func.Boolf; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Geometry; import io.anuke.arc.math.geom.Rectangle; @@ -78,12 +78,12 @@ public class Units{ } /** Returns the neareset ally tile in a range. */ - public static TileEntity findAllyTile(Team team, float x, float y, float range, Predicate pred){ + public static TileEntity findAllyTile(Team team, float x, float y, float range, Boolf pred){ return indexer.findTile(team, x, y, range, pred); } /** Returns the neareset enemy tile in a range. */ - public static TileEntity findEnemyTile(Team team, float x, float y, float range, Predicate pred){ + public static TileEntity findEnemyTile(Team team, float x, float y, float range, Boolf pred){ if(team == Team.derelict) return null; for(Team enemy : state.teams.enemiesOf(team)){ @@ -101,12 +101,12 @@ public class Units{ } /** Returns the closest target enemy. First, units are checked, then tile entities. */ - public static TargetTrait closestTarget(Team team, float x, float y, float range, Predicate unitPred){ + public static TargetTrait closestTarget(Team team, float x, float y, float range, Boolf unitPred){ return closestTarget(team, x, y, range, unitPred, t -> true); } /** Returns the closest target enemy. First, units are checked, then tile entities. */ - public static TargetTrait closestTarget(Team team, float x, float y, float range, Predicate unitPred, Predicate tilePred){ + public static TargetTrait closestTarget(Team team, float x, float y, float range, Boolf unitPred, Boolf tilePred){ if(team == Team.derelict) return null; Unit unit = closestEnemy(team, x, y, range, unitPred); @@ -118,14 +118,14 @@ public class Units{ } /** Returns the closest enemy of this team. Filter by predicate. */ - public static Unit closestEnemy(Team team, float x, float y, float range, Predicate predicate){ + public static Unit closestEnemy(Team team, float x, float y, float range, Boolf predicate){ if(team == Team.derelict) return null; result = null; cdist = 0f; nearbyEnemies(team, x - range, y - range, range*2f, range*2f, e -> { - if(e.isDead() || !predicate.test(e)) return; + if(e.isDead() || !predicate.get(e)) return; float dst2 = Mathf.dst2(e.x, e.y, x, y); if(dst2 < range*range && (result == null || dst2 < cdist)){ @@ -138,12 +138,12 @@ public class Units{ } /** Returns the closest ally of this team. Filter by predicate. */ - public static Unit closest(Team team, float x, float y, float range, Predicate predicate){ + public static Unit closest(Team team, float x, float y, float range, Boolf predicate){ result = null; cdist = 0f; nearby(team, x, y, range, e -> { - if(!predicate.test(e)) return; + if(!predicate.get(e)) return; float dist = Mathf.dst2(e.x, e.y, x, y); if(result == null || dist < cdist){ @@ -156,32 +156,32 @@ public class Units{ } /** Iterates over all units in a rectangle. */ - public static void nearby(Team team, float x, float y, float width, float height, Consumer cons){ + public static void nearby(Team team, float x, float y, float width, float height, Cons cons){ unitGroups[team.ordinal()].intersect(x, y, width, height, cons); playerGroup.intersect(x, y, width, height, player -> { if(player.getTeam() == team){ - cons.accept(player); + cons.get(player); } }); } /** Iterates over all units in a circle around this position. */ - public static void nearby(Team team, float x, float y, float radius, Consumer cons){ + public static void nearby(Team team, float x, float y, float radius, Cons cons){ unitGroups[team.ordinal()].intersect(x - radius, y - radius, radius*2f, radius*2f, unit -> { if(unit.withinDst(x, y, radius)){ - cons.accept(unit); + cons.get(unit); } }); playerGroup.intersect(x - radius, y - radius, radius*2f, radius*2f, unit -> { if(unit.getTeam() == team && unit.withinDst(x, y, radius)){ - cons.accept(unit); + cons.get(unit); } }); } /** Iterates over all units in a rectangle. */ - public static void nearby(float x, float y, float width, float height, Consumer cons){ + public static void nearby(float x, float y, float width, float height, Cons cons){ for(Team team : Team.all){ unitGroups[team.ordinal()].intersect(x, y, width, height, cons); } @@ -190,12 +190,12 @@ public class Units{ } /** Iterates over all units in a rectangle. */ - public static void nearby(Rectangle rect, Consumer cons){ + public static void nearby(Rectangle rect, Cons cons){ nearby(rect.x, rect.y, rect.width, rect.height, cons); } /** Iterates over all units that are enemies of this team. */ - public static void nearbyEnemies(Team team, float x, float y, float width, float height, Consumer cons){ + public static void nearbyEnemies(Team team, float x, float y, float width, float height, Cons cons){ EnumSet targets = state.teams.enemiesOf(team); for(Team other : targets){ @@ -204,18 +204,18 @@ public class Units{ playerGroup.intersect(x, y, width, height, player -> { if(targets.contains(player.getTeam())){ - cons.accept(player); + cons.get(player); } }); } /** Iterates over all units that are enemies of this team. */ - public static void nearbyEnemies(Team team, Rectangle rect, Consumer cons){ + public static void nearbyEnemies(Team team, Rectangle rect, Cons cons){ nearbyEnemies(team, rect.x, rect.y, rect.width, rect.height, cons); } /** Iterates over all units. */ - public static void all(Consumer cons){ + public static void all(Cons cons){ for(Team team : Team.all){ unitGroups[team.ordinal()].all().each(cons); } diff --git a/core/src/io/anuke/mindustry/game/Gamemode.java b/core/src/io/anuke/mindustry/game/Gamemode.java index 79fa228305..0608e7bb51 100644 --- a/core/src/io/anuke/mindustry/game/Gamemode.java +++ b/core/src/io/anuke/mindustry/game/Gamemode.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.game; import io.anuke.arc.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.mindustry.maps.*; @@ -44,25 +45,25 @@ public enum Gamemode{ rules.respawnTime = 0f; }); - private final Consumer rules; - private final Predicate validator; + private final Cons rules; + private final Boolf validator; public final boolean hidden; public final static Gamemode[] all = values(); - Gamemode(Consumer rules){ + Gamemode(Cons rules){ this(false, rules); } - Gamemode(boolean hidden, Consumer rules){ + Gamemode(boolean hidden, Cons rules){ this(hidden, rules, m -> true); } - Gamemode(Consumer rules, Predicate validator){ + Gamemode(Cons rules, Boolf validator){ this(false, rules, validator); } - Gamemode(boolean hidden, Consumer rules, Predicate validator){ + Gamemode(boolean hidden, Cons rules, Boolf validator){ this.rules = rules; this.hidden = hidden; this.validator = validator; @@ -84,13 +85,13 @@ public enum Gamemode{ /** Applies this preset to this ruleset. */ public Rules apply(Rules in){ - rules.accept(in); + rules.get(in); return in; } /** @return whether this mode can be played on the specified map. */ public boolean valid(Map map){ - return validator.test(map); + return validator.get(map); } public String description(){ diff --git a/core/src/io/anuke/mindustry/game/Tutorial.java b/core/src/io/anuke/mindustry/game/Tutorial.java index 3048561693..cffdb50ff6 100644 --- a/core/src/io/anuke/mindustry/game/Tutorial.java +++ b/core/src/io/anuke/mindustry/game/Tutorial.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.game; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.*; @@ -194,16 +195,16 @@ public class Tutorial{ },; protected String line = ""; - protected final Function text; + protected final Func text; protected Array sentences; - protected final BooleanProvider done; + protected final Boolp done; - TutorialStage(Function text, BooleanProvider done){ + TutorialStage(Func text, Boolp done){ this.text = text; this.done = done; } - TutorialStage(BooleanProvider done){ + TutorialStage(Boolp done){ this(line -> line, done); } diff --git a/core/src/io/anuke/mindustry/graphics/MenuRenderer.java b/core/src/io/anuke/mindustry/graphics/MenuRenderer.java index 3efe543625..89078c92e9 100644 --- a/core/src/io/anuke/mindustry/graphics/MenuRenderer.java +++ b/core/src/io/anuke/mindustry/graphics/MenuRenderer.java @@ -2,7 +2,7 @@ package io.anuke.mindustry.graphics; import io.anuke.arc.Core; import io.anuke.arc.collection.Array; -import io.anuke.arc.function.PositionConsumer; +import io.anuke.arc.func.Floatc2; import io.anuke.arc.graphics.Camera; import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.g2d.*; @@ -282,7 +282,7 @@ public class MenuRenderer implements Disposable{ }); } - private void flyers(PositionConsumer cons){ + private void flyers(Floatc2 cons){ float tw = width * tilesize * 1f + tilesize; float th = height * tilesize * 1f + tilesize; float range = 500f; @@ -291,7 +291,7 @@ public class MenuRenderer implements Disposable{ for(int i = 0; i < flyers; i++){ Tmp.v1.trns(flyerRot, time * (2f + flyerType.speed)); - cons.accept((Mathf.randomSeedRange(i, range) + Tmp.v1.x + Mathf.absin(time + Mathf.randomSeedRange(i + 2, 500), 10f, 3.4f) + offset) % (tw + Mathf.randomSeed(i + 5, 0, 500)), + cons.get((Mathf.randomSeedRange(i, range) + Tmp.v1.x + Mathf.absin(time + Mathf.randomSeedRange(i + 2, 500), 10f, 3.4f) + offset) % (tw + Mathf.randomSeed(i + 5, 0, 500)), (Mathf.randomSeedRange(i + 1, range) + Tmp.v1.y + Mathf.absin(time + Mathf.randomSeedRange(i + 3, 500), 10f, 3.4f) + offset) % th); } } diff --git a/core/src/io/anuke/mindustry/input/InputHandler.java b/core/src/io/anuke/mindustry/input/InputHandler.java index fef5509f7d..9cb1330617 100644 --- a/core/src/io/anuke/mindustry/input/InputHandler.java +++ b/core/src/io/anuke/mindustry/input/InputHandler.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.input; import io.anuke.annotations.Annotations.*; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.g2d.*; @@ -154,9 +155,9 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ public Eachable allRequests(){ return cons -> { - for(BuildRequest request : player.buildQueue()) cons.accept(request); - for(BuildRequest request : selectRequests) cons.accept(request); - for(BuildRequest request : lineRequests) cons.accept(request); + for(BuildRequest request : player.buildQueue()) cons.get(request); + for(BuildRequest request : selectRequests) cons.get(request); + for(BuildRequest request : lineRequests) cons.get(request); }; } @@ -311,7 +312,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ r2.setCenter(x * tilesize + offset, y * tilesize + offset); resultreq = null; - Predicate test = req -> { + Boolf test = req -> { if(req == skip) return false; Tile other = req.tile(); @@ -329,11 +330,11 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ }; for(BuildRequest req : player.buildQueue()){ - if(test.test(req)) return req; + if(test.get(req)) return req; } for(BuildRequest req : selectRequests){ - if(test.test(req)) return req; + if(test.get(req)) return req; } return null; @@ -768,7 +769,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90); } - void iterateLine(int startX, int startY, int endX, int endY, Consumer cons){ + void iterateLine(int startX, int startY, int endX, int endY, Cons cons){ Array points; boolean diagonal = Core.input.keyDown(Binding.diagonal_placement); if(Core.settings.getBool("swapdiagonal")){ @@ -805,7 +806,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{ line.rotation = rotation; } line.last = next == null; - cons.accept(line); + cons.get(line); Tmp.r3.setSize(block.size * tilesize).setCenter(point.x * tilesize + block.offset(), point.y * tilesize + block.offset()); } diff --git a/core/src/io/anuke/mindustry/io/versions/LegacyTypeTable.java b/core/src/io/anuke/mindustry/io/versions/LegacyTypeTable.java index 19168c9802..419d91e7ed 100644 --- a/core/src/io/anuke/mindustry/io/versions/LegacyTypeTable.java +++ b/core/src/io/anuke/mindustry/io/versions/LegacyTypeTable.java @@ -1,6 +1,6 @@ package io.anuke.mindustry.io.versions; -import io.anuke.arc.function.Supplier; +import io.anuke.arc.func.Prov; import io.anuke.mindustry.entities.type.Bullet; import io.anuke.mindustry.entities.effect.*; import io.anuke.mindustry.entities.type.Player; @@ -62,7 +62,7 @@ Before addition of new units: [build 79 and below] 14 = Revenant */ public class LegacyTypeTable{ - private static final Supplier[] build81Table = { + private static final Prov[] build81Table = { Player::new, Fire::new, Puddle::new, @@ -79,7 +79,7 @@ public class LegacyTypeTable{ Revenant::new }; - private static final Supplier[] build80Table = { + private static final Prov[] build80Table = { Player::new, Fire::new, Puddle::new, @@ -98,7 +98,7 @@ public class LegacyTypeTable{ Revenant::new }; - private static final Supplier[] build79Table = { + private static final Prov[] build79Table = { Player::new, Fire::new, Puddle::new, @@ -116,7 +116,7 @@ public class LegacyTypeTable{ Revenant::new }; - public static Supplier[] getTable(int build){ + public static Prov[] getTable(int build){ if(build == -1 || build == 81){ //return most recent one since that's probably it; not guaranteed return build81Table; diff --git a/core/src/io/anuke/mindustry/io/versions/Save1.java b/core/src/io/anuke/mindustry/io/versions/Save1.java index 554bf7c94a..efa4723a8f 100644 --- a/core/src/io/anuke/mindustry/io/versions/Save1.java +++ b/core/src/io/anuke/mindustry/io/versions/Save1.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.io.versions; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.mindustry.entities.traits.*; @@ -13,7 +14,7 @@ public class Save1 extends Save2{ @Override public void readEntities(DataInput stream) throws IOException{ - Supplier[] table = LegacyTypeTable.getTable(lastReadBuild); + Prov[] table = LegacyTypeTable.getTable(lastReadBuild); byte groups = stream.readByte(); diff --git a/core/src/io/anuke/mindustry/maps/Maps.java b/core/src/io/anuke/mindustry/maps/Maps.java index 6c16abfa1e..a25aedb788 100644 --- a/core/src/io/anuke/mindustry/maps/Maps.java +++ b/core/src/io/anuke/mindustry/maps/Maps.java @@ -6,16 +6,16 @@ import io.anuke.arc.assets.loaders.*; import io.anuke.arc.collection.*; import io.anuke.arc.collection.IntSet.*; import io.anuke.arc.files.*; -import io.anuke.arc.function.*; +import io.anuke.arc.func.*; import io.anuke.arc.graphics.*; import io.anuke.arc.util.*; import io.anuke.arc.util.async.*; import io.anuke.arc.util.io.*; import io.anuke.arc.util.serialization.*; import io.anuke.mindustry.content.*; -import io.anuke.mindustry.ctype.Content; -import io.anuke.mindustry.game.*; +import io.anuke.mindustry.ctype.*; import io.anuke.mindustry.game.EventType.*; +import io.anuke.mindustry.game.*; import io.anuke.mindustry.io.*; import io.anuke.mindustry.maps.MapPreviewLoader.*; import io.anuke.mindustry.maps.filters.*; @@ -223,10 +223,10 @@ public class Maps{ /** Attempts to run the following code; * catches any errors and attempts to display them in a readable way.*/ - public void tryCatchMapError(ExceptionRunnable run){ + public void tryCatchMapError(Urun run){ try{ run.run(); - }catch(Exception e){ + }catch(Throwable e){ Log.err(e); if("Outdated legacy map format".equals(e.getMessage())){ @@ -357,7 +357,7 @@ public class Maps{ Core.app.post(() -> previewList.add(map)); } - private void createNewPreview(Map map, Consumer failed){ + private void createNewPreview(Map map, Cons failed){ try{ //if it's here, then the preview failed to load or doesn't exist, make it //this has to be done synchronously! @@ -372,7 +372,7 @@ public class Maps{ } }); }catch(Exception e){ - failed.accept(e); + failed.get(e); Log.err("Failed to generate preview!", e); } } diff --git a/core/src/io/anuke/mindustry/maps/filters/FilterOption.java b/core/src/io/anuke/mindustry/maps/filters/FilterOption.java index b66d972465..bde2a34f27 100644 --- a/core/src/io/anuke/mindustry/maps/filters/FilterOption.java +++ b/core/src/io/anuke/mindustry/maps/filters/FilterOption.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.maps.filters; import io.anuke.arc.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.scene.style.*; import io.anuke.arc.scene.ui.*; @@ -16,13 +17,13 @@ import io.anuke.mindustry.world.blocks.*; import static io.anuke.mindustry.Vars.updateEditorOnChange; public abstract class FilterOption{ - public static final Predicate floorsOnly = b -> (b instanceof Floor && !(b instanceof OverlayFloor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full)); - public static final Predicate wallsOnly = b -> (!b.synthetic() && !(b instanceof Floor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full)); - public static final Predicate floorsOptional = b -> b == Blocks.air || ((b instanceof Floor && !(b instanceof OverlayFloor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full))); - public static final Predicate wallsOptional = b -> b == Blocks.air || ((!b.synthetic() && !(b instanceof Floor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full))); - public static final Predicate wallsOresOptional = b -> b == Blocks.air || (((!b.synthetic() && !(b instanceof Floor)) || (b instanceof OverlayFloor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full))); - public static final Predicate oresOnly = b -> b instanceof OverlayFloor && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full)); - public static final Predicate anyOptional = b -> floorsOnly.test(b) || wallsOnly.test(b) || oresOnly.test(b) || b == Blocks.air; + public static final Boolf floorsOnly = b -> (b instanceof Floor && !(b instanceof OverlayFloor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full)); + public static final Boolf wallsOnly = b -> (!b.synthetic() && !(b instanceof Floor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full)); + public static final Boolf floorsOptional = b -> b == Blocks.air || ((b instanceof Floor && !(b instanceof OverlayFloor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full))); + public static final Boolf wallsOptional = b -> b == Blocks.air || ((!b.synthetic() && !(b instanceof Floor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full))); + public static final Boolf wallsOresOptional = b -> b == Blocks.air || (((!b.synthetic() && !(b instanceof Floor)) || (b instanceof OverlayFloor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full))); + public static final Boolf oresOnly = b -> b instanceof OverlayFloor && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full)); + public static final Boolf anyOptional = b -> floorsOnly.get(b) || wallsOnly.get(b) || oresOnly.get(b) || b == Blocks.air; public abstract void build(Table table); @@ -30,15 +31,15 @@ public abstract class FilterOption{ static class SliderOption extends FilterOption{ final String name; - final FloatProvider getter; - final FloatConsumer setter; + final Floatp getter; + final Floatc setter; final float min, max, step; - SliderOption(String name, FloatProvider getter, FloatConsumer setter, float min, float max){ + SliderOption(String name, Floatp getter, Floatc setter, float min, float max){ this(name, getter, setter, min, max, (max - min) / 200); } - SliderOption(String name, FloatProvider getter, FloatConsumer setter, float min, float max, float step){ + SliderOption(String name, Floatp getter, Floatc setter, float min, float max, float step){ this.name = name; this.getter = getter; this.setter = setter; @@ -63,11 +64,11 @@ public abstract class FilterOption{ static class BlockOption extends FilterOption{ final String name; - final Supplier supplier; - final Consumer consumer; - final Predicate filter; + final Prov supplier; + final Cons consumer; + final Boolf filter; - BlockOption(String name, Supplier supplier, Consumer consumer, Predicate filter){ + BlockOption(String name, Prov supplier, Cons consumer, Boolf filter){ this.name = name; this.supplier = supplier; this.consumer = consumer; @@ -82,10 +83,10 @@ public abstract class FilterOption{ dialog.setFillParent(false); int i = 0; for(Block block : Vars.content.blocks()){ - if(!filter.test(block)) continue; + if(!filter.get(block)) continue; dialog.cont.addImage(block == Blocks.air ? Core.atlas.find("icon-none-small") : block.icon(Cicon.medium)).size(8 * 4).pad(3).get().clicked(() -> { - consumer.accept(block); + consumer.get(block); dialog.hide(); changed.run(); }); diff --git a/core/src/io/anuke/mindustry/maps/filters/MirrorFilter.java b/core/src/io/anuke/mindustry/maps/filters/MirrorFilter.java index f46673676e..41520adde0 100644 --- a/core/src/io/anuke/mindustry/maps/filters/MirrorFilter.java +++ b/core/src/io/anuke/mindustry/maps/filters/MirrorFilter.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.maps.filters; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.geom.*; @@ -49,15 +50,15 @@ public class MirrorFilter extends GenerateFilter{ float imageHeight = Math.max(vsize.y, vsize.x); float size = Math.max(image.getWidth() *2, image.getHeight()*2); - Consumer clamper = v -> + Cons clamper = v -> v.clamp( image.getX() + image.getWidth()/2f - imageWidth/2f, image.getX() + image.getWidth()/2f + imageWidth/2f, image.getY() + image.getHeight()/2f - imageHeight/2f, image.getY() + image.getHeight()/2f + imageHeight/2f); - clamper.accept(Tmp.v1.trns(angle - 90, size).add(image.getWidth()/2f + image.getX(), image.getHeight()/2f + image.getY())); - clamper.accept(Tmp.v2.set(Tmp.v1).sub(image.getWidth()/2f + image.getX(), image.getHeight()/2f + image.getY()).rotate(180f).add(image.getWidth()/2f + image.getX(), image.getHeight()/2f + image.getY())); + clamper.get(Tmp.v1.trns(angle - 90, size).add(image.getWidth()/2f + image.getX(), image.getHeight()/2f + image.getY())); + clamper.get(Tmp.v2.set(Tmp.v1).sub(image.getWidth()/2f + image.getX(), image.getHeight()/2f + image.getY()).rotate(180f).add(image.getWidth()/2f + image.getX(), image.getHeight()/2f + image.getY())); Lines.stroke(Scl.scl(3f), Pal.accent); Lines.line(Tmp.v1.x, Tmp.v1.y, Tmp.v2.x, Tmp.v2.y); diff --git a/core/src/io/anuke/mindustry/maps/filters/NoiseFilter.java b/core/src/io/anuke/mindustry/maps/filters/NoiseFilter.java index 90c60afc39..25aaeae3b1 100644 --- a/core/src/io/anuke/mindustry/maps/filters/NoiseFilter.java +++ b/core/src/io/anuke/mindustry/maps/filters/NoiseFilter.java @@ -29,7 +29,7 @@ public class NoiseFilter extends GenerateFilter{ if(noise > threshold){ in.floor = floor; - if(wallsOnly.test(in.block)) in.block = block; + if(wallsOnly.get(in.block)) in.block = block; } } } diff --git a/core/src/io/anuke/mindustry/maps/generators/BasicGenerator.java b/core/src/io/anuke/mindustry/maps/generators/BasicGenerator.java index a3229e5906..40911d31f6 100644 --- a/core/src/io/anuke/mindustry/maps/generators/BasicGenerator.java +++ b/core/src/io/anuke/mindustry/maps/generators/BasicGenerator.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.maps.generators; import io.anuke.arc.collection.*; -import io.anuke.arc.function.IntPositionConsumer; +import io.anuke.arc.func.Intc2; import io.anuke.arc.math.Mathf; import io.anuke.arc.math.geom.Geometry; import io.anuke.arc.math.geom.Point2; @@ -137,10 +137,10 @@ public abstract class BasicGenerator extends RandomGenerator{ }); } - public void each(IntPositionConsumer r){ + public void each(Intc2 r){ for(int x = 0; x < width; x++){ for(int y = 0; y < height; y++){ - r.accept(x, y); + r.get(x, y); } } } @@ -149,13 +149,13 @@ public abstract class BasicGenerator extends RandomGenerator{ return (float)sim2.octaveNoise2D(1f, 0f, 1f / scl, x + 0x361266f, y + 0x251259f) * mag; } - public void pass(Tile[][] tiles, IntPositionConsumer r){ + public void pass(Tile[][] tiles, Intc2 r){ for(int x = 0; x < width; x++){ for(int y = 0; y < height; y++){ floor = tiles[x][y].floor(); block = tiles[x][y].block(); ore = tiles[x][y].overlay(); - r.accept(x, y); + r.get(x, y); tiles[x][y] = new Tile(x, y, floor.id, ore.id, block.id); } } diff --git a/core/src/io/anuke/mindustry/mod/ContentParser.java b/core/src/io/anuke/mindustry/mod/ContentParser.java index dee6e8b32c..088e40710d 100644 --- a/core/src/io/anuke/mindustry/mod/ContentParser.java +++ b/core/src/io/anuke/mindustry/mod/ContentParser.java @@ -6,6 +6,7 @@ import io.anuke.arc.audio.mock.*; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.*; import io.anuke.arc.files.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.util.ArcAnnotate.*; @@ -242,7 +243,7 @@ public class ContentParser{ return (T)c; } - private TypeParser parser(ContentType type, Function constructor){ + private TypeParser parser(ContentType type, Func constructor){ return (mod, name, value) -> { T item; if(Vars.content.getByName(type, name) != null){ @@ -366,7 +367,7 @@ public class ContentParser{ } } - private Supplier supply(Class type){ + private Prov supply(Class type){ try{ java.lang.reflect.Constructor cons = type.getDeclaredConstructor(); return () -> { diff --git a/core/src/io/anuke/mindustry/mod/Mods.java b/core/src/io/anuke/mindustry/mod/Mods.java index ba3634e447..53584fcfee 100644 --- a/core/src/io/anuke/mindustry/mod/Mods.java +++ b/core/src/io/anuke/mindustry/mod/Mods.java @@ -4,6 +4,7 @@ import io.anuke.arc.*; import io.anuke.arc.assets.*; import io.anuke.arc.collection.*; import io.anuke.arc.files.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.Pixmap.*; @@ -405,8 +406,8 @@ public class Mods implements Loadable{ } /** Iterates through each mod with a main class.*/ - public void each(Consumer cons){ - loaded.each(p -> p.mod != null, p -> safeRun(p, () -> cons.accept(p.mod))); + public void each(Cons cons){ + loaded.each(p -> p.mod != null, p -> safeRun(p, () -> cons.get(p.mod))); } public void handleError(Throwable t, LoadedMod mod){ diff --git a/core/src/io/anuke/mindustry/net/ArcNetImpl.java b/core/src/io/anuke/mindustry/net/ArcNetImpl.java index 1c924b60c6..e2a5b3d6b2 100644 --- a/core/src/io/anuke/mindustry/net/ArcNetImpl.java +++ b/core/src/io/anuke/mindustry/net/ArcNetImpl.java @@ -2,7 +2,7 @@ package io.anuke.mindustry.net; import io.anuke.arc.*; import io.anuke.arc.collection.*; -import io.anuke.arc.function.*; +import io.anuke.arc.func.*; import io.anuke.arc.net.*; import io.anuke.arc.net.FrameworkMessage.*; import io.anuke.arc.util.*; @@ -21,7 +21,7 @@ import static io.anuke.mindustry.Vars.*; public class ArcNetImpl implements NetProvider{ final Client client; - final Supplier packetSupplier = () -> new DatagramPacket(new byte[256], 256); + final Prov packetSupplier = () -> new DatagramPacket(new byte[256], 256); final Server server; final CopyOnWriteArrayList connections = new CopyOnWriteArrayList<>(); @@ -183,7 +183,7 @@ public class ArcNetImpl implements NetProvider{ } @Override - public void pingHost(String address, int port, Consumer valid, Consumer invalid){ + public void pingHost(String address, int port, Cons valid, Cons invalid){ Threads.daemon(() -> { try{ DatagramSocket socket = new DatagramSocket(); @@ -196,15 +196,15 @@ public class ArcNetImpl implements NetProvider{ ByteBuffer buffer = ByteBuffer.wrap(packet.getData()); Host host = NetworkIO.readServerData(packet.getAddress().getHostAddress(), buffer); - Core.app.post(() -> valid.accept(host)); + Core.app.post(() -> valid.get(host)); }catch(Exception e){ - Core.app.post(() -> invalid.accept(e)); + Core.app.post(() -> invalid.get(e)); } }); } @Override - public void discoverServers(Consumer callback, Runnable done){ + public void discoverServers(Cons callback, Runnable done){ Array foundAddresses = new Array<>(); client.discoverHosts(port, multicastGroup, multicastPort, 3000, packet -> { Core.app.post(() -> { @@ -214,7 +214,7 @@ public class ArcNetImpl implements NetProvider{ } ByteBuffer buffer = ByteBuffer.wrap(packet.getData()); Host host = NetworkIO.readServerData(packet.getAddress().getHostAddress(), buffer); - callback.accept(host); + callback.get(host); foundAddresses.add(packet.getAddress()); }catch(Exception e){ //don't crash when there's an error pinging a a server or parsing data @@ -369,7 +369,7 @@ public class ArcNetImpl implements NetProvider{ if(id == -2){ return readFramework(byteBuffer); }else{ - Packet packet = Pools.obtain((Class)Registrator.getByID(id).type, (Supplier)Registrator.getByID(id).constructor); + Packet packet = Pools.obtain((Class)Registrator.getByID(id).type, (Prov)Registrator.getByID(id).constructor); packet.read(byteBuffer); return packet; } diff --git a/core/src/io/anuke/mindustry/net/CrashSender.java b/core/src/io/anuke/mindustry/net/CrashSender.java index 1240c22160..10d0eef335 100644 --- a/core/src/io/anuke/mindustry/net/CrashSender.java +++ b/core/src/io/anuke/mindustry/net/CrashSender.java @@ -4,6 +4,7 @@ import io.anuke.arc.*; import io.anuke.arc.Net.*; import io.anuke.arc.collection.*; import io.anuke.arc.files.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.util.*; import io.anuke.arc.util.io.*; @@ -21,7 +22,7 @@ import static io.anuke.mindustry.Vars.net; public class CrashSender{ - public static void send(Throwable exception, Consumer writeListener){ + public static void send(Throwable exception, Cons writeListener){ try{ exception.printStackTrace(); @@ -54,7 +55,7 @@ public class CrashSender{ File file = new File(OS.getAppDataDirectoryString(Vars.appName), "crashes/crash-report-" + new SimpleDateFormat("MM_dd_yyyy_HH_mm_ss").format(new Date()) + ".txt"); new FileHandle(OS.getAppDataDirectoryString(Vars.appName)).child("crashes").mkdirs(); new FileHandle(file).writeString(parseException(exception)); - writeListener.accept(file); + writeListener.get(file); }catch(Throwable e){ e.printStackTrace(); Log.err("Failed to save local crash report."); @@ -130,7 +131,7 @@ public class CrashSender{ } } - private static void httpPost(String url, String content, Consumer success, Consumer failure){ + private static void httpPost(String url, String content, Cons success, Cons failure){ new NetJavaImpl().http(new HttpRequest().method(HttpMethod.POST).content(content).url(url), success, failure); } diff --git a/core/src/io/anuke/mindustry/net/Net.java b/core/src/io/anuke/mindustry/net/Net.java index 6cb22a7794..348f7d2d16 100644 --- a/core/src/io/anuke/mindustry/net/Net.java +++ b/core/src/io/anuke/mindustry/net/Net.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.net; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.util.*; import io.anuke.arc.util.ArcAnnotate.*; @@ -25,8 +26,8 @@ public class Net{ StreamBuilder currentStream; private final Array packetQueue = new Array<>(); - private final ObjectMap, Consumer> clientListeners = new ObjectMap<>(); - private final ObjectMap, BiConsumer> serverListeners = new ObjectMap<>(); + private final ObjectMap, Cons> clientListeners = new ObjectMap<>(); + private final ObjectMap, Cons2> serverListeners = new ObjectMap<>(); private final IntMap streams = new IntMap<>(); private final NetProvider provider; @@ -170,7 +171,7 @@ public class Net{ * Starts discovering servers on a different thread. * Callback is run on the main libGDX thread. */ - public void discoverServers(Consumer cons, Runnable done){ + public void discoverServers(Cons cons, Runnable done){ provider.discoverServers(cons, done); } @@ -208,15 +209,15 @@ public class Net{ /** * Registers a client listener for when an object is recieved. */ - public void handleClient(Class type, Consumer listener){ + public void handleClient(Class type, Cons listener){ clientListeners.put(type, listener); } /** * Registers a server listener for when an object is recieved. */ - public void handleServer(Class type, BiConsumer listener){ - serverListeners.put(type, (BiConsumer)listener); + public void handleServer(Class type, Cons2 listener){ + serverListeners.put(type, (Cons2)listener); } /** @@ -244,7 +245,7 @@ public class Net{ if(clientLoaded || ((object instanceof Packet) && ((Packet)object).isImportant())){ if(clientListeners.get(object.getClass()) != null) - clientListeners.get(object.getClass()).accept(object); + clientListeners.get(object.getClass()).get(object); Pools.free(object); }else if(!((object instanceof Packet) && ((Packet)object).isUnimportant())){ packetQueue.add(object); @@ -263,7 +264,7 @@ public class Net{ if(serverListeners.get(object.getClass()) != null){ if(serverListeners.get(object.getClass()) != null) - serverListeners.get(object.getClass()).accept(connection, object); + serverListeners.get(object.getClass()).get(connection, object); Pools.free(object); }else{ Log.err("Unhandled packet type: '{0}'!", object.getClass()); @@ -273,7 +274,7 @@ public class Net{ /** * Pings a host in an new thread. If an error occured, failed() should be called with the exception. */ - public void pingHost(String address, int port, Consumer valid, Consumer failed){ + public void pingHost(String address, int port, Cons valid, Cons failed){ provider.pingHost(address, port, valid, failed); } @@ -324,10 +325,10 @@ public class Net{ * Callback should be run on the main thread. * @param done is the callback that should run after discovery. */ - void discoverServers(Consumer callback, Runnable done); + void discoverServers(Cons callback, Runnable done); /** Ping a host. If an error occured, failed() should be called with the exception. */ - void pingHost(String address, int port, Consumer valid, Consumer failed); + void pingHost(String address, int port, Cons valid, Cons failed); /** Host a server at specified port. */ void hostServer(int port) throws IOException; diff --git a/core/src/io/anuke/mindustry/net/Registrator.java b/core/src/io/anuke/mindustry/net/Registrator.java index cfbcffd163..73c729dbcb 100644 --- a/core/src/io/anuke/mindustry/net/Registrator.java +++ b/core/src/io/anuke/mindustry/net/Registrator.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.net; import io.anuke.arc.collection.ObjectIntMap; -import io.anuke.arc.function.Supplier; +import io.anuke.arc.func.Prov; import io.anuke.mindustry.net.Packets.*; public class Registrator{ @@ -35,9 +35,9 @@ public class Registrator{ public static class ClassEntry{ public final Class type; - public final Supplier constructor; + public final Prov constructor; - public ClassEntry(Class type, Supplier constructor){ + public ClassEntry(Class type, Prov constructor){ this.type = type; this.constructor = constructor; } diff --git a/core/src/io/anuke/mindustry/type/StatusEffect.java b/core/src/io/anuke/mindustry/type/StatusEffect.java index 0c6cf15bd2..706c2a1ca8 100644 --- a/core/src/io/anuke/mindustry/type/StatusEffect.java +++ b/core/src/io/anuke/mindustry/type/StatusEffect.java @@ -2,7 +2,7 @@ package io.anuke.mindustry.type; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.ObjectMap; -import io.anuke.arc.function.Supplier; +import io.anuke.arc.func.Prov; import io.anuke.arc.graphics.Color; import io.anuke.arc.math.Mathf; import io.anuke.arc.util.*; @@ -36,7 +36,7 @@ public class StatusEffect extends Content{ @Override public void init(){ for(Object[] pair : transInit){ - Supplier sup = (Supplier)pair[0]; + Prov sup = (Prov)pair[0]; TransitionHandler handler = (TransitionHandler)pair[1]; transitions.put(sup.get(), handler); } @@ -56,13 +56,13 @@ public class StatusEffect extends Content{ } } - protected void trans(Supplier effect, TransitionHandler handler){ + protected void trans(Prov effect, TransitionHandler handler){ transInit.add(new Object[]{effect, handler}); } @SuppressWarnings("unchecked") - protected void opposite(Supplier... effect){ - for(Supplier sup : effect){ + protected void opposite(Prov... effect){ + for(Prov sup : effect){ trans(sup, (unit, time, newTime, result) -> { time -= newTime * 0.5f; if(time > 0){ diff --git a/core/src/io/anuke/mindustry/type/TypeID.java b/core/src/io/anuke/mindustry/type/TypeID.java index 8af97048a6..c546f07169 100644 --- a/core/src/io/anuke/mindustry/type/TypeID.java +++ b/core/src/io/anuke/mindustry/type/TypeID.java @@ -1,13 +1,14 @@ package io.anuke.mindustry.type; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.mindustry.ctype.*; import io.anuke.mindustry.entities.traits.*; public class TypeID extends MappableContent{ - public final Supplier constructor; + public final Prov constructor; - public TypeID(String name, Supplier constructor){ + public TypeID(String name, Prov constructor){ super(name); this.constructor = constructor; } diff --git a/core/src/io/anuke/mindustry/type/UnitType.java b/core/src/io/anuke/mindustry/type/UnitType.java index c05d6f2eab..679c1c8a67 100644 --- a/core/src/io/anuke/mindustry/type/UnitType.java +++ b/core/src/io/anuke/mindustry/type/UnitType.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.type; import io.anuke.arc.*; import io.anuke.arc.audio.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.scene.ui.layout.*; @@ -16,7 +17,8 @@ import io.anuke.mindustry.ui.*; public class UnitType extends UnlockableContent{ public @NonNull TypeID typeID; - public @NonNull Supplier constructor; + public @NonNull + Prov constructor; public float health = 60; public float hitsize = 7f; @@ -43,7 +45,7 @@ public class UnitType extends UnlockableContent{ public TextureRegion legRegion, baseRegion, region; - public UnitType(String name, Supplier mainConstructor){ + public UnitType(String name, Prov mainConstructor){ this(name); create(mainConstructor); } @@ -53,7 +55,7 @@ public class UnitType extends UnlockableContent{ this.description = Core.bundle.getOrNull("unit." + name + ".description"); } - public void create(Supplier mainConstructor){ + public void create(Prov mainConstructor){ this.constructor = mainConstructor; this.description = Core.bundle.getOrNull("unit." + name + ".description"); this.typeID = new TypeID(name, mainConstructor); diff --git a/core/src/io/anuke/mindustry/type/Zone.java b/core/src/io/anuke/mindustry/type/Zone.java index b4088b24e6..460dbbdd15 100644 --- a/core/src/io/anuke/mindustry/type/Zone.java +++ b/core/src/io/anuke/mindustry/type/Zone.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.type; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.scene.ui.layout.*; @@ -22,7 +23,7 @@ public class Zone extends UnlockableContent{ //TODO autogenerate public Array resources = new Array<>(); - public Consumer rules = rules -> {}; + public Cons rules = rules -> {}; public boolean alwaysUnlocked; public int conditionWave = Integer.MAX_VALUE; public int launchPeriod = 10; @@ -54,7 +55,7 @@ public class Zone extends UnlockableContent{ return ((MapGenerator)generator).getMap().rules(); }else{ Rules rules = new Rules(); - this.rules.accept(rules); + this.rules.get(rules); return rules; } } @@ -137,7 +138,7 @@ public class Zone extends UnlockableContent{ public void updateLaunchCost(){ Array stacks = new Array<>(); - Consumer adder = stack -> { + Cons adder = stack -> { for(ItemStack other : stacks){ if(other.item == stack.item){ other.amount += stack.amount; @@ -147,8 +148,8 @@ public class Zone extends UnlockableContent{ stacks.add(new ItemStack(stack.item, stack.amount)); }; - for(ItemStack stack : baseLaunchCost) adder.accept(stack); - for(ItemStack stack : startingItems) adder.accept(stack); + for(ItemStack stack : baseLaunchCost) adder.get(stack); + for(ItemStack stack : startingItems) adder.get(stack); for(ItemStack stack : stacks){ if(stack.amount < 0) stack.amount = 0; diff --git a/core/src/io/anuke/mindustry/ui/Bar.java b/core/src/io/anuke/mindustry/ui/Bar.java index 56c17befae..1a84786163 100644 --- a/core/src/io/anuke/mindustry/ui/Bar.java +++ b/core/src/io/anuke/mindustry/ui/Bar.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.ui; import io.anuke.arc.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.g2d.*; @@ -14,12 +15,12 @@ import io.anuke.mindustry.gen.*; public class Bar extends Element{ private static Rectangle scissor = new Rectangle(); - private FloatProvider fraction; + private Floatp fraction; private String name = ""; private float value, lastValue, blink; private Color blinkColor = new Color(); - public Bar(String name, Color color, FloatProvider fraction){ + public Bar(String name, Color color, Floatp fraction){ this.fraction = fraction; this.name = Core.bundle.get(name); this.blinkColor.set(color); @@ -27,7 +28,7 @@ public class Bar extends Element{ setColor(color); } - public Bar(Supplier name, Supplier color, FloatProvider fraction){ + public Bar(Prov name, Prov color, Floatp fraction){ this.fraction = fraction; lastValue = value = Mathf.clamp(fraction.get()); update(() -> { @@ -45,7 +46,7 @@ public class Bar extends Element{ this.value = lastValue = blink = value; } - public void set(Supplier name, FloatProvider fraction, Color color){ + public void set(Prov name, Floatp fraction, Color color){ this.fraction = fraction; this.lastValue = fraction.get(); this.blinkColor.set(color); diff --git a/core/src/io/anuke/mindustry/ui/IntFormat.java b/core/src/io/anuke/mindustry/ui/IntFormat.java index 22d50ab495..695d177707 100644 --- a/core/src/io/anuke/mindustry/ui/IntFormat.java +++ b/core/src/io/anuke/mindustry/ui/IntFormat.java @@ -2,7 +2,7 @@ package io.anuke.mindustry.ui; import io.anuke.arc.Core; -import io.anuke.arc.function.Function; +import io.anuke.arc.func.Func; /** * A low-garbage way to format bundle strings. @@ -11,13 +11,13 @@ public class IntFormat{ private final StringBuilder builder = new StringBuilder(); private final String text; private int lastValue = Integer.MIN_VALUE; - private Function converter = String::valueOf; + private Func converter = String::valueOf; public IntFormat(String text){ this.text = text; } - public IntFormat(String text, Function converter){ + public IntFormat(String text, Func converter){ this.text = text; this.converter = converter; } diff --git a/core/src/io/anuke/mindustry/ui/ReqImage.java b/core/src/io/anuke/mindustry/ui/ReqImage.java index ddb66961b3..17c88a959b 100644 --- a/core/src/io/anuke/mindustry/ui/ReqImage.java +++ b/core/src/io/anuke/mindustry/ui/ReqImage.java @@ -1,6 +1,6 @@ package io.anuke.mindustry.ui; -import io.anuke.arc.function.BooleanProvider; +import io.anuke.arc.func.Boolp; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.scene.Element; import io.anuke.arc.scene.ui.Image; @@ -9,9 +9,9 @@ import io.anuke.arc.scene.ui.layout.Scl; import io.anuke.mindustry.graphics.Pal; public class ReqImage extends Stack{ - private final BooleanProvider valid; + private final Boolp valid; - public ReqImage(Element image, BooleanProvider valid){ + public ReqImage(Element image, Boolp valid){ this.valid = valid; add(image); add(new Element(){ @@ -30,7 +30,7 @@ public class ReqImage extends Stack{ }); } - public ReqImage(TextureRegion region, BooleanProvider valid){ + public ReqImage(TextureRegion region, Boolp valid){ this(new Image(region), valid); } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/ColorPickDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/ColorPickDialog.java index 4402d740c4..a397ef6a6d 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/ColorPickDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/ColorPickDialog.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.ui.dialogs; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.input.*; @@ -11,7 +12,7 @@ import io.anuke.mindustry.ui.*; import static io.anuke.mindustry.Vars.*; public class ColorPickDialog extends Dialog{ - private Consumer cons; + private Cons cons; public ColorPickDialog(){ super(""); @@ -26,7 +27,7 @@ public class ColorPickDialog extends Dialog{ Color color = playerColors[i]; ImageButton button = table.addImageButton(Tex.whiteui, Styles.clearTogglei, 34, () -> { - cons.accept(color); + cons.get(color); hide(); }).size(48).get(); button.setChecked(player.color.equals(color)); @@ -44,7 +45,7 @@ public class ColorPickDialog extends Dialog{ } - public void show(Consumer cons){ + public void show(Cons cons){ this.cons = cons; show(); } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/CustomRulesDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/CustomRulesDialog.java index e0e617929e..13ad72552d 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/CustomRulesDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/CustomRulesDialog.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.ui.dialogs; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.scene.style.*; @@ -23,7 +24,7 @@ import static io.anuke.mindustry.Vars.*; public class CustomRulesDialog extends FloatingDialog{ private Table main; private Rules rules; - private Supplier resetter; + private Prov resetter; private LoadoutDialog loadoutDialog; private FloatingDialog banDialog; @@ -108,7 +109,7 @@ public class CustomRulesDialog extends FloatingDialog{ }).size(300f, 64f); } - public void show(Rules rules, Supplier resetter){ + public void show(Rules rules, Prov resetter){ this.rules = rules; this.resetter = resetter; show(); @@ -173,16 +174,16 @@ public class CustomRulesDialog extends FloatingDialog{ number("$rules.enemycorebuildradius", f -> rules.enemyCoreBuildRadius = f * tilesize, () -> Math.min(rules.enemyCoreBuildRadius / tilesize, 200)); } - void number(String text, FloatConsumer cons, FloatProvider prov){ + void number(String text, Floatc cons, Floatp prov){ number(text, false, cons, prov, () -> true); } - void number(String text, boolean integer, FloatConsumer cons, FloatProvider prov, BooleanProvider condition){ + void number(String text, boolean integer, Floatc cons, Floatp prov, Boolp condition){ main.table(t -> { t.left(); t.add(text).left().padRight(5) .update(a -> a.setColor(condition.get() ? Color.white : Color.gray)); - Vars.platform.addDialog(t.addField((integer ? (int)prov.get() : prov.get()) + "", s -> cons.accept(Strings.parseFloat(s))) + Vars.platform.addDialog(t.addField((integer ? (int)prov.get() : prov.get()) + "", s -> cons.get(Strings.parseFloat(s))) .padRight(100f) .update(a -> a.setDisabled(!condition.get())) .valid(Strings::canParsePositiveFloat).width(120f).left().get()); @@ -190,11 +191,11 @@ public class CustomRulesDialog extends FloatingDialog{ main.row(); } - void check(String text, BooleanConsumer cons, BooleanProvider prov){ + void check(String text, Boolc cons, Boolp prov){ check(text, cons, prov, () -> true); } - void check(String text, BooleanConsumer cons, BooleanProvider prov, BooleanProvider condition){ + void check(String text, Boolc cons, Boolp prov, Boolp condition){ main.addCheck(text, cons).checked(prov.get()).update(a -> a.setDisabled(!condition.get())).padRight(100f).get().left(); main.row(); } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java index 4a8c1b54cd..7f3470afb2 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/DeployDialog.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.ui.dialogs; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.g2d.*; @@ -234,10 +235,10 @@ public class DeployDialog extends FloatingDialog{ if(zone.unlocked() && !hidden(zone)){ button.labelWrap(zone.localizedName()).style(Styles.outlineLabel).width(140).growX().get().setAlignment(Align.center); }else{ - Consumer flasher = zone.canUnlock() && !hidden(zone) ? e -> e.update(() -> e.getColor().set(Color.white).lerp(Pal.accent, Mathf.absin(3f, 1f))) : e -> {}; - flasher.accept(button.addImage(Icon.locked).get()); + Cons flasher = zone.canUnlock() && !hidden(zone) ? e -> e.update(() -> e.getColor().set(Color.white).lerp(Pal.accent, Mathf.absin(3f, 1f))) : e -> {}; + flasher.get(button.addImage(Icon.locked).get()); button.row(); - flasher.accept(button.add("$locked").get()); + flasher.get(button.add("$locked").get()); } } diff --git a/core/src/io/anuke/mindustry/ui/dialogs/FileChooser.java b/core/src/io/anuke/mindustry/ui/dialogs/FileChooser.java index 75b260594b..17f6e0b851 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/FileChooser.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/FileChooser.java @@ -3,7 +3,7 @@ package io.anuke.mindustry.ui.dialogs; import io.anuke.arc.*; import io.anuke.arc.collection.*; import io.anuke.arc.files.*; -import io.anuke.arc.function.*; +import io.anuke.arc.func.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.scene.event.*; import io.anuke.arc.scene.ui.*; @@ -27,11 +27,11 @@ public class FileChooser extends FloatingDialog{ private TextField navigation, filefield; private TextButton ok; private FileHistory stack = new FileHistory(); - private Predicate filter; - private Consumer selectListener; + private Boolf filter; + private Cons selectListener; private boolean open; - public FileChooser(String title, Predicate filter, boolean open, Consumer result){ + public FileChooser(String title, Boolf filter, boolean open, Cons result){ super(title); setFillParent(true); this.open = open; @@ -64,7 +64,7 @@ public class FileChooser extends FloatingDialog{ ok.clicked(() -> { if(ok.isDisabled()) return; if(selectListener != null) - selectListener.accept(directory.child(filefield.getText())); + selectListener.get(directory.child(filefield.getText())); hide(); }); @@ -212,7 +212,7 @@ public class FileChooser extends FloatingDialog{ group.setMinCheckCount(0); for(FileHandle file : names){ - if(!file.isDirectory() && !filter.test(file)) continue; //skip non-filtered files + if(!file.isDirectory() && !filter.get(file)) continue; //skip non-filtered files String filename = file.name(); diff --git a/core/src/io/anuke/mindustry/ui/dialogs/ModsDialog.java b/core/src/io/anuke/mindustry/ui/dialogs/ModsDialog.java index b74fdcbffe..dd9ef2b536 100644 --- a/core/src/io/anuke/mindustry/ui/dialogs/ModsDialog.java +++ b/core/src/io/anuke/mindustry/ui/dialogs/ModsDialog.java @@ -29,41 +29,40 @@ public class ModsDialog extends FloatingDialog{ buttons.addImageTextButton("$mods.guide", Icon.wiki, () -> Core.net.openURI(modGuideURL)) - .size(android ? 210f + 250f + 10f : 210, 64f).colspan(android ? 2 : 1); + .size(210, 64f).colspan(android ? 2 : 1); - if(!android){ - buttons.addImageTextButton("$mod.import.github", Icon.github, () -> { - ui.showTextInput("$mod.import.github", "", 64, "Anuken/ExampleMod", text -> { - ui.loadfrag.show(); - Core.net.httpGet("http://api.github.com/repos/" + text + "/zipball/master", loc -> { - Core.net.httpGet(loc.getHeader("Location"), result -> { - if(result.getStatus() != HttpStatus.OK){ - ui.showErrorMessage(Core.bundle.format("connectfail", result.getStatus())); - ui.loadfrag.hide(); - }else{ - try{ - FileHandle file = tmpDirectory.child(text.replace("/", "") + ".zip"); - Streams.copyStream(result.getResultAsStream(), file.write(false)); - mods.importMod(file); - file.delete(); - Core.app.post(() -> { - try{ - mods.reloadContent(); - setup(); - ui.loadfrag.hide(); - }catch(Throwable e){ - ui.showException(e); - } - }); - }catch(Throwable e){ - ui.showException(e); - } + buttons.addImageTextButton("$mod.import.github", Icon.github, () -> { + ui.showTextInput("$mod.import.github", "", 64, "Anuken/ExampleMod", text -> { + ui.loadfrag.show(); + Core.net.httpGet("http://api.github.com/repos/" + text + "/zipball/master", loc -> { + Core.net.httpGet(loc.getHeader("Location"), result -> { + if(result.getStatus() != HttpStatus.OK){ + ui.showErrorMessage(Core.bundle.format("connectfail", result.getStatus())); + ui.loadfrag.hide(); + }else{ + try{ + FileHandle file = tmpDirectory.child(text.replace("/", "") + ".zip"); + Streams.copyStream(result.getResultAsStream(), file.write(false)); + mods.importMod(file); + file.delete(); + Core.app.post(() -> { + try{ + mods.reloadContent(); + setup(); + ui.loadfrag.hide(); + }catch(Throwable e){ + ui.showException(e); + } + }); + }catch(Throwable e){ + modError(e); } - }, t -> Core.app.post(() -> ui.showException(t))); - }, t -> Core.app.post(() -> ui.showException(t))); - }); - }).size(250f, 64f); - } + } + }, t -> Core.app.post(() -> modError(t))); + }, t -> Core.app.post(() -> modError(t))); + }); + }).size(250f, 64f); + shown(this::setup); @@ -87,6 +86,16 @@ public class ModsDialog extends FloatingDialog{ })); } + void modError(Throwable error){ + ui.loadfrag.hide(); + + if(Strings.getCauses(error).contains(t -> t.getMessage() != null && t.getMessage().contains("SSL"))){ + ui.showErrorMessage("$feature.unsupported"); + }else{ + ui.showException(error); + } + } + void setup(){ cont.clear(); cont.defaults().width(520f).pad(4); diff --git a/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java b/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java index 8585bf94c7..9c6205eb85 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/BlockInventoryFragment.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.ui.fragments; import io.anuke.annotations.Annotations.*; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.input.*; @@ -130,7 +131,7 @@ public class BlockInventoryFragment extends Fragment{ container.add(i); - BooleanProvider canPick = () -> player.acceptsItem(item) && !state.isPaused(); + Boolp canPick = () -> player.acceptsItem(item) && !state.isPaused(); HandCursorListener l = new HandCursorListener(); l.setEnabled(canPick); @@ -203,7 +204,7 @@ public class BlockInventoryFragment extends Fragment{ table.setPosition(v.x, v.y, Align.topLeft); } - private Element itemImage(TextureRegion region, Supplier text){ + private Element itemImage(TextureRegion region, Prov text){ Stack stack = new Stack(); Table t = new Table().left().bottom(); diff --git a/core/src/io/anuke/mindustry/ui/fragments/LoadingFragment.java b/core/src/io/anuke/mindustry/ui/fragments/LoadingFragment.java index fc0a246851..ac55c24ff1 100644 --- a/core/src/io/anuke/mindustry/ui/fragments/LoadingFragment.java +++ b/core/src/io/anuke/mindustry/ui/fragments/LoadingFragment.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.ui.fragments; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.scene.Group; @@ -36,7 +37,7 @@ public class LoadingFragment extends Fragment{ }); } - public void setProgress(FloatProvider progress){ + public void setProgress(Floatp progress){ bar.reset(0f); bar.visible(true); bar.set(() -> ((int)(progress.get() * 100) + "%"), progress, Pal.accent); diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 0472713e87..d25688a9b1 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -7,6 +7,7 @@ import io.anuke.arc.Graphics.Cursor.*; import io.anuke.arc.audio.*; import io.anuke.arc.collection.EnumSet; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.g2d.*; @@ -514,7 +515,7 @@ public class Block extends BlockStorage{ bars.add("health", entity -> new Bar("blocks.health", Pal.health, entity::healthf).blink(Color.white)); if(hasLiquids){ - Function current; + Func current; if(consumes.has(ConsumeType.liquid) && consumes.get(ConsumeType.liquid) instanceof ConsumeLiquid){ Liquid liquid = consumes.get(ConsumeType.liquid).liquid; current = entity -> liquid; @@ -668,7 +669,7 @@ public class Block extends BlockStorage{ } public void displayBars(Tile tile, Table table){ - for(Function bar : bars.list()){ + for(Func bar : bars.list()){ table.add(bar.get(tile.entity)).growX(); table.row(); } diff --git a/core/src/io/anuke/mindustry/world/Tile.java b/core/src/io/anuke/mindustry/world/Tile.java index 2dfe5a8669..b449d5562b 100644 --- a/core/src/io/anuke/mindustry/world/Tile.java +++ b/core/src/io/anuke/mindustry/world/Tile.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.world; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.math.*; import io.anuke.arc.math.geom.*; @@ -251,7 +252,7 @@ public class Tile implements Position, TargetTrait{ * Returns the list of all tiles linked to this multiblock, or an empty array if it's not a multiblock. * This array contains all linked tiles, including this tile itself. */ - public void getLinkedTiles(Consumer cons){ + public void getLinkedTiles(Cons cons){ if(block.isMultiblock()){ int size = block.size; int offsetx = -(size - 1) / 2; @@ -259,11 +260,11 @@ public class Tile implements Position, TargetTrait{ for(int dx = 0; dx < size; dx++){ for(int dy = 0; dy < size; dy++){ Tile other = world.tile(x + dx + offsetx, y + dy + offsety); - if(other != null) cons.accept(other); + if(other != null) cons.get(other); } } }else{ - cons.accept(this); + cons.get(this); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/Autotiler.java b/core/src/io/anuke/mindustry/world/blocks/Autotiler.java index 4ee4d938fb..c7300315bc 100644 --- a/core/src/io/anuke/mindustry/world/blocks/Autotiler.java +++ b/core/src/io/anuke/mindustry/world/blocks/Autotiler.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.world.blocks; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.math.*; import io.anuke.arc.math.geom.*; diff --git a/core/src/io/anuke/mindustry/world/blocks/ItemSelection.java b/core/src/io/anuke/mindustry/world/blocks/ItemSelection.java index b892ade149..7fd51bd30e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/ItemSelection.java +++ b/core/src/io/anuke/mindustry/world/blocks/ItemSelection.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.world.blocks; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.scene.style.*; import io.anuke.arc.scene.ui.*; @@ -14,7 +15,7 @@ import static io.anuke.mindustry.Vars.*; public class ItemSelection{ - public static void buildItemTable(Table table, Supplier holder, Consumer consumer){ + public static void buildItemTable(Table table, Prov holder, Cons consumer){ Array items = content.items(); @@ -29,7 +30,7 @@ public class ItemSelection{ if(!data.isUnlocked(item) && world.isZone()) continue; ImageButton button = cont.addImageButton(Tex.whiteui, Styles.clearToggleTransi, 24, () -> control.input.frag.config.hideConfig()).group(group).get(); - button.changed(() -> consumer.accept(button.isChecked() ? item : null)); + button.changed(() -> consumer.get(button.isChecked() ? item : null)); button.getStyle().imageUp = new TextureRegionDrawable(item.icon(Cicon.small)); button.update(() -> button.setChecked(holder.get() == item)); diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/ForceProjector.java b/core/src/io/anuke/mindustry/world/blocks/defense/ForceProjector.java index 4107281512..f70913f5ad 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/ForceProjector.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/ForceProjector.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.world.blocks.defense; import io.anuke.arc.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.g2d.*; @@ -37,7 +38,7 @@ public class ForceProjector extends Block{ private static Tile paramTile; private static ForceProjector paramBlock; private static ForceEntity paramEntity; - private static Consumer shieldConsumer = trait -> { + private static Cons shieldConsumer = trait -> { if(trait.canBeAbsorbed() && trait.getTeam() != paramTile.getTeam() && paramBlock.isInsideHexagon(trait.getX(), trait.getY(), paramBlock.realRadius(paramEntity) * 2f, paramTile.drawx(), paramTile.drawy())){ trait.absorb(); Effects.effect(Fx.absorb, trait); diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/ItemTurret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/ItemTurret.java index 40110a7d26..3cce48833e 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/ItemTurret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/ItemTurret.java @@ -45,7 +45,7 @@ public class ItemTurret extends CooledTurret{ @Override public void build(Tile tile, Table table){ MultiReqImage image = new MultiReqImage(); - content.items().each(i -> filter.test(i) && (!world.isZone() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium)), + content.items().each(i -> filter.get(i) && (!world.isZone() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium)), () -> tile.entity != null && !((ItemTurretEntity)tile.entity).ammo.isEmpty() && ((ItemEntry)tile.entity().ammo.peek()).item == item))); table.add(image).size(8 * 4); diff --git a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java index 8a124ea3cc..e0b815d583 100644 --- a/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java +++ b/core/src/io/anuke/mindustry/world/blocks/defense/turrets/Turret.java @@ -4,7 +4,7 @@ import io.anuke.arc.Core; import io.anuke.arc.audio.*; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.EnumSet; -import io.anuke.arc.function.BiConsumer; +import io.anuke.arc.func.Cons2; import io.anuke.arc.graphics.Blending; import io.anuke.arc.graphics.Color; import io.anuke.arc.graphics.g2d.*; @@ -60,8 +60,8 @@ public abstract class Turret extends Block{ protected TextureRegion baseRegion, heatRegion; - protected BiConsumer drawer = (tile, entity) -> Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); - protected BiConsumer heatDrawer = (tile, entity) -> { + protected Cons2 drawer = (tile, entity) -> Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90); + protected Cons2 heatDrawer = (tile, entity) -> { if(entity.heat <= 0.00001f) return; Draw.color(heatColor, entity.heat); Draw.blend(Blending.additive); @@ -119,10 +119,10 @@ public abstract class Turret extends Block{ tr2.trns(entity.rotation, -entity.recoil); - drawer.accept(tile, entity); + drawer.get(tile, entity); if(heatRegion != Core.atlas.find("error")){ - heatDrawer.accept(tile, entity); + heatDrawer.get(tile, entity); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Conduit.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Conduit.java index 4abf4c9cdc..541446be35 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Conduit.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Conduit.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.world.blocks.distribution; import io.anuke.arc.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.*; diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java index eb54ff025d..b359111f9a 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Conveyor.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks.distribution; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.*; diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/ItemBridge.java b/core/src/io/anuke/mindustry/world/blocks/distribution/ItemBridge.java index 3c11b5903f..a79b225576 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/ItemBridge.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/ItemBridge.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.world.blocks.distribution; import io.anuke.arc.*; import io.anuke.arc.collection.*; import io.anuke.arc.collection.IntSet.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.g2d.*; diff --git a/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java b/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java index a1ef2bce86..ba0288b6be 100644 --- a/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java +++ b/core/src/io/anuke/mindustry/world/blocks/distribution/Sorter.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.world.blocks.distribution; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.*; diff --git a/core/src/io/anuke/mindustry/world/blocks/power/ConditionalConsumePower.java b/core/src/io/anuke/mindustry/world/blocks/power/ConditionalConsumePower.java index e94cfab6ba..1f9dadd3e9 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/ConditionalConsumePower.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/ConditionalConsumePower.java @@ -1,20 +1,20 @@ package io.anuke.mindustry.world.blocks.power; -import io.anuke.arc.function.Predicate; +import io.anuke.arc.func.Boolf; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.world.consumers.ConsumePower; /** A power consumer that only activates sometimes. */ public class ConditionalConsumePower extends ConsumePower{ - private final Predicate consume; + private final Boolf consume; - public ConditionalConsumePower(float usage, Predicate consume){ + public ConditionalConsumePower(float usage, Boolf consume){ super(usage, 0, false); this.consume = consume; } @Override public float requestedPower(TileEntity entity){ - return consume.test(entity) ? usage : 0f; + return consume.get(entity) ? usage : 0f; } } diff --git a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java index 556648a6b6..c9fbd3a635 100644 --- a/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java +++ b/core/src/io/anuke/mindustry/world/blocks/power/PowerNode.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks.power; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.g2d.*; @@ -101,13 +102,13 @@ public class PowerNode extends PowerBlock{ public void placed(Tile tile){ if(net.client()) return; - Predicate valid = other -> other != null && other != tile && ((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && linkValid(tile, other) + Boolf valid = other -> other != null && other != tile && ((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && linkValid(tile, other) && !other.entity.proximity().contains(tile) && other.entity.power.graph != tile.entity.power.graph; tempTiles.clear(); Geometry.circle(tile.x, tile.y, (int)(laserRange + 1), (x, y) -> { Tile other = world.ltile(x, y); - if(valid.test(other)){ + if(valid.get(other)){ if(!insulated(tile, other)){ tempTiles.add(other); } @@ -124,8 +125,8 @@ public class PowerNode extends PowerBlock{ super.placed(tile); } - private void getPotentialLinks(Tile tile, Consumer others){ - Predicate valid = other -> other != null && other != tile && other.entity != null && other.entity.power != null && + private void getPotentialLinks(Tile tile, Cons others){ + Boolf valid = other -> other != null && other != tile && other.entity != null && other.entity.power != null && ((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) && overlaps(tile.x * tilesize + offset(), tile.y * tilesize + offset(), other, laserRange * tilesize) && other.getTeam() == player.getTeam() && !other.entity.proximity().contains(tile) && !graphs.contains(other.entity.power.graph); @@ -134,7 +135,7 @@ public class PowerNode extends PowerBlock{ graphs.clear(); Geometry.circle(tile.x, tile.y, (int)(laserRange + 1), (x, y) -> { Tile other = world.ltile(x, y); - if(valid.test(other) && !tempTiles.contains(other)){ + if(valid.get(other) && !tempTiles.contains(other)){ tempTiles.add(other); } }); @@ -142,7 +143,7 @@ public class PowerNode extends PowerBlock{ tempTiles.sort(Structs.comparingFloat(t -> t.dst2(tile))); tempTiles.each(valid, t -> { graphs.add(t.entity.power.graph); - others.accept(t); + others.get(t); }); } @@ -331,12 +332,12 @@ public class PowerNode extends PowerBlock{ return bool[0]; } - public static void insulators(int x, int y, int x2, int y2, Consumer iterator){ + public static void insulators(int x, int y, int x2, int y2, Cons iterator){ world.raycastEach(x, y, x2, y2, (wx, wy) -> { Tile tile = world.ltile(wx, wy); if(tile != null && tile.block() != null && tile.block().insulated){ - iterator.accept(tile); + iterator.get(tile); } return false; diff --git a/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java b/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java index eb76325965..2792671efa 100644 --- a/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java +++ b/core/src/io/anuke/mindustry/world/blocks/production/GenericCrafter.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.world.blocks.production; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.*; @@ -25,8 +26,8 @@ public class GenericCrafter extends Block{ protected Effect updateEffect = Fx.none; protected float updateEffectChance = 0.04f; - protected Consumer drawer = null; - protected Supplier drawIcons = null; + protected Cons drawer = null; + protected Prov drawIcons = null; public GenericCrafter(String name){ super(name); @@ -73,7 +74,7 @@ public class GenericCrafter extends Block{ if(drawer == null){ super.draw(tile); }else{ - drawer.accept(tile); + drawer.get(tile); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/sandbox/ItemSource.java b/core/src/io/anuke/mindustry/world/blocks/sandbox/ItemSource.java index aebc81da2a..ba7d107c2c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/sandbox/ItemSource.java +++ b/core/src/io/anuke/mindustry/world/blocks/sandbox/ItemSource.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.world.blocks.sandbox; import io.anuke.arc.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.scene.ui.layout.*; diff --git a/core/src/io/anuke/mindustry/world/blocks/sandbox/LiquidSource.java b/core/src/io/anuke/mindustry/world/blocks/sandbox/LiquidSource.java index 03f1c0d82d..696842673d 100644 --- a/core/src/io/anuke/mindustry/world/blocks/sandbox/LiquidSource.java +++ b/core/src/io/anuke/mindustry/world/blocks/sandbox/LiquidSource.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.world.blocks.sandbox; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.scene.style.*; diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java b/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java index 045003a545..360015e78f 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/CoreBlock.java @@ -3,6 +3,7 @@ package io.anuke.mindustry.world.blocks.storage; import io.anuke.annotations.Annotations.*; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.g2d.*; import io.anuke.arc.math.*; @@ -111,7 +112,7 @@ public class CoreBlock extends StorageBlock{ @Override public void drawSelect(Tile tile){ Lines.stroke(1f, Pal.accent); - Consumer outline = t -> { + Cons outline = t -> { for(int i = 0; i < 4; i++){ Point2 p = Geometry.d8edge[i]; float offset = -Math.max(t.block().size - 1, 0) / 2f * tilesize; @@ -119,7 +120,7 @@ public class CoreBlock extends StorageBlock{ } }; if(tile.entity.proximity().contains(e -> isContainer(e) && e.entity.items == tile.entity.items)){ - outline.accept(tile); + outline.get(tile); } tile.entity.proximity().each(e -> isContainer(e) && e.entity.items == tile.entity.items, outline); Draw.reset(); diff --git a/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java b/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java index 0b5c7d2079..58af624e96 100644 --- a/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java +++ b/core/src/io/anuke/mindustry/world/blocks/storage/Unloader.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.world.blocks.storage; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.graphics.*; import io.anuke.arc.graphics.g2d.*; diff --git a/core/src/io/anuke/mindustry/world/consumers/ConsumeItemFilter.java b/core/src/io/anuke/mindustry/world/consumers/ConsumeItemFilter.java index 89c78d7ca0..1f1f3b240f 100644 --- a/core/src/io/anuke/mindustry/world/consumers/ConsumeItemFilter.java +++ b/core/src/io/anuke/mindustry/world/consumers/ConsumeItemFilter.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.world.consumers; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.scene.ui.layout.*; import io.anuke.arc.util.ArcAnnotate.*; @@ -15,9 +16,10 @@ import io.anuke.mindustry.world.meta.values.*; import static io.anuke.mindustry.Vars.*; public class ConsumeItemFilter extends Consume{ - public final @NonNull Predicate filter; + public final @NonNull + Boolf filter; - public ConsumeItemFilter(Predicate item){ + public ConsumeItemFilter(Boolf item){ this.filter = item; } @@ -34,7 +36,7 @@ public class ConsumeItemFilter extends Consume{ @Override public void build(Tile tile, Table table){ MultiReqImage image = new MultiReqImage(); - content.items().each(i -> filter.test(i) && (!world.isZone() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1), () -> tile.entity != null && tile.entity.items != null && tile.entity.items.has(item)))); + content.items().each(i -> filter.get(i) && (!world.isZone() || data.isUnlocked(i)), item -> image.add(new ReqImage(new ItemImage(item.icon(Cicon.medium), 1), () -> tile.entity != null && tile.entity.items != null && tile.entity.items.has(item)))); table.add(image).size(8 * 4); } @@ -53,7 +55,7 @@ public class ConsumeItemFilter extends Consume{ public void trigger(TileEntity entity){ for(int i = 0; i < content.items().size; i++){ Item item = content.item(i); - if(entity.items != null && entity.items.has(item) && this.filter.test(item)){ + if(entity.items != null && entity.items.has(item) && this.filter.get(item)){ entity.items.remove(item, 1); break; } @@ -64,7 +66,7 @@ public class ConsumeItemFilter extends Consume{ public boolean valid(TileEntity entity){ for(int i = 0; i < content.items().size; i++){ Item item = content.item(i); - if(entity.items != null && entity.items.has(item) && this.filter.test(item)){ + if(entity.items != null && entity.items.has(item) && this.filter.get(item)){ return true; } } diff --git a/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidFilter.java b/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidFilter.java index 5a58ca323f..1da3e86e50 100644 --- a/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidFilter.java +++ b/core/src/io/anuke/mindustry/world/consumers/ConsumeLiquidFilter.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.world.consumers; import io.anuke.arc.collection.*; -import io.anuke.arc.function.Predicate; +import io.anuke.arc.func.Boolf; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.type.Liquid; @@ -16,9 +16,9 @@ import io.anuke.mindustry.world.meta.values.LiquidFilterValue; import static io.anuke.mindustry.Vars.content; public class ConsumeLiquidFilter extends ConsumeLiquidBase{ - public final Predicate filter; + public final Boolf filter; - public ConsumeLiquidFilter(Predicate liquid, float amount){ + public ConsumeLiquidFilter(Boolf liquid, float amount){ super(amount); this.filter = liquid; } @@ -30,7 +30,7 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{ @Override public void build(Tile tile, Table table){ - Array list = content.liquids().select(l -> !l.isHidden() && filter.test(l)); + Array list = content.liquids().select(l -> !l.isHidden() && filter.get(l)); MultiReqImage image = new MultiReqImage(); list.each(liquid -> image.add(new ReqImage(liquid.icon(Cicon.medium), () -> tile.entity != null && tile.entity.liquids != null && tile.entity.liquids.get(liquid) >= use(tile.entity)))); @@ -49,7 +49,7 @@ public class ConsumeLiquidFilter extends ConsumeLiquidBase{ @Override public boolean valid(TileEntity entity){ - return entity != null && entity.liquids != null && filter.test(entity.liquids.current()) && entity.liquids.currentAmount() >= use(entity); + return entity != null && entity.liquids != null && filter.get(entity.liquids.current()) && entity.liquids.currentAmount() >= use(entity); } @Override diff --git a/core/src/io/anuke/mindustry/world/consumers/Consumers.java b/core/src/io/anuke/mindustry/world/consumers/Consumers.java index 5693b759a5..2c66a03596 100644 --- a/core/src/io/anuke/mindustry/world/consumers/Consumers.java +++ b/core/src/io/anuke/mindustry/world/consumers/Consumers.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.world.consumers; import io.anuke.arc.collection.*; -import io.anuke.arc.function.Predicate; +import io.anuke.arc.func.Boolf; import io.anuke.arc.util.Structs; import io.anuke.mindustry.Vars; import io.anuke.mindustry.entities.type.TileEntity; @@ -48,7 +48,7 @@ public class Consumers{ } /** Creates a consumer which only consumes power when the condition is met. */ - public ConsumePower powerCond(float usage, Predicate cons){ + public ConsumePower powerCond(float usage, Boolf cons){ return add(new ConditionalConsumePower(usage, cons)); } diff --git a/core/src/io/anuke/mindustry/world/meta/BlockBars.java b/core/src/io/anuke/mindustry/world/meta/BlockBars.java index 1e42281ba9..11706bc510 100644 --- a/core/src/io/anuke/mindustry/world/meta/BlockBars.java +++ b/core/src/io/anuke/mindustry/world/meta/BlockBars.java @@ -1,14 +1,14 @@ package io.anuke.mindustry.world.meta; import io.anuke.arc.collection.OrderedMap; -import io.anuke.arc.function.Function; +import io.anuke.arc.func.Func; import io.anuke.mindustry.entities.type.TileEntity; import io.anuke.mindustry.ui.Bar; public class BlockBars{ - private OrderedMap> bars = new OrderedMap<>(); + private OrderedMap> bars = new OrderedMap<>(); - public void add(String name, Function sup){ + public void add(String name, Func sup){ bars.put(name, sup); } @@ -18,7 +18,7 @@ public class BlockBars{ bars.remove(name); } - public Iterable> list(){ + public Iterable> list(){ return bars.values(); } } diff --git a/core/src/io/anuke/mindustry/world/meta/BuildVisibility.java b/core/src/io/anuke/mindustry/world/meta/BuildVisibility.java index 38c98aeaa2..111eff2048 100644 --- a/core/src/io/anuke/mindustry/world/meta/BuildVisibility.java +++ b/core/src/io/anuke/mindustry/world/meta/BuildVisibility.java @@ -1,5 +1,6 @@ package io.anuke.mindustry.world.meta; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.mindustry.*; @@ -10,13 +11,13 @@ public enum BuildVisibility{ sandboxOnly(() -> Vars.state.rules.infiniteResources), campaignOnly(() -> Vars.world.isZone()); - private final BooleanProvider visible; + private final Boolp visible; public boolean visible(){ return visible.get(); } - BuildVisibility(BooleanProvider visible){ + BuildVisibility(Boolp visible){ this.visible = visible; } } diff --git a/core/src/io/anuke/mindustry/world/meta/values/BoosterListValue.java b/core/src/io/anuke/mindustry/world/meta/values/BoosterListValue.java index 5fc06abd3e..673f096ed3 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/BoosterListValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/BoosterListValue.java @@ -1,6 +1,7 @@ package io.anuke.mindustry.world.meta.values; import io.anuke.arc.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.scene.ui.layout.*; import io.anuke.arc.util.*; @@ -14,9 +15,9 @@ import static io.anuke.mindustry.Vars.content; public class BoosterListValue implements StatValue{ protected float reload, maxUsed, multiplier; protected boolean baseReload; - protected Predicate filter; + protected Boolf filter; - public BoosterListValue(float reload, float maxUsed, float multiplier, boolean baseReload, Predicate filter){ + public BoosterListValue(float reload, float maxUsed, float multiplier, boolean baseReload, Boolf filter){ this.reload = reload; this.maxUsed = maxUsed; this.baseReload = baseReload; @@ -30,7 +31,7 @@ public class BoosterListValue implements StatValue{ table.row(); table.table(c -> { for(Liquid liquid : content.liquids()){ - if(!filter.test(liquid)) continue; + if(!filter.get(liquid)) continue; c.addImage(liquid.icon(Cicon.medium)).size(3 * 8).padRight(4).right().top(); c.add(liquid.localizedName()).padRight(10).left().top(); diff --git a/core/src/io/anuke/mindustry/world/meta/values/ItemFilterValue.java b/core/src/io/anuke/mindustry/world/meta/values/ItemFilterValue.java index 8bb1ecb6a0..2bdaa32377 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/ItemFilterValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/ItemFilterValue.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.world.meta.values; import io.anuke.arc.collection.Array; -import io.anuke.arc.function.Predicate; +import io.anuke.arc.func.Boolf; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.mindustry.type.Item; import io.anuke.mindustry.ui.ItemDisplay; @@ -10,9 +10,9 @@ import io.anuke.mindustry.world.meta.StatValue; import static io.anuke.mindustry.Vars.content; public class ItemFilterValue implements StatValue{ - private final Predicate filter; + private final Boolf filter; - public ItemFilterValue(Predicate filter){ + public ItemFilterValue(Boolf filter){ this.filter = filter; } diff --git a/core/src/io/anuke/mindustry/world/meta/values/LiquidFilterValue.java b/core/src/io/anuke/mindustry/world/meta/values/LiquidFilterValue.java index e30c2b0ba5..99f6ea4a31 100644 --- a/core/src/io/anuke/mindustry/world/meta/values/LiquidFilterValue.java +++ b/core/src/io/anuke/mindustry/world/meta/values/LiquidFilterValue.java @@ -1,7 +1,7 @@ package io.anuke.mindustry.world.meta.values; import io.anuke.arc.collection.Array; -import io.anuke.arc.function.Predicate; +import io.anuke.arc.func.Boolf; import io.anuke.arc.scene.ui.layout.Table; import io.anuke.mindustry.type.Liquid; import io.anuke.mindustry.ui.LiquidDisplay; @@ -10,11 +10,11 @@ import io.anuke.mindustry.world.meta.StatValue; import static io.anuke.mindustry.Vars.content; public class LiquidFilterValue implements StatValue{ - private final Predicate filter; + private final Boolf filter; private final float amount; private final boolean perSecond; - public LiquidFilterValue(Predicate filter, float amount, boolean perSecond){ + public LiquidFilterValue(Boolf filter, float amount, boolean perSecond){ this.filter = filter; this.amount = amount; this.perSecond = perSecond; @@ -25,7 +25,7 @@ public class LiquidFilterValue implements StatValue{ Array list = new Array<>(); for(Liquid item : content.liquids()){ - if(!item.isHidden() && filter.test(item)) list.add(item); + if(!item.isHidden() && filter.get(item)) list.add(item); } for(int i = 0; i < list.size; i++){ diff --git a/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java b/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java index bcf4ddfb82..a6f7648b31 100644 --- a/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java +++ b/desktop/src/io/anuke/mindustry/desktop/DesktopLauncher.java @@ -8,7 +8,7 @@ import io.anuke.arc.backends.sdl.*; import io.anuke.arc.backends.sdl.jni.*; import io.anuke.arc.collection.*; import io.anuke.arc.files.*; -import io.anuke.arc.function.*; +import io.anuke.arc.func.*; import io.anuke.arc.input.*; import io.anuke.arc.math.*; import io.anuke.arc.scene.event.*; @@ -232,12 +232,12 @@ public class DesktopLauncher extends ClientLauncher{ } static void handleCrash(Throwable e){ - Consumer dialog = Runnable::run; + Cons dialog = Runnable::run; boolean badGPU = false; if(e.getMessage() != null && (e.getMessage().contains("Couldn't create window") || e.getMessage().contains("OpenGL 2.0 or higher"))){ - dialog.accept(() -> message( + dialog.get(() -> message( e.getMessage().contains("Couldn't create window") ? "A graphics initialization error has occured! Try to update your graphics drivers:\n" + e.getMessage() : "Your graphics card does not support OpenGL 2.0!\n" + "Try to update your graphics drivers.\n\n" + @@ -253,7 +253,7 @@ public class DesktopLauncher extends ClientLauncher{ if(fc == null) fc = Strings.getFinalCause(e); Throwable cause = fc; if(!fbgp){ - dialog.accept(() -> message("A crash has occured. It has been saved in:\n" + file.getAbsolutePath() + "\n" + cause.getClass().getSimpleName().replace("Exception", "") + (cause.getMessage() == null ? "" : ":\n" + cause.getMessage()))); + dialog.get(() -> message("A crash has occured. It has been saved in:\n" + file.getAbsolutePath() + "\n" + cause.getClass().getSimpleName().replace("Exception", "") + (cause.getMessage() == null ? "" : ":\n" + cause.getMessage()))); } }); } diff --git a/desktop/src/io/anuke/mindustry/desktop/steam/SNet.java b/desktop/src/io/anuke/mindustry/desktop/steam/SNet.java index 4e4e8e680b..97d1172a98 100644 --- a/desktop/src/io/anuke/mindustry/desktop/steam/SNet.java +++ b/desktop/src/io/anuke/mindustry/desktop/steam/SNet.java @@ -6,6 +6,7 @@ import com.codedisaster.steamworks.SteamMatchmaking.*; import com.codedisaster.steamworks.SteamNetworking.*; import io.anuke.arc.*; import io.anuke.arc.collection.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.util.*; import io.anuke.arc.util.pooling.*; @@ -39,7 +40,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback, final IntMap steamConnections = new IntMap<>(); //maps steam ID -> valid net connection SteamID currentLobby, currentServer; - Consumer lobbyCallback; + Cons lobbyCallback; Runnable lobbyDoneCallback, joinCallback; public SNet(NetProvider provider){ @@ -164,7 +165,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback, } @Override - public void discoverServers(Consumer callback, Runnable done){ + public void discoverServers(Cons callback, Runnable done){ smat.addRequestLobbyListResultCountFilter(32); smat.requestLobbyList(); lobbyCallback = callback; @@ -172,7 +173,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback, } @Override - public void pingHost(String address, int port, Consumer valid, Consumer failed){ + public void pingHost(String address, int port, Cons valid, Cons failed){ provider.pingHost(address, port, valid, failed); } diff --git a/desktop/src/io/anuke/mindustry/desktop/steam/SWorkshop.java b/desktop/src/io/anuke/mindustry/desktop/steam/SWorkshop.java index ee0b4652fd..3b8a9178af 100644 --- a/desktop/src/io/anuke/mindustry/desktop/steam/SWorkshop.java +++ b/desktop/src/io/anuke/mindustry/desktop/steam/SWorkshop.java @@ -6,6 +6,7 @@ import com.codedisaster.steamworks.SteamUGC.*; import io.anuke.arc.*; import io.anuke.arc.collection.*; import io.anuke.arc.files.*; +import io.anuke.arc.func.*; import io.anuke.arc.function.*; import io.anuke.arc.scene.ui.*; import io.anuke.arc.util.*; @@ -22,8 +23,8 @@ public class SWorkshop implements SteamUGCCallback{ public final SteamUGC ugc = new SteamUGC(this); private ObjectMap, Array> workshopFiles = new ObjectMap<>(); - private ObjectMap, SteamResult>> detailHandlers = new ObjectMap<>(); - private Array> itemHandlers = new Array<>(); + private ObjectMap, SteamResult>> detailHandlers = new ObjectMap<>(); + private Array> itemHandlers = new Array<>(); private ObjectMap updatedHandlers = new ObjectMap<>(); public SWorkshop(){ @@ -169,7 +170,7 @@ public class SWorkshop implements SteamUGCCallback{ }, () -> p.addSteamID(sid)); } - void showPublish(Consumer published){ + void showPublish(Cons published){ FloatingDialog dialog = new FloatingDialog("$confirm"); dialog.setFillParent(false); dialog.cont.add("$publish.confirm").width(600f).wrap(); @@ -188,18 +189,18 @@ public class SWorkshop implements SteamUGCCallback{ dialog.show(); } - void query(SteamUGCQuery query, BiConsumer, SteamResult> handler){ + void query(SteamUGCQuery query, Cons2, SteamResult> handler){ Log.info("POST QUERY " + query); detailHandlers.put(query, handler); ugc.sendQueryUGCRequest(query); } - void updateItem(SteamPublishedFileID publishedFileID, Consumer tagger, Runnable updated){ + void updateItem(SteamPublishedFileID publishedFileID, Cons tagger, Runnable updated){ try{ SteamUGCUpdateHandle h = ugc.startItemUpdate(SVars.steamID, publishedFileID); Log.info("begin updateItem({0})", publishedFileID.toString()); - tagger.accept(h); + tagger.get(h); Log.info("Tagged."); ItemUpdateInfo info = new ItemUpdateInfo(); @@ -239,10 +240,10 @@ public class SWorkshop implements SteamUGCCallback{ details.add(new SteamUGCDetails()); ugc.getQueryUGCResult(query, i, details.get(i)); } - detailHandlers.get(query).accept(details, result); + detailHandlers.get(query).get(details, result); }else{ Log.info("Nothing found."); - detailHandlers.get(query).accept(new Array<>(), SteamResult.FileNotFound); + detailHandlers.get(query).get(new Array<>(), SteamResult.FileNotFound); } detailHandlers.remove(query); @@ -272,7 +273,7 @@ public class SWorkshop implements SteamUGCCallback{ if(!itemHandlers.isEmpty()){ if(result == SteamResult.OK){ Log.info("Passing to first handler."); - itemHandlers.first().accept(publishedFileID); + itemHandlers.first().get(publishedFileID); }else{ ui.showErrorMessage(Core.bundle.format("publish.error ", result.name())); } diff --git a/gradle.properties b/gradle.properties index 1a1e449fc9..3e1033435e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ org.gradle.daemon=true org.gradle.jvmargs=-Xms256m -Xmx1024m -archash=fa703e299e675a90cf32006d304fdca9305258dc +archash=45ccffb159cce2ba17687e81c14853efa647b102 diff --git a/ios/src/io/anuke/mindustry/IOSLauncher.java b/ios/src/io/anuke/mindustry/IOSLauncher.java index 72588f1296..30ebd5a082 100644 --- a/ios/src/io/anuke/mindustry/IOSLauncher.java +++ b/ios/src/io/anuke/mindustry/IOSLauncher.java @@ -3,7 +3,7 @@ package io.anuke.mindustry; import com.badlogic.gdx.backends.iosrobovm.*; import io.anuke.arc.*; import io.anuke.arc.files.*; -import io.anuke.arc.function.*; +import io.anuke.arc.func.*; import io.anuke.arc.scene.ui.layout.*; import io.anuke.arc.util.*; import io.anuke.arc.util.io.*; @@ -12,7 +12,6 @@ import io.anuke.mindustry.game.Saves.*; import io.anuke.mindustry.io.*; import io.anuke.mindustry.mod.*; import io.anuke.mindustry.ui.*; -import org.robovm.apple.dispatch.*; import org.robovm.apple.foundation.*; import org.robovm.apple.uikit.*; import org.robovm.objc.block.*; @@ -40,7 +39,7 @@ public class IOSLauncher extends IOSApplication.Delegate{ return new IOSApplication(new ClientLauncher(){ @Override - public void showFileChooser(boolean open, String extension, Consumer cons){ + public void showFileChooser(boolean open, String extension, Cons cons){ UIDocumentBrowserViewController cont = new UIDocumentBrowserViewController((NSArray)null); NSArray arr = new NSArray<>(new UIBarButtonItem(Core.bundle.get("cancel"), UIBarButtonItemStyle.Plain, @@ -60,7 +59,7 @@ public class IOSLauncher extends IOSApplication.Delegate{ if(documentURLs.size() < 1) return; cont.dismissViewController(true, () -> {}); - controller.importDocument(documentURLs.get(0), new NSURL(getDocumentsDirectory() + "/document"), UIDocumentBrowserImportMode.Copy, (url, error) -> cons.accept(Core.files.absolute(url.getPath()))); + controller.importDocument(documentURLs.get(0), new NSURL(getDocumentsDirectory() + "/document"), UIDocumentBrowserImportMode.Copy, (url, error) -> cons.get(Core.files.absolute(url.getPath()))); } @Override @@ -70,7 +69,7 @@ public class IOSLauncher extends IOSApplication.Delegate{ @Override public void didImportDocument(UIDocumentBrowserViewController controller, NSURL sourceURL, NSURL destinationURL){ - cons.accept(Core.files.absolute(destinationURL.getAbsoluteString())); + cons.get(Core.files.absolute(destinationURL.getAbsoluteString())); } @Override diff --git a/tests/src/test/java/ZoneTests.java b/tests/src/test/java/ZoneTests.java index d919e0fa47..eee1de8708 100644 --- a/tests/src/test/java/ZoneTests.java +++ b/tests/src/test/java/ZoneTests.java @@ -42,7 +42,7 @@ public class ZoneTests{ e.printStackTrace(); return; } - zone.rules.accept(state.rules); + zone.rules.get(state.rules); ObjectSet resources = new ObjectSet<>(); boolean hasSpawnPoint = false; diff --git a/tools/src/io/anuke/mindustry/BundleLauncher.java b/tools/src/io/anuke/mindustry/BundleLauncher.java index 69b0e525b9..3888f641da 100644 --- a/tools/src/io/anuke/mindustry/BundleLauncher.java +++ b/tools/src/io/anuke/mindustry/BundleLauncher.java @@ -2,7 +2,7 @@ package io.anuke.mindustry; import io.anuke.arc.collection.Array; import io.anuke.arc.collection.OrderedMap; -import io.anuke.arc.function.BiFunction; +import io.anuke.arc.func.Func2; import io.anuke.arc.util.Log; import io.anuke.arc.util.Strings; import io.anuke.arc.util.io.PropertiesUtils; @@ -50,7 +50,7 @@ public class BundleLauncher{ } } - BiFunction processor = (key, value) -> (key + " = " + value).replace("\\", "\\\\").replace("\n", "\\n") + "\n"; + Func2 processor = (key, value) -> (key + " = " + value).replace("\\", "\\\\").replace("\n", "\\n") + "\n"; Path output = child.resolveSibling("output/" + child.getFileName());