Removed all tmps, multithreading now functional
This commit is contained in:
@@ -17,7 +17,6 @@ import io.anuke.ucore.entities.SolidEntity;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
import io.anuke.ucore.util.Translator;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -290,10 +289,10 @@ public class Player extends SyncEntity{
|
||||
|
||||
i.time += 1f / i.spacing * Timers.delta();
|
||||
|
||||
Mathf.lerp2(Tmp.v2.set(i.last), i.target, i.time);
|
||||
Mathf.lerp2(movement.set(i.last), i.target, i.time);
|
||||
|
||||
x = Tmp.v2.x;
|
||||
y = Tmp.v2.y;
|
||||
x = movement.x;
|
||||
y = movement.y;
|
||||
|
||||
if(i.target.dst(x, y) > 128){
|
||||
set(i.target.x, i.target.y);
|
||||
|
||||
@@ -50,6 +50,7 @@ public abstract class SyncEntity extends DestructibleEntity{
|
||||
public class Interpolator {
|
||||
public Vector2 target = new Vector2();
|
||||
public Vector2 last = new Vector2();
|
||||
public Vector2 vec = new Vector2();
|
||||
public float targetrot;
|
||||
public float spacing = 1f;
|
||||
public float time;
|
||||
|
||||
@@ -4,19 +4,18 @@ import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||
import io.anuke.mindustry.graphics.Fx;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.entities.SolidEntity;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
import static io.anuke.mindustry.Vars.enemyGroup;
|
||||
|
||||
public class TeslaOrb extends Entity{
|
||||
private Array<Vector2> points = new Array<>();
|
||||
@@ -25,6 +24,7 @@ public class TeslaOrb extends Entity{
|
||||
private float range = 0;
|
||||
private float lifetime = 30f;
|
||||
private float life = 0f;
|
||||
private Vector2 vector = new Vector2();
|
||||
|
||||
public TeslaOrb(float x, float y, float range, int damage){
|
||||
set(x, y);
|
||||
@@ -83,7 +83,7 @@ public class TeslaOrb extends Entity{
|
||||
|
||||
float range = 1f;
|
||||
|
||||
Vector2 previous = Tmp.v1.set(x, y);
|
||||
Vector2 previous = vector.set(x, y);
|
||||
|
||||
for(Vector2 enemy : points){
|
||||
|
||||
|
||||
@@ -154,10 +154,10 @@ public class Enemy extends SyncEntity {
|
||||
|
||||
i.time += 1f / i.spacing * Timers.delta();
|
||||
|
||||
Mathf.lerp2(Tmp.v2.set(i.last), i.target, i.time);
|
||||
Mathf.lerp2(i.vec.set(i.last), i.target, i.time);
|
||||
|
||||
x = Tmp.v2.x;
|
||||
y = Tmp.v2.y;
|
||||
x = i.vec.x;
|
||||
y = i.vec.y;
|
||||
|
||||
angle = Mathf.lerpAngDelta(angle, i.targetrot, 0.6f);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -60,6 +59,10 @@ public class EnemyType {
|
||||
protected final int timerReload = timeid ++;
|
||||
protected final int timerReset = timeid ++;
|
||||
|
||||
protected final Vector2 shift = new Vector2();
|
||||
protected final Vector2 move = new Vector2();
|
||||
protected final Vector2 calc = new Vector2();
|
||||
|
||||
public EnemyType(String name){
|
||||
this.id = lastid++;
|
||||
this.name = name;
|
||||
@@ -158,14 +161,14 @@ public class EnemyType {
|
||||
Vector2 vec;
|
||||
|
||||
if(nearCore){
|
||||
vec = Tmp.v1.setZero();
|
||||
vec = move.setZero();
|
||||
if(targetCore) enemy.target = core.entity;
|
||||
}else{
|
||||
vec = world.pathfinder().find(enemy);
|
||||
vec.sub(enemy.x, enemy.y).limit(speed);
|
||||
}
|
||||
|
||||
Vector2 shift = Tmp.v3.setZero();
|
||||
shift.setZero();
|
||||
float shiftRange = enemy.hitbox.width + 2f;
|
||||
float avoidRange = shiftRange + 4f;
|
||||
float attractRange = avoidRange + 7f;
|
||||
@@ -180,11 +183,11 @@ public class EnemyType {
|
||||
float scl = Mathf.clamp(1.4f - dst / shiftRange) * mass * 1f/mass;
|
||||
shift.add((enemy.x - other.x) * scl, (enemy.y - other.y) * scl);
|
||||
}else if(dst < avoidRange){
|
||||
Tmp.v2.set((enemy.x - other.x), (enemy.y - other.y)).setLength(avoidSpeed);
|
||||
shift.add(Tmp.v2.scl(1.1f));
|
||||
calc.set((enemy.x - other.x), (enemy.y - other.y)).setLength(avoidSpeed);
|
||||
shift.add(calc.scl(1.1f));
|
||||
}else if(dst < attractRange && !nearCore){
|
||||
Tmp.v2.set((enemy.x - other.x), (enemy.y - other.y)).setLength(avoidSpeed);
|
||||
shift.add(Tmp.v2.scl(-1));
|
||||
calc.set((enemy.x - other.x), (enemy.y - other.y)).setLength(avoidSpeed);
|
||||
shift.add(calc.scl(-1));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package io.anuke.mindustry.entities.enemies.types;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||
import io.anuke.mindustry.entities.enemies.EnemyType;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
@@ -26,15 +24,16 @@ public class BlastType extends EnemyType {
|
||||
public void behavior(Enemy enemy){
|
||||
|
||||
float range = 10f;
|
||||
Vector2 offset = Tmp.v3.setZero();
|
||||
float ox = 0, oy = 0;
|
||||
|
||||
if(enemy.target instanceof TileEntity){
|
||||
TileEntity e = (TileEntity)enemy.target;
|
||||
range = (e.tile.block().width * tilesize) /2f + 8f;
|
||||
offset.set(e.tile.block().getPlaceOffset());
|
||||
ox = e.tile.block().getPlaceOffset().x;
|
||||
oy = e.tile.block().getPlaceOffset().y;
|
||||
}
|
||||
|
||||
if(enemy.target != null && enemy.target.distanceTo(enemy.x - offset.x, enemy.y - offset.y) < range){
|
||||
if(enemy.target != null && enemy.target.distanceTo(enemy.x - ox, enemy.y - oy) < range){
|
||||
explode(enemy);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user