1
0
mirror of https://github.com/Anuken/Mindustry.git synced 2024-11-11 14:56:10 +03:00

Updated RDX item, changed packet creation to use pooling

This commit is contained in:
Anuken 2018-05-08 10:53:36 -04:00
parent 7a94ebcf2a
commit 6cc1cecf5a
6 changed files with 21 additions and 16 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 241 B

After

Width:  |  Height:  |  Size: 233 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 107 KiB

After

Width:  |  Height:  |  Size: 107 KiB

View File

@ -64,7 +64,7 @@ public class Items {
fluxiness = 0.5f;
}
},
rdx = new Item("rdx", Color.valueOf("e3d39e")){
rdx = new Item("rdx", Color.valueOf("ff795e")){
{
material = false;
flammability = 0.2f;

View File

@ -1,5 +1,6 @@
package io.anuke.mindustry.net;
import com.badlogic.gdx.utils.Pools;
import io.anuke.mindustry.Vars;
import io.anuke.mindustry.entities.Player;
import io.anuke.mindustry.entities.SyncEntity;
@ -16,7 +17,7 @@ import static io.anuke.mindustry.Vars.*;
public class NetEvents {
public static void handleFriendlyFireChange(boolean enabled){
FriendlyFireChangePacket packet = new FriendlyFireChangePacket();
FriendlyFireChangePacket packet = Pools.obtain(FriendlyFireChangePacket.class);
packet.enabled = enabled;
netCommon.sendMessage(enabled ? "[accent]Friendly fire enabled." : "[accent]Friendly fire disabled.");
@ -25,57 +26,57 @@ public class NetEvents {
}
public static void handleGameOver(){
Net.send(new GameOverPacket(), SendMode.tcp);
Net.send(Pools.obtain(GameOverPacket.class), SendMode.tcp);
}
public static void handleUnitDeath(Unit entity){
EntityDeathPacket packet = new EntityDeathPacket();
EntityDeathPacket packet = Pools.obtain(EntityDeathPacket.class);
packet.id = entity.id;
packet.group = (byte)entity.getGroup().getID();
Net.send(packet, SendMode.tcp);
}
public static void handleBlockDestroyed(TileEntity entity){
BlockDestroyPacket packet = new BlockDestroyPacket();
BlockDestroyPacket packet = Pools.obtain(BlockDestroyPacket.class);
packet.position = entity.tile.packedPosition();
Net.send(packet, SendMode.tcp);
}
public static void handleBlockDamaged(TileEntity entity){
BlockUpdatePacket packet = new BlockUpdatePacket();
BlockUpdatePacket packet = Pools.obtain(BlockUpdatePacket.class);
packet.health = (int)entity.health;
packet.position = entity.tile.packedPosition();
Net.send(packet, SendMode.udp);
}
public static void handleBlockConfig(Tile tile, byte data){
BlockConfigPacket packet = new BlockConfigPacket();
BlockConfigPacket packet = Pools.obtain(BlockConfigPacket.class);
packet.data = data;
packet.position = tile.packedPosition();
Net.send(packet, SendMode.tcp);
}
public static void handleBlockTap(Tile tile){
BlockTapPacket packet = new BlockTapPacket();
BlockTapPacket packet = Pools.obtain(BlockTapPacket.class);
packet.position = tile.packedPosition();
Net.send(packet, SendMode.tcp);
}
public static void handleWeaponSwitch(){
WeaponSwitchPacket packet = new WeaponSwitchPacket();
WeaponSwitchPacket packet = Pools.obtain(WeaponSwitchPacket.class);
packet.weapon = Vars.player.weapon.id;
packet.playerid = Vars.player.id;
Net.send(packet, SendMode.tcp);
}
public static void handleUpgrade(Weapon weapon){
UpgradePacket packet = new UpgradePacket();
UpgradePacket packet = Pools.obtain(UpgradePacket.class);
packet.id = weapon.id;
Net.send(packet, SendMode.tcp);
}
public static void handleSendMessage(String message){
ChatPacket packet = new ChatPacket();
ChatPacket packet = Pools.obtain(ChatPacket.class);
packet.text = message;
packet.name = player.name;
packet.id = player.id;
@ -87,7 +88,7 @@ public class NetEvents {
}
public static void handleShoot(SyncEntity entity, float x, float y, float angle, short data){
EntityShootPacket packet = new EntityShootPacket();
EntityShootPacket packet = Pools.obtain(EntityShootPacket.class);
packet.groupid = (byte)entity.getGroup().getID();
packet.x = x;
packet.y = y;
@ -98,7 +99,7 @@ public class NetEvents {
}
public static void handlePlace(int x, int y, Block block, int rotation){
PlacePacket packet = new PlacePacket();
PlacePacket packet = Pools.obtain(PlacePacket.class);
packet.x = (short)x;
packet.y = (short)y;
packet.rotation = (byte)rotation;
@ -108,14 +109,14 @@ public class NetEvents {
}
public static void handleBreak(int x, int y){
BreakPacket packet = new BreakPacket();
BreakPacket packet = Pools.obtain(BreakPacket.class);
packet.x = (short)x;
packet.y = (short)y;
Net.send(packet, SendMode.tcp);
}
public static void handleAdminSet(Player player, boolean admin){
PlayerAdminPacket packet = new PlayerAdminPacket();
PlayerAdminPacket packet = Pools.obtain(PlayerAdminPacket.class);
packet.admin = admin;
packet.id = player.id;
player.isAdmin = admin;
@ -123,7 +124,7 @@ public class NetEvents {
}
public static void handleAdministerRequest(Player target, AdminAction action){
AdministerRequestPacket packet = new AdministerRequestPacket();
AdministerRequestPacket packet = Pools.obtain(AdministerRequestPacket.class);
packet.id = target.id;
packet.action = action;
Net.send(packet, SendMode.tcp);

View File

@ -4,6 +4,7 @@ import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.ObjectMap;
import com.badlogic.gdx.utils.ObjectSet;
import com.badlogic.gdx.utils.Pools;
import com.esotericsoftware.kryonet.*;
import com.esotericsoftware.kryonet.Listener.LagListener;
import com.esotericsoftware.minlog.Log;
@ -132,6 +133,7 @@ public class KryoClient implements ClientProvider{
}else{
client.sendUDP(object);
}
Pools.free(object);
}
@Override

View File

@ -3,6 +3,7 @@ package io.anuke.kryonet;
import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.utils.Array;
import com.badlogic.gdx.utils.Base64Coder;
import com.badlogic.gdx.utils.Pools;
import com.esotericsoftware.kryonet.Connection;
import com.esotericsoftware.kryonet.FrameworkMessage;
import com.esotericsoftware.kryonet.Listener;
@ -361,6 +362,7 @@ public class KryoServer implements ServerProvider {
Log.info("Connection removed {0}", k);
}
}
Pools.free(object);
}
@Override