mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-27 15:02:03 -08:00
Refactoring of functional package
This commit is contained in:
parent
f0fa643930
commit
0722ad2f4c
86 changed files with 456 additions and 396 deletions
|
|
@ -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">
|
||||
|
|
|
|||
|
|
@ -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<FileHandle> cons){
|
||||
public void showFileChooser(boolean open, String extension, Cons<FileHandle> 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);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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<Tile> pred){
|
||||
public TileEntity findTile(Team team, float x, float y, float range, Boolf<Tile> pred){
|
||||
return findTile(team, x, y, range, pred, false);
|
||||
}
|
||||
|
||||
public TileEntity findTile(Team team, float x, float y, float range, Predicate<Tile> pred, boolean usePriority){
|
||||
public TileEntity findTile(Team team, float x, float y, float range, Boolf<Tile> 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;
|
||||
|
|
|
|||
|
|
@ -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<Team, IntArray> targeter;
|
||||
private final Cons2<Team, IntArray> targeter;
|
||||
|
||||
PathTarget(BiConsumer<Team, IntArray> targeter){
|
||||
PathTarget(Cons2<Team, IntArray> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String, MappableContent>[] contentNameMap = new ObjectMap[ContentType.values().length];
|
||||
private Array<Content>[] contentMap = new Array[ContentType.values().length];
|
||||
private MappableContent[][] temporaryMapper;
|
||||
private ObjectSet<Consumer<Content>> initialization = new ObjectSet<>();
|
||||
private ObjectSet<Cons<Content>> 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<Content> callable){
|
||||
private void initialize(Cons<Content> 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);
|
||||
|
|
|
|||
|
|
@ -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()){
|
||||
|
|
|
|||
|
|
@ -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<FileHandle> cons){
|
||||
default void showFileChooser(boolean open, String extension, Cons<FileHandle> 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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Unit> draw = u -> {
|
||||
Cons<Unit> 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<? extends BaseUnit> 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();
|
||||
|
|
|
|||
|
|
@ -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<String> confirmed){
|
||||
public void showTextInput(String titleText, String dtext, int textLength, String def, boolean inumeric, Cons<String> 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<String> confirmed){
|
||||
public void showTextInput(String title, String text, String def, Cons<String> confirmed){
|
||||
showTextInput(title, text, 32, def, confirmed);
|
||||
}
|
||||
|
||||
public void showTextInput(String titleText, String text, int textLength, String def, Consumer<String> confirmed){
|
||||
public void showTextInput(String titleText, String text, int textLength, String def, Cons<String> 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);
|
||||
|
|
|
|||
|
|
@ -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<Tile> tester;
|
||||
Consumer<Tile> setter;
|
||||
Boolf<Tile> tester;
|
||||
Cons<Tile> 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<Tile> tester, Consumer<Tile> filler){
|
||||
void fill(MapEditor editor, int x, int y, boolean replace, Boolf<Tile> tester, Cons<Tile> 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++;
|
||||
|
|
|
|||
|
|
@ -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<Tile> tester){
|
||||
public void drawBlocks(int x, int y, Boolf<Tile> tester){
|
||||
drawBlocks(x, y, false, tester);
|
||||
}
|
||||
|
||||
public void drawBlocks(int x, int y, boolean square, Predicate<Tile> tester){
|
||||
public void drawBlocks(int x, int y, boolean square, Boolf<Tile> 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<Tile> drawer = tile -> {
|
||||
if(!tester.test(tile)) return;
|
||||
Cons<Tile> 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<Tile> drawer){
|
||||
public void drawCircle(int x, int y, Cons<Tile> 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<Tile> drawer){
|
||||
public void drawSquare(int x, int y, Cons<Tile> 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ImageButton> group = new ButtonGroup<>();
|
||||
Table[] lastTable = {null};
|
||||
|
||||
Consumer<EditorTool> addTool = tool -> {
|
||||
Cons<EditorTool> 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(() -> {
|
||||
|
|
|
|||
|
|
@ -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<GenerateFilter>[] filterTypes = new Supplier[]{
|
||||
private final Prov<GenerateFilter>[] 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<Array<GenerateFilter>> applier;
|
||||
private Cons<Array<GenerateFilter>> applier;
|
||||
private CachedTile ctile = new CachedTile(){
|
||||
//nothing.
|
||||
@Override
|
||||
|
|
@ -95,13 +96,13 @@ public class MapGenerateDialog extends FloatingDialog{
|
|||
onResize(this::rebuildFilters);
|
||||
}
|
||||
|
||||
public void show(Array<GenerateFilter> filters, Consumer<Array<GenerateFilter>> applier){
|
||||
public void show(Array<GenerateFilter> filters, Cons<Array<GenerateFilter>> applier){
|
||||
this.filters = filters;
|
||||
this.applier = applier;
|
||||
show();
|
||||
}
|
||||
|
||||
public void show(Consumer<Array<GenerateFilter>> applier){
|
||||
public void show(Cons<Array<GenerateFilter>> 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<GenerateFilter> gen : filterTypes){
|
||||
for(Prov<GenerateFilter> 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(){
|
||||
|
|
|
|||
|
|
@ -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<Map> loader){
|
||||
public MapLoadDialog(Cons<Map> 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();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<String> listener;
|
||||
private Cons<String> listener;
|
||||
|
||||
public MapSaveDialog(Consumer<String> cons){
|
||||
public MapSaveDialog(Cons<String> 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");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Unit> cons = e -> {
|
||||
Cons<Unit> 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<Unit> predicate, Consumer<Unit> acceptor){
|
||||
Consumer<Unit> cons = entity -> {
|
||||
if(!predicate.test(entity)) return;
|
||||
public static void damageUnits(Team team, float x, float y, float size, float damage, Boolf<Unit> predicate, Cons<Unit> acceptor){
|
||||
Cons<Unit> 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<Unit> cons = entity -> {
|
||||
Cons<Unit> cons = entity -> {
|
||||
if(entity.getTeam() == team || entity.dst(x, y) > radius){
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<EffectContainer> cons){
|
||||
public void scaled(float lifetime, Cons<EffectContainer> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<T extends Entity>{
|
|||
private final Rectangle intersectRect = new Rectangle();
|
||||
private IntMap<T> map;
|
||||
private QuadTree tree;
|
||||
private Consumer<T> removeListener;
|
||||
private Consumer<T> addListener;
|
||||
private Cons<T> removeListener;
|
||||
private Cons<T> addListener;
|
||||
|
||||
private final Rectangle viewport = new Rectangle();
|
||||
private int count = 0;
|
||||
|
|
@ -60,20 +61,20 @@ public class EntityGroup<T extends Entity>{
|
|||
draw(e -> true);
|
||||
}
|
||||
|
||||
public void draw(Predicate<T> toDraw){
|
||||
public void draw(Boolf<T> toDraw){
|
||||
draw(toDraw, t -> ((DrawTrait)t).draw());
|
||||
}
|
||||
|
||||
public void draw(Predicate<T> toDraw, Consumer<T> cons){
|
||||
public void draw(Boolf<T> toDraw, Cons<T> 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<T extends Entity>{
|
|||
return useTree;
|
||||
}
|
||||
|
||||
public void setRemoveListener(Consumer<T> removeListener){
|
||||
public void setRemoveListener(Cons<T> removeListener){
|
||||
this.removeListener = removeListener;
|
||||
}
|
||||
|
||||
public void setAddListener(Consumer<T> addListener){
|
||||
public void setAddListener(Cons<T> addListener){
|
||||
this.addListener = addListener;
|
||||
}
|
||||
|
||||
|
|
@ -148,7 +149,7 @@ public class EntityGroup<T extends Entity>{
|
|||
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<T extends Entity>{
|
|||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public void intersect(float x, float y, float width, float height, Consumer<? super T> out){
|
||||
public void intersect(float x, float y, float width, float height, Cons<? super T> 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<T extends Entity>{
|
|||
return entityArray.size;
|
||||
}
|
||||
|
||||
public int count(Predicate<T> pred){
|
||||
public int count(Boolf<T> 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<T extends Entity>{
|
|||
}
|
||||
|
||||
if(addListener != null){
|
||||
addListener.accept(type);
|
||||
addListener.get(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -221,7 +222,7 @@ public class EntityGroup<T extends Entity>{
|
|||
entitiesToRemove.add(type);
|
||||
|
||||
if(removeListener != null){
|
||||
removeListener.accept(type);
|
||||
removeListener.get(type);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -244,10 +245,10 @@ public class EntityGroup<T extends Entity>{
|
|||
map.clear();
|
||||
}
|
||||
|
||||
public T find(Predicate<T> pred){
|
||||
public T find(Boolf<T> 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;
|
||||
|
|
|
|||
|
|
@ -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<Tile> pred){
|
||||
public static TileEntity findAllyTile(Team team, float x, float y, float range, Boolf<Tile> 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<Tile> pred){
|
||||
public static TileEntity findEnemyTile(Team team, float x, float y, float range, Boolf<Tile> 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<Unit> unitPred){
|
||||
public static TargetTrait closestTarget(Team team, float x, float y, float range, Boolf<Unit> 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<Unit> unitPred, Predicate<Tile> tilePred){
|
||||
public static TargetTrait closestTarget(Team team, float x, float y, float range, Boolf<Unit> unitPred, Boolf<Tile> 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<Unit> predicate){
|
||||
public static Unit closestEnemy(Team team, float x, float y, float range, Boolf<Unit> 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<Unit> predicate){
|
||||
public static Unit closest(Team team, float x, float y, float range, Boolf<Unit> 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<Unit> cons){
|
||||
public static void nearby(Team team, float x, float y, float width, float height, Cons<Unit> 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<Unit> cons){
|
||||
public static void nearby(Team team, float x, float y, float radius, Cons<Unit> 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<Unit> cons){
|
||||
public static void nearby(float x, float y, float width, float height, Cons<Unit> 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<Unit> cons){
|
||||
public static void nearby(Rectangle rect, Cons<Unit> 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<Unit> cons){
|
||||
public static void nearbyEnemies(Team team, float x, float y, float width, float height, Cons<Unit> cons){
|
||||
EnumSet<Team> 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<Unit> cons){
|
||||
public static void nearbyEnemies(Team team, Rectangle rect, Cons<Unit> cons){
|
||||
nearbyEnemies(team, rect.x, rect.y, rect.width, rect.height, cons);
|
||||
}
|
||||
|
||||
/** Iterates over all units. */
|
||||
public static void all(Consumer<Unit> cons){
|
||||
public static void all(Cons<Unit> cons){
|
||||
for(Team team : Team.all){
|
||||
unitGroups[team.ordinal()].all().each(cons);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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> rules;
|
||||
private final Predicate<Map> validator;
|
||||
private final Cons<Rules> rules;
|
||||
private final Boolf<Map> validator;
|
||||
|
||||
public final boolean hidden;
|
||||
public final static Gamemode[] all = values();
|
||||
|
||||
Gamemode(Consumer<Rules> rules){
|
||||
Gamemode(Cons<Rules> rules){
|
||||
this(false, rules);
|
||||
}
|
||||
|
||||
Gamemode(boolean hidden, Consumer<Rules> rules){
|
||||
Gamemode(boolean hidden, Cons<Rules> rules){
|
||||
this(hidden, rules, m -> true);
|
||||
}
|
||||
|
||||
Gamemode(Consumer<Rules> rules, Predicate<Map> validator){
|
||||
Gamemode(Cons<Rules> rules, Boolf<Map> validator){
|
||||
this(false, rules, validator);
|
||||
}
|
||||
|
||||
Gamemode(boolean hidden, Consumer<Rules> rules, Predicate<Map> validator){
|
||||
Gamemode(boolean hidden, Cons<Rules> rules, Boolf<Map> 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(){
|
||||
|
|
|
|||
|
|
@ -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<String, String> text;
|
||||
protected final Func<String, String> text;
|
||||
protected Array<String> sentences;
|
||||
protected final BooleanProvider done;
|
||||
protected final Boolp done;
|
||||
|
||||
TutorialStage(Function<String, String> text, BooleanProvider done){
|
||||
TutorialStage(Func<String, String> text, Boolp done){
|
||||
this.text = text;
|
||||
this.done = done;
|
||||
}
|
||||
|
||||
TutorialStage(BooleanProvider done){
|
||||
TutorialStage(Boolp done){
|
||||
this(line -> line, done);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<BuildRequest> 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<BuildRequest> test = req -> {
|
||||
Boolf<BuildRequest> 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<PlaceLine> cons){
|
||||
void iterateLine(int startX, int startY, int endX, int endY, Cons<PlaceLine> cons){
|
||||
Array<Point2> 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());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Exception> failed){
|
||||
private void createNewPreview(Map map, Cons<Exception> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Block> floorsOnly = b -> (b instanceof Floor && !(b instanceof OverlayFloor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full));
|
||||
public static final Predicate<Block> wallsOnly = b -> (!b.synthetic() && !(b instanceof Floor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full));
|
||||
public static final Predicate<Block> 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<Block> 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<Block> 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<Block> oresOnly = b -> b instanceof OverlayFloor && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full));
|
||||
public static final Predicate<Block> anyOptional = b -> floorsOnly.test(b) || wallsOnly.test(b) || oresOnly.test(b) || b == Blocks.air;
|
||||
public static final Boolf<Block> floorsOnly = b -> (b instanceof Floor && !(b instanceof OverlayFloor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full));
|
||||
public static final Boolf<Block> wallsOnly = b -> (!b.synthetic() && !(b instanceof Floor)) && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full));
|
||||
public static final Boolf<Block> 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<Block> 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<Block> 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<Block> oresOnly = b -> b instanceof OverlayFloor && Core.atlas.isFound(b.icon(io.anuke.mindustry.ui.Cicon.full));
|
||||
public static final Boolf<Block> 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<Block> supplier;
|
||||
final Consumer<Block> consumer;
|
||||
final Predicate<Block> filter;
|
||||
final Prov<Block> supplier;
|
||||
final Cons<Block> consumer;
|
||||
final Boolf<Block> filter;
|
||||
|
||||
BlockOption(String name, Supplier<Block> supplier, Consumer<Block> consumer, Predicate<Block> filter){
|
||||
BlockOption(String name, Prov<Block> supplier, Cons<Block> consumer, Boolf<Block> 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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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<Vector2> clamper = v ->
|
||||
Cons<Vector2> 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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 <T extends Content> TypeParser<T> parser(ContentType type, Function<String, T> constructor){
|
||||
private <T extends Content> TypeParser<T> parser(ContentType type, Func<String, T> constructor){
|
||||
return (mod, name, value) -> {
|
||||
T item;
|
||||
if(Vars.content.getByName(type, name) != null){
|
||||
|
|
@ -366,7 +367,7 @@ public class ContentParser{
|
|||
}
|
||||
}
|
||||
|
||||
private <T> Supplier<T> supply(Class<T> type){
|
||||
private <T> Prov<T> supply(Class<T> type){
|
||||
try{
|
||||
java.lang.reflect.Constructor<T> cons = type.getDeclaredConstructor();
|
||||
return () -> {
|
||||
|
|
|
|||
|
|
@ -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<Mod> cons){
|
||||
loaded.each(p -> p.mod != null, p -> safeRun(p, () -> cons.accept(p.mod)));
|
||||
public void each(Cons<Mod> cons){
|
||||
loaded.each(p -> p.mod != null, p -> safeRun(p, () -> cons.get(p.mod)));
|
||||
}
|
||||
|
||||
public void handleError(Throwable t, LoadedMod mod){
|
||||
|
|
|
|||
|
|
@ -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<DatagramPacket> packetSupplier = () -> new DatagramPacket(new byte[256], 256);
|
||||
final Prov<DatagramPacket> packetSupplier = () -> new DatagramPacket(new byte[256], 256);
|
||||
|
||||
final Server server;
|
||||
final CopyOnWriteArrayList<ArcConnection> connections = new CopyOnWriteArrayList<>();
|
||||
|
|
@ -183,7 +183,7 @@ public class ArcNetImpl implements NetProvider{
|
|||
}
|
||||
|
||||
@Override
|
||||
public void pingHost(String address, int port, Consumer<Host> valid, Consumer<Exception> invalid){
|
||||
public void pingHost(String address, int port, Cons<Host> valid, Cons<Exception> 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<Host> callback, Runnable done){
|
||||
public void discoverServers(Cons<Host> callback, Runnable done){
|
||||
Array<InetAddress> 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<Packet>)Registrator.getByID(id).type, (Supplier<Packet>)Registrator.getByID(id).constructor);
|
||||
Packet packet = Pools.obtain((Class<Packet>)Registrator.getByID(id).type, (Prov<Packet>)Registrator.getByID(id).constructor);
|
||||
packet.read(byteBuffer);
|
||||
return packet;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<File> writeListener){
|
||||
public static void send(Throwable exception, Cons<File> 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<HttpResponse> success, Consumer<Throwable> failure){
|
||||
private static void httpPost(String url, String content, Cons<HttpResponse> success, Cons<Throwable> failure){
|
||||
new NetJavaImpl().http(new HttpRequest().method(HttpMethod.POST).content(content).url(url), success, failure);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Object> packetQueue = new Array<>();
|
||||
private final ObjectMap<Class<?>, Consumer> clientListeners = new ObjectMap<>();
|
||||
private final ObjectMap<Class<?>, BiConsumer<NetConnection, Object>> serverListeners = new ObjectMap<>();
|
||||
private final ObjectMap<Class<?>, Cons> clientListeners = new ObjectMap<>();
|
||||
private final ObjectMap<Class<?>, Cons2<NetConnection, Object>> serverListeners = new ObjectMap<>();
|
||||
private final IntMap<StreamBuilder> 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<Host> cons, Runnable done){
|
||||
public void discoverServers(Cons<Host> 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 <T> void handleClient(Class<T> type, Consumer<T> listener){
|
||||
public <T> void handleClient(Class<T> type, Cons<T> listener){
|
||||
clientListeners.put(type, listener);
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a server listener for when an object is recieved.
|
||||
*/
|
||||
public <T> void handleServer(Class<T> type, BiConsumer<NetConnection, T> listener){
|
||||
serverListeners.put(type, (BiConsumer<NetConnection, Object>)listener);
|
||||
public <T> void handleServer(Class<T> type, Cons2<NetConnection, T> listener){
|
||||
serverListeners.put(type, (Cons2<NetConnection, Object>)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<Host> valid, Consumer<Exception> failed){
|
||||
public void pingHost(String address, int port, Cons<Host> valid, Cons<Exception> 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<Host> callback, Runnable done);
|
||||
void discoverServers(Cons<Host> callback, Runnable done);
|
||||
|
||||
/** Ping a host. If an error occured, failed() should be called with the exception. */
|
||||
void pingHost(String address, int port, Consumer<Host> valid, Consumer<Exception> failed);
|
||||
void pingHost(String address, int port, Cons<Host> valid, Cons<Exception> failed);
|
||||
|
||||
/** Host a server at specified port. */
|
||||
void hostServer(int port) throws IOException;
|
||||
|
|
|
|||
|
|
@ -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 <T extends Packet> ClassEntry(Class<T> type, Supplier<T> constructor){
|
||||
public <T extends Packet> ClassEntry(Class<T> type, Prov<T> constructor){
|
||||
this.type = type;
|
||||
this.constructor = constructor;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<StatusEffect> sup = (Supplier<StatusEffect>)pair[0];
|
||||
Prov<StatusEffect> sup = (Prov<StatusEffect>)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<StatusEffect> effect, TransitionHandler handler){
|
||||
protected void trans(Prov<StatusEffect> effect, TransitionHandler handler){
|
||||
transInit.add(new Object[]{effect, handler});
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
protected void opposite(Supplier... effect){
|
||||
for(Supplier<StatusEffect> sup : effect){
|
||||
protected void opposite(Prov... effect){
|
||||
for(Prov<StatusEffect> sup : effect){
|
||||
trans(sup, (unit, time, newTime, result) -> {
|
||||
time -= newTime * 0.5f;
|
||||
if(time > 0){
|
||||
|
|
|
|||
|
|
@ -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<? extends TypeTrait> constructor;
|
||||
public final Prov<? extends TypeTrait> constructor;
|
||||
|
||||
public TypeID(String name, Supplier<? extends TypeTrait> constructor){
|
||||
public TypeID(String name, Prov<? extends TypeTrait> constructor){
|
||||
super(name);
|
||||
this.constructor = constructor;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<? extends BaseUnit> constructor;
|
||||
public @NonNull
|
||||
Prov<? extends BaseUnit> constructor;
|
||||
|
||||
public float health = 60;
|
||||
public float hitsize = 7f;
|
||||
|
|
@ -43,7 +45,7 @@ public class UnitType extends UnlockableContent{
|
|||
|
||||
public TextureRegion legRegion, baseRegion, region;
|
||||
|
||||
public <T extends BaseUnit> UnitType(String name, Supplier<T> mainConstructor){
|
||||
public <T extends BaseUnit> UnitType(String name, Prov<T> mainConstructor){
|
||||
this(name);
|
||||
create(mainConstructor);
|
||||
}
|
||||
|
|
@ -53,7 +55,7 @@ public class UnitType extends UnlockableContent{
|
|||
this.description = Core.bundle.getOrNull("unit." + name + ".description");
|
||||
}
|
||||
|
||||
public <T extends BaseUnit> void create(Supplier<T> mainConstructor){
|
||||
public <T extends BaseUnit> void create(Prov<T> mainConstructor){
|
||||
this.constructor = mainConstructor;
|
||||
this.description = Core.bundle.getOrNull("unit." + name + ".description");
|
||||
this.typeID = new TypeID(name, mainConstructor);
|
||||
|
|
|
|||
|
|
@ -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<Item> resources = new Array<>();
|
||||
|
||||
public Consumer<Rules> rules = rules -> {};
|
||||
public Cons<Rules> 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<ItemStack> stacks = new Array<>();
|
||||
|
||||
Consumer<ItemStack> adder = stack -> {
|
||||
Cons<ItemStack> 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;
|
||||
|
|
|
|||
|
|
@ -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<String> name, Supplier<Color> color, FloatProvider fraction){
|
||||
public Bar(Prov<String> name, Prov<Color> 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<String> name, FloatProvider fraction, Color color){
|
||||
public void set(Prov<String> name, Floatp fraction, Color color){
|
||||
this.fraction = fraction;
|
||||
this.lastValue = fraction.get();
|
||||
this.blinkColor.set(color);
|
||||
|
|
|
|||
|
|
@ -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<Integer, String> converter = String::valueOf;
|
||||
private Func<Integer, String> converter = String::valueOf;
|
||||
|
||||
public IntFormat(String text){
|
||||
this.text = text;
|
||||
}
|
||||
|
||||
public IntFormat(String text, Function<Integer, String> converter){
|
||||
public IntFormat(String text, Func<Integer, String> converter){
|
||||
this.text = text;
|
||||
this.converter = converter;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Color> cons;
|
||||
private Cons<Color> 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<Color> cons){
|
||||
public void show(Cons<Color> cons){
|
||||
this.cons = cons;
|
||||
show();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Rules> resetter;
|
||||
private Prov<Rules> 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<Rules> resetter){
|
||||
public void show(Rules rules, Prov<Rules> 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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Element> 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<Element> 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());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<FileHandle> filter;
|
||||
private Consumer<FileHandle> selectListener;
|
||||
private Boolf<FileHandle> filter;
|
||||
private Cons<FileHandle> selectListener;
|
||||
private boolean open;
|
||||
|
||||
public FileChooser(String title, Predicate<FileHandle> filter, boolean open, Consumer<FileHandle> result){
|
||||
public FileChooser(String title, Boolf<FileHandle> filter, boolean open, Cons<FileHandle> 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();
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<CharSequence> text){
|
||||
private Element itemImage(TextureRegion region, Prov<CharSequence> text){
|
||||
Stack stack = new Stack();
|
||||
|
||||
Table t = new Table().left().bottom();
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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<TileEntity, Liquid> current;
|
||||
Func<TileEntity, Liquid> current;
|
||||
if(consumes.has(ConsumeType.liquid) && consumes.get(ConsumeType.liquid) instanceof ConsumeLiquid){
|
||||
Liquid liquid = consumes.<ConsumeLiquid>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<TileEntity, Bar> bar : bars.list()){
|
||||
for(Func<TileEntity, Bar> bar : bars.list()){
|
||||
table.add(bar.get(tile.entity)).growX();
|
||||
table.row();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Tile> cons){
|
||||
public void getLinkedTiles(Cons<Tile> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
|
|
|||
|
|
@ -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<Item> holder, Consumer<Item> consumer){
|
||||
public static void buildItemTable(Table table, Prov<Item> holder, Cons<Item> consumer){
|
||||
|
||||
Array<Item> 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));
|
||||
|
||||
|
|
|
|||
|
|
@ -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<AbsorbTrait> shieldConsumer = trait -> {
|
||||
private static Cons<AbsorbTrait> 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);
|
||||
|
|
|
|||
|
|
@ -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.<ItemTurretEntity>entity().ammo.peek()).item == item)));
|
||||
|
||||
table.add(image).size(8 * 4);
|
||||
|
|
|
|||
|
|
@ -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<Tile, TurretEntity> drawer = (tile, entity) -> Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||
protected BiConsumer<Tile, TurretEntity> heatDrawer = (tile, entity) -> {
|
||||
protected Cons2<Tile, TurretEntity> drawer = (tile, entity) -> Draw.rect(region, tile.drawx() + tr2.x, tile.drawy() + tr2.y, entity.rotation - 90);
|
||||
protected Cons2<Tile, TurretEntity> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
|
|
|||
|
|
@ -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<TileEntity> consume;
|
||||
private final Boolf<TileEntity> consume;
|
||||
|
||||
public ConditionalConsumePower(float usage, Predicate<TileEntity> consume){
|
||||
public ConditionalConsumePower(float usage, Boolf<TileEntity> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Tile> 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<Tile> 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<Tile> others){
|
||||
Predicate<Tile> valid = other -> other != null && other != tile && other.entity != null && other.entity.power != null &&
|
||||
private void getPotentialLinks(Tile tile, Cons<Tile> others){
|
||||
Boolf<Tile> 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<Tile> iterator){
|
||||
public static void insulators(int x, int y, int x2, int y2, Cons<Tile> 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;
|
||||
|
|
|
|||
|
|
@ -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<Tile> drawer = null;
|
||||
protected Supplier<TextureRegion[]> drawIcons = null;
|
||||
protected Cons<Tile> drawer = null;
|
||||
protected Prov<TextureRegion[]> 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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
|
|
|||
|
|
@ -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<Tile> outline = t -> {
|
||||
Cons<Tile> 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();
|
||||
|
|
|
|||
|
|
@ -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.*;
|
||||
|
|
|
|||
|
|
@ -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<Item> filter;
|
||||
public final @NonNull
|
||||
Boolf<Item> filter;
|
||||
|
||||
public ConsumeItemFilter(Predicate<Item> item){
|
||||
public ConsumeItemFilter(Boolf<Item> 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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Liquid> filter;
|
||||
public final Boolf<Liquid> filter;
|
||||
|
||||
public ConsumeLiquidFilter(Predicate<Liquid> liquid, float amount){
|
||||
public ConsumeLiquidFilter(Boolf<Liquid> 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<Liquid> list = content.liquids().select(l -> !l.isHidden() && filter.test(l));
|
||||
Array<Liquid> 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
|
||||
|
|
|
|||
|
|
@ -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<TileEntity> cons){
|
||||
public ConsumePower powerCond(float usage, Boolf<TileEntity> cons){
|
||||
return add(new ConditionalConsumePower(usage, cons));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<String, Function<TileEntity, Bar>> bars = new OrderedMap<>();
|
||||
private OrderedMap<String, Func<TileEntity, Bar>> bars = new OrderedMap<>();
|
||||
|
||||
public void add(String name, Function<TileEntity, Bar> sup){
|
||||
public void add(String name, Func<TileEntity, Bar> sup){
|
||||
bars.put(name, sup);
|
||||
}
|
||||
|
||||
|
|
@ -18,7 +18,7 @@ public class BlockBars{
|
|||
bars.remove(name);
|
||||
}
|
||||
|
||||
public Iterable<Function<TileEntity, Bar>> list(){
|
||||
public Iterable<Func<TileEntity, Bar>> list(){
|
||||
return bars.values();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Liquid> filter;
|
||||
protected Boolf<Liquid> filter;
|
||||
|
||||
public BoosterListValue(float reload, float maxUsed, float multiplier, boolean baseReload, Predicate<Liquid> filter){
|
||||
public BoosterListValue(float reload, float maxUsed, float multiplier, boolean baseReload, Boolf<Liquid> 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();
|
||||
|
|
|
|||
|
|
@ -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<Item> filter;
|
||||
private final Boolf<Item> filter;
|
||||
|
||||
public ItemFilterValue(Predicate<Item> filter){
|
||||
public ItemFilterValue(Boolf<Item> filter){
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Liquid> filter;
|
||||
private final Boolf<Liquid> filter;
|
||||
private final float amount;
|
||||
private final boolean perSecond;
|
||||
|
||||
public LiquidFilterValue(Predicate<Liquid> filter, float amount, boolean perSecond){
|
||||
public LiquidFilterValue(Boolf<Liquid> filter, float amount, boolean perSecond){
|
||||
this.filter = filter;
|
||||
this.amount = amount;
|
||||
this.perSecond = perSecond;
|
||||
|
|
@ -25,7 +25,7 @@ public class LiquidFilterValue implements StatValue{
|
|||
Array<Liquid> 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++){
|
||||
|
|
|
|||
|
|
@ -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<Runnable> dialog = Runnable::run;
|
||||
Cons<Runnable> 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())));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<SteamConnection> steamConnections = new IntMap<>(); //maps steam ID -> valid net connection
|
||||
|
||||
SteamID currentLobby, currentServer;
|
||||
Consumer<Host> lobbyCallback;
|
||||
Cons<Host> lobbyCallback;
|
||||
Runnable lobbyDoneCallback, joinCallback;
|
||||
|
||||
public SNet(NetProvider provider){
|
||||
|
|
@ -164,7 +165,7 @@ public class SNet implements SteamNetworkingCallback, SteamMatchmakingCallback,
|
|||
}
|
||||
|
||||
@Override
|
||||
public void discoverServers(Consumer<Host> callback, Runnable done){
|
||||
public void discoverServers(Cons<Host> 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<Host> valid, Consumer<Exception> failed){
|
||||
public void pingHost(String address, int port, Cons<Host> valid, Cons<Exception> failed){
|
||||
provider.pingHost(address, port, valid, failed);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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<Class<? extends Publishable>, Array<FileHandle>> workshopFiles = new ObjectMap<>();
|
||||
private ObjectMap<SteamUGCQuery, BiConsumer<Array<SteamUGCDetails>, SteamResult>> detailHandlers = new ObjectMap<>();
|
||||
private Array<Consumer<SteamPublishedFileID>> itemHandlers = new Array<>();
|
||||
private ObjectMap<SteamUGCQuery, Cons2<Array<SteamUGCDetails>, SteamResult>> detailHandlers = new ObjectMap<>();
|
||||
private Array<Cons<SteamPublishedFileID>> itemHandlers = new Array<>();
|
||||
private ObjectMap<SteamPublishedFileID, Runnable> updatedHandlers = new ObjectMap<>();
|
||||
|
||||
public SWorkshop(){
|
||||
|
|
@ -169,7 +170,7 @@ public class SWorkshop implements SteamUGCCallback{
|
|||
}, () -> p.addSteamID(sid));
|
||||
}
|
||||
|
||||
void showPublish(Consumer<SteamPublishedFileID> published){
|
||||
void showPublish(Cons<SteamPublishedFileID> 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<Array<SteamUGCDetails>, SteamResult> handler){
|
||||
void query(SteamUGCQuery query, Cons2<Array<SteamUGCDetails>, SteamResult> handler){
|
||||
Log.info("POST QUERY " + query);
|
||||
detailHandlers.put(query, handler);
|
||||
ugc.sendQueryUGCRequest(query);
|
||||
}
|
||||
|
||||
void updateItem(SteamPublishedFileID publishedFileID, Consumer<SteamUGCUpdateHandle> tagger, Runnable updated){
|
||||
void updateItem(SteamPublishedFileID publishedFileID, Cons<SteamUGCUpdateHandle> 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()));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,3 @@
|
|||
org.gradle.daemon=true
|
||||
org.gradle.jvmargs=-Xms256m -Xmx1024m
|
||||
archash=fa703e299e675a90cf32006d304fdca9305258dc
|
||||
archash=45ccffb159cce2ba17687e81c14853efa647b102
|
||||
|
|
|
|||
|
|
@ -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<FileHandle> cons){
|
||||
public void showFileChooser(boolean open, String extension, Cons<FileHandle> cons){
|
||||
UIDocumentBrowserViewController cont = new UIDocumentBrowserViewController((NSArray)null);
|
||||
|
||||
NSArray<UIBarButtonItem> 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
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public class ZoneTests{
|
|||
e.printStackTrace();
|
||||
return;
|
||||
}
|
||||
zone.rules.accept(state.rules);
|
||||
zone.rules.get(state.rules);
|
||||
ObjectSet<Item> resources = new ObjectSet<>();
|
||||
boolean hasSpawnPoint = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -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<String, String, String> processor = (key, value) -> (key + " = " + value).replace("\\", "\\\\").replace("\n", "\\n") + "\n";
|
||||
Func2<String, String, String> processor = (key, value) -> (key + " = " + value).replace("\\", "\\\\").replace("\n", "\\n") + "\n";
|
||||
|
||||
Path output = child.resolveSibling("output/" + child.getFileName());
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue