More multiplayer setup, possible android support

This commit is contained in:
Anuken
2017-12-31 22:06:18 -05:00
parent 701c7f6e78
commit 62ae6dc159
13 changed files with 354 additions and 206 deletions

View File

@@ -1,6 +1,7 @@
package io.anuke.mindustry.net;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.IntArray;
import com.badlogic.gdx.utils.IntMap;
import com.badlogic.gdx.utils.ObjectMap;
import io.anuke.mindustry.net.Streamable.StreamBegin;
@@ -48,6 +49,11 @@ public class Net{
server = false;
active = false;
}
/**Returns a list of all connections IDs.*/
public static IntArray getConnections(){
return serverProvider.getConnections();
}
/**Send an object to all connected clients, or to the server if this is a client.*/
public static void send(Object object, SendMode mode){
@@ -182,6 +188,8 @@ public class Net{
public void sendExcept(int id, Object object, SendMode mode);
/**Close the server connection.*/
public void close();
/**Return all connected users.*/
public IntArray getConnections();
/**Register classes to be sent.*/
public void register(Class<?>... types);
}

View File

@@ -96,6 +96,6 @@ public class Packets {
}
public static class BlockUpdatePacket{
public int health;
public int health, position;
}
}

View File

@@ -29,6 +29,8 @@ public class Registrator {
PathPacket.class,
BulletPacket.class,
EnemyDeathPacket.class,
BlockUpdatePacket.class,
BlockDestroyPacket.class,
Class.class,
byte[].class,

View File

@@ -1,9 +1,14 @@
package io.anuke.mindustry.net;
import com.badlogic.gdx.math.Vector2;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.enemies.Enemy;
import io.anuke.mindustry.graphics.Fx;
import io.anuke.ucore.core.Effects;
import io.anuke.ucore.core.Timers;
import io.anuke.ucore.entities.Entity;
import io.anuke.ucore.util.Angles;
import io.anuke.ucore.util.Mathf;
//TODO clean up this giant mess
@@ -36,6 +41,11 @@ public interface Syncable {
entity.set(i.target.x, i.target.y);
}
if(Vars.android && i.target.dst(entity.x, entity.y) > 2f && Timers.get(entity, "dashfx", 3)){
Angles.translation(entity.angle + 180, 3f);
Effects.effect(Fx.dashsmoke, entity.x + Angles.x(), entity.y + Angles.y());
}
entity.x = Mathf.lerpDelta(entity.x, i.target.x, 0.4f);
entity.y = Mathf.lerpDelta(entity.y, i.target.y, 0.4f);
entity.angle = Mathf.lerpAngDelta(entity.angle, i.targetrot, 0.6f);