1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-09-11 08:15:35 +03:00

Code cleanup

This commit is contained in:
Anuken 2018-10-06 11:56:39 -04:00
parent 0ce226d0c9
commit fd107ab5b8
48 changed files with 94 additions and 195 deletions

View File

@ -1,7 +1,7 @@
![Imgur](https://i.imgur.com/w4N0yhv.png)
[![Build Status](https://travis-ci.org/Anuken/Mindustry.svg?branch=master)](https://travis-ci.org/Anuken/Mindustry)
[![Discord](https://img.shields.io/discord/391020510269669376.svg)](discord.gg/mindustry)
[![Discord](https://img.shields.io/discord/391020510269669376.svg)](https://discord.gg/mindustry)
A pixelated sandbox tower defense game made using [LibGDX](https://libgdx.badlogicgames.com/). Winner of the [GDL Metal Monstrosity Jam](https://itch.io/jam/gdl---metal-monstrosity-jam).

View File

@ -31,8 +31,8 @@ task deploy(type: Copy){
dependsOn "assembleRelease"
from "build/outputs/apk/google/release/android-google-release.apk"
into "../deploy/";
rename ("android-google-release.apk", appName + "-android-" + getVersionString() + ".apk");
into "../deploy/"
rename ("android-google-release.apk", appName + "-android-" + getVersionString() + ".apk")
}
android {
@ -100,7 +100,7 @@ android {
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
}else{
println("No keystore info property found!");
println("No keystore info property found!")
}
}
}
@ -115,11 +115,11 @@ android {
// the natives configuration, and extracts them to the proper libs/ folders
// so they get packed with the APK.
task copyAndroidNatives() {
file("libs/armeabi/").mkdirs();
file("libs/armeabi-v7a/").mkdirs();
file("libs/arm64-v8a/").mkdirs();
file("libs/x86_64/").mkdirs();
file("libs/x86/").mkdirs();
file("libs/armeabi/").mkdirs()
file("libs/armeabi-v7a/").mkdirs()
file("libs/arm64-v8a/").mkdirs()
file("libs/x86_64/").mkdirs()
file("libs/x86/").mkdirs()
configurations.natives.files.each { jar ->
def outputDir = null
@ -181,7 +181,7 @@ eclipse {
project {
name = appName + "-android"
natures 'com.android.ide.eclipse.adt.AndroidNature'
buildCommands.clear();
buildCommands.clear()
buildCommand "com.android.ide.eclipse.adt.ResourceManagerBuilder"
buildCommand "com.android.ide.eclipse.adt.PreCompilerBuilder"
buildCommand "org.eclipse.jdt.core.javabuilder"
@ -191,14 +191,14 @@ eclipse {
// sets up the Android Idea project, using the old Ant based build.
idea {
module {
sourceDirs += file("src");
sourceDirs += file("src")
scopes = [COMPILE: [plus: [project.configurations.compile]]]
iml {
withXml {
def node = it.asNode()
def builder = NodeBuilder.newInstance();
builder.current = node;
def builder = NodeBuilder.newInstance()
builder.current = node
builder.component(name: "FacetManager") {
facet(type: "android", name: "Android") {
configuration {

View File

@ -59,7 +59,7 @@ public class AndroidTextFieldDialog{
while(!isBuild){
try{
Thread.sleep(10);
}catch(InterruptedException e){
}catch(InterruptedException ignored){
}
}

View File

@ -46,13 +46,10 @@ public class DonationsActivity extends FragmentActivity{
public void onStart(){
super.onStart();
Button b = ((Button) findViewById(org.sufficientlysecure.donations.R.id.donations__google_android_market_donate_button));
b.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View view){
donationsFragment.donateGoogleOnClick(donationsFragment.getView());
b.setEnabled(false);
}
Button b = findViewById(org.sufficientlysecure.donations.R.id.donations__google_android_market_donate_button);
b.setOnClickListener(view -> {
donationsFragment.donateGoogleOnClick(donationsFragment.getView());
b.setEnabled(false);
});
}
@ -64,7 +61,7 @@ public class DonationsActivity extends FragmentActivity{
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data){
super.onActivityResult(requestCode, resultCode, data);
Button b = ((Button) findViewById(org.sufficientlysecure.donations.R.id.donations__google_android_market_donate_button));
Button b = findViewById(org.sufficientlysecure.donations.R.id.donations__google_android_market_donate_button);
b.setEnabled(true);
FragmentManager fragmentManager = getSupportFragmentManager();

View File

@ -27,7 +27,7 @@ allprojects {
appName = 'Mindustry'
gdxVersion = '1.9.8'
roboVMVersion = '2.3.0'
uCoreVersion = 'e0789c76198a90cb115e12f03d44ddec35b35a6e'
uCoreVersion = '4bee866809b94c7fac6c83620b05bed4650cca26'
getVersionString = {
String buildVersion = getBuildVersion()
@ -47,10 +47,10 @@ allprojects {
def output = 'en\n'
def bundles = new File(project(':core').projectDir, 'assets/bundles/')
bundles.listFiles().each { other ->
if(other.name == "bundle.properties") return;
if(other.name == "bundle.properties") return
output += other.name.substring("bundle".length() + 1, other.name.lastIndexOf('.')) + "\n"
}
new File(project(':core').projectDir, 'assets/locales').text = output;
new File(project(':core').projectDir, 'assets/locales').text = output
}
writeVersion = {
@ -59,7 +59,7 @@ allprojects {
try{
pfile.createNewFile()
}catch (Exception e){}
}catch (Exception ignored){}
if(pfile.exists()) {

View File

@ -629,7 +629,7 @@ tutorial.begin=Votre mission, si vous l'acceptez est de détruire [LIGHT_GRAY]l'
tutorial.drill=Le minage manuel est inefficace.\n[accent]Des foreuses[]peuvent miner automatiquement.\nPlacez-en une sur un filon de cuivre.
tutorial.conveyor=[accent]Les Tapis roulants[] sont utilisés pour transporter des objets jusqu'à la base.\nFaites une ligne de tapis roulants de la foreuse à la base .
tutorial.morecopper=Plus de cuivre est demandé .\n\nRécupérez le soit manuellement soit construisez plus de foreuses.
tutorial.turret=Des constructions défensives doivent être construites pour repousser [LIGHT_GRAY]les ennemis[].\Construisez une tourelle "duo" près de votre base.
tutorial.turret=Des constructions défensives doivent être construites pour repousser [LIGHT_GRAY]les ennemis[].Construisez une tourelle "duo" près de votre base.
tutorial.drillturret=Les tourelles "Duo" ont besoin de [accent]munitions en cuivre[] pour tirer.\nPlacez une foreuse à côté de la tourelle pour l'approvisionner avec du cuivre.
tutorial.waves=Les [LIGHT_GRAY]ennemies[] approchent.\n\nDéfendez votre base pour 2 vagues. Construisez plus de tourelles.
tutorial.lead=Plus de minerais sont forables. Explorez et minez du[accent] Plomb[].\n\nRamenez votre unité à la base pour transférer les ressources.
@ -644,5 +644,5 @@ tutorial.nodelink=L'énergie peut être transféré à l'aide de blocs utilisant
tutorial.silicon=Du silicone est maintenant produit. Obtenez-en.\n\nAugmenter la production est recommandé.
tutorial.daggerfactory=Construire [accent]une usine de "Poignards" []est recommandé .\n\nElle sera utilisée pour produire des unités d'attaque.
tutorial.router=Les usines ont besoin de ressources pour fonctionner.\nCréez un routeur pour séparer les objets.
tutorial.dagger=Reliez des transmetteurs énergétiques à l'usine.\nUne fois que les conditions seront remplies , un mécha sera créé.\n\Construisez autant de foreuses, de générateurs et de tapis roulants que nécessaire.
tutorial.dagger=Reliez des transmetteurs énergétiques à l'usine.\nUne fois que les conditions seront remplies , un mécha sera créé.\nConstruisez autant de foreuses, de générateurs et de tapis roulants que nécessaire.
tutorial.battle=[LIGHT_GRAY]L'Ennemi[] a révélé sa base .\nDétruisez la avec votre unité et des méchas "Poignard".

View File

@ -136,8 +136,7 @@ public class ContentLoader{
}
//set up ID mapping
for(int k = 0; k < contentMap.length; k ++){
Array<Content> arr = contentMap[k];
for(Array<Content> arr : contentMap){
for(int i = 0; i < arr.size; i++){
int id = arr.get(i).id;
if(id < 0) id += 256;

View File

@ -19,8 +19,7 @@ public abstract class Platform {
public String format(Date date){return "invalid";}
/**Format a number by adding in commas or periods where needed.*/
public String format(int number){return "invalid";}
/**Show a native error dialog.*/
public void showError(String text){}
/**Add a text input dialog that should show up after the field is tapped.*/
public void addDialog(TextField field){
addDialog(field, 16);

View File

@ -180,11 +180,6 @@ public class UI extends SceneModule{
loadfrag.build(group);
}
@Override
public boolean hasMouse(){
return super.hasMouse();
}
@Override
public void resize(int width, int height){
super.resize(width, height);

View File

@ -102,7 +102,7 @@ public enum EditorTool{
byte brt = Bits.packByte((byte) editor.getDrawRotation(), (byte) editor.getDrawTeam().ordinal());
dest = floor ? bf : bw;
byte draw = (byte) editor.getDrawBlock().id;
byte draw = editor.getDrawBlock().id;
if(dest == draw){
return;

View File

@ -48,7 +48,7 @@ public class MapEditor{
if(clear){
for(int x = 0; x < map.width(); x++){
for(int y = 0; y < map.height(); y++){
map.write(x, y, DataPosition.floor, (byte) Blocks.stone.id);
map.write(x, y, DataPosition.floor, Blocks.stone.id);
}
}
}
@ -277,7 +277,7 @@ public class MapEditor{
map = new MapTileData(width, height);
for(int x = 0; x < map.width(); x++){
for(int y = 0; y < map.height(); y++){
map.write(x, y, DataPosition.floor, (byte) Blocks.stone.id);
map.write(x, y, DataPosition.floor, Blocks.stone.id);
}
}
renderer.resize(width, height);

View File

@ -12,14 +12,14 @@ import io.anuke.ucore.entities.impl.BaseBulletType;
import io.anuke.ucore.util.Translator;
public abstract class BulletType extends Content implements BaseBulletType<Bullet>{
public float lifetime = 100;
public float speed = 1f;
public float damage = 1;
public float lifetime;
public float speed;
public float damage;
public float hitsize = 4;
public float drawSize = 20f;
public float drag = 0f;
public boolean pierce;
public Effect hiteffect = null, despawneffect = null;
public Effect hiteffect, despawneffect;
/**Knockback in velocity.*/
public float knockback;

View File

@ -32,7 +32,6 @@ import io.anuke.ucore.util.SeedRandom;
import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;
import static io.anuke.mindustry.Vars.bulletGroup;
import static io.anuke.mindustry.Vars.world;
@ -161,14 +160,10 @@ public class Lightning extends SolidEntity implements Poolable, DrawTrait, SyncT
}
@Override
public void write(DataOutput data) throws IOException{
}
public void write(DataOutput data){}
@Override
public void read(DataInput data, long time) throws IOException{
}
public void read(DataInput data, long time){}
@Override
public float lifetime(){

View File

@ -334,16 +334,6 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
}
@Override
public void drawUnder(){
}
@Override
public void drawOver(){
}
@Override
public float getMaxVelocity(){
return type.maxVelocity;

View File

@ -39,7 +39,6 @@ import static io.anuke.mindustry.Vars.*;
public class Drone extends FlyingUnit implements BuilderTrait{
protected static float discoverRange = 120f;
protected static boolean initialized;
protected static int timerRepairEffect = timerIndex++;
protected Item targetItem;
@ -234,17 +233,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{
}
};
{
initEvents();
}
/**
* Initialize placement event notifier system.
* Static initialization is to be avoided, thus, this is done lazily.
*/
private static void initEvents(){
if(initialized) return;
static{
Events.on(BlockBuildEvent.class, event -> {
EntityGroup<BaseUnit> group = unitGroups[event.team.ordinal()];
@ -257,8 +246,6 @@ public class Drone extends FlyingUnit implements BuilderTrait{
}
}
});
initialized = true;
}
private void notifyPlaced(BuildEntity entity){

View File

@ -31,8 +31,7 @@ public class Unlocks{
* @return whether or not this content was newly unlocked.
*/
public boolean unlockContent(UnlockableContent content){
if(rootSet().isUnlocked(content)) return false;
return currentSet().unlockContent(content);
return !rootSet().isUnlocked(content) && currentSet().unlockContent(content);
}
private ContentUnlockSet currentSet(){
@ -76,7 +75,7 @@ public class Unlocks{
public void load(){
sets.clear();
ObjectMap<String, ObjectMap<ContentType, Array<String>>> result = Settings.getObject("content-sets", ObjectMap.class, () -> new ObjectMap<>());
ObjectMap<String, ObjectMap<ContentType, Array<String>>> result = Settings.getObject("content-sets", ObjectMap.class, ObjectMap::new);
for(Entry<String, ObjectMap<ContentType, Array<String>>> outer : result.entries()){
ContentUnlockSet cset = new ContentUnlockSet();

View File

@ -252,7 +252,7 @@ public class MobileInput extends InputHandler implements GestureListener{
act.addImageButton("icon-arrow", 16 * 2f, () -> rotation = Mathf.mod(rotation + 1, 4))
.update(i -> i.getImage().setRotationOrigin(rotation * 90, Align.center))
.disabled(i -> recipe == null || !recipe.result.rotate);
}).visible(() -> mode != none).touchable(Touchable.enabled);;
}).visible(() -> mode != none).touchable(Touchable.enabled);
c.row();
@ -267,7 +267,7 @@ public class MobileInput extends InputHandler implements GestureListener{
showGuide("deconstruction");
}
}).update(l -> l.setChecked(mode == breaking));
}).margin(5).touchable(Touchable.enabled);;
}).margin(5).touchable(Touchable.enabled);
c.table("pane", cancel -> {
cancel.defaults().size(60f);

View File

@ -74,12 +74,12 @@ public class MapIO{
Block block = ColorMapper.getByColor(pixmap.getPixel(y, pixmap.getWidth() - 1 - x));
if(block == null){
data.write(x, y, DataPosition.floor, (byte) Blocks.stone.id);
data.write(x, y, DataPosition.floor, Blocks.stone.id);
}else{
data.write(x, y, DataPosition.floor, (byte) block.id);
data.write(x, y, DataPosition.floor, block.id);
}
data.write(x, y, DataPosition.wall, (byte) Blocks.air.id);
data.write(x, y, DataPosition.wall, Blocks.air.id);
}
}

View File

@ -55,21 +55,19 @@ public abstract class SaveFileVersion{
Array<Content>[] map = content.getContentMap();
int mappable = 0;
for(int i =0; i < map.length; i ++){
Array<Content> arr = map[i];
for(Array<Content> arr : map){
if(arr.size > 0 && arr.first() instanceof MappableContent){
mappable ++;
mappable++;
}
}
stream.writeByte(mappable);
for(int i =0; i < map.length; i ++){
Array<Content> arr = map[i];
for(Array<Content> arr : map){
if(arr.size > 0 && arr.first() instanceof MappableContent){
stream.writeByte(arr.first().getContentType().ordinal());
stream.writeShort(arr.size);
for(Content c : arr){
stream.writeUTF(((MappableContent)c).getContentName());
stream.writeUTF(((MappableContent) c).getContentName());
}
}
}

View File

@ -152,7 +152,7 @@ public class TypeIO{
@WriteClass(Block.class)
public static void writeBlock(ByteBuffer buffer, Block block){
buffer.put((byte) block.id);
buffer.put(block.id);
}
@ReadClass(Block.class)
@ -278,7 +278,7 @@ public class TypeIO{
@WriteClass(Liquid.class)
public static void writeLiquid(ByteBuffer buffer, Liquid liquid){
buffer.put((byte) liquid.id);
buffer.put(liquid.id);
}
@ReadClass(Liquid.class)
@ -298,7 +298,7 @@ public class TypeIO{
@WriteClass(BulletType.class)
public static void writeBulletType(ByteBuffer buffer, BulletType type){
buffer.put((byte) type.id);
buffer.put(type.id);
}
@ReadClass(BulletType.class)
@ -308,7 +308,7 @@ public class TypeIO{
@WriteClass(Item.class)
public static void writeItem(ByteBuffer buffer, Item item){
buffer.put(item == null ? -1 : (byte) item.id);
buffer.put(item == null ? -1 : item.id);
}
@ReadClass(Item.class)
@ -319,7 +319,7 @@ public class TypeIO{
@WriteClass(Recipe.class)
public static void writeRecipe(ByteBuffer buffer, Recipe recipe){
buffer.put((byte) recipe.id);
buffer.put(recipe.id);
}
@ReadClass(Recipe.class)

View File

@ -159,7 +159,7 @@ public class Maps implements Disposable{
}
}else{
customMapNames = Settings.getObject("custom-maps", Array.class, () -> new Array<>());
customMapNames = Settings.getObject("custom-maps", Array.class, Array::new);
for(String name : customMapNames){
try{

View File

@ -16,35 +16,42 @@ import static io.anuke.mindustry.Vars.mobile;
public class SectorPresets{
private final GridMap<SectorPreset> presets = new GridMap<SectorPreset>(){{
//base tutorial mission
put(0, 0, new SectorPreset(TutorialSector.getMissions(), Array.with(Items.copper), 1));
put(0, 0, new SectorPreset(TutorialSector.getMissions(), 1));
//water mission
put(-2, 0, new SectorPreset(Array.with(), Array.with(Items.copper), 1));
put(-2, 0, new SectorPreset(Array.with(), 1));
//command center mission
//TODO generate enemy base
//TODO make 2x2
//TODO more gen info
put(0, 1, new SectorPreset(Structs.array(new BlockMission(UnitBlocks.daggerFactory), Missions.blockRecipe(UnitBlocks.commandCenter),
new CommandMission(UnitCommand.retreat), new CommandMission(UnitCommand.attack), new BattleMission()), Array.with(Items.copper), 1));
new CommandMission(UnitCommand.retreat), new CommandMission(UnitCommand.attack), new BattleMission()), 2));
//reconstructor mission
put(0, -1, new SectorPreset(Structs.array(Missions.blockRecipe(mobile ? UpgradeBlocks.tridentPad : UpgradeBlocks.deltaPad),
new MechMission(Mechs.delta)), Array.with(Items.copper), 1));
new MechMission(Mechs.delta)), 1));
//oil mission
put(1, 0, new SectorPreset(Array.with(), Array.with(Items.copper), 1));
put(1, 0, new SectorPreset(Array.with(), 1));
}};
private final GridMap<Array<Item>> orePresets = new GridMap<Array<Item>>(){{
put(0, 0, Array.with(Items.copper));
put(1, 0, Array.with(Items.copper, Items.lead, Items.coal));
}};
public Array<Item> getOres(int x, int y){
return orePresets.get(x, y);
}
public SectorPreset get(int x, int y){
return presets.get(x, y);
}
public static class SectorPreset{
public final Array<Mission> missions;
public final Array<Item> ores;
public final int size;
public SectorPreset(Array<Mission> missions, Array<Item> ores, int size){
public SectorPreset(Array<Mission> missions, int size){
this.missions = missions;
this.ores = ores;
this.size = size;
}

View File

@ -207,12 +207,7 @@ public class Sectors{
}
public Array<Item> getOres(int x, int y){
if(x == 0 && y == 0){
return Array.with(Items.copper);
}else if(x == 1 && y == 0){
return Array.with(Items.copper, Items.lead, Items.coal);
}
return Array.with(Items.copper);
return presets.getOres(x, y) == null ? Array.with(Items.copper) : presets.getOres(x, y);
}
/**Unlocks a sector. This shows nearby sectors.*/
@ -263,7 +258,7 @@ public class Sectors{
}
grid.clear();
Array<Sector> out = Settings.getObject("sectors", Array.class, () -> new Array<>());
Array<Sector> out = Settings.getObject("sectors", Array.class, Array::new);
for(Sector sector : out){
createTexture(sector);
@ -297,6 +292,7 @@ public class Sectors{
if(presets.get(sector.x, sector.y) != null){
SectorPreset p = presets.get(sector.x, sector.y);
sector.missions.addAll(p.missions);
sector.width = sector.height = p.size;
}else{
genMissions(sector);
}

View File

@ -276,8 +276,8 @@ public class Administration{
}
private void load(){
playerInfo = Settings.getObject("player-info", ObjectMap.class, () -> new ObjectMap<>());
bannedIPs = Settings.getObject("banned-ips", Array.class, () -> new Array<>());
playerInfo = Settings.getObject("player-info", ObjectMap.class, ObjectMap::new);
bannedIPs = Settings.getObject("banned-ips", Array.class, Array::new);
}
@Serialize

View File

@ -22,7 +22,6 @@ import io.anuke.ucore.util.Log;
import io.anuke.ucore.util.Strings;
import static io.anuke.mindustry.Vars.*;
import static io.anuke.mindustry.Vars.port;
public class JoinDialog extends FloatingDialog{
Array<Server> servers = new Array<>();
@ -327,7 +326,7 @@ public class JoinDialog extends FloatingDialog{
}
private void loadServers(){
servers = Settings.getObject("server-list", Array.class, () -> new Array<>());
servers = Settings.getObject("server-list", Array.class, Array::new);
}
private void saveServers(){

View File

@ -52,7 +52,6 @@ public class SaveDialog extends LoadDialog{
slot.save();
}catch(Throwable e){
e.printStackTrace();
e = (e.getCause() == null ? e : e.getCause());
ui.showError("[orange]" + Bundles.get("text.savefail"));
}

View File

@ -313,8 +313,8 @@ public class BlocksFragment extends Fragment{
descTable.row();
descTable.add(requirements);
descTable.left();
descTable.add(requirements);
for(ItemStack stack : recipe.requirements){
requirements.addImage(stack.item.region).size(8 * 3);

View File

@ -142,7 +142,7 @@ public class BuildBlock extends Block{
for(TextureRegion region : target.getBlockIcon()){
Shaders.blockbuild.region = region;
Shaders.blockbuild.progress = (float) entity.progress;
Shaders.blockbuild.progress = entity.progress;
Shaders.blockbuild.apply();
Draw.rect(region, tile.drawx(), tile.drawy(), target.rotate ? tile.getRotation() * 90 : 0);
@ -165,11 +165,6 @@ public class BuildBlock extends Block{
}
}
@Override
public void update(Tile tile){
}
@Override
public TileEntity newEntity(){
return new BuildEntity();

View File

@ -27,7 +27,7 @@ public class Floor extends Block{
120, 29, 122, 30, 123, 31, 126, 32, 127, 33, 208, 34, 210, 35, 214, 36, 216, 37,
218, 38, 219, 39, 222, 40, 223, 41, 248, 42, 250, 43, 251, 44, 254, 45, 255, 46, 0, 47);
/** number of different variant regions to use */
public int variants = 0;
public int variants;
/** edge fallback, used mainly for ores */
public String edge = "stone";
/** Multiplies unit velocity by this when walked on. */

View File

@ -10,7 +10,6 @@ import io.anuke.ucore.scene.ui.ButtonGroup;
import io.anuke.ucore.scene.ui.ImageButton;
import io.anuke.ucore.scene.ui.layout.Table;
import static io.anuke.mindustry.Vars.control;
import static io.anuke.mindustry.Vars.*;
public interface SelectionTrait{

View File

@ -6,10 +6,6 @@ import io.anuke.mindustry.world.ItemBuffer;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.util.Mathf;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
public class BufferedItemBridge extends ExtendingItemBridge{
protected int timerAccept = timers++;
@ -47,15 +43,5 @@ public class BufferedItemBridge extends ExtendingItemBridge{
class BufferedItemBridgeEntity extends ItemBridgeEntity{
ItemBuffer buffer = new ItemBuffer(bufferCapacity, speed);
@Override
public void write(DataOutputStream stream) throws IOException{
super.write(stream);
}
@Override
public void read(DataInputStream stream) throws IOException{
super.read(stream);
}
}
}

View File

@ -77,9 +77,7 @@ public class Conduit extends LiquidBlock{
Tile other = tile.getNearby(Mathf.mod(tile.getRotation() - direction, 4));
if(other != null) other = other.target();
if(other == null || !(other.block().hasLiquids) || !(other.block().outputsLiquid)) return false;
return (tile.getNearby(tile.getRotation()) == other)
|| (!other.block().rotate || other.getNearby(other.getRotation()) == tile);
return other != null && other.block().hasLiquids && other.block().outputsLiquid && ((tile.getNearby(tile.getRotation()) == other) || (!other.block().rotate || other.getNearby(other.getRotation()) == tile));
}
@Override

View File

@ -20,9 +20,6 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import static io.anuke.mindustry.Vars.itemSize;
import static io.anuke.mindustry.Vars.tilesize;
import static io.anuke.mindustry.Vars.*;
public class Conveyor extends Block{

View File

@ -80,11 +80,6 @@ public class WarpGate extends PowerBlock{
entity.color = color;
}
@Override
public void setStats(){
super.setStats();
}
@Override
public void playerPlaced(Tile tile){
Call.setTeleporterColor(null, tile, lastColor);

View File

@ -32,11 +32,6 @@ public class Fracker extends SolidPump{
topRegion = Draw.region(name + "-top");
}
@Override
public void setStats(){
super.setStats();
}
@Override
public void draw(Tile tile){
FrackerEntity entity = tile.entity();

View File

@ -9,7 +9,6 @@ import io.anuke.mindustry.world.consumers.ConsumeLiquid;
import io.anuke.mindustry.world.meta.BlockBar;
import io.anuke.mindustry.world.meta.BlockStat;
import io.anuke.mindustry.world.modules.LiquidModule;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
public class LiquidMixer extends LiquidBlock{

View File

@ -166,11 +166,8 @@ public class PowerSmelter extends PowerBlock{
}
}
if(useFlux && item.fluxiness >= minFlux){
return tile.entity.items.get(item) < itemCapacity;
}
return useFlux && item.fluxiness >= minFlux && tile.entity.items.get(item) < itemCapacity;
return false;
}
@Override

View File

@ -9,7 +9,6 @@ import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.meta.BlockStat;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Effects.Effect;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.graphics.Draw;
import io.anuke.ucore.util.Mathf;
@ -107,8 +106,7 @@ public class SolidPump extends Pump{
@Override
protected boolean isValid(Tile tile){
if(tile == null) return false;
return !tile.floor().isLiquid;
return tile != null && !tile.floor().isLiquid;
}
@Override

View File

@ -179,12 +179,6 @@ public class CoreBlock extends StorageBlock{
return tile.entity.items.get(item) < itemCapacity && item.type == ItemType.material;
}
@Override
public void onDestroyed(Tile tile){
super.onDestroyed(tile);
//TODO more dramatic effects
}
@Override
public void handleItem(Item item, Tile tile, Tile source){
if(Net.server() || !Net.active()) super.handleItem(item, tile, source);

View File

@ -28,11 +28,6 @@ public class Vault extends StorageBlock{
}
}
@Override
public void handleItem(Item item, Tile tile, Tile source){
super.handleItem(item, tile, source);
}
@Override
public boolean acceptItem(Item item, Tile tile, Tile source){
return tile.entity.items.total() < itemCapacity;

View File

@ -32,8 +32,7 @@ public class ConsumePower extends Consume{
@Override
public boolean valid(Block block, TileEntity entity){
if(entity.power == null) return false;
return entity.power.amount >= use(block, entity);
return entity.power != null && entity.power.amount >= use(block, entity);
}
@Override

View File

@ -97,7 +97,7 @@ task packrCmd() {
"--mainclass", project.ext.mainClassName,
"--jdk", PACKR_DIR + "jdk-" + getPlatform() + ".zip",
"--icon", ICON_DIR.getAbsolutePath(),
"--vmargs", (getPlatform().equals("mac") ? "XstartOnFirstThread" : "Xms256m"),
"--vmargs", (getPlatform() == "mac" ? "XstartOnFirstThread" : "Xms256m"),
"Djava.net.preferIPv4Stack=true",
"--classpath", "--", PACKR_DIR + "config.json")
}

View File

@ -60,11 +60,6 @@ public class DesktopPlatform extends Platform{
return NumberFormat.getIntegerInstance().format(number);
}
@Override
public void showError(String text){
}
@Override
public String getLocaleName(Locale locale){
return locale.getDisplayName(locale);

View File

@ -45,13 +45,11 @@ public class FrameworkSerializer {
return p;
}else if(id == 1){
DiscoverHost p = new DiscoverHost();
return p;
return new DiscoverHost();
}else if(id == 2){
KeepAlive p = new KeepAlive();
return p;
return new KeepAlive();
}else if(id == 3){
RegisterUDP p = new RegisterUDP();
p.connectionID = buffer.getInt();

View File

@ -4,7 +4,7 @@ sourceCompatibility = 1.8
sourceSets.main.java.srcDirs = [ "src/" ]
project.ext.mainClassName = "io.anuke.mindustry.server.ServerLauncher"
project.ext.assetsDir = new File("../core/assets");
project.ext.assetsDir = new File("../core/assets")
task run(dependsOn: classes, type: JavaExec) {
main = project.mainClassName
@ -30,7 +30,7 @@ task dist(type: Jar) {
from files(sourceSets.main.output.classesDirs)
from files(sourceSets.main.output.resourcesDir)
from {configurations.compile.collect {zipTree(it)}}
from files(project.assetsDir);
from files(project.assetsDir)
writeVersion()
@ -43,8 +43,8 @@ task deploy(type: Copy){
dependsOn "dist"
from "build/libs/server-release.jar"
into "../deploy/";
rename ("server-release.jar", appName + "-server-" + getVersionString() + ".jar");
into "../deploy/"
rename ("server-release.jar", appName + "-server-" + getVersionString() + ".jar")
}
dist.dependsOn classes

View File

@ -291,8 +291,7 @@ public class ServerControl extends Module{
handler.register("difficulty", "<difficulty>", "Set game difficulty.", arg -> {
try{
Difficulty diff = Difficulty.valueOf(arg[0]);
state.difficulty = diff;
state.difficulty = Difficulty.valueOf(arg[0]);
info("Difficulty set to '{0}'.", arg[0]);
}catch(IllegalArgumentException e){
err("No difficulty with name '{0}' found.", arg[0]);

View File

@ -1,6 +1,6 @@
include 'desktop', 'html', 'core', 'android', 'kryonet', 'server', 'ios', 'annotations', 'tools', 'tests'
if(System.properties["release"] == null || System.properties["release"].equals("false")){
if(System.properties["release"] == null || System.properties["release"] == "false"){
if (new File(settingsDir, '../uCore').exists()) {
include ':uCore'
project(':uCore').projectDir = new File(settingsDir, '../uCore')

View File

@ -14,14 +14,14 @@ def textureFolder = "../core/assets-raw/sprites/generated/"
task swapColors(){
doLast{
if (project.hasProperty("colors")) {
def carr = new File(getProperty("colors")).text.split("\n");
def carr = new File(getProperty("colors")).text.split("\n")
def map = [:]
def swaps = 0
carr.each {str -> map[Color.argb8888(Color.valueOf(str.split("=")[0]))] = Color.argb8888(Color.valueOf(str.split("=")[1]))}
def tmpc = new Color()
fileTree(dir: '../core/assets-raw/sprites', include: "**/*.png").visit { file ->
if(file.isDirectory()) return;
if(file.isDirectory()) return
swaps ++
def img = ImageIO.read(file.file)
@ -39,7 +39,7 @@ task swapColors(){
}
println "Swapped $swaps images."
}else{
throw new InvalidUserDataException("No replacement colors specified. Use -Pcolors=\"<path to color file>\"");
throw new InvalidUserDataException("No replacement colors specified. Use -Pcolors=\"<path to color file>\"")
}
}
}