Updated Bullet to use floats
This commit is contained in:
@@ -5,6 +5,7 @@ import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import com.badlogic.gdx.utils.reflect.Method;
|
||||
import com.badlogic.gdx.utils.reflect.ReflectionException;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.net.Net.SendMode;
|
||||
import io.anuke.mindustry.net.Packets.InvokePacket;
|
||||
@@ -17,6 +18,8 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.nio.ByteBuffer;
|
||||
|
||||
import static io.anuke.mindustry.Vars.playerGroup;
|
||||
|
||||
/**Class for invoking static methods of other classes remotely.*/
|
||||
public class Invoke {
|
||||
private static ObjectMap<Class, ObjectMap<String, Method>> methods = new ObjectMap<>();
|
||||
@@ -52,6 +55,10 @@ public class Invoke {
|
||||
on(NetEvents.class, methodName, args);
|
||||
}
|
||||
|
||||
public static void eventRemote(String methodName, Object... args){
|
||||
on(NetEvents.class, methodName, args);
|
||||
}
|
||||
|
||||
//TODO refactor to serializer map!
|
||||
static void writeObjects(ByteBuffer buffer, Object[] objects){
|
||||
for(Object o : objects){
|
||||
@@ -76,6 +83,8 @@ public class Invoke {
|
||||
}else if(type == Entity.class){
|
||||
buffer.put((byte)((Entity)o).getGroup().getID());
|
||||
buffer.putInt(((Entity)o).id);
|
||||
}else if(type == Player.class){
|
||||
buffer.putInt(((Player)o).id);
|
||||
}else if(type == Team.class){
|
||||
buffer.put((byte)((Team)o).ordinal());
|
||||
}else if(type == String.class){
|
||||
@@ -110,6 +119,9 @@ public class Invoke {
|
||||
byte group = buffer.get();
|
||||
int id = buffer.getInt();
|
||||
obj = Entities.getGroup(group).getByID(id);
|
||||
}else if(type == Player.class){
|
||||
int id = buffer.getInt();
|
||||
obj = playerGroup.getByID(id);
|
||||
}else if(type == Team.class){
|
||||
obj = Team.values()[buffer.get()];
|
||||
}else if(type == String.class){
|
||||
|
||||
@@ -18,13 +18,10 @@ import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class NetEvents {
|
||||
|
||||
public static void handleFriendlyFireChange(boolean enabled){
|
||||
FriendlyFireChangePacket packet = Pools.obtain(FriendlyFireChangePacket.class);
|
||||
packet.enabled = enabled;
|
||||
public static void friendlyFireChange(boolean enabled){
|
||||
state.friendlyFire = enabled;
|
||||
|
||||
netCommon.sendMessage(enabled ? "[accent]Friendly fire enabled." : "[accent]Friendly fire disabled.");
|
||||
|
||||
Net.send(packet, SendMode.tcp);
|
||||
if(Net.server()) netCommon.sendMessage(enabled ? "[accent]Friendly fire enabled." : "[accent]Friendly fire disabled.");
|
||||
}
|
||||
|
||||
public static void handleGameOver(){
|
||||
@@ -117,12 +114,12 @@ public class NetEvents {
|
||||
Net.send(packet, SendMode.tcp);
|
||||
}
|
||||
|
||||
public static void handleAdminSet(Player player, boolean admin){
|
||||
PlayerAdminPacket packet = Pools.obtain(PlayerAdminPacket.class);
|
||||
packet.admin = admin;
|
||||
packet.id = player.id;
|
||||
public static void adminSet(Player player, boolean admin){
|
||||
player.isAdmin = admin;
|
||||
Net.send(packet, SendMode.tcp);
|
||||
|
||||
if(Net.client()){
|
||||
ui.listfrag.rebuild();
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleAdministerRequest(Player target, AdminAction action){
|
||||
|
||||
@@ -477,24 +477,6 @@ public class Packets {
|
||||
public void read(ByteBuffer buffer) { }
|
||||
}
|
||||
|
||||
public static class FriendlyFireChangePacket implements Packet{
|
||||
public boolean enabled;
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer buffer) {
|
||||
buffer.put(enabled ? 1 : (byte)0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuffer buffer) {
|
||||
enabled = buffer.get() == 1;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CustomMapPacket extends Streamable{
|
||||
|
||||
}
|
||||
|
||||
public static class MapAckPacket implements Packet{
|
||||
@Override
|
||||
public void write(ByteBuffer buffer) { }
|
||||
@@ -517,23 +499,6 @@ public class Packets {
|
||||
}
|
||||
}
|
||||
|
||||
public static class PlayerAdminPacket implements Packet{
|
||||
public boolean admin;
|
||||
public int id;
|
||||
|
||||
@Override
|
||||
public void write(ByteBuffer buffer) {
|
||||
buffer.put(admin ? (byte)1 : 0);
|
||||
buffer.putInt(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(ByteBuffer buffer) {
|
||||
admin = buffer.get() == 1;
|
||||
id = buffer.getInt();
|
||||
}
|
||||
}
|
||||
|
||||
public static class AdministerRequestPacket implements Packet{
|
||||
public AdminAction action;
|
||||
public int id;
|
||||
|
||||
@@ -32,12 +32,9 @@ public class Registrator {
|
||||
EntityRequestPacket.class,
|
||||
ConnectConfirmPacket.class,
|
||||
GameOverPacket.class,
|
||||
FriendlyFireChangePacket.class,
|
||||
CustomMapPacket.class,
|
||||
MapAckPacket.class,
|
||||
EntitySpawnPacket.class,
|
||||
NetErrorPacket.class,
|
||||
PlayerAdminPacket.class,
|
||||
AdministerRequestPacket.class,
|
||||
TracePacket.class,
|
||||
InvokePacket.class,
|
||||
|
||||
Reference in New Issue
Block a user