Improved Discord RPC, refactored Input and fixed net crash
This commit is contained in:
@@ -67,7 +67,7 @@ public class AndroidLauncher extends AndroidApplication{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSceneChange(String state, String details, String icon) { }
|
public void updateRPC() { }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGameExit() { }
|
public void onGameExit() { }
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class Mindustry extends ModuleCore {
|
|||||||
@Override public String format(int number){ return number + ""; }
|
@Override public String format(int number){ return number + ""; }
|
||||||
@Override public void openLink(String link){ }
|
@Override public void openLink(String link){ }
|
||||||
@Override public void addDialog(TextField field){}
|
@Override public void addDialog(TextField field){}
|
||||||
@Override public void onSceneChange(String state, String details, String icon) {}
|
@Override public void updateRPC() {}
|
||||||
@Override public void onGameExit() {}
|
@Override public void onGameExit() {}
|
||||||
@Override public void openDonations() {}
|
@Override public void openDonations() {}
|
||||||
@Override public void requestWritePerms() {}
|
@Override public void requestWritePerms() {}
|
||||||
|
|||||||
@@ -299,8 +299,6 @@ public class Control extends Module{
|
|||||||
});
|
});
|
||||||
|
|
||||||
Timers.run(18, ()-> ui.hideLoading());
|
Timers.run(18, ()-> ui.hideLoading());
|
||||||
|
|
||||||
Mindustry.platforms.onSceneChange("Playing on map: " + map.name, "Wave 1", "fight");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public GameMode getMode(){
|
public GameMode getMode(){
|
||||||
@@ -350,10 +348,9 @@ public class Control extends Module{
|
|||||||
int spawnamount = spawn.evaluate(wave, lane);
|
int spawnamount = spawn.evaluate(wave, lane);
|
||||||
|
|
||||||
for(int i = 0; i < spawnamount; i ++){
|
for(int i = 0; i < spawnamount; i ++){
|
||||||
int index = i;
|
|
||||||
float range = 12f;
|
float range = 12f;
|
||||||
|
|
||||||
Timers.run(index*5f, ()->{
|
Timers.run(i*5f, ()->{
|
||||||
|
|
||||||
Enemy enemy = new Enemy(spawn.type);
|
Enemy enemy = new Enemy(spawn.type);
|
||||||
enemy.set(tile.worldx() + Mathf.range(range), tile.worldy() + Mathf.range(range));
|
enemy.set(tile.worldx() + Mathf.range(range), tile.worldy() + Mathf.range(range));
|
||||||
@@ -383,8 +380,7 @@ public class Control extends Module{
|
|||||||
wavetime = waveSpacing();
|
wavetime = waveSpacing();
|
||||||
extrawavetime = maxwavespace;
|
extrawavetime = maxwavespace;
|
||||||
|
|
||||||
Mindustry.platforms.onSceneChange("Playing on map: "
|
Mindustry.platforms.updateRPC();
|
||||||
+ Vars.world.getMap().name, "Wave " + wave, "fight");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void enemyDeath(){
|
public void enemyDeath(){
|
||||||
@@ -399,9 +395,7 @@ public class Control extends Module{
|
|||||||
Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y);
|
Effects.shake(5, 6, Core.camera.position.x, Core.camera.position.y);
|
||||||
Sounds.play("corexplode");
|
Sounds.play("corexplode");
|
||||||
for(int i = 0; i < 16; i ++){
|
for(int i = 0; i < 16; i ++){
|
||||||
Timers.run(i*2, ()->{
|
Timers.run(i*2, ()-> Effects.effect(Fx.explosion, core.worldx()+Mathf.range(40), core.worldy()+Mathf.range(40)));
|
||||||
Effects.effect(Fx.explosion, core.worldx()+Mathf.range(40), core.worldy()+Mathf.range(40));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
Effects.effect(Fx.coreexplosion, core.worldx(), core.worldy());
|
Effects.effect(Fx.coreexplosion, core.worldx(), core.worldy());
|
||||||
|
|
||||||
@@ -516,7 +510,9 @@ public class Control extends Module{
|
|||||||
|
|
||||||
Entities.initPhysics();
|
Entities.initPhysics();
|
||||||
|
|
||||||
Entities.setCollider(tilesize, (x, y) -> world.solid(x, y));
|
Entities.setCollider(tilesize, world::solid);
|
||||||
|
|
||||||
|
Mindustry.platforms.updateRPC();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
package io.anuke.mindustry.core;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
|
import io.anuke.mindustry.Mindustry;
|
||||||
|
import io.anuke.ucore.core.Timers;
|
||||||
|
|
||||||
public class GameState{
|
public class GameState{
|
||||||
private static State state = State.menu;
|
private static State state = State.menu;
|
||||||
|
|
||||||
public static void set(State astate){
|
public static void set(State astate){
|
||||||
|
|
||||||
|
if((astate == State.playing && state == State.menu) || (astate == State.menu && state != State.menu)){
|
||||||
|
Timers.runTask(5f, Mindustry.platforms::updateRPC);
|
||||||
|
}
|
||||||
|
|
||||||
state = astate;
|
state = astate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -11,7 +19,7 @@ public class GameState{
|
|||||||
return state == astate;
|
return state == astate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static enum State{
|
public enum State{
|
||||||
paused, playing, menu, dead
|
paused, playing, menu, dead
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,14 +3,13 @@ package io.anuke.mindustry.core;
|
|||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.utils.TimeUtils;
|
import com.badlogic.gdx.utils.TimeUtils;
|
||||||
import com.badlogic.gdx.utils.compression.Lzma;
|
import com.badlogic.gdx.utils.compression.Lzma;
|
||||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
|
||||||
import com.badlogic.gdx.utils.reflect.ReflectionException;
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.entities.Bullet;
|
import io.anuke.mindustry.entities.Bullet;
|
||||||
import io.anuke.mindustry.entities.BulletType;
|
import io.anuke.mindustry.entities.BulletType;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||||
|
import io.anuke.mindustry.entities.enemies.EnemyType;
|
||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.io.NetworkIO;
|
import io.anuke.mindustry.io.NetworkIO;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
@@ -178,18 +177,14 @@ public class NetClient extends Module {
|
|||||||
|
|
||||||
Net.handle(EnemySpawnPacket.class, spawn -> {
|
Net.handle(EnemySpawnPacket.class, spawn -> {
|
||||||
Gdx.app.postRunnable(() -> {
|
Gdx.app.postRunnable(() -> {
|
||||||
try{
|
Enemy enemy = new Enemy(EnemyType.getByID(spawn.type));
|
||||||
Enemy enemy = ClassReflection.newInstance(spawn.type);
|
enemy.set(spawn.x, spawn.y);
|
||||||
enemy.set(spawn.x, spawn.y);
|
enemy.tier = spawn.tier;
|
||||||
enemy.tier = spawn.tier;
|
enemy.lane = spawn.lane;
|
||||||
enemy.lane = spawn.lane;
|
enemy.id = spawn.id;
|
||||||
enemy.id = spawn.id;
|
enemy.add();
|
||||||
enemy.add();
|
|
||||||
|
|
||||||
Effects.effect(Fx.spawn, enemy);
|
Effects.effect(Fx.spawn, enemy);
|
||||||
}catch (ReflectionException e){
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -201,7 +201,7 @@ public class NetServer extends Module{
|
|||||||
|
|
||||||
public void handleEnemySpawn(Enemy enemy){
|
public void handleEnemySpawn(Enemy enemy){
|
||||||
EnemySpawnPacket packet = new EnemySpawnPacket();
|
EnemySpawnPacket packet = new EnemySpawnPacket();
|
||||||
packet.type = enemy.getClass();
|
packet.type = enemy.type.id;
|
||||||
packet.lane = (byte)enemy.lane;
|
packet.lane = (byte)enemy.lane;
|
||||||
packet.tier = (byte)enemy.tier;
|
packet.tier = (byte)enemy.tier;
|
||||||
packet.x = enemy.x;
|
packet.x = enemy.x;
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ import io.anuke.mindustry.entities.Player;
|
|||||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||||
import io.anuke.mindustry.graphics.BlockRenderer;
|
import io.anuke.mindustry.graphics.BlockRenderer;
|
||||||
import io.anuke.mindustry.graphics.Shaders;
|
import io.anuke.mindustry.graphics.Shaders;
|
||||||
|
import io.anuke.mindustry.input.InputHandler;
|
||||||
import io.anuke.mindustry.input.PlaceMode;
|
import io.anuke.mindustry.input.PlaceMode;
|
||||||
import io.anuke.mindustry.ui.fragments.ToolFragment;
|
import io.anuke.mindustry.ui.fragments.ToolFragment;
|
||||||
import io.anuke.mindustry.world.SpawnPoint;
|
import io.anuke.mindustry.world.SpawnPoint;
|
||||||
@@ -334,11 +335,13 @@ public class Renderer extends RendererModule{
|
|||||||
tiley = Mathf.scl2(vec.y, tilesize);
|
tiley = Mathf.scl2(vec.y, tilesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
InputHandler input = control.getInput();
|
||||||
|
|
||||||
//draw placement box
|
//draw placement box
|
||||||
if((player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && (!ui.hasMouse() || android)
|
if((input.recipe != null && Vars.control.hasItems(input.recipe.requirements) && (!ui.hasMouse() || android)
|
||||||
&& control.input.drawPlace())){
|
&& control.input.drawPlace())){
|
||||||
|
|
||||||
player.placeMode.draw(control.input.getBlockX(), control.input.getBlockY(), control.input.getBlockEndX(), control.input.getBlockEndY());
|
input.placeMode.draw(control.input.getBlockX(), control.input.getBlockY(), control.input.getBlockEndX(), control.input.getBlockEndY());
|
||||||
|
|
||||||
Draw.thickness(1f);
|
Draw.thickness(1f);
|
||||||
Draw.color(Color.SCARLET);
|
Draw.color(Color.SCARLET);
|
||||||
@@ -346,11 +349,11 @@ public class Renderer extends RendererModule{
|
|||||||
Draw.dashCircle(spawn.start.worldx(), spawn.start.worldy(), enemyspawnspace);
|
Draw.dashCircle(spawn.start.worldx(), spawn.start.worldy(), enemyspawnspace);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.breakMode == PlaceMode.holdDelete)
|
if(input.breakMode == PlaceMode.holdDelete)
|
||||||
player.breakMode.draw(tilex, tiley, 0, 0);
|
input.breakMode.draw(tilex, tiley, 0, 0);
|
||||||
|
|
||||||
}else if(player.breakMode.delete && control.input.drawPlace() && player.recipe == null){ //TODO test!
|
}else if(input.breakMode.delete && control.input.drawPlace() && input.recipe == null){ //TODO test!
|
||||||
player.breakMode.draw(control.input.getBlockX(), control.input.getBlockY(),
|
input.breakMode.draw(control.input.getBlockX(), control.input.getBlockY(),
|
||||||
control.input.getBlockEndX(), control.input.getBlockEndY());
|
control.input.getBlockEndX(), control.input.getBlockEndY());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -362,7 +365,7 @@ public class Renderer extends RendererModule{
|
|||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
|
||||||
//draw selected block health
|
//draw selected block health
|
||||||
if(player.recipe == null && !ui.hasMouse()){
|
if(input.recipe == null && !ui.hasMouse()){
|
||||||
Tile tile = world.tile(tilex, tiley);
|
Tile tile = world.tile(tilex, tiley);
|
||||||
|
|
||||||
if(tile != null && tile.block() != Blocks.air){
|
if(tile != null && tile.block() != Blocks.air){
|
||||||
|
|||||||
@@ -1,9 +1,6 @@
|
|||||||
package io.anuke.mindustry.core;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.math.GridPoint2;
|
import com.badlogic.gdx.math.GridPoint2;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
@@ -22,6 +19,9 @@ import io.anuke.ucore.util.Bundles;
|
|||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Tmp;
|
import io.anuke.ucore.util.Tmp;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.control;
|
||||||
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
public class Tutorial{
|
public class Tutorial{
|
||||||
private Stage stage;
|
private Stage stage;
|
||||||
private Label info;
|
private Label info;
|
||||||
@@ -274,7 +274,7 @@ public class Tutorial{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void onSwitch(){
|
void onSwitch(){
|
||||||
Vars.player.recipe = null;
|
control.getInput().recipe = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
drillInfo{
|
drillInfo{
|
||||||
@@ -348,7 +348,8 @@ public class Tutorial{
|
|||||||
for(int i = 0; i < 4; i ++){
|
for(int i = 0; i < 4; i ++){
|
||||||
world.tile(control.core.x + 2, control.core.y - 2 + i).setBlock(DistributionBlocks.conveyor, 1);
|
world.tile(control.core.x + 2, control.core.y - 2 + i).setBlock(DistributionBlocks.conveyor, 1);
|
||||||
}
|
}
|
||||||
Vars.player.recipe = null;
|
|
||||||
|
control.getInput().recipe = null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
turretExplanation{
|
turretExplanation{
|
||||||
|
|||||||
@@ -2,10 +2,8 @@ package io.anuke.mindustry.entities;
|
|||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.input.PlaceMode;
|
|
||||||
import io.anuke.mindustry.net.Syncable;
|
import io.anuke.mindustry.net.Syncable;
|
||||||
import io.anuke.mindustry.resource.Mech;
|
import io.anuke.mindustry.resource.Mech;
|
||||||
import io.anuke.mindustry.resource.Recipe;
|
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
import io.anuke.mindustry.resource.Weapon;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.Blocks;
|
import io.anuke.mindustry.world.blocks.Blocks;
|
||||||
@@ -33,12 +31,6 @@ public class Player extends DestructibleEntity implements Syncable{
|
|||||||
public transient boolean isLocal = false;
|
public transient boolean isLocal = false;
|
||||||
public transient Interpolator<Player> inter = new Interpolator<>(SyncType.player);
|
public transient Interpolator<Player> inter = new Interpolator<>(SyncType.player);
|
||||||
|
|
||||||
public transient float breaktime = 0;
|
|
||||||
public transient Recipe recipe;
|
|
||||||
public transient int placerot;
|
|
||||||
public transient PlaceMode placeMode = android ? PlaceMode.cursor : PlaceMode.hold;
|
|
||||||
public transient PlaceMode breakMode = android ? PlaceMode.none : PlaceMode.holdDelete;
|
|
||||||
|
|
||||||
public Player(){
|
public Player(){
|
||||||
hitbox.setSize(5);
|
hitbox.setSize(5);
|
||||||
hitboxTile.setSize(4f);
|
hitboxTile.setSize(4f);
|
||||||
@@ -132,7 +124,7 @@ public class Player extends DestructibleEntity implements Syncable{
|
|||||||
vector.y += ya*speed;
|
vector.y += ya*speed;
|
||||||
vector.x += xa*speed;
|
vector.x += xa*speed;
|
||||||
|
|
||||||
boolean shooting = !Inputs.keyDown("dash") && Inputs.keyDown("shootInternal") && recipe == null
|
boolean shooting = !Inputs.keyDown("dash") && Inputs.keyDown("shootInternal") && control.getInput().recipe == null
|
||||||
&& !ui.hasMouse() && !control.getInput().onConfigurable();
|
&& !ui.hasMouse() && !control.getInput().onConfigurable();
|
||||||
|
|
||||||
if(shooting && Timers.get(this, "reload", weapon.reload)){
|
if(shooting && Timers.get(this, "reload", weapon.reload)){
|
||||||
|
|||||||
@@ -1,11 +1,8 @@
|
|||||||
package io.anuke.mindustry.input;
|
package io.anuke.mindustry.input;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.input.GestureDetector;
|
import com.badlogic.gdx.input.GestureDetector;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.GameState;
|
import io.anuke.mindustry.core.GameState;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
@@ -20,6 +17,8 @@ import io.anuke.ucore.scene.ui.layout.Unit;
|
|||||||
import io.anuke.ucore.scene.utils.Cursors;
|
import io.anuke.ucore.scene.utils.Cursors;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class AndroidInput extends InputHandler{
|
public class AndroidInput extends InputHandler{
|
||||||
public float lmousex, lmousey;
|
public float lmousex, lmousey;
|
||||||
public float mousex, mousey;
|
public float mousex, mousey;
|
||||||
@@ -38,7 +37,7 @@ public class AndroidInput extends InputHandler{
|
|||||||
@Override public float getCursorEndY(){ return Gdx.input.getY(0); }
|
@Override public float getCursorEndY(){ return Gdx.input.getY(0); }
|
||||||
@Override public float getCursorX(){ return mousex; }
|
@Override public float getCursorX(){ return mousex; }
|
||||||
@Override public float getCursorY(){ return mousey; }
|
@Override public float getCursorY(){ return mousey; }
|
||||||
@Override public boolean drawPlace(){ return (placing && !brokeBlock) || (player.placeMode.pan && player.recipe != null); }
|
@Override public boolean drawPlace(){ return (placing && !brokeBlock) || (placeMode.pan && recipe != null); }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean touchUp(int screenX, int screenY, int pointer, int button){
|
public boolean touchUp(int screenX, int screenY, int pointer, int button){
|
||||||
@@ -47,10 +46,10 @@ public class AndroidInput extends InputHandler{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(placing && pointer == 0 && !player.placeMode.pan && !breaking()){
|
if(placing && pointer == 0 && !placeMode.pan && !breaking()){
|
||||||
player.placeMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
placeMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
||||||
}else if(pointer == 0 && !player.breakMode.pan && breaking() && drawPlace()){
|
}else if(pointer == 0 && !breakMode.pan && breaking() && drawPlace()){
|
||||||
player.breakMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
breakMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
||||||
}
|
}
|
||||||
placing = false;
|
placing = false;
|
||||||
return false;
|
return false;
|
||||||
@@ -64,7 +63,7 @@ public class AndroidInput extends InputHandler{
|
|||||||
lmousex = screenX;
|
lmousex = screenX;
|
||||||
lmousey = screenY;
|
lmousey = screenY;
|
||||||
|
|
||||||
if((!player.placeMode.pan || breaking()) && pointer == 0){
|
if((!placeMode.pan || breaking()) && pointer == 0){
|
||||||
mousex = screenX;
|
mousex = screenX;
|
||||||
mousey = screenY;
|
mousey = screenY;
|
||||||
}
|
}
|
||||||
@@ -105,18 +104,18 @@ public class AndroidInput extends InputHandler{
|
|||||||
|
|
||||||
public void breakBlock(){
|
public void breakBlock(){
|
||||||
Tile tile = selected();
|
Tile tile = selected();
|
||||||
player.breaktime += Timers.delta();
|
breaktime += Timers.delta();
|
||||||
|
|
||||||
if(player.breaktime >= tile.block().breaktime){
|
if(breaktime >= tile.block().breaktime){
|
||||||
brokeBlock = true;
|
brokeBlock = true;
|
||||||
breakBlock(tile.x, tile.y, true);
|
breakBlock(tile.x, tile.y, true);
|
||||||
player.breaktime = 0f;
|
breaktime = 0f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
enableHold = player.breakMode == PlaceMode.holdDelete;
|
enableHold = breakMode == PlaceMode.holdDelete;
|
||||||
|
|
||||||
float scl = Settings.getInt("sensitivity")/100f * Unit.dp.scl(1f);
|
float scl = Settings.getInt("sensitivity")/100f * Unit.dp.scl(1f);
|
||||||
float xa = Inputs.getAxis("move_x");
|
float xa = Inputs.getAxis("move_x");
|
||||||
@@ -127,9 +126,9 @@ public class AndroidInput extends InputHandler{
|
|||||||
player.x += xa * 4f;
|
player.x += xa * 4f;
|
||||||
player.y += ya * 4f;
|
player.y += ya * 4f;
|
||||||
|
|
||||||
player.placerot += Inputs.getAxis("rotate_alt");
|
rotation += Inputs.getAxis("rotate_alt");
|
||||||
player.placerot += Inputs.getAxis("rotate");
|
rotation += Inputs.getAxis("rotate");
|
||||||
player.placerot = Mathf.mod(player.placerot, 4);
|
rotation = Mathf.mod(rotation, 4);
|
||||||
|
|
||||||
if(enableHold && Gdx.input.isTouched(0) && Mathf.near2d(lmousex, lmousey, Gdx.input.getX(0), Gdx.input.getY(0), Unit.dp.scl(50))
|
if(enableHold && Gdx.input.isTouched(0) && Mathf.near2d(lmousex, lmousey, Gdx.input.getX(0), Gdx.input.getY(0), Unit.dp.scl(50))
|
||||||
&& !ui.hasMouse()){
|
&& !ui.hasMouse()){
|
||||||
@@ -146,11 +145,11 @@ public class AndroidInput extends InputHandler{
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
if(warmup > warmupDelay && validBreak(sel.x, sel.y)){
|
if(warmup > warmupDelay && validBreak(sel.x, sel.y)){
|
||||||
player.breaktime += Timers.delta();
|
breaktime += Timers.delta();
|
||||||
|
|
||||||
if(player.breaktime > selected().block().breaktime){
|
if(breaktime > selected().block().breaktime){
|
||||||
breakBlock();
|
breakBlock();
|
||||||
player.breaktime = 0;
|
breaktime = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -158,7 +157,7 @@ public class AndroidInput extends InputHandler{
|
|||||||
mousey = ly;
|
mousey = ly;
|
||||||
}else{
|
}else{
|
||||||
warmup = 0;
|
warmup = 0;
|
||||||
player.breaktime = 0;
|
breaktime = 0;
|
||||||
|
|
||||||
mousex = Mathf.clamp(mousex, 0, Gdx.graphics.getWidth());
|
mousex = Mathf.clamp(mousex, 0, Gdx.graphics.getWidth());
|
||||||
mousey = Mathf.clamp(mousey, 0, Gdx.graphics.getHeight());
|
mousey = Mathf.clamp(mousey, 0, Gdx.graphics.getHeight());
|
||||||
@@ -167,17 +166,17 @@ public class AndroidInput extends InputHandler{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean tryPlaceBlock(int x, int y, boolean sound){
|
public boolean tryPlaceBlock(int x, int y, boolean sound){
|
||||||
if(player.recipe != null &&
|
if(recipe != null &&
|
||||||
validPlace(x, y, player.recipe.result) && cursorNear() &&
|
validPlace(x, y, recipe.result) && cursorNear() &&
|
||||||
Vars.control.hasItems(player.recipe.requirements)){
|
Vars.control.hasItems(recipe.requirements)){
|
||||||
|
|
||||||
placeBlock(x, y, player.recipe.result, player.placerot, true, sound);
|
placeBlock(x, y, recipe.result, rotation, true, sound);
|
||||||
|
|
||||||
for(ItemStack stack : player.recipe.requirements){
|
for(ItemStack stack : recipe.requirements){
|
||||||
Vars.control.removeItem(stack);
|
Vars.control.removeItem(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Vars.control.hasItems(player.recipe.requirements)){
|
if(!Vars.control.hasItems(recipe.requirements)){
|
||||||
Cursors.restoreCursor();
|
Cursors.restoreCursor();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -186,6 +185,6 @@ public class AndroidInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean breaking(){
|
public boolean breaking(){
|
||||||
return player.recipe == null;
|
return recipe == null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,7 @@
|
|||||||
package io.anuke.mindustry.input;
|
package io.anuke.mindustry.input;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
import io.anuke.mindustry.core.GameState;
|
import io.anuke.mindustry.core.GameState;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.resource.Weapon;
|
import io.anuke.mindustry.resource.Weapon;
|
||||||
@@ -16,6 +13,8 @@ import io.anuke.ucore.core.Timers;
|
|||||||
import io.anuke.ucore.scene.utils.Cursors;
|
import io.anuke.ucore.scene.utils.Cursors;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class DesktopInput extends InputHandler{
|
public class DesktopInput extends InputHandler{
|
||||||
int mousex, mousey;
|
int mousex, mousey;
|
||||||
int endx, endy;
|
int endx, endy;
|
||||||
@@ -34,14 +33,14 @@ public class DesktopInput extends InputHandler{
|
|||||||
if(player.isDead()) return;
|
if(player.isDead()) return;
|
||||||
|
|
||||||
if(Inputs.keyRelease("select")){
|
if(Inputs.keyRelease("select")){
|
||||||
player.placeMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
placeMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
||||||
}
|
}
|
||||||
|
|
||||||
if(Inputs.keyRelease("break") && !beganBreak){
|
if(Inputs.keyRelease("break") && !beganBreak){
|
||||||
player.breakMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
breakMode.released(getBlockX(), getBlockY(), getBlockEndX(), getBlockEndY());
|
||||||
}
|
}
|
||||||
|
|
||||||
if((Inputs.keyTap("select") && player.recipe != null) || Inputs.keyTap("break")){
|
if((Inputs.keyTap("select") && recipe != null) || Inputs.keyTap("break")){
|
||||||
Vector2 vec = Graphics.world(Gdx.input.getX(), Gdx.input.getY());
|
Vector2 vec = Graphics.world(Gdx.input.getX(), Gdx.input.getY());
|
||||||
mousex = (int)vec.x;
|
mousex = (int)vec.x;
|
||||||
mousey = (int)vec.y;
|
mousey = (int)vec.y;
|
||||||
@@ -60,23 +59,23 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!rotated) {
|
if(!rotated) {
|
||||||
player.placerot += Inputs.getAxis("rotate_alt");
|
rotation += Inputs.getAxis("rotate_alt");
|
||||||
rotated = true;
|
rotated = true;
|
||||||
}
|
}
|
||||||
if(!Inputs.getAxisActive("rotate_alt")) rotated = false;
|
if(!Inputs.getAxisActive("rotate_alt")) rotated = false;
|
||||||
|
|
||||||
if(!rotatedAlt) {
|
if(!rotatedAlt) {
|
||||||
player.placerot += Inputs.getAxis("rotate");
|
rotation += Inputs.getAxis("rotate");
|
||||||
rotatedAlt = true;
|
rotatedAlt = true;
|
||||||
}
|
}
|
||||||
if(!Inputs.getAxisActive("rotate")) rotatedAlt = false;
|
if(!Inputs.getAxisActive("rotate")) rotatedAlt = false;
|
||||||
|
|
||||||
player.placerot = Mathf.mod(player.placerot, 4);
|
rotation = Mathf.mod(rotation, 4);
|
||||||
|
|
||||||
if(Inputs.keyDown("break")){
|
if(Inputs.keyDown("break")){
|
||||||
player.breakMode = PlaceMode.areaDelete;
|
breakMode = PlaceMode.areaDelete;
|
||||||
}else{
|
}else{
|
||||||
player.breakMode = PlaceMode.hold;
|
breakMode = PlaceMode.hold;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(int i = 1; i <= 6 && i <= control.getWeapons().size; i ++){
|
for(int i = 1; i <= 6 && i <= control.getWeapons().size; i ++){
|
||||||
@@ -105,41 +104,41 @@ public class DesktopInput extends InputHandler{
|
|||||||
beganBreak = false;
|
beganBreak = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.recipe != null && Inputs.keyTap("break")){
|
if(recipe != null && Inputs.keyTap("break")){
|
||||||
beganBreak = true;
|
beganBreak = true;
|
||||||
player.recipe = null;
|
recipe = null;
|
||||||
Cursors.restoreCursor();
|
Cursors.restoreCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
//block breaking
|
//block breaking
|
||||||
if(enableHold && Inputs.keyDown("break") && cursor != null && validBreak(tilex(), tiley())){
|
if(enableHold && Inputs.keyDown("break") && cursor != null && validBreak(tilex(), tiley())){
|
||||||
player.breaktime += Timers.delta();
|
breaktime += Timers.delta();
|
||||||
if(player.breaktime >= cursor.getBreakTime()){
|
if(breaktime >= cursor.getBreakTime()){
|
||||||
breakBlock(cursor.x, cursor.y, true);
|
breakBlock(cursor.x, cursor.y, true);
|
||||||
player.breaktime = 0f;
|
breaktime = 0f;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
player.breaktime = 0f;
|
breaktime = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int tilex(){
|
public int tilex(){
|
||||||
return (player.recipe != null && player.recipe.result.isMultiblock() &&
|
return (recipe != null && recipe.result.isMultiblock() &&
|
||||||
player.recipe.result.width % 2 == 0) ?
|
recipe.result.width % 2 == 0) ?
|
||||||
Mathf.scl(Graphics.mouseWorld().x, tilesize) : Mathf.scl2(Graphics.mouseWorld().x, tilesize);
|
Mathf.scl(Graphics.mouseWorld().x, tilesize) : Mathf.scl2(Graphics.mouseWorld().x, tilesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int tiley(){
|
public int tiley(){
|
||||||
return (player.recipe != null && player.recipe.result.isMultiblock() &&
|
return (recipe != null && recipe.result.isMultiblock() &&
|
||||||
player.recipe.result.height % 2 == 0) ?
|
recipe.result.height % 2 == 0) ?
|
||||||
Mathf.scl(Graphics.mouseWorld().y, tilesize) : Mathf.scl2(Graphics.mouseWorld().y, tilesize);
|
Mathf.scl(Graphics.mouseWorld().y, tilesize) : Mathf.scl2(Graphics.mouseWorld().y, tilesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int currentWeapon(){
|
public int currentWeapon(){
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for(Weapon weapon : control.getWeapons()){
|
for(Weapon weapon : control.getWeapons()){
|
||||||
if(player.weapon == weapon)
|
if(weapon == weapon)
|
||||||
return i;
|
return i;
|
||||||
i ++;
|
i ++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,14 +31,14 @@ public class GestureHandler extends GestureAdapter{
|
|||||||
public boolean tap (float x, float y, int count, int button) {
|
public boolean tap (float x, float y, int count, int button) {
|
||||||
if(ui.hasMouse() || input.brokeBlock) return false;
|
if(ui.hasMouse() || input.brokeBlock) return false;
|
||||||
|
|
||||||
if(!player.placeMode.pan || player.recipe == null){
|
if(!control.getInput().placeMode.pan || control.getInput().recipe == null){
|
||||||
input.mousex = x;
|
input.mousex = x;
|
||||||
input.mousey = y;
|
input.mousey = y;
|
||||||
|
|
||||||
if(player.recipe == null)
|
if(control.getInput().recipe == null)
|
||||||
player.breakMode.tapped(input.getBlockX(), input.getBlockY());
|
control.getInput().breakMode.tapped(input.getBlockX(), input.getBlockY());
|
||||||
else
|
else
|
||||||
player.placeMode.tapped(input.getBlockX(), input.getBlockY());
|
control.getInput().placeMode.tapped(input.getBlockX(), input.getBlockY());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -47,13 +47,13 @@ public class GestureHandler extends GestureAdapter{
|
|||||||
public boolean pan(float x, float y, float deltaX, float deltaY){
|
public boolean pan(float x, float y, float deltaX, float deltaY){
|
||||||
if(Vars.control.showCursor() && !Inputs.keyDown("select")) return false;
|
if(Vars.control.showCursor() && !Inputs.keyDown("select")) return false;
|
||||||
|
|
||||||
if(!Vars.control.showCursor() && !(player.recipe != null && Vars.control.hasItems(player.recipe.requirements) && player.placeMode.lockCamera) &&
|
if(!Vars.control.showCursor() && !(control.getInput().recipe != null && Vars.control.hasItems(control.getInput().recipe.requirements) && control.getInput().placeMode.lockCamera) &&
|
||||||
!(player.recipe == null && player.breakMode.lockCamera)){
|
!(control.getInput().recipe == null && control.getInput().breakMode.lockCamera)){
|
||||||
float dx = deltaX*Core.camera.zoom/Core.cameraScale, dy = deltaY*Core.camera.zoom/Core.cameraScale;
|
float dx = deltaX*Core.camera.zoom/Core.cameraScale, dy = deltaY*Core.camera.zoom/Core.cameraScale;
|
||||||
player.x -= dx;
|
player.x -= dx;
|
||||||
player.y += dy;
|
player.y += dy;
|
||||||
player.targetAngle = Mathf.atan2(dx, -dy);
|
player.targetAngle = Mathf.atan2(dx, -dy);
|
||||||
}else if(player.placeMode.lockCamera && (player.placeMode.pan && player.recipe != null)){
|
}else if(control.getInput().placeMode.lockCamera && (control.getInput().placeMode.pan && control.getInput().recipe != null)){
|
||||||
input.mousex += deltaX;
|
input.mousex += deltaX;
|
||||||
input.mousey += deltaY;
|
input.mousey += deltaY;
|
||||||
}
|
}
|
||||||
@@ -63,7 +63,7 @@ public class GestureHandler extends GestureAdapter{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean pinch (Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) {
|
public boolean pinch (Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2) {
|
||||||
if(player.recipe == null && !player.breakMode.lockCamera)
|
if(control.getInput().recipe == null && !control.getInput().breakMode.lockCamera)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if(pinch1.x < 0){
|
if(pinch1.x < 0){
|
||||||
|
|||||||
@@ -28,6 +28,12 @@ import io.anuke.ucore.util.Tmp;
|
|||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public abstract class InputHandler extends InputAdapter{
|
public abstract class InputHandler extends InputAdapter{
|
||||||
|
public float breaktime = 0;
|
||||||
|
public Recipe recipe;
|
||||||
|
public int rotation;
|
||||||
|
public PlaceMode placeMode = android ? PlaceMode.cursor : PlaceMode.hold;
|
||||||
|
public PlaceMode breakMode = android ? PlaceMode.none : PlaceMode.holdDelete;
|
||||||
|
|
||||||
public abstract void update();
|
public abstract void update();
|
||||||
public abstract float getCursorX();
|
public abstract float getCursorX();
|
||||||
public abstract float getCursorY();
|
public abstract float getCursorY();
|
||||||
@@ -50,17 +56,17 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean tryPlaceBlock(int x, int y, boolean sound){
|
public boolean tryPlaceBlock(int x, int y, boolean sound){
|
||||||
if(player.recipe != null &&
|
if(recipe != null &&
|
||||||
validPlace(x, y, player.recipe.result) && !ui.hasMouse() && cursorNear() &&
|
validPlace(x, y, recipe.result) && !ui.hasMouse() && cursorNear() &&
|
||||||
Vars.control.hasItems(player.recipe.requirements)){
|
Vars.control.hasItems(recipe.requirements)){
|
||||||
|
|
||||||
placeBlock(x, y, player.recipe.result, player.placerot, true, sound);
|
placeBlock(x, y, recipe.result, rotation, true, sound);
|
||||||
|
|
||||||
for(ItemStack stack : player.recipe.requirements){
|
for(ItemStack stack : recipe.requirements){
|
||||||
Vars.control.removeItem(stack);
|
Vars.control.removeItem(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!Vars.control.hasItems(player.recipe.requirements)){
|
if(!Vars.control.hasItems(recipe.requirements)){
|
||||||
Cursors.restoreCursor();
|
Cursors.restoreCursor();
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -77,7 +83,7 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean round2(){
|
public boolean round2(){
|
||||||
return !(player.recipe != null && player.recipe.result.isMultiblock() && player.recipe.result.height % 2 == 0);
|
return !(recipe != null && recipe.result.isMultiblock() && recipe.result.height % 2 == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean validPlace(int x, int y, Block type){
|
public boolean validPlace(int x, int y, Block type){
|
||||||
@@ -116,7 +122,7 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
Block block = Vars.control.getTutorial().getPlaceBlock();
|
Block block = Vars.control.getTutorial().getPlaceBlock();
|
||||||
|
|
||||||
if(type != block || point.x != x - control.getCore().x || point.y != y - control.getCore().y
|
if(type != block || point.x != x - control.getCore().x || point.y != y - control.getCore().y
|
||||||
|| (rotation != -1 && rotation != Vars.player.placerot)){
|
|| (rotation != -1 && rotation != this.rotation)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}else if(Vars.control.getTutorial().active()){
|
}else if(Vars.control.getTutorial().active()){
|
||||||
@@ -160,7 +166,7 @@ public abstract class InputHandler extends InputAdapter{
|
|||||||
Block block = Vars.control.getTutorial().getPlaceBlock();
|
Block block = Vars.control.getTutorial().getPlaceBlock();
|
||||||
|
|
||||||
if(block != Blocks.air || point.x != x - control.getCore().x || point.y != y - control.getCore().y
|
if(block != Blocks.air || point.x != x - control.getCore().x || point.y != y - control.getCore().y
|
||||||
|| (rotation != -1 && rotation != Vars.player.placerot)){
|
|| (rotation != -1 && rotation != this.rotation)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
package io.anuke.mindustry.input;
|
package io.anuke.mindustry.input;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.Input.Buttons;
|
import com.badlogic.gdx.Input.Buttons;
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Colors;
|
import com.badlogic.gdx.graphics.Colors;
|
||||||
import com.badlogic.gdx.math.MathUtils;
|
import com.badlogic.gdx.math.MathUtils;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.ui.fragments.ToolFragment;
|
import io.anuke.mindustry.ui.fragments.ToolFragment;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
@@ -20,6 +17,8 @@ import io.anuke.ucore.scene.utils.Cursors;
|
|||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Tmp;
|
import io.anuke.ucore.util.Tmp;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public enum PlaceMode{
|
public enum PlaceMode{
|
||||||
cursor{
|
cursor{
|
||||||
{
|
{
|
||||||
@@ -32,23 +31,23 @@ public enum PlaceMode{
|
|||||||
float x = tilex * Vars.tilesize;
|
float x = tilex * Vars.tilesize;
|
||||||
float y = tiley * Vars.tilesize;
|
float y = tiley * Vars.tilesize;
|
||||||
|
|
||||||
boolean valid = control.getInput().validPlace(tilex, tiley, player.recipe.result) && (android || control.getInput().cursorNear());
|
boolean valid = control.getInput().validPlace(tilex, tiley, control.getInput().recipe.result) && (android || control.getInput().cursorNear());
|
||||||
|
|
||||||
Vector2 offset = player.recipe.result.getPlaceOffset();
|
Vector2 offset = control.getInput().recipe.result.getPlaceOffset();
|
||||||
|
|
||||||
float si = MathUtils.sin(Timers.time() / 6f) + 1.5f;
|
float si = MathUtils.sin(Timers.time() / 6f) + 1.5f;
|
||||||
|
|
||||||
Draw.color(valid ? Colors.get("place") : Colors.get("placeInvalid"));
|
Draw.color(valid ? Colors.get("place") : Colors.get("placeInvalid"));
|
||||||
Draw.thickness(2f);
|
Draw.thickness(2f);
|
||||||
Draw.linecrect(x + offset.x, y + offset.y, tilesize * player.recipe.result.width + si,
|
Draw.linecrect(x + offset.x, y + offset.y, tilesize * control.getInput().recipe.result.width + si,
|
||||||
tilesize * player.recipe.result.height + si);
|
tilesize * control.getInput().recipe.result.height + si);
|
||||||
|
|
||||||
player.recipe.result.drawPlace(tilex, tiley, player.placerot, valid);
|
control.getInput().recipe.result.drawPlace(tilex, tiley, control.getInput().rotation, valid);
|
||||||
Draw.thickness(2f);
|
Draw.thickness(2f);
|
||||||
|
|
||||||
if(player.recipe.result.rotate){
|
if(control.getInput().recipe.result.rotate){
|
||||||
Draw.color(Colors.get("placeRotate"));
|
Draw.color(Colors.get("placeRotate"));
|
||||||
Tmp.v1.set(7, 0).rotate(player.placerot * 90);
|
Tmp.v1.set(7, 0).rotate(control.getInput().rotation * 90);
|
||||||
Draw.line(x, y, x + Tmp.v1.x, y + Tmp.v1.y);
|
Draw.line(x, y, x + Tmp.v1.x, y + Tmp.v1.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -95,12 +94,12 @@ public enum PlaceMode{
|
|||||||
if(tile.isLinked())
|
if(tile.isLinked())
|
||||||
tile = tile.getLinked();
|
tile = tile.getLinked();
|
||||||
Vector2 offset = tile.block().getPlaceOffset();
|
Vector2 offset = tile.block().getPlaceOffset();
|
||||||
float fract = player.breaktime / tile.getBreakTime();
|
float fract = control.getInput().breaktime / tile.getBreakTime();
|
||||||
|
|
||||||
if(Inputs.buttonDown(Buttons.RIGHT)){
|
if(Inputs.buttonDown(Buttons.RIGHT)){
|
||||||
Draw.color(Color.YELLOW, Color.SCARLET, fract);
|
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);
|
Draw.linecrect(tile.worldx() + offset.x, tile.worldy() + offset.y, tile.block().width * Vars.tilesize, tile.block().height * Vars.tilesize);
|
||||||
}else if(android && player.breaktime > 0){
|
}else if(android && control.getInput().breaktime > 0){
|
||||||
Draw.color(Colors.get("breakStart"), Colors.get("break"), fract);
|
Draw.color(Colors.get("breakStart"), Colors.get("break"), fract);
|
||||||
Draw.polygon(25, tile.worldx() + offset.x, tile.worldy() + offset.y, 4 + (1f - fract) * 26);
|
Draw.polygon(25, tile.worldx() + offset.x, tile.worldy() + offset.y, 4 + (1f - fract) * 26);
|
||||||
}
|
}
|
||||||
@@ -254,7 +253,7 @@ public enum PlaceMode{
|
|||||||
}
|
}
|
||||||
|
|
||||||
float t = Vars.tilesize;
|
float t = Vars.tilesize;
|
||||||
Block block = player.recipe.result;
|
Block block = control.getInput().recipe.result;
|
||||||
Vector2 offset = block.getPlaceOffset();
|
Vector2 offset = block.getPlaceOffset();
|
||||||
|
|
||||||
process(tilex, tiley, endx, endy);
|
process(tilex, tiley, endx, endy);
|
||||||
@@ -296,15 +295,15 @@ public enum PlaceMode{
|
|||||||
int px = tx + cx * Mathf.sign(ex - tx),
|
int px = tx + cx * Mathf.sign(ex - tx),
|
||||||
py = ty + cy * Mathf.sign(ey - ty);
|
py = ty + cy * Mathf.sign(ey - ty);
|
||||||
|
|
||||||
if(!control.getInput().validPlace(px, py, player.recipe.result)
|
if(!control.getInput().validPlace(px, py, control.getInput().recipe.result)
|
||||||
|| !control.hasItems(player.recipe.requirements, amount)){
|
|| !control.hasItems(control.getInput().recipe.requirements, amount)){
|
||||||
Draw.linecrect(px * t + offset.x, py * t + offset.y, t*block.width, t*block.height);
|
Draw.linecrect(px * t + offset.x, py * t + offset.y, t*block.width, t*block.height);
|
||||||
}
|
}
|
||||||
amount ++;
|
amount ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.recipe.result.rotate){
|
if(control.getInput().recipe.result.rotate){
|
||||||
float cx = tx * t, cy = ty * t;
|
float cx = tx * t, cy = ty * t;
|
||||||
Draw.color(Colors.get("placeRotate"));
|
Draw.color(Colors.get("placeRotate"));
|
||||||
Tmp.v1.set(7, 0).rotate(rotation * 90);
|
Tmp.v1.set(7, 0).rotate(rotation * 90);
|
||||||
@@ -317,7 +316,7 @@ public enum PlaceMode{
|
|||||||
public void released(int tilex, int tiley, int endx, int endy){
|
public void released(int tilex, int tiley, int endx, int endy){
|
||||||
process(tilex, tiley, endx, endy);
|
process(tilex, tiley, endx, endy);
|
||||||
|
|
||||||
player.placerot = this.rotation;
|
control.getInput().rotation = this.rotation;
|
||||||
|
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for(int x = 0; x <= Math.abs(this.endx - this.tilex); x ++){
|
for(int x = 0; x <= Math.abs(this.endx - this.tilex); x ++){
|
||||||
@@ -356,7 +355,7 @@ public enum PlaceMode{
|
|||||||
else if(endy < tiley)
|
else if(endy < tiley)
|
||||||
rotation = 3;
|
rotation = 3;
|
||||||
else
|
else
|
||||||
rotation = player.placerot;
|
rotation = control.getInput().rotation;
|
||||||
|
|
||||||
if(endx < tilex){
|
if(endx < tilex){
|
||||||
int t = endx;
|
int t = endx;
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ public interface PlatformFunction{
|
|||||||
public String format(int number);
|
public String format(int number);
|
||||||
public void openLink(String link);
|
public void openLink(String link);
|
||||||
public void addDialog(TextField field);
|
public void addDialog(TextField field);
|
||||||
public void onSceneChange(String state, String details, String icon);
|
public void updateRPC();
|
||||||
public void onGameExit();
|
public void onGameExit();
|
||||||
public void openDonations();
|
public void openDonations();
|
||||||
public void requestWritePerms();
|
public void requestWritePerms();
|
||||||
|
|||||||
@@ -265,7 +265,7 @@ public class Save12 extends SaveFileVersion {
|
|||||||
stream.writeInt(tile.block().id); //block ID
|
stream.writeInt(tile.block().id); //block ID
|
||||||
|
|
||||||
if(tile.entity != null){
|
if(tile.entity != null){
|
||||||
stream.writeByte(tile.getRotation()); //placerot
|
stream.writeByte(tile.getRotation()); //rotation
|
||||||
stream.writeInt(tile.entity.health); //health
|
stream.writeInt(tile.entity.health); //health
|
||||||
int amount = 0;
|
int amount = 0;
|
||||||
for(int i = 0; i < tile.entity.items.length; i ++){
|
for(int i = 0; i < tile.entity.items.length; i ++){
|
||||||
|
|||||||
@@ -293,7 +293,7 @@ public class Save13 extends SaveFileVersion {
|
|||||||
if(tile.block() instanceof BlockPart) stream.writeByte(tile.link);
|
if(tile.block() instanceof BlockPart) stream.writeByte(tile.link);
|
||||||
|
|
||||||
if(tile.entity != null){
|
if(tile.entity != null){
|
||||||
stream.writeByte(tile.getRotation()); //placerot
|
stream.writeByte(tile.getRotation()); //rotation
|
||||||
stream.writeShort(tile.entity.health); //health
|
stream.writeShort(tile.entity.health); //health
|
||||||
byte amount = 0;
|
byte amount = 0;
|
||||||
for(int i = 0; i < tile.entity.items.length; i ++){
|
for(int i = 0; i < tile.entity.items.length; i ++){
|
||||||
|
|||||||
@@ -322,7 +322,7 @@ public class Save14 extends SaveFileVersion{
|
|||||||
if(tile.block() instanceof BlockPart) stream.writeByte(tile.link);
|
if(tile.block() instanceof BlockPart) stream.writeByte(tile.link);
|
||||||
|
|
||||||
if(tile.entity != null){
|
if(tile.entity != null){
|
||||||
stream.writeByte(tile.getRotation()); //placerot
|
stream.writeByte(tile.getRotation()); //rotation
|
||||||
stream.writeShort(tile.entity.health); //health
|
stream.writeShort(tile.entity.health); //health
|
||||||
byte amount = 0;
|
byte amount = 0;
|
||||||
for(int i = 0; i < tile.entity.items.length; i ++){
|
for(int i = 0; i < tile.entity.items.length; i ++){
|
||||||
|
|||||||
@@ -6,9 +6,11 @@ import com.badlogic.gdx.utils.IntArray;
|
|||||||
import com.badlogic.gdx.utils.IntMap;
|
import com.badlogic.gdx.utils.IntMap;
|
||||||
import com.badlogic.gdx.utils.ObjectMap;
|
import com.badlogic.gdx.utils.ObjectMap;
|
||||||
import com.badlogic.gdx.utils.async.AsyncExecutor;
|
import com.badlogic.gdx.utils.async.AsyncExecutor;
|
||||||
|
import io.anuke.mindustry.Mindustry;
|
||||||
import io.anuke.mindustry.net.Streamable.StreamBegin;
|
import io.anuke.mindustry.net.Streamable.StreamBegin;
|
||||||
import io.anuke.mindustry.net.Streamable.StreamBuilder;
|
import io.anuke.mindustry.net.Streamable.StreamBuilder;
|
||||||
import io.anuke.mindustry.net.Streamable.StreamChunk;
|
import io.anuke.mindustry.net.Streamable.StreamChunk;
|
||||||
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.function.Consumer;
|
import io.anuke.ucore.function.Consumer;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -31,6 +33,8 @@ public class Net{
|
|||||||
clientProvider.connect(ip, port);
|
clientProvider.connect(ip, port);
|
||||||
active = true;
|
active = true;
|
||||||
server = false;
|
server = false;
|
||||||
|
|
||||||
|
Timers.runTask(60f, Mindustry.platforms::updateRPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Host a server at an address*/
|
/**Host a server at an address*/
|
||||||
@@ -38,6 +42,8 @@ public class Net{
|
|||||||
serverProvider.host(port);
|
serverProvider.host(port);
|
||||||
active = true;
|
active = true;
|
||||||
server = true;
|
server = true;
|
||||||
|
|
||||||
|
Timers.runTask(60f, Mindustry.platforms::updateRPC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Closes the server.*/
|
/**Closes the server.*/
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package io.anuke.mindustry.net;
|
package io.anuke.mindustry.net;
|
||||||
|
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
|
||||||
|
|
||||||
/**Class for storing all packets.*/
|
/**Class for storing all packets.*/
|
||||||
public class Packets {
|
public class Packets {
|
||||||
@@ -86,8 +85,7 @@ public class Packets {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class EnemySpawnPacket{
|
public static class EnemySpawnPacket{
|
||||||
public Class<? extends Enemy> type;
|
public byte type, lane, tier;
|
||||||
public byte lane, tier;
|
|
||||||
public float x, y;
|
public float x, y;
|
||||||
public int id;
|
public int id;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,40 +1,34 @@
|
|||||||
package io.anuke.mindustry.ui.fragments;
|
package io.anuke.mindustry.ui.fragments;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.graphics.Colors;
|
import com.badlogic.gdx.graphics.Colors;
|
||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import com.badlogic.gdx.math.Interpolation;
|
import com.badlogic.gdx.math.Interpolation;
|
||||||
import com.badlogic.gdx.utils.Align;
|
|
||||||
import com.badlogic.gdx.utils.Array;
|
import com.badlogic.gdx.utils.Array;
|
||||||
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.Mindustry;
|
|
||||||
import io.anuke.mindustry.core.GameState;
|
import io.anuke.mindustry.core.GameState;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
|
import io.anuke.mindustry.input.InputHandler;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.resource.ItemStack;
|
import io.anuke.mindustry.resource.ItemStack;
|
||||||
import io.anuke.mindustry.resource.Recipe;
|
import io.anuke.mindustry.resource.Recipe;
|
||||||
import io.anuke.mindustry.resource.Section;
|
import io.anuke.mindustry.resource.Section;
|
||||||
import io.anuke.mindustry.ui.FloatingDialog;
|
import io.anuke.mindustry.ui.FloatingDialog;
|
||||||
import io.anuke.ucore.UCore;
|
|
||||||
import io.anuke.ucore.core.Core;
|
|
||||||
import io.anuke.ucore.core.Draw;
|
import io.anuke.ucore.core.Draw;
|
||||||
import io.anuke.ucore.graphics.Hue;
|
import io.anuke.ucore.graphics.Hue;
|
||||||
import io.anuke.ucore.scene.actions.Actions;
|
import io.anuke.ucore.scene.actions.Actions;
|
||||||
import io.anuke.ucore.scene.builders.button;
|
|
||||||
import io.anuke.ucore.scene.builders.imagebutton;
|
|
||||||
import io.anuke.ucore.scene.builders.table;
|
import io.anuke.ucore.scene.builders.table;
|
||||||
import io.anuke.ucore.scene.event.Touchable;
|
import io.anuke.ucore.scene.event.Touchable;
|
||||||
import io.anuke.ucore.scene.ui.*;
|
import io.anuke.ucore.scene.ui.*;
|
||||||
import io.anuke.ucore.scene.ui.layout.Stack;
|
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.scene.ui.layout.Value;
|
|
||||||
import io.anuke.ucore.util.Bundles;
|
import io.anuke.ucore.util.Bundles;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
import io.anuke.ucore.util.Strings;
|
import io.anuke.ucore.util.Strings;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.control;
|
||||||
|
import static io.anuke.mindustry.Vars.fontscale;
|
||||||
|
|
||||||
public class BlocksFragment implements Fragment{
|
public class BlocksFragment implements Fragment{
|
||||||
private Table desctable, itemtable, blocks;
|
private Table desctable, itemtable, blocks;
|
||||||
private Stack stack = new Stack();
|
private Stack stack = new Stack();
|
||||||
@@ -42,6 +36,7 @@ public class BlocksFragment implements Fragment{
|
|||||||
private boolean shown = true;
|
private boolean shown = true;
|
||||||
|
|
||||||
public void build(){
|
public void build(){
|
||||||
|
InputHandler input = control.getInput();
|
||||||
|
|
||||||
new table(){{
|
new table(){{
|
||||||
abottom();
|
abottom();
|
||||||
@@ -52,12 +47,12 @@ public class BlocksFragment implements Fragment{
|
|||||||
blocks = new table(){{
|
blocks = new table(){{
|
||||||
|
|
||||||
itemtable = new Table("button");
|
itemtable = new Table("button");
|
||||||
itemtable.setVisible(() -> player.recipe == null);
|
itemtable.setVisible(() -> input.recipe == null);
|
||||||
|
|
||||||
desctable = new Table("button");
|
desctable = new Table("button");
|
||||||
desctable.setVisible(() -> player.recipe != null);
|
desctable.setVisible(() -> input.recipe != null);
|
||||||
desctable.update(() -> {
|
desctable.update(() -> {
|
||||||
if(player.recipe == null && desctable.getChildren().size != 0){
|
if(input.recipe == null && desctable.getChildren().size != 0){
|
||||||
desctable.clear();
|
desctable.clear();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -93,8 +88,8 @@ public class BlocksFragment implements Fragment{
|
|||||||
|
|
||||||
ImageButton button = new ImageButton("icon-" + sec.name(), "toggle");
|
ImageButton button = new ImageButton("icon-" + sec.name(), "toggle");
|
||||||
button.clicked(() -> {
|
button.clicked(() -> {
|
||||||
if (!table.isVisible() && player.recipe != null) {
|
if (!table.isVisible() && input.recipe != null) {
|
||||||
player.recipe = null;
|
input.recipe = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
button.setName("sectionbutton" + sec.name());
|
button.setName("sectionbutton" + sec.name());
|
||||||
@@ -117,10 +112,10 @@ public class BlocksFragment implements Fragment{
|
|||||||
ImageButton image = new ImageButton(region, "select");
|
ImageButton image = new ImageButton(region, "select");
|
||||||
|
|
||||||
image.clicked(() -> {
|
image.clicked(() -> {
|
||||||
if (player.recipe == r) {
|
if (input.recipe == r) {
|
||||||
player.recipe = null;
|
input.recipe = null;
|
||||||
} else {
|
} else {
|
||||||
player.recipe = r;
|
input.recipe = r;
|
||||||
updateRecipe();
|
updateRecipe();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -131,7 +126,7 @@ public class BlocksFragment implements Fragment{
|
|||||||
image.update(() -> {
|
image.update(() -> {
|
||||||
boolean canPlace = !control.getTutorial().active() || control.getTutorial().canPlace();
|
boolean canPlace = !control.getTutorial().active() || control.getTutorial().canPlace();
|
||||||
boolean has = (control.hasItems(r.requirements)) && canPlace;
|
boolean has = (control.hasItems(r.requirements)) && canPlace;
|
||||||
image.setChecked(player.recipe == r);
|
image.setChecked(input.recipe == r);
|
||||||
image.setTouchable(canPlace ? Touchable.enabled : Touchable.disabled);
|
image.setTouchable(canPlace ? Touchable.enabled : Touchable.disabled);
|
||||||
image.getImage().setColor(has ? Color.WHITE : Hue.lightness(0.33f));
|
image.getImage().setColor(has ? Color.WHITE : Hue.lightness(0.33f));
|
||||||
});
|
});
|
||||||
@@ -174,7 +169,7 @@ public class BlocksFragment implements Fragment{
|
|||||||
}
|
}
|
||||||
|
|
||||||
void updateRecipe(){
|
void updateRecipe(){
|
||||||
Recipe recipe = player.recipe;
|
Recipe recipe = Vars.control.getInput().recipe;
|
||||||
desctable.clear();
|
desctable.clear();
|
||||||
desctable.setTouchable(Touchable.enabled);
|
desctable.setTouchable(Touchable.enabled);
|
||||||
|
|
||||||
|
|||||||
@@ -1,161 +1,161 @@
|
|||||||
package io.anuke.mindustry.ui.fragments;
|
package io.anuke.mindustry.ui.fragments;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.graphics.Color;
|
import com.badlogic.gdx.graphics.Color;
|
||||||
import com.badlogic.gdx.math.Interpolation;
|
import com.badlogic.gdx.math.Interpolation;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
|
|
||||||
import io.anuke.mindustry.core.GameState;
|
import io.anuke.mindustry.core.GameState;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
|
import io.anuke.mindustry.input.InputHandler;
|
||||||
import io.anuke.mindustry.input.PlaceMode;
|
import io.anuke.mindustry.input.PlaceMode;
|
||||||
import io.anuke.ucore.core.Core;
|
import io.anuke.ucore.core.Core;
|
||||||
import io.anuke.ucore.scene.actions.Actions;
|
import io.anuke.ucore.scene.actions.Actions;
|
||||||
import io.anuke.ucore.scene.builders.*;
|
import io.anuke.ucore.scene.builders.imagebutton;
|
||||||
|
import io.anuke.ucore.scene.builders.table;
|
||||||
import io.anuke.ucore.scene.event.Touchable;
|
import io.anuke.ucore.scene.event.Touchable;
|
||||||
import io.anuke.ucore.scene.ui.ButtonGroup;
|
import io.anuke.ucore.scene.ui.ButtonGroup;
|
||||||
import io.anuke.ucore.scene.ui.ImageButton;
|
import io.anuke.ucore.scene.ui.ImageButton;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.control;
|
||||||
|
|
||||||
public class PlacementFragment implements Fragment{
|
public class PlacementFragment implements Fragment{
|
||||||
boolean shown = false;
|
boolean shown = false;
|
||||||
Table breaktable, next;
|
Table breaktable, next;
|
||||||
|
|
||||||
public void build(){
|
public void build(){
|
||||||
if(android){
|
InputHandler input = control.getInput();
|
||||||
|
|
||||||
float s = 50f;
|
float s = 50f;
|
||||||
|
|
||||||
|
new table(){{
|
||||||
|
visible(() -> !GameState.is(State.menu));
|
||||||
|
|
||||||
|
abottom();
|
||||||
|
aleft();
|
||||||
|
|
||||||
|
ButtonGroup<ImageButton> placeGroup = new ButtonGroup<>();
|
||||||
|
ButtonGroup<ImageButton> breakGroup = new ButtonGroup<>();
|
||||||
|
|
||||||
|
update(t -> {
|
||||||
|
|
||||||
|
if(!input.placeMode.delete){
|
||||||
|
placeGroup.setMinCheckCount(1);
|
||||||
|
for(ImageButton button : placeGroup.getButtons()){
|
||||||
|
if(button.getName().equals(input.placeMode.name())){
|
||||||
|
button.setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
placeGroup.setMinCheckCount(0);
|
||||||
|
for(ImageButton button : placeGroup.getButtons())
|
||||||
|
button.setChecked(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(input.placeMode.delete || input.breakMode.both){
|
||||||
|
PlaceMode mode = input.breakMode;
|
||||||
|
breakGroup.setMinCheckCount(1);
|
||||||
|
for(ImageButton button : breakGroup.getButtons()){
|
||||||
|
if(button.getName().equals(mode.name())){
|
||||||
|
button.setChecked(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
breakGroup.setMinCheckCount(0);
|
||||||
|
for(ImageButton button : breakGroup.getButtons())
|
||||||
|
button.setChecked(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
new table(){{
|
new table(){{
|
||||||
visible(() -> !GameState.is(State.menu));
|
visible(() -> input.recipe != null);
|
||||||
|
touchable(Touchable.enabled);
|
||||||
|
|
||||||
|
aleft();
|
||||||
|
|
||||||
|
new table("pane"){{
|
||||||
|
margin(5f);
|
||||||
|
aleft();
|
||||||
|
|
||||||
|
defaults().size(s, s + 4).padBottom(-5.5f);
|
||||||
|
|
||||||
|
Color color = Color.GRAY;
|
||||||
|
|
||||||
|
new imagebutton("icon-cancel", 14*3, ()->{
|
||||||
|
input.recipe = null;
|
||||||
|
}).imageColor(color)
|
||||||
|
.visible(()->input.recipe != null);
|
||||||
|
|
||||||
|
for(PlaceMode mode : PlaceMode.values()){
|
||||||
|
if(!mode.shown || mode.delete) continue;
|
||||||
|
|
||||||
|
new imagebutton("icon-" + mode.name(), "toggle", 10*3, ()->{
|
||||||
|
control.getInput().resetCursor();
|
||||||
|
input.placeMode = mode;
|
||||||
|
}).group(placeGroup).get().setName(mode.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
new imagebutton("icon-arrow", 14*3, ()->{
|
||||||
|
input.rotation = Mathf.mod(input.rotation + 1, 4);
|
||||||
|
}).imageColor(color).visible(() -> input.recipe != null).update(image ->{
|
||||||
|
image.getImage().setRotation(input.rotation *90);
|
||||||
|
image.getImage().setOrigin(Align.center);
|
||||||
|
});
|
||||||
|
|
||||||
|
}}.padBottom(-5).left().end();
|
||||||
|
}}.left().end();
|
||||||
|
|
||||||
|
row();
|
||||||
|
|
||||||
|
new table(){{
|
||||||
abottom();
|
abottom();
|
||||||
aleft();
|
aleft();
|
||||||
|
|
||||||
ButtonGroup<ImageButton> placeGroup = new ButtonGroup<>();
|
height(s+5+4);
|
||||||
ButtonGroup<ImageButton> breakGroup = new ButtonGroup<>();
|
|
||||||
|
|
||||||
update(t -> {
|
next = new table("pane"){{
|
||||||
|
margin(5f);
|
||||||
|
|
||||||
if(!player.placeMode.delete){
|
defaults().padBottom(-5.5f);
|
||||||
placeGroup.setMinCheckCount(1);
|
|
||||||
for(ImageButton button : placeGroup.getButtons()){
|
|
||||||
if(button.getName().equals(player.placeMode.name())){
|
|
||||||
button.setChecked(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
placeGroup.setMinCheckCount(0);
|
|
||||||
for(ImageButton button : placeGroup.getButtons())
|
|
||||||
button.setChecked(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(player.placeMode.delete || player.breakMode.both){
|
new imagebutton("icon-arrow-right", 10 * 3, () -> {
|
||||||
PlaceMode mode = player.breakMode;
|
toggle(!shown);
|
||||||
breakGroup.setMinCheckCount(1);
|
}).update(l -> l.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-left" : "icon-" + input.breakMode.name())).size(s, s+4);
|
||||||
for(ImageButton button : breakGroup.getButtons()){
|
|
||||||
if(button.getName().equals(mode.name())){
|
|
||||||
button.setChecked(true);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
breakGroup.setMinCheckCount(0);
|
|
||||||
for(ImageButton button : breakGroup.getButtons())
|
|
||||||
button.setChecked(false);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
new table(){{
|
}}.end().get();
|
||||||
visible(() -> player.recipe != null);
|
|
||||||
|
breaktable = new table("pane"){{
|
||||||
|
visible(() -> shown);
|
||||||
|
margin(5f);
|
||||||
|
marginLeft(0f);
|
||||||
touchable(Touchable.enabled);
|
touchable(Touchable.enabled);
|
||||||
|
|
||||||
aleft();
|
aleft();
|
||||||
|
|
||||||
new table("pane"){{
|
defaults().size(s, s+4);
|
||||||
margin(5f);
|
|
||||||
aleft();
|
|
||||||
|
|
||||||
defaults().size(s, s + 4).padBottom(-5.5f);
|
for(PlaceMode mode : PlaceMode.values()){
|
||||||
|
if(!mode.shown || !mode.delete) continue;
|
||||||
|
|
||||||
Color color = Color.GRAY;
|
defaults().padBottom(-5.5f);
|
||||||
|
|
||||||
new imagebutton("icon-cancel", 14*3, ()->{
|
new imagebutton("icon-" + mode.name(), "toggle", 10*3, ()->{
|
||||||
player.recipe = null;
|
control.getInput().resetCursor();
|
||||||
}).imageColor(color)
|
input.breakMode = mode;
|
||||||
.visible(()->player.recipe != null);
|
if(!mode.both) input.placeMode = mode;
|
||||||
|
}).group(breakGroup).get().setName(mode.name());
|
||||||
|
}
|
||||||
|
|
||||||
for(PlaceMode mode : PlaceMode.values()){
|
}}.end().get();
|
||||||
if(!mode.shown || mode.delete) continue;
|
|
||||||
|
|
||||||
new imagebutton("icon-" + mode.name(), "toggle", 10*3, ()->{
|
breaktable.getParent().swapActor(breaktable, next);
|
||||||
control.getInput().resetCursor();
|
|
||||||
player.placeMode = mode;
|
|
||||||
}).group(placeGroup).get().setName(mode.name());
|
|
||||||
}
|
|
||||||
|
|
||||||
new imagebutton("icon-arrow", 14*3, ()->{
|
breaktable.getTranslation().set(-breaktable.getPrefWidth(), 0);
|
||||||
player.placerot = Mathf.mod(player.placerot + 1, 4);
|
|
||||||
}).imageColor(color).visible(() -> player.recipe != null).update(image ->{
|
|
||||||
image.getImage().setRotation(player.placerot *90);
|
|
||||||
image.getImage().setOrigin(Align.center);
|
|
||||||
});
|
|
||||||
|
|
||||||
}}.padBottom(-5).left().end();
|
}}.end().get();
|
||||||
}}.left().end();
|
|
||||||
|
|
||||||
row();
|
}}.end();
|
||||||
|
|
||||||
new table(){{
|
|
||||||
abottom();
|
|
||||||
aleft();
|
|
||||||
|
|
||||||
height(s+5+4);
|
|
||||||
|
|
||||||
next = new table("pane"){{
|
|
||||||
margin(5f);
|
|
||||||
|
|
||||||
defaults().padBottom(-5.5f);
|
|
||||||
|
|
||||||
new imagebutton("icon-arrow-right", 10 * 3, () -> {
|
|
||||||
toggle(!shown);
|
|
||||||
}).update(l -> l.getStyle().imageUp = Core.skin.getDrawable(shown ? "icon-arrow-left" : "icon-" + player.breakMode.name())).size(s, s+4);
|
|
||||||
|
|
||||||
}}.end().get();
|
|
||||||
|
|
||||||
breaktable = new table("pane"){{
|
|
||||||
visible(() -> shown);
|
|
||||||
margin(5f);
|
|
||||||
marginLeft(0f);
|
|
||||||
touchable(Touchable.enabled);
|
|
||||||
aleft();
|
|
||||||
|
|
||||||
defaults().size(s, s+4);
|
|
||||||
|
|
||||||
for(PlaceMode mode : PlaceMode.values()){
|
|
||||||
if(!mode.shown || !mode.delete) continue;
|
|
||||||
|
|
||||||
defaults().padBottom(-5.5f);
|
|
||||||
|
|
||||||
new imagebutton("icon-" + mode.name(), "toggle", 10*3, ()->{
|
|
||||||
control.getInput().resetCursor();
|
|
||||||
player.breakMode = mode;
|
|
||||||
if(!mode.both) player.placeMode = mode;
|
|
||||||
}).group(breakGroup).get().setName(mode.name());
|
|
||||||
}
|
|
||||||
|
|
||||||
}}.end().get();
|
|
||||||
|
|
||||||
breaktable.getParent().swapActor(breaktable, next);
|
|
||||||
|
|
||||||
breaktable.getTranslation().set(-breaktable.getPrefWidth(), 0);
|
|
||||||
|
|
||||||
}}.end().get();
|
|
||||||
|
|
||||||
}}.end();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void toggle(boolean show){
|
private void toggle(boolean show){
|
||||||
|
|||||||
@@ -1,56 +1,58 @@
|
|||||||
package io.anuke.mindustry.ui.fragments;
|
package io.anuke.mindustry.ui.fragments;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
|
||||||
|
|
||||||
import com.badlogic.gdx.Gdx;
|
import com.badlogic.gdx.Gdx;
|
||||||
import com.badlogic.gdx.math.Vector2;
|
import com.badlogic.gdx.math.Vector2;
|
||||||
import com.badlogic.gdx.utils.Align;
|
import com.badlogic.gdx.utils.Align;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.core.GameState;
|
import io.anuke.mindustry.core.GameState;
|
||||||
import io.anuke.mindustry.core.GameState.State;
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
|
import io.anuke.mindustry.input.InputHandler;
|
||||||
import io.anuke.mindustry.input.PlaceMode;
|
import io.anuke.mindustry.input.PlaceMode;
|
||||||
import io.anuke.ucore.core.Core;
|
import io.anuke.ucore.core.Core;
|
||||||
import io.anuke.ucore.core.Graphics;
|
import io.anuke.ucore.core.Graphics;
|
||||||
import io.anuke.ucore.scene.ui.layout.Table;
|
import io.anuke.ucore.scene.ui.layout.Table;
|
||||||
|
|
||||||
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class ToolFragment implements Fragment{
|
public class ToolFragment implements Fragment{
|
||||||
private Table tools;
|
private Table tools;
|
||||||
public int px, py, px2, py2;
|
public int px, py, px2, py2;
|
||||||
public boolean confirming;
|
public boolean confirming;
|
||||||
|
|
||||||
public void build(){
|
public void build(){
|
||||||
|
InputHandler input = control.getInput();
|
||||||
|
|
||||||
float isize = 14*3;
|
float isize = 14*3;
|
||||||
|
|
||||||
tools = new Table();
|
tools = new Table();
|
||||||
|
|
||||||
tools.addIButton("icon-cancel", isize, () -> {
|
tools.addIButton("icon-cancel", isize, () -> {
|
||||||
if(player.placeMode == PlaceMode.areaDelete && confirming){
|
if(input.placeMode == PlaceMode.areaDelete && confirming){
|
||||||
confirming = false;
|
confirming = false;
|
||||||
}else{
|
}else{
|
||||||
player.recipe = null;
|
input.recipe = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
tools.addIButton("icon-rotate", isize, () -> {
|
tools.addIButton("icon-rotate", isize, () -> {
|
||||||
player.placerot++;
|
input.rotation++;
|
||||||
player.placerot %= 4;
|
input.rotation %= 4;
|
||||||
});
|
});
|
||||||
|
|
||||||
tools.addIButton("icon-check", isize, () -> {
|
tools.addIButton("icon-check", isize, () -> {
|
||||||
if(player.placeMode == PlaceMode.areaDelete && confirming){
|
if(input.placeMode == PlaceMode.areaDelete && confirming){
|
||||||
player.placeMode.released(px, py, px2, py2);
|
input.placeMode.released(px, py, px2, py2);
|
||||||
confirming = false;
|
confirming = false;
|
||||||
}else{
|
}else{
|
||||||
player.placeMode.tapped(control.getInput().getBlockX(), control.getInput().getBlockY());
|
input.placeMode.tapped(control.getInput().getBlockX(), control.getInput().getBlockY());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Core.scene.add(tools);
|
Core.scene.add(tools);
|
||||||
|
|
||||||
tools.setVisible(() ->
|
tools.setVisible(() ->
|
||||||
!GameState.is(State.menu) && android && ((player.recipe != null && control.hasItems(player.recipe.requirements) &&
|
!GameState.is(State.menu) && android && ((input.recipe != null && control.hasItems(input.recipe.requirements) &&
|
||||||
player.placeMode == PlaceMode.cursor) || confirming)
|
input.placeMode == PlaceMode.cursor) || confirming)
|
||||||
);
|
);
|
||||||
|
|
||||||
tools.update(() -> {
|
tools.update(() -> {
|
||||||
@@ -63,7 +65,7 @@ public class ToolFragment implements Fragment{
|
|||||||
Gdx.graphics.getHeight() - control.getInput().getCursorY() - 15*Core.cameraScale, Align.top);
|
Gdx.graphics.getHeight() - control.getInput().getCursorY() - 15*Core.cameraScale, Align.top);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(player.placeMode != PlaceMode.areaDelete){
|
if(input.placeMode != PlaceMode.areaDelete){
|
||||||
confirming = false;
|
confirming = false;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ public class Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void draw(Tile tile){
|
public void draw(Tile tile){
|
||||||
//note: multiblocks do not support placerot
|
//note: multiblocks do not support rotation
|
||||||
if(!isMultiblock()){
|
if(!isMultiblock()){
|
||||||
Draw.rect(variants > 0 ? (name() + Mathf.randomSeed(tile.id(), 1, variants)) : name(),
|
Draw.rect(variants > 0 ? (name() + Mathf.randomSeed(tile.id(), 1, variants)) : name(),
|
||||||
tile.worldx(), tile.worldy(), rotate ? tile.getRotation() * 90 : 0);
|
tile.worldx(), tile.worldy(), rotate ? tile.getRotation() * 90 : 0);
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ public class Tile{
|
|||||||
|
|
||||||
/**Packed block data. Left is floor, right is block.*/
|
/**Packed block data. Left is floor, right is block.*/
|
||||||
private short blocks;
|
private short blocks;
|
||||||
/**Packed data. Left is placerot, right is extra data, packed into two half-bytes: left is dump, right is extra.*/
|
/**Packed data. Left is rotation, right is extra data, packed into two half-bytes: left is dump, right is extra.*/
|
||||||
private short data;
|
private short data;
|
||||||
/**The coordinates of the core tile this is linked to, in the form of two bytes packed into one.
|
/**The coordinates of the core tile this is linked to, in the form of two bytes packed into one.
|
||||||
* This is relative to the block it is linked to; negate coords to find the link.*/
|
* This is relative to the block it is linked to; negate coords to find the link.*/
|
||||||
@@ -56,7 +56,7 @@ public class Tile{
|
|||||||
return Bits.getLeftByte(blocks);
|
return Bits.getLeftByte(blocks);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Return relative placerot to a coordinate. Returns -1 if the coordinate is not near this tile.*/
|
/**Return relative rotation to a coordinate. Returns -1 if the coordinate is not near this tile.*/
|
||||||
public int relativeTo(int cx, int cy){
|
public int relativeTo(int cx, int cy){
|
||||||
if(x == cx && y == cy - 1) return 1;
|
if(x == cx && y == cy - 1) return 1;
|
||||||
if(x == cx && y == cy + 1) return 3;
|
if(x == cx && y == cy + 1) return 3;
|
||||||
|
|||||||
@@ -1,14 +1,11 @@
|
|||||||
package io.anuke.mindustry.world.blocks;
|
package io.anuke.mindustry.world.blocks;
|
||||||
|
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
|
||||||
import io.anuke.mindustry.graphics.Fx;
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
import io.anuke.mindustry.resource.Item;
|
import io.anuke.mindustry.resource.Item;
|
||||||
import io.anuke.mindustry.resource.Liquid;
|
import io.anuke.mindustry.resource.Liquid;
|
||||||
import io.anuke.mindustry.world.Block;
|
import io.anuke.mindustry.world.Block;
|
||||||
import io.anuke.mindustry.world.Tile;
|
|
||||||
import io.anuke.mindustry.world.blocks.types.defense.CoreBlock;
|
import io.anuke.mindustry.world.blocks.types.defense.CoreBlock;
|
||||||
import io.anuke.mindustry.world.blocks.types.production.*;
|
import io.anuke.mindustry.world.blocks.types.production.*;
|
||||||
import io.anuke.ucore.core.Effects;
|
|
||||||
|
|
||||||
public class ProductionBlocks{
|
public class ProductionBlocks{
|
||||||
public static final Block
|
public static final Block
|
||||||
@@ -152,32 +149,8 @@ public class ProductionBlocks{
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
omnidrill = new Drill("omnidrill"){
|
omnidrill = new Omnidrill("omnidrill"){
|
||||||
{
|
|
||||||
drillEffect = Fx.sparkbig;
|
|
||||||
resource = null;
|
|
||||||
result = null;
|
|
||||||
time = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(Tile tile){
|
|
||||||
TileEntity entity = tile.entity;
|
|
||||||
|
|
||||||
if(tile.floor().drops != null && entity.timer.get(timerDrill, 60 * time)){
|
|
||||||
offloadNear(tile, tile.floor().drops.item);
|
|
||||||
Effects.effect(drillEffect, tile.worldx(), tile.worldy());
|
|
||||||
}
|
|
||||||
|
|
||||||
if(entity.timer.get(timerDump, 30)){
|
|
||||||
tryDump(tile);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isLayer(Tile tile){
|
|
||||||
return tile.floor().drops == null;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
coalgenerator = new ItemPowerGenerator("coalgenerator"){
|
coalgenerator = new ItemPowerGenerator("coalgenerator"){
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,59 @@
|
|||||||
|
package io.anuke.mindustry.world.blocks.types.production;
|
||||||
|
|
||||||
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
|
import io.anuke.mindustry.graphics.Fx;
|
||||||
|
import io.anuke.mindustry.resource.Item;
|
||||||
|
import io.anuke.mindustry.world.Block;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
import io.anuke.ucore.core.Draw;
|
||||||
|
import io.anuke.ucore.core.Effects;
|
||||||
|
import io.anuke.ucore.util.Tmp;
|
||||||
|
|
||||||
|
public class Omnidrill extends Drill {
|
||||||
|
|
||||||
|
public Omnidrill(String name){
|
||||||
|
super(name);
|
||||||
|
drillEffect = Fx.sparkbig;
|
||||||
|
resource = null;
|
||||||
|
result = null;
|
||||||
|
time = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void draw(Tile tile){
|
||||||
|
super.draw(tile);
|
||||||
|
|
||||||
|
if(tile.floor().drops == null) return;
|
||||||
|
Item item = tile.floor().drops.item;
|
||||||
|
|
||||||
|
TextureRegion region = Draw.region("icon-" + item.name);
|
||||||
|
Tmp.tr1.setRegion(region, 4, 4, 1, 1);
|
||||||
|
|
||||||
|
Draw.rect(Tmp.tr1, tile.worldx(), tile.worldy(), 2f, 2f);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canReplace(Block other) {
|
||||||
|
return other instanceof Drill && other != this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void update(Tile tile){
|
||||||
|
TileEntity entity = tile.entity;
|
||||||
|
|
||||||
|
if(tile.floor().drops != null && entity.timer.get(timerDrill, 60 * time)){
|
||||||
|
offloadNear(tile, tile.floor().drops.item);
|
||||||
|
Effects.effect(drillEffect, tile.worldx(), tile.worldy());
|
||||||
|
}
|
||||||
|
|
||||||
|
if(entity.timer.get(timerDump, 30)){
|
||||||
|
tryDump(tile);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isLayer(Tile tile){
|
||||||
|
return tile.floor().drops == null;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -10,6 +10,8 @@ import io.anuke.kryonet.KryoClient;
|
|||||||
import io.anuke.kryonet.KryoServer;
|
import io.anuke.kryonet.KryoServer;
|
||||||
import io.anuke.mindustry.Mindustry;
|
import io.anuke.mindustry.Mindustry;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
|
import io.anuke.mindustry.core.GameState;
|
||||||
|
import io.anuke.mindustry.core.GameState.State;
|
||||||
import io.anuke.mindustry.io.PlatformFunction;
|
import io.anuke.mindustry.io.PlatformFunction;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.ucore.scene.ui.TextField;
|
import io.anuke.ucore.scene.ui.TextField;
|
||||||
@@ -38,7 +40,7 @@ public class DesktopLauncher {
|
|||||||
config.setWindowIcon("sprites/icon.png");
|
config.setWindowIcon("sprites/icon.png");
|
||||||
|
|
||||||
DiscordRPC lib = DiscordRPC.INSTANCE;
|
DiscordRPC lib = DiscordRPC.INSTANCE;
|
||||||
String applicationId = "397335883319083018";
|
String applicationId = "398246104468291591";
|
||||||
DiscordEventHandlers handlers = new DiscordEventHandlers();
|
DiscordEventHandlers handlers = new DiscordEventHandlers();
|
||||||
lib.Discord_Initialize(applicationId, handlers, true, "");
|
lib.Discord_Initialize(applicationId, handlers, true, "");
|
||||||
|
|
||||||
@@ -67,24 +69,34 @@ public class DesktopLauncher {
|
|||||||
|
|
||||||
@Override public void addDialog(TextField field){}
|
@Override public void addDialog(TextField field){}
|
||||||
@Override public void openDonations(){}
|
@Override public void openDonations(){}
|
||||||
@Override public void requestWritePerms() {}
|
@Override public void requestWritePerms(){}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSceneChange(String state, String details, String icon) {
|
public void updateRPC() {
|
||||||
DiscordRichPresence presence = new DiscordRichPresence();
|
DiscordRichPresence presence = new DiscordRichPresence();
|
||||||
presence.startTimestamp = System.currentTimeMillis() / 1000; // epoch second
|
|
||||||
presence.state = state;
|
if(!GameState.is(State.menu)){
|
||||||
presence.details = details;
|
presence.state = "Map: " + Strings.capitalize(Vars.world.getMap().name);
|
||||||
|
presence.details = "Wave " + Vars.control.getWave();
|
||||||
|
if(Net.active() ){
|
||||||
|
presence.partyMax = 16;
|
||||||
|
presence.partySize = Vars.control.playerGroup.amount();
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
presence.state = "In Menu";
|
||||||
|
}
|
||||||
|
|
||||||
|
//presence.startTimestamp = System.currentTimeMillis() / 1000; // epoch second
|
||||||
presence.largeImageKey = "logo";
|
presence.largeImageKey = "logo";
|
||||||
presence.largeImageText = details;
|
presence.largeImageText = presence.details;
|
||||||
|
|
||||||
lib.Discord_UpdatePresence(presence);
|
lib.Discord_UpdatePresence(presence);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onGameExit() {
|
public void onGameExit() {
|
||||||
DiscordRPC.INSTANCE.Discord_Shutdown();
|
DiscordRPC.INSTANCE.Discord_Shutdown();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Mindustry.args = Array.with(arg);
|
Mindustry.args = Array.with(arg);
|
||||||
@@ -97,7 +109,7 @@ public class DesktopLauncher {
|
|||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
||||||
//don't create crash logs for me, as it's expected
|
//don't create crash logs for me (anuke), as it's expected
|
||||||
if(System.getProperty("user.name").equals("anuke")) return;
|
if(System.getProperty("user.name").equals("anuke")) return;
|
||||||
|
|
||||||
String result = Strings.parseException(e, true);
|
String result = Strings.parseException(e, true);
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ public class HtmlLauncher extends GwtApplication {
|
|||||||
Window.open(link, "_blank", "");
|
Window.open(link, "_blank", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onSceneChange(String state, String details, String icon) {}
|
@Override public void updateRPC() {}
|
||||||
@Override public void onGameExit() {}
|
@Override public void onGameExit() {}
|
||||||
@Override public void addDialog(TextField field){}
|
@Override public void addDialog(TextField field){}
|
||||||
@Override public void openDonations(){}
|
@Override public void openDonations(){}
|
||||||
|
|||||||
Reference in New Issue
Block a user