Fixed bugs with multiplayer on Android and new place modes

This commit is contained in:
Anuken 2018-01-16 17:22:35 -05:00
parent 6211afb904
commit 7827ab4267
9 changed files with 18 additions and 13 deletions

View file

@ -10,7 +10,7 @@ import io.anuke.ucore.UCore;
import io.anuke.ucore.scene.ui.layout.Unit;
public class Vars{
public static final boolean testAndroid = false;
public static final boolean testAndroid = true;
//shorthand for whether or not this is running on android
public static final boolean android = (Gdx.app.getType() == ApplicationType.Android) || testAndroid;
//shorthand for whether or not this is running on GWT

View file

@ -546,6 +546,7 @@ public class Control extends Module{
@Override
public void update(){
//UCore.log(input.placeMode, input.breakMode, input.lastPlaceMode);
if(Gdx.input != proxy){
Gdx.input = proxy;

View file

@ -48,7 +48,7 @@ public class NetClient extends Module {
IntSet requests = new IntSet();
IntSet recieved = new IntSet();
float playerSyncTime = 2;
float dataTimeout = 60*13; //13 seconds timeout
float dataTimeout = 60*15; //13 seconds timeout
public NetClient(){

View file

@ -60,7 +60,7 @@ public class DamageArea{
};
Entities.getNearby(Vars.control.enemyGroup, rect, cons);
Entities.getNearby(Vars.control.playerGroup, rect, cons);
if(!Vars.control.isFriendlyFire()) Entities.getNearby(Vars.control.playerGroup, rect, cons);
}
public static void damageEntities(float x, float y, float radius, int damage){

View file

@ -36,6 +36,7 @@ public abstract class InputHandler extends InputAdapter{
public PlaceMode placeMode = android ? PlaceMode.cursor : PlaceMode.hold;
public PlaceMode breakMode = android ? PlaceMode.none : PlaceMode.holdDelete;
public PlaceMode lastPlaceMode = placeMode;
public PlaceMode lastBreakMode = breakMode;
public abstract void update();
public abstract float getCursorX();

View file

@ -1,8 +1,6 @@
package io.anuke.mindustry.input;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Input.Buttons;
import com.badlogic.gdx.graphics.Color;
import com.badlogic.gdx.graphics.Colors;
import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
@ -11,7 +9,6 @@ import io.anuke.mindustry.ui.fragments.ToolFragment;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.ucore.core.Draw;
import io.anuke.ucore.core.Inputs;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.scene.utils.Cursors;
import io.anuke.ucore.util.Bundles;
@ -97,12 +94,9 @@ public enum PlaceMode{
Vector2 offset = tile.block().getPlaceOffset();
float fract = control.getInput().breaktime / tile.getBreakTime();
if(Inputs.buttonDown(Buttons.RIGHT)){
Draw.color(Color.YELLOW, Color.SCARLET, fract);
Draw.linecrect(tile.worldx() + offset.x, tile.worldy() + offset.y, tile.block().width * Vars.tilesize, tile.block().height * Vars.tilesize);
}else if(android && control.getInput().breaktime > 0){
if(android && control.getInput().breaktime > 0){
Draw.color(Colors.get("breakStart"), Colors.get("break"), fract);
Draw.polygon(tile.worldy() + offset.y, tile.worldx() + offset.x, 25, 4 + (1f - fract) * 26);
Draw.polygon(tile.worldx() + offset.y, tile.worldy() + offset.x, 25, 4 + (1f - fract) * 26);
}
Draw.reset();
}

View file

@ -54,6 +54,7 @@ public class PlacementFragment implements Fragment{
placing = false;
container.clearActions();
container.actions(Actions.translateBy(0, -(container.getTranslation().y + translation), i, n));
if (!input.lastBreakMode.both) input.placeMode = input.lastBreakMode;
}else{
placing = true;
container.clearActions();
@ -131,6 +132,7 @@ public class PlacementFragment implements Fragment{
new imagebutton("icon-" + mode.name(), "toggle", 10 * 3, () -> {
control.getInput().resetCursor();
input.breakMode = mode;
input.lastBreakMode = mode;
if (!mode.both){
input.placeMode = mode;
}else{

View file

@ -18,6 +18,7 @@ import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.AbstractList;
import java.util.Collections;
import java.util.List;
import static io.anuke.mindustry.Vars.tilesize;
@ -235,7 +236,7 @@ public class Conveyor extends Block{
}
};
wrapper.sort(Conveyor::compareItems);
Collections.sort(wrapper, Conveyor::compareItems);
}
private static int compareItems(Integer a, Integer b){

View file

@ -3,6 +3,7 @@ package io.anuke.mindustry.world.blocks.types.production;
import com.badlogic.gdx.utils.Array;
import io.anuke.mindustry.resource.Liquid;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Layer;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.types.LiquidBlock;
@ -24,7 +25,12 @@ public class Pump extends LiquidBlock{
layer = Layer.overlay;
flowfactor = 3f;
}
@Override
public boolean canReplace(Block other) {
return other instanceof Pump && other != this;
}
@Override
public void getStats(Array<String> list){
super.getStats(list);