More cleanup

This commit is contained in:
Anuken
2019-12-25 11:16:54 -05:00
parent 514d4817c8
commit 475794640d
47 changed files with 117 additions and 117 deletions
+2 -2
View File
@@ -24,7 +24,7 @@ import static mindustry.Vars.*;
public class Damage{
private static Rectangle rect = new Rectangle();
private static Rectangle hitrect = new Rectangle();
private static Vector2 tr = new Vector2();
private static Vec2 tr = new Vec2();
private static GridBits bits = new GridBits(30, 30);
private static IntQueue propagation = new IntQueue();
private static IntSet collidedBlocks = new IntSet();
@@ -133,7 +133,7 @@ public class Damage{
other.width += expand * 2;
other.height += expand * 2;
Vector2 vec = Geometry.raycastRect(x, y, x2, y2, other);
Vec2 vec = Geometry.raycastRect(x, y, x2, y2, other);
if(vec != null){
Effects.effect(effect, vec.x, vec.y);
@@ -18,8 +18,8 @@ public class EntityCollisions{
//tile collisions
private Rectangle tmp = new Rectangle();
private Vector2 vector = new Vector2();
private Vector2 l1 = new Vector2();
private Vec2 vector = new Vec2();
private Vec2 l1 = new Vec2();
private Rectangle r1 = new Rectangle();
private Rectangle r2 = new Rectangle();
@@ -72,7 +72,7 @@ public class EntityCollisions{
tmp.setSize(tilesize).setCenter(wx * tilesize, wy * tilesize);
if(tmp.overlaps(rect)){
Vector2 v = Geometry.overlap(rect, tmp, x);
Vec2 v = Geometry.overlap(rect, tmp, x);
rect.x += v.x;
rect.y += v.y;
}
@@ -157,7 +157,7 @@ public class EntityCollisions{
}
private boolean collide(float x1, float y1, float w1, float h1, float vx1, float vy1,
float x2, float y2, float w2, float h2, float vx2, float vy2, Vector2 out){
float x2, float y2, float w2, float h2, float vx2, float vy2, Vec2 out){
float px = vx1, py = vy1;
vx1 -= vx2;
+8 -8
View File
@@ -9,8 +9,8 @@ import mindustry.entities.traits.*;
* Class for predicting shoot angles based on velocities of targets.
*/
public class Predict{
private static Vector2 vec = new Vector2();
private static Vector2 vresult = new Vector2();
private static Vec2 vec = new Vec2();
private static Vec2 vresult = new Vec2();
/**
* Calculates of intercept of a stationary and moving target. Do not call from multiple threads!
@@ -23,7 +23,7 @@ public class Predict{
* @param v speed of bullet
* @return the intercept location
*/
public static Vector2 intercept(float srcx, float srcy, float dstx, float dsty, float dstvx, float dstvy, float v){
public static Vec2 intercept(float srcx, float srcy, float dstx, float dsty, float dstvx, float dstvy, float v){
dstvx /= Time.delta();
dstvy /= Time.delta();
float tx = dstx - srcx,
@@ -35,10 +35,10 @@ public class Predict{
float c = tx * tx + ty * ty;
// Solve quadratic
Vector2 ts = quad(a, b, c);
Vec2 ts = quad(a, b, c);
// Find smallest positive solution
Vector2 sol = vresult.set(dstx, dsty);
Vec2 sol = vresult.set(dstx, dsty);
if(ts != null){
float t0 = ts.x, t1 = ts.y;
float t = Math.min(t0, t1);
@@ -54,12 +54,12 @@ public class Predict{
/**
* See {@link #intercept(float, float, float, float, float, float, float)}.
*/
public static Vector2 intercept(TargetTrait src, TargetTrait dst, float v){
public static Vec2 intercept(TargetTrait src, TargetTrait dst, float v){
return intercept(src.getX(), src.getY(), dst.getX(), dst.getY(), dst.getTargetVelocityX() - src.getTargetVelocityX()/2f, dst.getTargetVelocityY() - src.getTargetVelocityY()/2f, v);
}
private static Vector2 quad(float a, float b, float c){
Vector2 sol = null;
private static Vec2 quad(float a, float b, float c){
Vec2 sol = null;
if(Math.abs(a) < 1e-6){
if(Math.abs(b) < 1e-6){
sol = Math.abs(c) < 1e-6 ? vec.set(0, 0) : null;
@@ -6,7 +6,7 @@ import arc.graphics.g2d.*;
import arc.math.Interpolation;
import arc.math.Mathf;
import arc.math.geom.Position;
import arc.math.geom.Vector2;
import arc.math.geom.Vec2;
import arc.util.Time;
import arc.util.pooling.Pools;
import mindustry.entities.*;
@@ -20,9 +20,9 @@ import mindustry.world.Tile;
import static mindustry.Vars.*;
public class ItemTransfer extends TimedEntity implements DrawTrait{
private Vector2 from = new Vector2();
private Vector2 current = new Vector2();
private Vector2 tovec = new Vector2();
private Vec2 from = new Vec2();
private Vec2 current = new Vec2();
private Vec2 tovec = new Vec2();
private Item item;
private float seed;
private Position to;
@@ -35,7 +35,7 @@ public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{
private static final float hitRange = 30f;
private static int lastSeed = 0;
private Array<Vector2> lines = new Array<>();
private Array<Vec2> lines = new Array<>();
private Color color = Pal.lancerLaser;
/** For pooling use only. Do not call directly! */
@@ -70,7 +70,7 @@ public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{
for(int i = 0; i < length / 2; i++){
Bullet.create(Bullets.damageLightning, l, team, x, y, 0f, 1f, 1f, dmg);
l.lines.add(new Vector2(x + Mathf.range(3f), y + Mathf.range(3f)));
l.lines.add(new Vec2(x + Mathf.range(3f), y + Mathf.range(3f)));
if(l.lines.size > 1){
bhit[0] = false;
@@ -229,7 +229,7 @@ public interface BuilderTrait extends Entity, TeamTrait{
//due to iOS weirdness, this is apparently required
class BuildDataStatic{
static Vector2[] tmptr = new Vector2[]{new Vector2(), new Vector2(), new Vector2(), new Vector2()};
static Vec2[] tmptr = new Vec2[]{new Vec2(), new Vec2(), new Vec2(), new Vec2()};
}
/** Draw placement effects for an entity. */
@@ -11,7 +11,7 @@ public interface SolidTrait extends QuadTreeObject, MoveTrait, VelocityTrait, En
void hitboxTile(Rectangle rectangle);
Vector2 lastPosition();
Vec2 lastPosition();
default boolean collidesGrid(int x, int y){
return true;
@@ -1,11 +1,11 @@
package mindustry.entities.traits;
import arc.math.geom.Vector2;
import arc.math.geom.Vec2;
import arc.util.Time;
public interface VelocityTrait extends MoveTrait{
Vector2 velocity();
Vec2 velocity();
default void applyImpulse(float x, float y){
velocity().x += x / mass();
+2 -2
View File
@@ -56,7 +56,7 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool
bullet.velocity.set(0, type.speed).setAngle(angle).scl(velocityScl);
if(type.keepVelocity){
bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait)owner).velocity() : Vector2.ZERO);
bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait)owner).velocity() : Vec2.ZERO);
}
bullet.team = team;
@@ -297,7 +297,7 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool
}
@Override
public Vector2 velocity(){
public Vec2 velocity(){
return velocity;
}
+3 -3
View File
@@ -71,7 +71,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
private float walktime, itemtime;
private Queue<BuildRequest> placeQueue = new Queue<>();
private Tile mining;
private Vector2 movement = new Vector2();
private Vec2 movement = new Vec2();
private boolean moved;
//endregion
@@ -598,7 +598,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
movement.y += Mathf.clamp((Core.input.mouseY() - Core.graphics.getHeight() / 2) * 0.005f, -1, 1) * speed;
}
Vector2 vec = Core.input.mouseWorld(control.input.getMouseX(), control.input.getMouseY());
Vec2 vec = Core.input.mouseWorld(control.input.getMouseX(), control.input.getMouseY());
pointerX = vec.x;
pointerY = vec.y;
updateShooting();
@@ -738,7 +738,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
rotation = Mathf.slerpDelta(rotation, angleTo(target), 0.2f);
}
Vector2 intercept = Predict.intercept(this, target, getWeapon().bullet.speed);
Vec2 intercept = Predict.intercept(this, target, getWeapon().bullet.speed);
pointerX = intercept.x;
pointerY = intercept.y;
@@ -1,19 +1,19 @@
package mindustry.entities.type;
import arc.math.geom.Vector2;
import arc.math.geom.Vec2;
import mindustry.entities.traits.SolidTrait;
public abstract class SolidEntity extends BaseEntity implements SolidTrait{
protected transient Vector2 velocity = new Vector2(0f, 0.0001f);
private transient Vector2 lastPosition = new Vector2();
protected transient Vec2 velocity = new Vec2(0f, 0.0001f);
private transient Vec2 lastPosition = new Vec2();
@Override
public Vector2 lastPosition(){
public Vec2 lastPosition(){
return lastPosition;
}
@Override
public Vector2 velocity(){
public Vec2 velocity(){
return velocity;
}
}
@@ -5,7 +5,7 @@ import arc.Events;
import arc.struct.Array;
import arc.struct.ObjectSet;
import arc.math.geom.Point2;
import arc.math.geom.Vector2;
import arc.math.geom.Vec2;
import arc.util.*;
import arc.util.ArcAnnotate.*;
import mindustry.entities.EntityGroup;
@@ -288,8 +288,8 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
}
@Override
public Vector2 velocity(){
return Vector2.ZERO;
public Vec2 velocity(){
return Vec2.ZERO;
}
@Override
+2 -2
View File
@@ -39,7 +39,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
public static final float maxAbsVelocity = 127f / velocityPercision;
public static final int noSpawner = Pos.get(-1, 1);
private static final Vector2 moveVector = new Vector2();
private static final Vec2 moveVector = new Vec2();
public float rotation;
@@ -118,7 +118,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
}
@Override
public Vector2 velocity(){
public Vec2 velocity(){
return velocity;
}
@@ -65,7 +65,7 @@ public class FlyingUnit extends BaseUnit{
getWeapon().update(FlyingUnit.this, wx + Tmp.v2.x, wy + Tmp.v2.y, weaponAngles[wi], left);
}
}else{
Vector2 to = Predict.intercept(FlyingUnit.this, target, ammo.speed);
Vec2 to = Predict.intercept(FlyingUnit.this, target, ammo.speed);
getWeapon().update(FlyingUnit.this, to.x, to.y);
}
}
@@ -20,7 +20,7 @@ import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class GroundUnit extends BaseUnit{
protected static Vector2 vec = new Vector2();
protected static Vec2 vec = new Vec2();
protected float walkTime;
protected float stuckTime;
@@ -175,7 +175,7 @@ public class GroundUnit extends BaseUnit{
if(Angles.near(angleTo(target), rotation, 13f)){
BulletType ammo = getWeapon().bullet;
Vector2 to = Predict.intercept(GroundUnit.this, target, ammo.speed);
Vec2 to = Predict.intercept(GroundUnit.this, target, ammo.speed);
getWeapon().update(GroundUnit.this, to.x, to.y);
}