More cleanup
This commit is contained in:
@@ -32,7 +32,7 @@ import static mindustry.Vars.*;
|
||||
public class NetServer implements ApplicationListener{
|
||||
private final static int maxSnapshotSize = 430, timerBlockSync = 0;
|
||||
private final static float serverSyncTime = 12, kickDuration = 30 * 1000, blockSyncTime = 60 * 10;
|
||||
private final static Vector2 vector = new Vector2();
|
||||
private final static Vec2 vector = new Vec2();
|
||||
private final static Rectangle viewport = new Rectangle();
|
||||
/** If a player goes away of their server-side coordinates by this distance, they get teleported back. */
|
||||
private final static float correctDist = 16f;
|
||||
|
||||
@@ -120,7 +120,7 @@ public class Renderer implements ApplicationListener{
|
||||
landTime = 0f;
|
||||
graphics.clear(Color.black);
|
||||
}else{
|
||||
Vector2 position = Tmp.v3.set(player);
|
||||
Vec2 position = Tmp.v3.set(player);
|
||||
|
||||
if(player.isDead()){
|
||||
TileEntity core = player.getClosestCore();
|
||||
|
||||
@@ -475,7 +475,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
|
||||
}
|
||||
|
||||
table.update(() -> {
|
||||
Vector2 v = button.localToStageCoordinates(Tmp.v1.setZero());
|
||||
Vec2 v = button.localToStageCoordinates(Tmp.v1.setZero());
|
||||
table.setPosition(v.x, v.y, Align.topLeft);
|
||||
if(!isShown()){
|
||||
table.remove();
|
||||
|
||||
@@ -187,7 +187,7 @@ public class MapGenerateDialog extends FloatingDialog{
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 v = pane.stageToLocalCoordinates(Core.input.mouse());
|
||||
Vec2 v = pane.stageToLocalCoordinates(Core.input.mouse());
|
||||
|
||||
if(v.x >= 0 && v.y >= 0 && v.x <= pane.getWidth() && v.y <= pane.getHeight()){
|
||||
Core.scene.setScrollFocus(pane);
|
||||
|
||||
@@ -27,9 +27,9 @@ public class MapView extends Element implements GestureListener{
|
||||
private float zoom = 1f;
|
||||
private boolean grid = false;
|
||||
private GridImage image = new GridImage(0, 0);
|
||||
private Vector2 vec = new Vector2();
|
||||
private Vec2 vec = new Vec2();
|
||||
private Rectangle rect = new Rectangle();
|
||||
private Vector2[][] brushPolygons = new Vector2[MapEditor.brushSizes.length][0];
|
||||
private Vec2[][] brushPolygons = new Vec2[MapEditor.brushSizes.length][0];
|
||||
|
||||
private boolean drawing;
|
||||
private int lastx, lasty;
|
||||
@@ -214,7 +214,7 @@ public class MapView extends Element implements GestureListener{
|
||||
}
|
||||
}
|
||||
|
||||
private Vector2 unproject(int x, int y){
|
||||
private Vec2 unproject(int x, int y){
|
||||
float ratio = 1f / ((float)editor.width() / editor.height());
|
||||
float size = Math.min(width, height);
|
||||
float sclwidth = size * zoom;
|
||||
@@ -268,9 +268,9 @@ public class MapView extends Element implements GestureListener{
|
||||
|
||||
if((!editor.drawBlock.isMultiblock() || tool == EditorTool.eraser) && tool != EditorTool.fill){
|
||||
if(tool == EditorTool.line && drawing){
|
||||
Vector2 v1 = unproject(startx, starty).add(x, y);
|
||||
Vec2 v1 = unproject(startx, starty).add(x, y);
|
||||
float sx = v1.x, sy = v1.y;
|
||||
Vector2 v2 = unproject(lastx, lasty).add(x, y);
|
||||
Vec2 v2 = unproject(lastx, lasty).add(x, y);
|
||||
|
||||
Lines.poly(brushPolygons[index], sx, sy, scaling);
|
||||
Lines.poly(brushPolygons[index], v2.x, v2.y, scaling);
|
||||
@@ -278,7 +278,7 @@ public class MapView extends Element implements GestureListener{
|
||||
|
||||
if((tool.edit || (tool == EditorTool.line && !drawing)) && (!mobile || drawing)){
|
||||
Point2 p = project(mousex, mousey);
|
||||
Vector2 v = unproject(p.x, p.y).add(x, y);
|
||||
Vec2 v = unproject(p.x, p.y).add(x, y);
|
||||
|
||||
//pencil square outline
|
||||
if(tool == EditorTool.pencil && tool.mode == 1){
|
||||
@@ -290,7 +290,7 @@ public class MapView extends Element implements GestureListener{
|
||||
}else{
|
||||
if((tool.edit || tool == EditorTool.line) && (!mobile || drawing)){
|
||||
Point2 p = project(mousex, mousey);
|
||||
Vector2 v = unproject(p.x, p.y).add(x, y);
|
||||
Vec2 v = unproject(p.x, p.y).add(x, y);
|
||||
float offset = (editor.drawBlock.size % 2 == 0 ? scaling / 2f : 0f);
|
||||
Lines.square(
|
||||
v.x + scaling / 2f + offset,
|
||||
@@ -332,7 +332,7 @@ public class MapView extends Element implements GestureListener{
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean pinch(Vector2 initialPointer1, Vector2 initialPointer2, Vector2 pointer1, Vector2 pointer2){
|
||||
public boolean pinch(Vec2 initialPointer1, Vec2 initialPointer2, Vec2 pointer1, Vec2 pointer2){
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -53,7 +53,7 @@ public class LoopControl{
|
||||
private class SoundData{
|
||||
float volume;
|
||||
float total;
|
||||
Vector2 sum = new Vector2();
|
||||
Vec2 sum = new Vec2();
|
||||
|
||||
int soundID;
|
||||
float curVolume;
|
||||
|
||||
@@ -63,7 +63,7 @@ public class LightRenderer{
|
||||
float v2 = lmid.getV();
|
||||
|
||||
|
||||
Vector2 v1 = Tmp.v1.trnsExact(rot + 90f, stroke);
|
||||
Vec2 v1 = Tmp.v1.trnsExact(rot + 90f, stroke);
|
||||
float lx1 = x - v1.x, ly1 = y - v1.y,
|
||||
lx2 = x + v1.x, ly2 = y + v1.y,
|
||||
lx3 = x2 + v1.x, ly3 = y2 + v1.y,
|
||||
@@ -100,7 +100,7 @@ public class LightRenderer{
|
||||
Draw.vert(ledge.getTexture(), vertices, 0, vertices.length);
|
||||
|
||||
|
||||
Vector2 v3 = Tmp.v2.trnsExact(rot, stroke);
|
||||
Vec2 v3 = Tmp.v2.trnsExact(rot, stroke);
|
||||
|
||||
u = ledge.getU();
|
||||
v = ledge.getV2();
|
||||
|
||||
@@ -122,7 +122,7 @@ public class OverlayRenderer{
|
||||
|
||||
//draw selected block
|
||||
if(input.block == null && !Core.scene.hasMouse()){
|
||||
Vector2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
||||
Vec2 vec = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
||||
Tile tile = world.ltileWorld(vec.x, vec.y);
|
||||
|
||||
if(tile != null && tile.block() != Blocks.air && tile.getTeam() == player.getTeam()){
|
||||
@@ -139,7 +139,7 @@ public class OverlayRenderer{
|
||||
|
||||
//draw selection overlay when dropping item
|
||||
if(input.isDroppingItem()){
|
||||
Vector2 v = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
||||
Vec2 v = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
|
||||
float size = 8;
|
||||
Draw.rect(player.item().item.icon(Cicon.medium), v.x, v.y, size, size);
|
||||
Draw.color(Pal.accent);
|
||||
|
||||
@@ -43,7 +43,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
final static float playerSelectRange = mobile ? 17f : 11f;
|
||||
/** Maximum line length. */
|
||||
final static int maxLength = 100;
|
||||
final static Vector2 stackTrns = new Vector2();
|
||||
final static Vec2 stackTrns = new Vec2();
|
||||
final static Rectangle r1 = new Rectangle(), r2 = new Rectangle();
|
||||
/** Distance on the back from where items originate. */
|
||||
final static float backTrns = 3f;
|
||||
@@ -120,7 +120,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
|
||||
ItemTransfer.create(item,
|
||||
player.x + Angles.trnsx(player.rotation + 180f, backTrns), player.y + Angles.trnsy(player.rotation + 180f, backTrns),
|
||||
new Vector2(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> {
|
||||
new Vec2(tile.drawx() + stackTrns.x, tile.drawy() + stackTrns.y), () -> {
|
||||
if(tile.block() != block || tile.entity == null || tile.entity.items == null) return;
|
||||
|
||||
tile.block().handleStack(item, removed, tile, player);
|
||||
@@ -639,7 +639,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
int tileX(float cursorX){
|
||||
Vector2 vec = Core.input.mouseWorld(cursorX, 0);
|
||||
Vec2 vec = Core.input.mouseWorld(cursorX, 0);
|
||||
if(selectedBlock()){
|
||||
vec.sub(block.offset(), block.offset());
|
||||
}
|
||||
@@ -647,7 +647,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
int tileY(float cursorY){
|
||||
Vector2 vec = Core.input.mouseWorld(0, cursorY);
|
||||
Vec2 vec = Core.input.mouseWorld(0, cursorY);
|
||||
if(selectedBlock()){
|
||||
vec.sub(block.offset(), block.offset());
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
||||
private final float edgePan = Scl.scl(60f);
|
||||
|
||||
//gesture data
|
||||
private Vector2 vector = new Vector2();
|
||||
private Vec2 vector = new Vec2();
|
||||
private float lastZoom = -1;
|
||||
|
||||
/** Position where the player started dragging a line. */
|
||||
|
||||
@@ -11,7 +11,7 @@ import mindustry.maps.filters.FilterOption.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class MirrorFilter extends GenerateFilter{
|
||||
private final Vector2 v1 = new Vector2(), v2 = new Vector2(), v3 = new Vector2();
|
||||
private final Vec2 v1 = new Vec2(), v2 = new Vec2(), v3 = new Vec2();
|
||||
|
||||
int angle = 45;
|
||||
|
||||
@@ -44,12 +44,12 @@ public class MirrorFilter extends GenerateFilter{
|
||||
public void draw(Image image){
|
||||
super.draw(image);
|
||||
|
||||
Vector2 vsize = Scaling.fit.apply(image.getDrawable().getMinWidth(), image.getDrawable().getMinHeight(), image.getWidth(), image.getHeight());
|
||||
Vec2 vsize = Scaling.fit.apply(image.getDrawable().getMinWidth(), image.getDrawable().getMinHeight(), image.getWidth(), image.getHeight());
|
||||
float imageWidth = Math.max(vsize.x, vsize.y);
|
||||
float imageHeight = Math.max(vsize.y, vsize.x);
|
||||
|
||||
float size = Math.max(image.getWidth() *2, image.getHeight()*2);
|
||||
Cons<Vector2> clamper = v ->
|
||||
Cons<Vec2> clamper = v ->
|
||||
v.clamp(
|
||||
image.getX() + image.getWidth()/2f - imageWidth/2f,
|
||||
image.getX() + image.getWidth()/2f + imageWidth/2f,
|
||||
@@ -64,7 +64,7 @@ public class MirrorFilter extends GenerateFilter{
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
void mirror(Vector2 p, float x0, float y0, float x1, float y1){
|
||||
void mirror(Vec2 p, float x0, float y0, float x1, float y1){
|
||||
//special case: uneven map mirrored at 45 degree angle
|
||||
if(in.width != in.height && angle % 90 != 0){
|
||||
p.x = (p.x - in.width/2f) * -1 + in.width/2f;
|
||||
@@ -80,7 +80,7 @@ public class MirrorFilter extends GenerateFilter{
|
||||
}
|
||||
}
|
||||
|
||||
boolean left(Vector2 a, Vector2 b, Vector2 c){
|
||||
boolean left(Vec2 a, Vec2 b, Vec2 c){
|
||||
return ((b.x - a.x)*(c.y - a.y) - (b.y - a.y)*(c.x - a.x)) > 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -460,7 +460,7 @@ public class ContentParser{
|
||||
builder.append("[accent][[").append(e.getClass().getSimpleName().replace("Exception", ""))
|
||||
.append("][] ")
|
||||
.append(e.getMessage() != null ?
|
||||
e.getMessage().replace("io.anuke.mindustry.", "").replace("io.anuke.arc.", "") : "").append("\n");
|
||||
e.getMessage().replace("mindustry.", "").replace("arc.", "") : "").append("\n");
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
|
||||
@@ -6,14 +6,14 @@ import arc.util.*;
|
||||
|
||||
public class Interpolator{
|
||||
//used for movement
|
||||
public Vector2 target = new Vector2();
|
||||
public Vector2 last = new Vector2();
|
||||
public Vec2 target = new Vec2();
|
||||
public Vec2 last = new Vec2();
|
||||
public float[] targets = {};
|
||||
public float[] lasts = {};
|
||||
public long lastUpdated, updateSpacing;
|
||||
|
||||
//current state
|
||||
public Vector2 pos = new Vector2();
|
||||
public Vec2 pos = new Vec2();
|
||||
public float[] values = {};
|
||||
|
||||
public void read(float cx, float cy, float x, float y, float... target1ds){
|
||||
|
||||
@@ -199,7 +199,7 @@ public class BlockInventoryFragment extends Fragment{
|
||||
}
|
||||
|
||||
private void updateTablePosition(){
|
||||
Vector2 v = Core.input.mouseScreen(tile.drawx() + tile.block().size * tilesize / 2f, tile.drawy() + tile.block().size * tilesize / 2f);
|
||||
Vec2 v = Core.input.mouseScreen(tile.drawx() + tile.block().size * tilesize / 2f, tile.drawy() + tile.block().size * tilesize / 2f);
|
||||
table.pack();
|
||||
table.setPosition(v.x, v.y, Align.topLeft);
|
||||
}
|
||||
|
||||
@@ -208,7 +208,7 @@ public class HudFragment extends Fragment{
|
||||
if(b.isChecked()){
|
||||
Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
|
||||
if(e == null){
|
||||
Vector2 world = Core.input.mouseWorld();
|
||||
Vec2 world = Core.input.mouseWorld();
|
||||
Units.nearby(world.x, world.y, 1f, 1f, unit -> {
|
||||
if(!found[0] && unit instanceof BaseUnit){
|
||||
if(Core.input.keyTap(KeyCode.MOUSE_LEFT)){
|
||||
|
||||
@@ -433,7 +433,7 @@ public class PlacementFragment extends Fragment{
|
||||
Block getSelected(){
|
||||
Block toDisplay = null;
|
||||
|
||||
Vector2 v = topTable.stageToLocalCoordinates(Core.input.mouse());
|
||||
Vec2 v = topTable.stageToLocalCoordinates(Core.input.mouse());
|
||||
|
||||
//setup hovering tile
|
||||
if(!Core.scene.hasMouse() && topTable.hit(v.x, v.y, false) == null){
|
||||
|
||||
@@ -489,7 +489,7 @@ public class Block extends BlockStorage{
|
||||
|
||||
/** Update table alignment after configuring.*/
|
||||
public void updateTableAlign(Tile tile, Table table){
|
||||
Vector2 pos = Core.input.mouseScreen(tile.drawx(), tile.drawy() - tile.block().size * tilesize / 2f - 1);
|
||||
Vec2 pos = Core.input.mouseScreen(tile.drawx(), tile.drawy() - tile.block().size * tilesize / 2f - 1);
|
||||
table.setPosition(pos.x, pos.y, Align.top);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package mindustry.world;
|
||||
|
||||
import arc.struct.Array;
|
||||
import arc.math.Mathf;
|
||||
import arc.math.geom.Vector2;
|
||||
import arc.math.geom.Vec2;
|
||||
import arc.util.*;
|
||||
import mindustry.Vars;
|
||||
import mindustry.content.Fx;
|
||||
@@ -83,7 +83,7 @@ public abstract class BlockStorage extends UnlockableContent{
|
||||
}
|
||||
|
||||
/** Returns offset for stack placement. */
|
||||
public void getStackOffset(Item item, Tile tile, Vector2 trns){
|
||||
public void getStackOffset(Item item, Tile tile, Vec2 trns){
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ public class Edges{
|
||||
private static final int maxRadius = 12;
|
||||
private static Point2[][] edges = new Point2[maxSize][0];
|
||||
private static Point2[][] edgeInside = new Point2[maxSize][0];
|
||||
private static Vector2[][] polygons = new Vector2[maxRadius * 2][0];
|
||||
private static Vec2[][] polygons = new Vec2[maxRadius * 2][0];
|
||||
|
||||
static{
|
||||
for(int i = 0; i < maxRadius * 2; i++){
|
||||
@@ -60,7 +60,7 @@ public class Edges{
|
||||
tiley + Mathf.clamp(other.y - tiley, -(size - 1) / 2, (size / 2)));
|
||||
}
|
||||
|
||||
public static Vector2[] getPixelPolygon(float radius){
|
||||
public static Vec2[] getPixelPolygon(float radius){
|
||||
if(radius < 1 || radius > maxRadius)
|
||||
throw new RuntimeException("Polygon size must be between 1 and " + maxRadius);
|
||||
return polygons[(int)(radius * 2) - 1];
|
||||
|
||||
@@ -449,8 +449,8 @@ public class Tile implements Position, TargetTrait{
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector2 velocity(){
|
||||
return Vector2.ZERO;
|
||||
public Vec2 velocity(){
|
||||
return Vec2.ZERO;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -52,7 +52,7 @@ public class DeflectorWall extends Wall{
|
||||
|
||||
bullet.hitbox(rect2);
|
||||
|
||||
Vector2 position = Geometry.raycastRect(bullet.x - bullet.velocity().x*Time.delta(), bullet.y - bullet.velocity().y*Time.delta(), bullet.x + bullet.velocity().x*Time.delta(), bullet.y + bullet.velocity().y*Time.delta(),
|
||||
Vec2 position = Geometry.raycastRect(bullet.x - bullet.velocity().x*Time.delta(), bullet.y - bullet.velocity().y*Time.delta(), bullet.x + bullet.velocity().x*Time.delta(), bullet.y + bullet.velocity().y*Time.delta(),
|
||||
rect.setSize(size * tilesize + rect2.width*2 + rect2.height*2).setCenter(entity.x, entity.y));
|
||||
|
||||
if(position != null){
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package mindustry.world.blocks.defense.turrets;
|
||||
|
||||
import arc.math.Mathf;
|
||||
import arc.math.geom.Vector2;
|
||||
import arc.math.geom.Vec2;
|
||||
import mindustry.entities.Predict;
|
||||
import mindustry.entities.type.Bullet;
|
||||
import mindustry.entities.bullet.BulletType;
|
||||
@@ -31,7 +31,7 @@ public class ArtilleryTurret extends ItemTurret{
|
||||
|
||||
tr.trns(entity.rotation, size * tilesize / 2);
|
||||
|
||||
Vector2 predict = Predict.intercept(tile, entity.target, type.speed);
|
||||
Vec2 predict = Predict.intercept(tile, entity.target, type.speed);
|
||||
|
||||
float dst = entity.dst(predict.x, predict.y);
|
||||
float maxTraveled = type.lifetime * type.speed;
|
||||
|
||||
@@ -10,7 +10,7 @@ import arc.graphics.Color;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.Angles;
|
||||
import arc.math.Mathf;
|
||||
import arc.math.geom.Vector2;
|
||||
import arc.math.geom.Vec2;
|
||||
import arc.util.Time;
|
||||
import mindustry.content.Fx;
|
||||
import mindustry.entities.*;
|
||||
@@ -54,8 +54,8 @@ public abstract class Turret extends Block{
|
||||
public boolean targetAir = true;
|
||||
public boolean targetGround = true;
|
||||
|
||||
protected Vector2 tr = new Vector2();
|
||||
protected Vector2 tr2 = new Vector2();
|
||||
protected Vec2 tr = new Vec2();
|
||||
protected Vec2 tr2 = new Vec2();
|
||||
|
||||
public TextureRegion baseRegion, heatRegion;
|
||||
|
||||
@@ -162,7 +162,7 @@ public abstract class Turret extends Block{
|
||||
float speed = type.speed;
|
||||
if(speed < 0.1f) speed = 9999999f;
|
||||
|
||||
Vector2 result = Predict.intercept(entity, entity.target, speed);
|
||||
Vec2 result = Predict.intercept(entity, entity.target, speed);
|
||||
if(result.isZero()){
|
||||
result.set(entity.target.getX(), entity.target.getY());
|
||||
}
|
||||
|
||||
@@ -28,8 +28,8 @@ public class Conveyor extends Block implements Autotiler{
|
||||
private static ItemPos drawpos = new ItemPos();
|
||||
private static ItemPos pos1 = new ItemPos();
|
||||
private static ItemPos pos2 = new ItemPos();
|
||||
private final Vector2 tr1 = new Vector2();
|
||||
private final Vector2 tr2 = new Vector2();
|
||||
private final Vec2 tr1 = new Vec2();
|
||||
private final Vec2 tr2 = new Vec2();
|
||||
private TextureRegion[][] regions = new TextureRegion[7][4];
|
||||
|
||||
public float speed = 0f;
|
||||
@@ -283,7 +283,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getStackOffset(Item item, Tile tile, Vector2 trns){
|
||||
public void getStackOffset(Item item, Tile tile, Vec2 trns){
|
||||
trns.trns(tile.rotation() * 90 + 180f, tilesize / 2f);
|
||||
}
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ public class MessageBlock extends Block{
|
||||
|
||||
@Override
|
||||
public void updateTableAlign(Tile tile, Table table){
|
||||
Vector2 pos = Core.input.mouseScreen(tile.drawx(), tile.drawy() + tile.block().size * tilesize / 2f + 1);
|
||||
Vec2 pos = Core.input.mouseScreen(tile.drawx(), tile.drawy() + tile.block().size * tilesize / 2f + 1);
|
||||
table.setPosition(pos.x, pos.y, Align.bottom);
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import static mindustry.Vars.*;
|
||||
public class NuclearReactor extends PowerGenerator{
|
||||
public final int timerFuel = timers++;
|
||||
|
||||
public final Vector2 tr = new Vector2();
|
||||
public final Vec2 tr = new Vec2();
|
||||
|
||||
public Color lightColor = Color.valueOf("7f19ea");
|
||||
public Color coolColor = new Color(1, 1, 1, 0f);
|
||||
|
||||
@@ -22,7 +22,7 @@ public class PowerNode extends PowerBlock{
|
||||
protected static boolean returnValue = false;
|
||||
|
||||
protected final ObjectSet<PowerGraph> graphs = new ObjectSet<>();
|
||||
protected final Vector2 t1 = new Vector2(), t2 = new Vector2();
|
||||
protected final Vec2 t1 = new Vec2(), t2 = new Vec2();
|
||||
|
||||
public TextureRegion laser, laserEnd;
|
||||
public float laserRange = 6;
|
||||
|
||||
Reference in New Issue
Block a user