Code cleanup
This commit is contained in:
@@ -133,7 +133,7 @@ public class AndroidLauncher extends AndroidApplication{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onRequestPermissionsResult(int requestCode, String permissions[], int[] grantResults){
|
||||
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults){
|
||||
if(requestCode == PERMISSION_REQUEST_CODE){
|
||||
for(int i : grantResults){
|
||||
if(i != PackageManager.PERMISSION_GRANTED) return;
|
||||
|
||||
@@ -7,6 +7,18 @@ import java.lang.annotation.Target;
|
||||
|
||||
public class Annotations{
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface Nullable{
|
||||
|
||||
}
|
||||
|
||||
@Target(ElementType.METHOD)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface NonNull{
|
||||
|
||||
}
|
||||
|
||||
/** Marks a class as serializable.*/
|
||||
@Target(ElementType.TYPE)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
|
||||
@@ -43,7 +43,7 @@ allprojects{
|
||||
arcHash = 'git ls-remote https://github.com/Anuken/Arc.git'.execute().text.split("\t")[0]
|
||||
}catch(e){
|
||||
e.printStackTrace()
|
||||
arcHash = "-SNAPSHOT";
|
||||
arcHash = "-SNAPSHOT"
|
||||
}
|
||||
}
|
||||
return arcHash
|
||||
|
||||
@@ -184,7 +184,8 @@ builtin = Built-In
|
||||
map.delete.confirm = Are you sure you want to delete this map? This action cannot be undone!
|
||||
map.random = [accent]Random Map
|
||||
map.nospawn = This map does not have any cores for the player to spawn in! Add a[ROYAL] blue[] core to this map in the editor.
|
||||
map.nospawn.pvp = This map does not have any enemy cores for player to spawn into! Add[SCARLET] red[] cores to this map in the editor.
|
||||
map.nospawn.pvp = This map does not have any enemy cores for player to spawn into! Add[SCARLET] non-blue[] cores to this map in the editor.
|
||||
map.nospawn.attack = This map does not have any enemy cores for player to attack! Add[SCARLET] red[] cores to this map in the editor.
|
||||
map.invalid = Error loading map: corrupted or invalid map file.
|
||||
editor.brush = Brush
|
||||
editor.openin = Open In Editor
|
||||
|
||||
@@ -8,7 +8,10 @@ import io.anuke.arc.graphics.GL20;
|
||||
import io.anuke.arc.graphics.g2d.Draw;
|
||||
import io.anuke.arc.graphics.g2d.TextureAtlas;
|
||||
import io.anuke.arc.input.KeyCode;
|
||||
import io.anuke.arc.util.*;
|
||||
import io.anuke.arc.util.BufferUtils;
|
||||
import io.anuke.arc.util.Interval;
|
||||
import io.anuke.arc.util.Strings;
|
||||
import io.anuke.arc.util.Time;
|
||||
import io.anuke.mindustry.content.Mechs;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Effects;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.core;
|
||||
|
||||
import io.anuke.annotations.Annotations.Nullable;
|
||||
import io.anuke.arc.ApplicationListener;
|
||||
import io.anuke.arc.Core;
|
||||
import io.anuke.arc.Events;
|
||||
@@ -96,11 +97,11 @@ public class World implements ApplicationListener{
|
||||
return tiles == null ? 0 : tiles[0].length;
|
||||
}
|
||||
|
||||
public Tile tile(int pos){
|
||||
public @Nullable Tile tile(int pos){
|
||||
return tiles == null ? null : tile(Pos.x(pos), Pos.y(pos));
|
||||
}
|
||||
|
||||
public Tile tile(int x, int y){
|
||||
public @Nullable Tile tile(int x, int y){
|
||||
if(tiles == null){
|
||||
return null;
|
||||
}
|
||||
@@ -112,7 +113,7 @@ public class World implements ApplicationListener{
|
||||
return tiles[x][y];
|
||||
}
|
||||
|
||||
public Tile tileWorld(float x, float y){
|
||||
public @Nullable Tile tileWorld(float x, float y){
|
||||
return tile(Math.round(x / tilesize), Math.round(y / tilesize));
|
||||
}
|
||||
|
||||
@@ -271,6 +272,11 @@ public class World implements ApplicationListener{
|
||||
if(invalidMap){
|
||||
ui.showError("$map.nospawn.pvp");
|
||||
}
|
||||
}else if(!state.rules.waves){ //pvp maps need two cores to be valid
|
||||
invalidMap = state.teams.get(waveTeam).cores.isEmpty();
|
||||
if(invalidMap){
|
||||
ui.showError("$map.nospawn.attack");
|
||||
}
|
||||
}
|
||||
}else{
|
||||
invalidMap = true;
|
||||
|
||||
@@ -233,7 +233,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
Tile tile = editor.tile(x, y);
|
||||
DummyTile write = writeTiles[x][y];
|
||||
|
||||
tile.setRotation((byte)write.rotation);
|
||||
tile.setRotation(write.rotation);
|
||||
tile.setFloor((Floor)content.block(write.floor));
|
||||
tile.setBlock(content.block(write.block));
|
||||
tile.setTeam(Team.all[write.team]);
|
||||
|
||||
@@ -140,7 +140,7 @@ public class MapRenderer implements Disposable{
|
||||
offsetX = tilesize/2f - region.getWidth()/2f * Draw.scl;
|
||||
offsetY = tilesize/2f - region.getHeight()/2f * Draw.scl;
|
||||
}else if(wall == Blocks.air && tile.ore() != null){
|
||||
region = tile.ore().editorVariantRegions()[Mathf.randomSeed(idxWall, 0, tile.ore().editorVariantRegions().length-1)];;
|
||||
region = tile.ore().editorVariantRegions()[Mathf.randomSeed(idxWall, 0, tile.ore().editorVariantRegions().length-1)];
|
||||
}else{
|
||||
region = Core.atlas.find("clear-editor");
|
||||
}
|
||||
|
||||
@@ -156,11 +156,11 @@ public class Effects{
|
||||
}
|
||||
}
|
||||
|
||||
public static interface EffectProvider{
|
||||
public interface EffectProvider{
|
||||
void createEffect(Effect effect, Color color, float x, float y, float rotation, Object data);
|
||||
}
|
||||
|
||||
public static interface EffectRenderer{
|
||||
public interface EffectRenderer{
|
||||
void render(EffectContainer effect);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -308,25 +308,20 @@ public abstract class InputHandler implements InputProcessor{
|
||||
}
|
||||
}
|
||||
|
||||
public boolean cursorNear(){
|
||||
return true;
|
||||
}
|
||||
|
||||
public void tryPlaceBlock(int x, int y){
|
||||
if(block != null && validPlace(x, y, block, rotation) && cursorNear()){
|
||||
if(block != null && validPlace(x, y, block, rotation)){
|
||||
placeBlock(x, y, block, rotation);
|
||||
}
|
||||
}
|
||||
|
||||
public void tryBreakBlock(int x, int y){
|
||||
if(cursorNear() && validBreak(x, y)){
|
||||
if(validBreak(x, y)){
|
||||
breakBlock(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean validPlace(int x, int y, Block type, int rotation){
|
||||
return Build.validPlace(player.getTeam(), x, y, type, rotation) &&
|
||||
Mathf.dst(player.x, player.y, x * tilesize, y * tilesize) < Player.placeDistance;
|
||||
return Build.validPlace(player.getTeam(), x, y, type, rotation);
|
||||
}
|
||||
|
||||
public boolean validBreak(int x, int y){
|
||||
|
||||
@@ -67,10 +67,7 @@ public class PowerCrafter extends Block{
|
||||
if(outputItem != null && tile.entity.items.get(outputItem) >= itemCapacity){
|
||||
return false;
|
||||
}
|
||||
if(outputLiquid != null && tile.entity.liquids.get(outputLiquid) >= liquidCapacity - 0.01f){
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
return outputLiquid == null || !(tile.entity.liquids.get(outputLiquid) >= liquidCapacity - 0.01f);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -169,10 +169,10 @@ public class ItemLiquidGeneratorTests extends PowerTestFixture{
|
||||
float currentDuration = 0.0f;
|
||||
while((currentDuration += Time.delta()) <= fakeItemDuration){
|
||||
generator.update(tile);
|
||||
assertEquals(expectedEfficiency, entity.productionEfficiency, "Duration: " + String.valueOf(currentDuration));
|
||||
assertEquals(expectedEfficiency, entity.productionEfficiency, "Duration: " + currentDuration);
|
||||
}
|
||||
generator.update(tile);
|
||||
assertEquals(0.0f, entity.productionEfficiency, "Duration: " + String.valueOf(currentDuration));
|
||||
assertEquals(0.0f, entity.productionEfficiency, "Duration: " + currentDuration);
|
||||
}
|
||||
|
||||
enum InputType{
|
||||
|
||||
@@ -152,7 +152,7 @@ task scaleSprites4x(){
|
||||
J = getRGB(x, y + 2),
|
||||
K = getRGB(x - 2, y),
|
||||
L = getRGB(x + 2, y),
|
||||
M = getRGB(x, y - 2);
|
||||
M = getRGB(x, y - 2)
|
||||
|
||||
if (B==D && B!=F && D!=H && (E!=A || E==C || E==G || A==J || A==K)) p1 = B
|
||||
if (B==F & B!=D & F!=H && (E!=C || E==A || E==I || C==J || C==L)) p2 = F
|
||||
|
||||
@@ -30,7 +30,7 @@ public class BundleLauncher {
|
||||
Log.info("Parsing bundle: {0}", child);
|
||||
|
||||
OrderedMap<String, String> other = new OrderedMap<>();
|
||||
PropertiesUtils.load(other, Files.newBufferedReader(child, StandardCharsets.UTF_8));
|
||||
PropertiesUtils.load(other, Files.newBufferedReader(child, Strings.utf8));
|
||||
removals.clear();
|
||||
|
||||
for(String key : other.orderedKeys()){
|
||||
@@ -68,7 +68,7 @@ public class BundleLauncher {
|
||||
other.remove(key);
|
||||
}
|
||||
|
||||
Files.write(child, result.toString().getBytes(StandardCharsets.UTF_8));
|
||||
Files.write(child, result.toString().getBytes(Strings.utf8));
|
||||
|
||||
}catch (IOException e){
|
||||
throw new RuntimeException(e);
|
||||
|
||||
Reference in New Issue
Block a user