Pools replace with Pooling / Removed all core reflection
This commit is contained in:
@@ -82,7 +82,7 @@ public class Renderer extends RendererModule{
|
||||
if(view.overlaps(pos)){
|
||||
|
||||
if(!(effect instanceof GroundEffect)){
|
||||
EffectEntity entity = Pooling.obtain(EffectEntity.class);
|
||||
EffectEntity entity = Pooling.obtain(EffectEntity.class, EffectEntity::new);
|
||||
entity.effect = effect;
|
||||
entity.color = color;
|
||||
entity.rotation = rotation;
|
||||
@@ -94,7 +94,7 @@ public class Renderer extends RendererModule{
|
||||
}
|
||||
threads.runGraphics(() -> effectGroup.add(entity));
|
||||
}else{
|
||||
GroundEffectEntity entity = Pooling.obtain(GroundEffectEntity.class);
|
||||
GroundEffectEntity entity = Pooling.obtain(GroundEffectEntity.class, GroundEffectEntity::new);
|
||||
entity.effect = effect;
|
||||
entity.color = color;
|
||||
entity.rotation = rotation;
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Pools;
|
||||
import com.badlogic.gdx.utils.Queue;
|
||||
import io.anuke.annotations.Annotations.Loc;
|
||||
import io.anuke.annotations.Annotations.Remote;
|
||||
@@ -373,7 +372,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
|
||||
public void drawName(){
|
||||
GlyphLayout layout = Pools.obtain(GlyphLayout.class);
|
||||
GlyphLayout layout = Pooling.obtain(GlyphLayout.class, GlyphLayout::new);
|
||||
|
||||
Draw.tscl(0.25f / 2);
|
||||
layout.setText(Core.font, name);
|
||||
@@ -390,7 +389,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
||||
}
|
||||
|
||||
Draw.reset();
|
||||
Pools.free(layout);
|
||||
Pooling.free(layout);
|
||||
Draw.tscl(fontScale);
|
||||
}
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class StatusController implements Saveable{
|
||||
}
|
||||
|
||||
//otherwise, no opposites found, add direct effect
|
||||
StatusEntry entry = Pooling.obtain(StatusEntry.class);
|
||||
StatusEntry entry = Pooling.obtain(StatusEntry.class, StatusEntry::new);
|
||||
entry.set(effect, newTime);
|
||||
statuses.add(entry);
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public class StatusController implements Saveable{
|
||||
for(int i = 0; i < amount; i++){
|
||||
byte id = stream.readByte();
|
||||
float time = stream.readShort() / 2f;
|
||||
StatusEntry entry = Pooling.obtain(StatusEntry.class);
|
||||
StatusEntry entry = Pooling.obtain(StatusEntry.class, StatusEntry::new);
|
||||
entry.set(content.getByID(ContentType.status, id), time);
|
||||
statuses.add(entry);
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
||||
}
|
||||
|
||||
public static void create(BulletType type, Entity owner, Team team, float x, float y, float angle, float velocityScl, float lifetimeScl, Object data){
|
||||
Bullet bullet = Pooling.obtain(Bullet.class);
|
||||
Bullet bullet = Pooling.obtain(Bullet.class, Bullet::new);
|
||||
bullet.type = type;
|
||||
bullet.owner = owner;
|
||||
bullet.data = data;
|
||||
|
||||
@@ -56,7 +56,7 @@ public class Fire extends TimedEntity implements SaveTrait, SyncTrait, Poolable{
|
||||
Fire fire = map.get(tile.packedPosition());
|
||||
|
||||
if(fire == null){
|
||||
fire = Pooling.obtain(Fire.class);
|
||||
fire = Pooling.obtain(Fire.class, Fire::new);
|
||||
fire.tile = tile;
|
||||
fire.lifetime = baseLifetime;
|
||||
fire.set(tile.worldx(), tile.worldy());
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ItemTransfer extends TimedEntity implements DrawTrait{
|
||||
}
|
||||
|
||||
public static void create(Item item, float fromx, float fromy, PosTrait to, Runnable done){
|
||||
ItemTransfer tr = Pooling.obtain(ItemTransfer.class);
|
||||
ItemTransfer tr = Pooling.obtain(ItemTransfer.class, ItemTransfer::new);
|
||||
tr.item = item;
|
||||
tr.from.set(fromx, fromy);
|
||||
tr.to = to;
|
||||
|
||||
@@ -59,7 +59,7 @@ public class Lightning extends TimedEntity implements Poolable, DrawTrait, SyncT
|
||||
/**Do not invoke!*/
|
||||
@Remote(called = Loc.server)
|
||||
public static void createLighting(int seed, Team team, Effect effect, Color color, float damage, float x, float y, float targetAngle, int length){
|
||||
Lightning l = Pooling.obtain(Lightning.class);
|
||||
Lightning l = Pooling.obtain(Lightning.class, Lightning::new);
|
||||
|
||||
//TODO hacky workaround
|
||||
if(checkShield(team, x, y)) return;
|
||||
|
||||
@@ -105,7 +105,7 @@ public class Puddle extends BaseEntity implements SaveTrait, Poolable, DrawTrait
|
||||
if(p == null){
|
||||
if(Net.client()) return; //not clientside.
|
||||
|
||||
Puddle puddle = Pooling.obtain(Puddle.class);
|
||||
Puddle puddle = Pooling.obtain(Puddle.class, Puddle::new);
|
||||
puddle.tile = tile;
|
||||
puddle.liquid = liquid;
|
||||
puddle.amount = amount;
|
||||
|
||||
@@ -8,7 +8,6 @@ import com.badlogic.gdx.net.HttpRequestBuilder;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntMap;
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.mindustry.gen.Call;
|
||||
import io.anuke.mindustry.net.Packets.KickReason;
|
||||
@@ -68,7 +67,7 @@ public class Net{
|
||||
if(loaded){
|
||||
//handle all packets that were skipped while loading
|
||||
for(int i = 0; i < packetQueue.size; i++){
|
||||
Log.info("Processing {0} packet post-load.", ClassReflection.getSimpleName(packetQueue.get(i).getClass()));
|
||||
Log.info("Processing {0} packet post-load.", packetQueue.get(i).getClass());
|
||||
handleClientReceived(packetQueue.get(i));
|
||||
}
|
||||
}
|
||||
@@ -238,14 +237,14 @@ public class Net{
|
||||
}
|
||||
}else if(!((object instanceof Packet) && ((Packet) object).isUnimportant())){
|
||||
packetQueue.add(object);
|
||||
Log.info("Queuing packet {0}.", ClassReflection.getSimpleName(object.getClass()));
|
||||
Log.info("Queuing packet {0}.", object);
|
||||
}else{
|
||||
synchronized(packetPoolLock){
|
||||
Pooling.free(object);
|
||||
}
|
||||
}
|
||||
}else{
|
||||
Log.err("Unhandled packet type: '{0}'!", ClassReflection.getSimpleName(object.getClass()));
|
||||
Log.err("Unhandled packet type: '{0}'!", object);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,7 +260,7 @@ public class Net{
|
||||
Pooling.free(object);
|
||||
}
|
||||
}else{
|
||||
Log.err("Unhandled packet type: '{0}'!", ClassReflection.getSimpleName(object.getClass()));
|
||||
Log.err("Unhandled packet type: '{0}'!", object.getClass());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.net;
|
||||
import com.badlogic.gdx.utils.ObjectIntMap;
|
||||
import io.anuke.mindustry.net.Packets.*;
|
||||
import io.anuke.ucore.function.Supplier;
|
||||
import io.anuke.ucore.util.Pooling;
|
||||
|
||||
public class Registrator{
|
||||
private static ClassEntry[] classes = {
|
||||
@@ -18,7 +17,6 @@ public class Registrator{
|
||||
static{
|
||||
if(classes.length > 127) throw new RuntimeException("Can't have more than 127 registered classes!");
|
||||
for(int i = 0; i < classes.length; i++){
|
||||
Pooling.registerType((Class<Packet>) classes[i].type, (Supplier<Packet>) classes[i].constructor);
|
||||
ids.put(classes[i].type, i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import com.badlogic.gdx.files.FileHandle;
|
||||
import com.badlogic.gdx.graphics.g2d.GlyphLayout;
|
||||
import com.badlogic.gdx.utils.Align;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.Pools;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.core.Platform;
|
||||
import io.anuke.ucore.core.Core;
|
||||
@@ -18,6 +17,7 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.scene.utils.UIUtils;
|
||||
import io.anuke.ucore.util.OS;
|
||||
import io.anuke.ucore.util.Pooling;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -186,7 +186,7 @@ public class FileChooser extends FloatingDialog{
|
||||
//if is mac, don't display extra info since you can only ever go to downloads
|
||||
navigation.setText(OS.isMac ? directory.name() : directory.toString());
|
||||
|
||||
GlyphLayout layout = Pools.obtain(GlyphLayout.class);
|
||||
GlyphLayout layout = Pooling.obtain(GlyphLayout.class, GlyphLayout::new);
|
||||
|
||||
layout.setText(Core.font, navigation.getText());
|
||||
|
||||
@@ -196,7 +196,7 @@ public class FileChooser extends FloatingDialog{
|
||||
navigation.setCursorPosition(navigation.getText().length());
|
||||
}
|
||||
|
||||
Pools.free(layout);
|
||||
Pooling.free(layout);
|
||||
|
||||
files.clearChildren();
|
||||
files.top().left();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import io.anuke.mindustry.core.GameState.State;
|
||||
import io.anuke.mindustry.game.Saves.SaveSlot;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
@@ -55,7 +54,7 @@ public class SaveDialog extends LoadDialog{
|
||||
e.printStackTrace();
|
||||
e = (e.getCause() == null ? e : e.getCause());
|
||||
|
||||
ui.showError("[orange]" + Bundles.get("text.savefail") + "\n[white]" + ClassReflection.getSimpleName(e.getClass()) + ": " + e.getMessage() + "\n" + "at " + e.getStackTrace()[0].getFileName() + ":" + e.getStackTrace()[0].getLineNumber());
|
||||
ui.showError("[orange]" + Bundles.get("text.savefail"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.world;
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import io.anuke.mindustry.entities.Damage;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
@@ -466,7 +465,7 @@ public class Block extends BaseBlock {
|
||||
"floor", tile.floor().name,
|
||||
"x", tile.x,
|
||||
"y", tile.y,
|
||||
"entity.name", ClassReflection.getSimpleName(tile.entity.getClass()),
|
||||
"entity.name", tile.entity.getClass(),
|
||||
"entity.x", tile.entity.x,
|
||||
"entity.y", tile.entity.y,
|
||||
"entity.id", tile.entity.id,
|
||||
|
||||
@@ -3,7 +3,6 @@ package io.anuke.mindustry.world;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||
@@ -472,7 +471,7 @@ public class Tile implements PosTrait, TargetTrait{
|
||||
Block block = block();
|
||||
Block floor = floor();
|
||||
|
||||
return floor.name() + ":" + block.name() + "[" + x + "," + y + "] " + "entity=" + (entity == null ? "null" : ClassReflection.getSimpleName(entity.getClass())) +
|
||||
return floor.name() + ":" + block.name() + "[" + x + "," + y + "] " + "entity=" + (entity == null ? "null" : (entity.getClass())) +
|
||||
(link != 0 ? " link=[" + (Bits.getLeftByte(link) - 8) + ", " + (Bits.getRightByte(link) - 8) + "]" : "");
|
||||
}
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class MassDriver extends Block{
|
||||
entity.reload = 1f;
|
||||
entity.power.amount = 0f;
|
||||
|
||||
DriverBulletData data = Pooling.obtain(DriverBulletData.class);
|
||||
DriverBulletData data = Pooling.obtain(DriverBulletData.class, DriverBulletData::new);
|
||||
data.from = entity;
|
||||
data.to = other;
|
||||
for(int i = 0; i < content.items().size; i++){
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.anuke.mindustry.world.consumers;
|
||||
|
||||
import com.badlogic.gdx.utils.ObjectMap;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
import com.badlogic.gdx.utils.reflect.ClassReflection;
|
||||
import io.anuke.mindustry.type.Item;
|
||||
import io.anuke.mindustry.type.ItemStack;
|
||||
import io.anuke.mindustry.type.Liquid;
|
||||
@@ -22,7 +21,7 @@ public class Consumers{
|
||||
public void checkRequired(Block block){
|
||||
for(Class<? extends Consume> c : required){
|
||||
if(!map.containsKey(c)){
|
||||
throw new RuntimeException("Missing required consumer of type \"" + ClassReflection.getSimpleName(c) + "\" in block \"" + block.name + "\"!");
|
||||
throw new RuntimeException("Missing required consumer of type \"" + c + "\" in block \"" + block.name + "\"!");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user