Bugfixes, minor optimizations

This commit is contained in:
Anuken
2018-07-11 19:57:27 -04:00
parent b4a20c8fcb
commit d89feb2c75
8 changed files with 34 additions and 28 deletions

View File

@@ -9,7 +9,7 @@ buildscript {
dependencies { dependencies {
classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.0' classpath 'com.mobidevelop.robovm:robovm-gradle-plugin:2.3.0'
classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6' classpath 'de.richsource.gradle.plugins:gwt-gradle-plugin:0.6'
classpath 'com.android.tools.build:gradle:3.1.0' classpath 'com.android.tools.build:gradle:3.1.3'
classpath "com.badlogicgames.gdx:gdx-tools:1.9.8" classpath "com.badlogicgames.gdx:gdx-tools:1.9.8"
} }
} }

View File

@@ -662,6 +662,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
/**Resets all values of the player.*/ /**Resets all values of the player.*/
public void reset(){ public void reset(){
status.clear();
team = Team.blue; team = Team.blue;
inventory.clear(); inventory.clear();
placeQueue.clear(); placeQueue.clear();

View File

@@ -19,6 +19,9 @@ import static io.anuke.mindustry.Vars.*;
public class Units { public class Units {
private static Rectangle rect = new Rectangle(); private static Rectangle rect = new Rectangle();
private static Rectangle hitrect = new Rectangle(); private static Rectangle hitrect = new Rectangle();
private static Unit result;
private static float cdist;
private static boolean boolResult;
/**Validates a target. /**Validates a target.
* @param target The target to validate * @param target The target to validate
@@ -49,20 +52,20 @@ public class Units {
rect.setSize(type.size * tilesize, type.size * tilesize); rect.setSize(type.size * tilesize, type.size * tilesize);
rect.setCenter(tile.drawx(), tile.drawy()); rect.setCenter(tile.drawx(), tile.drawy());
boolean[] value = new boolean[1]; boolResult = false;
Units.getNearby(rect, unit -> { Units.getNearby(rect, unit -> {
if (value[0]) return; if (boolResult) return;
if (!unit.isFlying()) { if (!unit.isFlying()) {
unit.getHitbox(hitrect); unit.getHitbox(hitrect);
if (hitrect.overlaps(rect)) { if (hitrect.overlaps(rect)) {
value[0] = true; boolResult = true;
} }
} }
}); });
return value[0]; return boolResult;
} }
/**Returns whether there are any entities on this tile, with the hitbox expanded.*/ /**Returns whether there are any entities on this tile, with the hitbox expanded.*/
@@ -138,8 +141,8 @@ public class Units {
/**Returns the closest enemy of this team. Filter by predicate.*/ /**Returns the closest enemy of this team. Filter by predicate.*/
public static Unit getClosestEnemy(Team team, float x, float y, float range, Predicate<Unit> predicate){ public static Unit getClosestEnemy(Team team, float x, float y, float range, Predicate<Unit> predicate){
Unit[] result = {null}; result = null;
float[] cdist = {0}; cdist = 0f;
rect.setSize(range*2f).setCenter(x, y); rect.setSize(range*2f).setCenter(x, y);
@@ -149,20 +152,20 @@ public class Units {
float dist = Vector2.dst(e.x, e.y, x, y); float dist = Vector2.dst(e.x, e.y, x, y);
if (dist < range) { if (dist < range) {
if (result[0] == null || dist < cdist[0]) { if (result == null || dist < cdist) {
result[0] = e; result = e;
cdist[0] = dist; cdist = dist;
} }
} }
}); });
return result[0]; return result;
} }
/**Returns the closest ally of this team. Filter by predicate.*/ /**Returns the closest ally of this team. Filter by predicate.*/
public static Unit getClosest(Team team, float x, float y, float range, Predicate<Unit> predicate){ public static Unit getClosest(Team team, float x, float y, float range, Predicate<Unit> predicate){
Unit[] result = {null}; result = null;
float[] cdist = {0}; cdist = 0f;
rect.setSize(range*2f).setCenter(x, y); rect.setSize(range*2f).setCenter(x, y);
@@ -172,14 +175,14 @@ public class Units {
float dist = Vector2.dst(e.x, e.y, x, y); float dist = Vector2.dst(e.x, e.y, x, y);
if (dist < range) { if (dist < range) {
if (result[0] == null || dist < cdist[0]) { if (result == null || dist < cdist) {
result[0] = e; result = e;
cdist[0] = dist; cdist = dist;
} }
} }
}); });
return result[0]; return result;
} }
/**Iterates over all units in a rectangle.*/ /**Iterates over all units in a rectangle.*/

View File

@@ -66,16 +66,15 @@ public enum CacheLayer {
protected void beginShader(){ protected void beginShader(){
//renderer.getBlocks().endFloor(); //renderer.getBlocks().endFloor();
renderer.effectSurface.getBuffer().begin(); renderer.effectSurface.getBuffer().bind();
Graphics.clear(Color.CLEAR); Graphics.clear(Color.CLEAR);
//renderer.getBlocks().beginFloor(); //renderer.getBlocks().beginFloor();
} }
public void endShader(Shader shader){ public void endShader(Shader shader){
renderer.getBlocks().endFloor(); renderer.getBlocks().endFloor();
renderer.effectSurface.getBuffer().end();
renderer.pixelSurface.getBuffer().begin(); renderer.pixelSurface.getBuffer().bind();
Graphics.shader(shader); Graphics.shader(shader);
Graphics.begin(); Graphics.begin();

View File

@@ -45,7 +45,7 @@ public class UnlocksDialog extends FloatingDialog {
table.table(list -> { table.table(list -> {
list.left(); list.left();
int maxWidth = UIUtils.portrait() ? 7 : 14; int maxWidth = UIUtils.portrait() ? 7 : 13;
int size = 8*6; int size = 8*6;
int count = 0; int count = 0;

View File

@@ -17,8 +17,8 @@ public class OverflowGate extends Splitter {
if(dir == -1) return null; if(dir == -1) return null;
Tile to = dest.getNearby(dir); Tile to = dest.getNearby(dir);
if(!(to.block().acceptItem(item, to, dest) && if(!(to.block().acceptItem(item, to, dest) ||
!(to.block().instantTransfer && source.block().instantTransfer))){ (to.block().instantTransfer && source.block().instantTransfer))){
Tile a = dest.getNearby(Mathf.mod(dir - 1, 4)); Tile a = dest.getNearby(Mathf.mod(dir - 1, 4));
Tile b = dest.getNearby(Mathf.mod(dir + 1, 4)); Tile b = dest.getNearby(Mathf.mod(dir + 1, 4));
boolean ac = !(a.block().instantTransfer && source.block().instantTransfer) && boolean ac = !(a.block().instantTransfer && source.block().instantTransfer) &&
@@ -26,6 +26,10 @@ public class OverflowGate extends Splitter {
boolean bc = !(b.block().instantTransfer && source.block().instantTransfer) && boolean bc = !(b.block().instantTransfer && source.block().instantTransfer) &&
b.block().acceptItem(item, b, dest); b.block().acceptItem(item, b, dest);
if(!ac && !bc){
return null;
}
if(ac && !bc){ if(ac && !bc){
to = a; to = a;
}else if(bc && !ac){ }else if(bc && !ac){

View File

@@ -131,9 +131,9 @@ public class WorldGenerator {
for(int i = ores.size-1; i >= 0; i --){ for(int i = ores.size-1; i >= 0; i --){
OreEntry entry = ores.get(i); OreEntry entry = ores.get(i);
if(entry.noise.octaveNoise2D(2, 0.7, 1f / (2 + i*2), x, y)/2f + if(entry.noise.octaveNoise2D(1, 0.7, 1f / (4 + i*2), x, y)/4f +
entry.ridge.getValue(x, y, 1f / (28 + i*4)) >= 2.0f - entry.frequency*4.0f Math.abs(0.5f-entry.noise.octaveNoise2D(2, 0.7, 1f / (50 + i*2), x, y)) > 0.5f &&
&& entry.ridge.getValue(x+9999, y+9999, 1f/100f) > 0.4){ Math.abs(0.5f-entry.noise.octaveNoise2D(1, 1, 1f / (55 + i*4), x, y)) > 0.25f){
tile.setFloor((Floor) OreBlocks.get(tile.floor(), entry.item)); tile.setFloor((Floor) OreBlocks.get(tile.floor(), entry.item));
break; break;
} }
@@ -166,7 +166,7 @@ public class WorldGenerator {
Block wall = Blocks.air; Block wall = Blocks.air;
double elevation = sim.octaveNoise2D(3, 0.5, 1f/100, x, y) * 4.1 - 1; double elevation = sim.octaveNoise2D(3, 0.5, 1f/100, x, y) * 4.1 - 1;
double temp = sim3.octaveNoise2D(7, 0.53, 1f/320f, x, y); double temp = sim3.octaveNoise2D(7, 0.54, 1f/320f, x, y);
double r = sim2.octaveNoise2D(1, 0.6, 1f/70, x, y); double r = sim2.octaveNoise2D(1, 0.6, 1f/70, x, y);
double edgeDist = Math.max(width/2, height/2) - Math.max(Math.abs(x - width/2), Math.abs(y - height/2)); double edgeDist = Math.max(width/2, height/2) - Math.max(Math.abs(x - width/2), Math.abs(y - height/2));

View File

@@ -1,6 +1,5 @@
org.gradle.daemon=true org.gradle.daemon=true
org.gradle.jvmargs=-Xms512m -Xmx1536m org.gradle.jvmargs=-Xms512m -Xmx1536m
org.gradle.configureondemand=true
android.enableAapt2=true android.enableAapt2=true
android.injected.build.model.only.versioned=3 android.injected.build.model.only.versioned=3
android.enableD8=true android.enableD8=true