Improvements to annotation code generation system, client RMI
This commit is contained in:
@@ -10,6 +10,7 @@ import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.SyncEntity;
|
||||
import io.anuke.mindustry.gen.CallServer;
|
||||
import io.anuke.mindustry.io.Platform;
|
||||
import io.anuke.mindustry.io.Version;
|
||||
import io.anuke.mindustry.net.*;
|
||||
@@ -162,6 +163,10 @@ public class NetServer extends Module{
|
||||
//...don't do anything here as it's already handled by the packet itself
|
||||
});
|
||||
|
||||
Net.handleServer(InvokePacket.class, (id, packet) -> {
|
||||
CallServer.readPacket(packet.writeBuffer, packet.type, connections.get(id));
|
||||
});
|
||||
|
||||
Net.handleServer(EntityShootPacket.class, (id, packet) -> {
|
||||
Player player = connections.get(id);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import io.anuke.ucore.scene.builders.table;
|
||||
import io.anuke.ucore.scene.ui.*;
|
||||
import io.anuke.ucore.scene.ui.layout.Stack;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.utils.UIUtils;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.input.Input;
|
||||
import io.anuke.ucore.util.Log;
|
||||
@@ -387,15 +388,14 @@ public class MapEditorDialog extends Dialog{
|
||||
private void doInput(){
|
||||
//tool select
|
||||
for(int i = 0; i < EditorTool.values().length; i ++){
|
||||
int code = i == 0 ? 5 : i;
|
||||
if(Inputs.keyTap("weapon_" + code)){
|
||||
if(Inputs.keyTap(Input.valueOf("NUM_" + (i+1)))){
|
||||
view.setTool(EditorTool.values()[i]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//ctrl keys (undo, redo, save)
|
||||
if(Inputs.keyDown(Input.CONTROL_LEFT)){
|
||||
if(UIUtils.ctrl()){
|
||||
if(Inputs.keyTap(Input.Z)){
|
||||
view.undo();
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import io.anuke.mindustry.content.Weapons;
|
||||
import io.anuke.mindustry.content.fx.ExplosionFx;
|
||||
import io.anuke.mindustry.entities.effect.DamageArea;
|
||||
import io.anuke.mindustry.game.Team;
|
||||
import io.anuke.mindustry.gen.CallClient;
|
||||
import io.anuke.mindustry.graphics.Palette;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.NetEvents;
|
||||
@@ -338,7 +339,8 @@ public class Player extends Unit implements BlockPlacer{
|
||||
currentPlace = null;
|
||||
}else if(distanceTo(check) <= placeDistance){
|
||||
BuildEntity entity = check.entity();
|
||||
entity.progress += 1f / entity.result.health;
|
||||
|
||||
entity.progress += 1f / entity.recipe.cost;
|
||||
rotation = Mathf.slerpDelta(rotation, angleTo(entity), 0.4f);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,8 @@ package io.anuke.mindustry.net;
|
||||
|
||||
import com.badlogic.gdx.utils.Pools;
|
||||
import io.anuke.annotations.Annotations.Local;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
import io.anuke.annotations.Annotations.RemoteClient;
|
||||
import io.anuke.annotations.Annotations.RemoteServer;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.SyncEntity;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
@@ -17,7 +18,7 @@ import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class NetEvents {
|
||||
|
||||
@Remote
|
||||
@RemoteClient
|
||||
@Local
|
||||
public static void friendlyFireChange(boolean enabled){
|
||||
state.friendlyFire = enabled;
|
||||
@@ -25,6 +26,17 @@ public class NetEvents {
|
||||
if(Net.server()) netCommon.sendMessage(enabled ? "[accent]Friendly fire enabled." : "[accent]Friendly fire disabled.");
|
||||
}
|
||||
|
||||
@RemoteServer
|
||||
public static void notifySomethingFromClient(Player player, int x, float y){
|
||||
|
||||
}
|
||||
|
||||
@RemoteClient
|
||||
@Local
|
||||
public static void notifySomethingFromServerLocal(int y, float x, boolean w){
|
||||
|
||||
}
|
||||
|
||||
public static void handleGameOver(){
|
||||
Net.send(Pools.obtain(GameOverPacket.class), SendMode.tcp);
|
||||
}
|
||||
@@ -116,7 +128,7 @@ public class NetEvents {
|
||||
Net.send(packet, SendMode.tcp);
|
||||
}
|
||||
|
||||
@Remote
|
||||
@RemoteClient
|
||||
@Local
|
||||
public static void adminSet(Player player, boolean admin){
|
||||
player.isAdmin = admin;
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.badlogic.gdx.utils.reflect.ReflectionException;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.SyncEntity;
|
||||
import io.anuke.mindustry.gen.CallEvent;
|
||||
import io.anuke.mindustry.gen.CallClient;
|
||||
import io.anuke.mindustry.io.Version;
|
||||
import io.anuke.mindustry.net.Packet.ImportantPacket;
|
||||
import io.anuke.mindustry.net.Packet.UnimportantPacket;
|
||||
@@ -43,9 +43,11 @@ public class Packets {
|
||||
type = buffer.get();
|
||||
|
||||
if(Net.client()){
|
||||
CallEvent.readPacket(buffer, type);
|
||||
CallClient.readPacket(buffer, type);
|
||||
}else{
|
||||
buffer.position(buffer.position() + writeLength);
|
||||
byte[] bytes = new byte[writeLength];
|
||||
buffer.get(bytes);
|
||||
writeBuffer = ByteBuffer.wrap(bytes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,9 @@ public class Item implements Comparable<Item>{
|
||||
public int hardness = 0;
|
||||
/**the burning color of this item*/
|
||||
public Color flameColor = Palette.darkFlame.cpy();
|
||||
/**base material cost of this item, used for calculating place times
|
||||
* 1 cost = 1 tick added to build time*/
|
||||
public float cost = 1f;
|
||||
|
||||
public Item(String name, Color color) {
|
||||
this.id = items.size;
|
||||
|
||||
@@ -13,6 +13,7 @@ public class Recipe {
|
||||
public final Block result;
|
||||
public final ItemStack[] requirements;
|
||||
public final Section section;
|
||||
public final float cost;
|
||||
|
||||
public boolean desktopOnly = false, debugOnly = false;
|
||||
|
||||
@@ -22,6 +23,13 @@ public class Recipe {
|
||||
this.requirements = requirements;
|
||||
this.section = section;
|
||||
|
||||
float timeToPlace = 0f;
|
||||
for(ItemStack stack : requirements){
|
||||
timeToPlace += stack.amount * stack.item.cost;
|
||||
}
|
||||
|
||||
this.cost = timeToPlace;
|
||||
|
||||
allRecipes.add(this);
|
||||
recipeMap.put(result, this);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.gen.CallEvent;
|
||||
import io.anuke.mindustry.gen.CallClient;
|
||||
import io.anuke.mindustry.net.Administration.PlayerInfo;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.NetConnection;
|
||||
@@ -49,7 +49,7 @@ public class AdminsDialog extends FloatingDialog {
|
||||
for(Player player : playerGroup.all()){
|
||||
NetConnection c = Net.getConnection(player.clientid);
|
||||
if(c != null){
|
||||
CallEvent.adminSet(player, false);
|
||||
CallClient.adminSet(player, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package io.anuke.mindustry.ui.fragments;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.gen.CallEvent;
|
||||
import io.anuke.mindustry.gen.CallClient;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.mindustry.net.NetConnection;
|
||||
import io.anuke.mindustry.net.NetEvents;
|
||||
@@ -49,7 +49,7 @@ public class PlayerListFragment implements Fragment{
|
||||
margin(12f);
|
||||
|
||||
get().addCheck("$text.server.friendlyfire", b -> {
|
||||
CallEvent.friendlyFireChange(b);
|
||||
// CallClient.friendlyFireChange(b);
|
||||
}).growX().update(i -> i.setChecked(state.friendlyFire)).disabled(b -> Net.client()).padRight(5);
|
||||
|
||||
new button("$text.server.bans", () -> {
|
||||
@@ -160,12 +160,12 @@ public class PlayerListFragment implements Fragment{
|
||||
if(netServer.admins.isAdmin(id, connection.address)){
|
||||
ui.showConfirm("$text.confirm", "$text.confirmunadmin", () -> {
|
||||
netServer.admins.unAdminPlayer(id);
|
||||
CallEvent.adminSet(player, false);
|
||||
CallClient.adminSet(player, false);
|
||||
});
|
||||
}else{
|
||||
ui.showConfirm("$text.confirm", "$text.confirmadmin", () -> {
|
||||
netServer.admins.adminPlayer(id, connection.address);
|
||||
CallEvent.adminSet(player, true);
|
||||
CallClient.adminSet(player, true);
|
||||
});
|
||||
}
|
||||
}).update(b ->{
|
||||
|
||||
Reference in New Issue
Block a user