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
+1 -1
View File
@@ -12,7 +12,7 @@
<option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND"> <option name="PACKAGES_TO_USE_IMPORT_ON_DEMAND">
<value> <value>
<package name="java.awt" withSubpackages="false" static="false" /> <package name="java.awt" withSubpackages="false" static="false" />
<package name="io.anuke.mindustry" withSubpackages="false" static="true" /> <package name="mindustry" withSubpackages="false" static="true" />
<package name="javax.swing" withSubpackages="false" static="false" /> <package name="javax.swing" withSubpackages="false" static="false" />
</value> </value>
</option> </option>
@@ -97,7 +97,7 @@ public class RemoteWriteGenerator{
if(!forwarded && methodEntry.local != Loc.none){ if(!forwarded && methodEntry.local != Loc.none){
//add in local checks //add in local checks
if(methodEntry.local != Loc.both){ if(methodEntry.local != Loc.both){
method.beginControlFlow("if(" + getCheckString(methodEntry.local) + " || !io.anuke.mindustry.Vars.net.active())"); method.beginControlFlow("if(" + getCheckString(methodEntry.local) + " || !mindustry.Vars.net.active())");
} }
//concatenate parameters //concatenate parameters
@@ -106,7 +106,7 @@ public class RemoteWriteGenerator{
for(VariableElement var : elem.getParameters()){ for(VariableElement var : elem.getParameters()){
//special case: calling local-only methods uses the local player //special case: calling local-only methods uses the local player
if(index == 0 && methodEntry.where == Loc.client){ if(index == 0 && methodEntry.where == Loc.client){
results.append("io.anuke.mindustry.Vars.player"); results.append("mindustry.Vars.player");
}else{ }else{
results.append(var.getSimpleName()); results.append(var.getSimpleName());
} }
@@ -159,7 +159,7 @@ public class RemoteWriteGenerator{
boolean writePlayerSkipCheck = methodEntry.where == Loc.both && i == 0; boolean writePlayerSkipCheck = methodEntry.where == Loc.both && i == 0;
if(writePlayerSkipCheck){ //write begin check if(writePlayerSkipCheck){ //write begin check
method.beginControlFlow("if(io.anuke.mindustry.Vars.net.server())"); method.beginControlFlow("if(mindustry.Vars.net.server())");
} }
if(Utils.isPrimitive(typeName)){ //check if it's a primitive, and if so write it if(Utils.isPrimitive(typeName)){ //check if it's a primitive, and if so write it
@@ -194,12 +194,12 @@ public class RemoteWriteGenerator{
if(forwarded){ //forward packet if(forwarded){ //forward packet
if(!methodEntry.local.isClient){ //if the client doesn't get it called locally, forward it back after validation if(!methodEntry.local.isClient){ //if the client doesn't get it called locally, forward it back after validation
sendString = "io.anuke.mindustry.Vars.net.send("; sendString = "mindustry.Vars.net.send(";
}else{ }else{
sendString = "io.anuke.mindustry.Vars.net.sendExcept(exceptConnection, "; sendString = "mindustry.Vars.net.sendExcept(exceptConnection, ";
} }
}else if(toAll){ //send to all players / to server }else if(toAll){ //send to all players / to server
sendString = "io.anuke.mindustry.Vars.net.send("; sendString = "mindustry.Vars.net.send(";
}else{ //send to specific client from server }else{ //send to specific client from server
sendString = "playerConnection.send("; sendString = "playerConnection.send(";
} }
@@ -217,8 +217,8 @@ public class RemoteWriteGenerator{
} }
private String getCheckString(Loc loc){ private String getCheckString(Loc loc){
return loc.isClient && loc.isServer ? "io.anuke.mindustry.Vars.net.server() || io.anuke.mindustry.Vars.net.client()" : return loc.isClient && loc.isServer ? "mindustry.Vars.net.server() || mindustry.Vars.net.client()" :
loc.isClient ? "io.anuke.mindustry.Vars.net.client()" : loc.isClient ? "mindustry.Vars.net.client()" :
loc.isServer ? "io.anuke.mindustry.Vars.net.server()" : "false"; loc.isServer ? "mindustry.Vars.net.server()" : "false";
} }
} }
+3 -3
View File
@@ -230,7 +230,7 @@ project(":core"){
task cleanGen{ task cleanGen{
doFirst{ doFirst{
delete{ delete{
delete "../core/src/io/anuke/mindustry/gen/" delete "../core/src/mindustry/gen/"
} }
} }
} }
@@ -238,11 +238,11 @@ project(":core"){
task copyGen{ task copyGen{
doLast{ doLast{
copy{ copy{
from("../core/build/generated/sources/annotationProcessor/java/main/io/anuke/mindustry/gen"){ from("../core/build/generated/sources/annotationProcessor/java/main/mindustry/gen"){
include "**/*.java" include "**/*.java"
} }
into "../core/src/io/anuke/mindustry/gen" into "../core/src/mindustry/gen"
} }
} }
} }
+1 -1
View File
@@ -32,7 +32,7 @@ import static mindustry.Vars.*;
public class NetServer implements ApplicationListener{ public class NetServer implements ApplicationListener{
private final static int maxSnapshotSize = 430, timerBlockSync = 0; private final static int maxSnapshotSize = 430, timerBlockSync = 0;
private final static float serverSyncTime = 12, kickDuration = 30 * 1000, blockSyncTime = 60 * 10; 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(); private final static Rectangle viewport = new Rectangle();
/** If a player goes away of their server-side coordinates by this distance, they get teleported back. */ /** If a player goes away of their server-side coordinates by this distance, they get teleported back. */
private final static float correctDist = 16f; private final static float correctDist = 16f;
+1 -1
View File
@@ -120,7 +120,7 @@ public class Renderer implements ApplicationListener{
landTime = 0f; landTime = 0f;
graphics.clear(Color.black); graphics.clear(Color.black);
}else{ }else{
Vector2 position = Tmp.v3.set(player); Vec2 position = Tmp.v3.set(player);
if(player.isDead()){ if(player.isDead()){
TileEntity core = player.getClosestCore(); TileEntity core = player.getClosestCore();
@@ -475,7 +475,7 @@ public class MapEditorDialog extends Dialog implements Disposable{
} }
table.update(() -> { table.update(() -> {
Vector2 v = button.localToStageCoordinates(Tmp.v1.setZero()); Vec2 v = button.localToStageCoordinates(Tmp.v1.setZero());
table.setPosition(v.x, v.y, Align.topLeft); table.setPosition(v.x, v.y, Align.topLeft);
if(!isShown()){ if(!isShown()){
table.remove(); table.remove();
@@ -187,7 +187,7 @@ public class MapGenerateDialog extends FloatingDialog{
return; 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()){ if(v.x >= 0 && v.y >= 0 && v.x <= pane.getWidth() && v.y <= pane.getHeight()){
Core.scene.setScrollFocus(pane); Core.scene.setScrollFocus(pane);
+8 -8
View File
@@ -27,9 +27,9 @@ public class MapView extends Element implements GestureListener{
private float zoom = 1f; private float zoom = 1f;
private boolean grid = false; private boolean grid = false;
private GridImage image = new GridImage(0, 0); private GridImage image = new GridImage(0, 0);
private Vector2 vec = new Vector2(); private Vec2 vec = new Vec2();
private Rectangle rect = new Rectangle(); 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 boolean drawing;
private int lastx, lasty; 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 ratio = 1f / ((float)editor.width() / editor.height());
float size = Math.min(width, height); float size = Math.min(width, height);
float sclwidth = size * zoom; 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((!editor.drawBlock.isMultiblock() || tool == EditorTool.eraser) && tool != EditorTool.fill){
if(tool == EditorTool.line && drawing){ 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; 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], sx, sy, scaling);
Lines.poly(brushPolygons[index], v2.x, v2.y, 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)){ if((tool.edit || (tool == EditorTool.line && !drawing)) && (!mobile || drawing)){
Point2 p = project(mousex, mousey); 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 //pencil square outline
if(tool == EditorTool.pencil && tool.mode == 1){ if(tool == EditorTool.pencil && tool.mode == 1){
@@ -290,7 +290,7 @@ public class MapView extends Element implements GestureListener{
}else{ }else{
if((tool.edit || tool == EditorTool.line) && (!mobile || drawing)){ if((tool.edit || tool == EditorTool.line) && (!mobile || drawing)){
Point2 p = project(mousex, mousey); 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); float offset = (editor.drawBlock.size % 2 == 0 ? scaling / 2f : 0f);
Lines.square( Lines.square(
v.x + scaling / 2f + offset, v.x + scaling / 2f + offset,
@@ -332,7 +332,7 @@ public class MapView extends Element implements GestureListener{
} }
@Override @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; return false;
} }
+2 -2
View File
@@ -24,7 +24,7 @@ import static mindustry.Vars.*;
public class Damage{ public class Damage{
private static Rectangle rect = new Rectangle(); private static Rectangle rect = new Rectangle();
private static Rectangle hitrect = 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 GridBits bits = new GridBits(30, 30);
private static IntQueue propagation = new IntQueue(); private static IntQueue propagation = new IntQueue();
private static IntSet collidedBlocks = new IntSet(); private static IntSet collidedBlocks = new IntSet();
@@ -133,7 +133,7 @@ public class Damage{
other.width += expand * 2; other.width += expand * 2;
other.height += 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){ if(vec != null){
Effects.effect(effect, vec.x, vec.y); Effects.effect(effect, vec.x, vec.y);
@@ -18,8 +18,8 @@ public class EntityCollisions{
//tile collisions //tile collisions
private Rectangle tmp = new Rectangle(); private Rectangle tmp = new Rectangle();
private Vector2 vector = new Vector2(); private Vec2 vector = new Vec2();
private Vector2 l1 = new Vector2(); private Vec2 l1 = new Vec2();
private Rectangle r1 = new Rectangle(); private Rectangle r1 = new Rectangle();
private Rectangle r2 = new Rectangle(); private Rectangle r2 = new Rectangle();
@@ -72,7 +72,7 @@ public class EntityCollisions{
tmp.setSize(tilesize).setCenter(wx * tilesize, wy * tilesize); tmp.setSize(tilesize).setCenter(wx * tilesize, wy * tilesize);
if(tmp.overlaps(rect)){ if(tmp.overlaps(rect)){
Vector2 v = Geometry.overlap(rect, tmp, x); Vec2 v = Geometry.overlap(rect, tmp, x);
rect.x += v.x; rect.x += v.x;
rect.y += v.y; 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, 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; float px = vx1, py = vy1;
vx1 -= vx2; vx1 -= vx2;
+8 -8
View File
@@ -9,8 +9,8 @@ import mindustry.entities.traits.*;
* Class for predicting shoot angles based on velocities of targets. * Class for predicting shoot angles based on velocities of targets.
*/ */
public class Predict{ public class Predict{
private static Vector2 vec = new Vector2(); private static Vec2 vec = new Vec2();
private static Vector2 vresult = new Vector2(); private static Vec2 vresult = new Vec2();
/** /**
* Calculates of intercept of a stationary and moving target. Do not call from multiple threads! * 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 * @param v speed of bullet
* @return the intercept location * @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(); dstvx /= Time.delta();
dstvy /= Time.delta(); dstvy /= Time.delta();
float tx = dstx - srcx, float tx = dstx - srcx,
@@ -35,10 +35,10 @@ public class Predict{
float c = tx * tx + ty * ty; float c = tx * tx + ty * ty;
// Solve quadratic // Solve quadratic
Vector2 ts = quad(a, b, c); Vec2 ts = quad(a, b, c);
// Find smallest positive solution // Find smallest positive solution
Vector2 sol = vresult.set(dstx, dsty); Vec2 sol = vresult.set(dstx, dsty);
if(ts != null){ if(ts != null){
float t0 = ts.x, t1 = ts.y; float t0 = ts.x, t1 = ts.y;
float t = Math.min(t0, t1); float t = Math.min(t0, t1);
@@ -54,12 +54,12 @@ public class Predict{
/** /**
* See {@link #intercept(float, float, float, float, float, float, float)}. * 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); 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){ private static Vec2 quad(float a, float b, float c){
Vector2 sol = null; Vec2 sol = null;
if(Math.abs(a) < 1e-6){ if(Math.abs(a) < 1e-6){
if(Math.abs(b) < 1e-6){ if(Math.abs(b) < 1e-6){
sol = Math.abs(c) < 1e-6 ? vec.set(0, 0) : null; 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.Interpolation;
import arc.math.Mathf; import arc.math.Mathf;
import arc.math.geom.Position; import arc.math.geom.Position;
import arc.math.geom.Vector2; import arc.math.geom.Vec2;
import arc.util.Time; import arc.util.Time;
import arc.util.pooling.Pools; import arc.util.pooling.Pools;
import mindustry.entities.*; import mindustry.entities.*;
@@ -20,9 +20,9 @@ import mindustry.world.Tile;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class ItemTransfer extends TimedEntity implements DrawTrait{ public class ItemTransfer extends TimedEntity implements DrawTrait{
private Vector2 from = new Vector2(); private Vec2 from = new Vec2();
private Vector2 current = new Vector2(); private Vec2 current = new Vec2();
private Vector2 tovec = new Vector2(); private Vec2 tovec = new Vec2();
private Item item; private Item item;
private float seed; private float seed;
private Position to; private Position to;
@@ -35,7 +35,7 @@ public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{
private static final float hitRange = 30f; private static final float hitRange = 30f;
private static int lastSeed = 0; private static int lastSeed = 0;
private Array<Vector2> lines = new Array<>(); private Array<Vec2> lines = new Array<>();
private Color color = Pal.lancerLaser; private Color color = Pal.lancerLaser;
/** For pooling use only. Do not call directly! */ /** 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++){ for(int i = 0; i < length / 2; i++){
Bullet.create(Bullets.damageLightning, l, team, x, y, 0f, 1f, 1f, dmg); 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){ if(l.lines.size > 1){
bhit[0] = false; bhit[0] = false;
@@ -229,7 +229,7 @@ public interface BuilderTrait extends Entity, TeamTrait{
//due to iOS weirdness, this is apparently required //due to iOS weirdness, this is apparently required
class BuildDataStatic{ 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. */ /** Draw placement effects for an entity. */
@@ -11,7 +11,7 @@ public interface SolidTrait extends QuadTreeObject, MoveTrait, VelocityTrait, En
void hitboxTile(Rectangle rectangle); void hitboxTile(Rectangle rectangle);
Vector2 lastPosition(); Vec2 lastPosition();
default boolean collidesGrid(int x, int y){ default boolean collidesGrid(int x, int y){
return true; return true;
@@ -1,11 +1,11 @@
package mindustry.entities.traits; package mindustry.entities.traits;
import arc.math.geom.Vector2; import arc.math.geom.Vec2;
import arc.util.Time; import arc.util.Time;
public interface VelocityTrait extends MoveTrait{ public interface VelocityTrait extends MoveTrait{
Vector2 velocity(); Vec2 velocity();
default void applyImpulse(float x, float y){ default void applyImpulse(float x, float y){
velocity().x += x / mass(); 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); bullet.velocity.set(0, type.speed).setAngle(angle).scl(velocityScl);
if(type.keepVelocity){ 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; bullet.team = team;
@@ -297,7 +297,7 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool
} }
@Override @Override
public Vector2 velocity(){ public Vec2 velocity(){
return velocity; return velocity;
} }
+3 -3
View File
@@ -71,7 +71,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
private float walktime, itemtime; private float walktime, itemtime;
private Queue<BuildRequest> placeQueue = new Queue<>(); private Queue<BuildRequest> placeQueue = new Queue<>();
private Tile mining; private Tile mining;
private Vector2 movement = new Vector2(); private Vec2 movement = new Vec2();
private boolean moved; private boolean moved;
//endregion //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; 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; pointerX = vec.x;
pointerY = vec.y; pointerY = vec.y;
updateShooting(); updateShooting();
@@ -738,7 +738,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
rotation = Mathf.slerpDelta(rotation, angleTo(target), 0.2f); 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; pointerX = intercept.x;
pointerY = intercept.y; pointerY = intercept.y;
@@ -1,19 +1,19 @@
package mindustry.entities.type; package mindustry.entities.type;
import arc.math.geom.Vector2; import arc.math.geom.Vec2;
import mindustry.entities.traits.SolidTrait; import mindustry.entities.traits.SolidTrait;
public abstract class SolidEntity extends BaseEntity implements SolidTrait{ public abstract class SolidEntity extends BaseEntity implements SolidTrait{
protected transient Vector2 velocity = new Vector2(0f, 0.0001f); protected transient Vec2 velocity = new Vec2(0f, 0.0001f);
private transient Vector2 lastPosition = new Vector2(); private transient Vec2 lastPosition = new Vec2();
@Override @Override
public Vector2 lastPosition(){ public Vec2 lastPosition(){
return lastPosition; return lastPosition;
} }
@Override @Override
public Vector2 velocity(){ public Vec2 velocity(){
return velocity; return velocity;
} }
} }
@@ -5,7 +5,7 @@ import arc.Events;
import arc.struct.Array; import arc.struct.Array;
import arc.struct.ObjectSet; import arc.struct.ObjectSet;
import arc.math.geom.Point2; import arc.math.geom.Point2;
import arc.math.geom.Vector2; import arc.math.geom.Vec2;
import arc.util.*; import arc.util.*;
import arc.util.ArcAnnotate.*; import arc.util.ArcAnnotate.*;
import mindustry.entities.EntityGroup; import mindustry.entities.EntityGroup;
@@ -288,8 +288,8 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
} }
@Override @Override
public Vector2 velocity(){ public Vec2 velocity(){
return Vector2.ZERO; return Vec2.ZERO;
} }
@Override @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 float maxAbsVelocity = 127f / velocityPercision;
public static final int noSpawner = Pos.get(-1, 1); 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; public float rotation;
@@ -118,7 +118,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
} }
@Override @Override
public Vector2 velocity(){ public Vec2 velocity(){
return 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); getWeapon().update(FlyingUnit.this, wx + Tmp.v2.x, wy + Tmp.v2.y, weaponAngles[wi], left);
} }
}else{ }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); getWeapon().update(FlyingUnit.this, to.x, to.y);
} }
} }
@@ -20,7 +20,7 @@ import mindustry.world.meta.*;
import static mindustry.Vars.*; import static mindustry.Vars.*;
public class GroundUnit extends BaseUnit{ public class GroundUnit extends BaseUnit{
protected static Vector2 vec = new Vector2(); protected static Vec2 vec = new Vec2();
protected float walkTime; protected float walkTime;
protected float stuckTime; protected float stuckTime;
@@ -175,7 +175,7 @@ public class GroundUnit extends BaseUnit{
if(Angles.near(angleTo(target), rotation, 13f)){ if(Angles.near(angleTo(target), rotation, 13f)){
BulletType ammo = getWeapon().bullet; 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); getWeapon().update(GroundUnit.this, to.x, to.y);
} }
+1 -1
View File
@@ -53,7 +53,7 @@ public class LoopControl{
private class SoundData{ private class SoundData{
float volume; float volume;
float total; float total;
Vector2 sum = new Vector2(); Vec2 sum = new Vec2();
int soundID; int soundID;
float curVolume; float curVolume;
@@ -63,7 +63,7 @@ public class LightRenderer{
float v2 = lmid.getV(); 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, float lx1 = x - v1.x, ly1 = y - v1.y,
lx2 = x + v1.x, ly2 = y + v1.y, lx2 = x + v1.x, ly2 = y + v1.y,
lx3 = x2 + v1.x, ly3 = y2 + 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); 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(); u = ledge.getU();
v = ledge.getV2(); v = ledge.getV2();
@@ -122,7 +122,7 @@ public class OverlayRenderer{
//draw selected block //draw selected block
if(input.block == null && !Core.scene.hasMouse()){ 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); Tile tile = world.ltileWorld(vec.x, vec.y);
if(tile != null && tile.block() != Blocks.air && tile.getTeam() == player.getTeam()){ if(tile != null && tile.block() != Blocks.air && tile.getTeam() == player.getTeam()){
@@ -139,7 +139,7 @@ public class OverlayRenderer{
//draw selection overlay when dropping item //draw selection overlay when dropping item
if(input.isDroppingItem()){ if(input.isDroppingItem()){
Vector2 v = Core.input.mouseWorld(input.getMouseX(), input.getMouseY()); Vec2 v = Core.input.mouseWorld(input.getMouseX(), input.getMouseY());
float size = 8; float size = 8;
Draw.rect(player.item().item.icon(Cicon.medium), v.x, v.y, size, size); Draw.rect(player.item().item.icon(Cicon.medium), v.x, v.y, size, size);
Draw.color(Pal.accent); Draw.color(Pal.accent);
+4 -4
View File
@@ -43,7 +43,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
final static float playerSelectRange = mobile ? 17f : 11f; final static float playerSelectRange = mobile ? 17f : 11f;
/** Maximum line length. */ /** Maximum line length. */
final static int maxLength = 100; 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(); final static Rectangle r1 = new Rectangle(), r2 = new Rectangle();
/** Distance on the back from where items originate. */ /** Distance on the back from where items originate. */
final static float backTrns = 3f; final static float backTrns = 3f;
@@ -120,7 +120,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
ItemTransfer.create(item, ItemTransfer.create(item,
player.x + Angles.trnsx(player.rotation + 180f, backTrns), player.y + Angles.trnsy(player.rotation + 180f, backTrns), 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; if(tile.block() != block || tile.entity == null || tile.entity.items == null) return;
tile.block().handleStack(item, removed, tile, player); tile.block().handleStack(item, removed, tile, player);
@@ -639,7 +639,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
} }
int tileX(float cursorX){ int tileX(float cursorX){
Vector2 vec = Core.input.mouseWorld(cursorX, 0); Vec2 vec = Core.input.mouseWorld(cursorX, 0);
if(selectedBlock()){ if(selectedBlock()){
vec.sub(block.offset(), block.offset()); vec.sub(block.offset(), block.offset());
} }
@@ -647,7 +647,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
} }
int tileY(float cursorY){ int tileY(float cursorY){
Vector2 vec = Core.input.mouseWorld(0, cursorY); Vec2 vec = Core.input.mouseWorld(0, cursorY);
if(selectedBlock()){ if(selectedBlock()){
vec.sub(block.offset(), block.offset()); vec.sub(block.offset(), block.offset());
} }
+1 -1
View File
@@ -36,7 +36,7 @@ public class MobileInput extends InputHandler implements GestureListener{
private final float edgePan = Scl.scl(60f); private final float edgePan = Scl.scl(60f);
//gesture data //gesture data
private Vector2 vector = new Vector2(); private Vec2 vector = new Vec2();
private float lastZoom = -1; private float lastZoom = -1;
/** Position where the player started dragging a line. */ /** Position where the player started dragging a line. */
@@ -11,7 +11,7 @@ import mindustry.maps.filters.FilterOption.*;
import mindustry.world.*; import mindustry.world.*;
public class MirrorFilter extends GenerateFilter{ 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; int angle = 45;
@@ -44,12 +44,12 @@ public class MirrorFilter extends GenerateFilter{
public void draw(Image image){ public void draw(Image image){
super.draw(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 imageWidth = Math.max(vsize.x, vsize.y);
float imageHeight = Math.max(vsize.y, vsize.x); float imageHeight = Math.max(vsize.y, vsize.x);
float size = Math.max(image.getWidth() *2, image.getHeight()*2); float size = Math.max(image.getWidth() *2, image.getHeight()*2);
Cons<Vector2> clamper = v -> Cons<Vec2> clamper = v ->
v.clamp( v.clamp(
image.getX() + image.getWidth()/2f - imageWidth/2f, image.getX() + image.getWidth()/2f - imageWidth/2f,
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(); 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 //special case: uneven map mirrored at 45 degree angle
if(in.width != in.height && angle % 90 != 0){ if(in.width != in.height && angle % 90 != 0){
p.x = (p.x - in.width/2f) * -1 + in.width/2f; 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; return ((b.x - a.x)*(c.y - a.y) - (b.y - a.y)*(c.x - a.x)) > 0;
} }
} }
+1 -1
View File
@@ -460,7 +460,7 @@ public class ContentParser{
builder.append("[accent][[").append(e.getClass().getSimpleName().replace("Exception", "")) builder.append("[accent][[").append(e.getClass().getSimpleName().replace("Exception", ""))
.append("][] ") .append("][] ")
.append(e.getMessage() != null ? .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(); return builder.toString();
+3 -3
View File
@@ -6,14 +6,14 @@ import arc.util.*;
public class Interpolator{ public class Interpolator{
//used for movement //used for movement
public Vector2 target = new Vector2(); public Vec2 target = new Vec2();
public Vector2 last = new Vector2(); public Vec2 last = new Vec2();
public float[] targets = {}; public float[] targets = {};
public float[] lasts = {}; public float[] lasts = {};
public long lastUpdated, updateSpacing; public long lastUpdated, updateSpacing;
//current state //current state
public Vector2 pos = new Vector2(); public Vec2 pos = new Vec2();
public float[] values = {}; public float[] values = {};
public void read(float cx, float cy, float x, float y, float... target1ds){ 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(){ 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.pack();
table.setPosition(v.x, v.y, Align.topLeft); table.setPosition(v.x, v.y, Align.topLeft);
} }
@@ -208,7 +208,7 @@ public class HudFragment extends Fragment{
if(b.isChecked()){ if(b.isChecked()){
Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true); Element e = Core.scene.hit(Core.input.mouseX(), Core.input.mouseY(), true);
if(e == null){ if(e == null){
Vector2 world = Core.input.mouseWorld(); Vec2 world = Core.input.mouseWorld();
Units.nearby(world.x, world.y, 1f, 1f, unit -> { Units.nearby(world.x, world.y, 1f, 1f, unit -> {
if(!found[0] && unit instanceof BaseUnit){ if(!found[0] && unit instanceof BaseUnit){
if(Core.input.keyTap(KeyCode.MOUSE_LEFT)){ if(Core.input.keyTap(KeyCode.MOUSE_LEFT)){
@@ -433,7 +433,7 @@ public class PlacementFragment extends Fragment{
Block getSelected(){ Block getSelected(){
Block toDisplay = null; Block toDisplay = null;
Vector2 v = topTable.stageToLocalCoordinates(Core.input.mouse()); Vec2 v = topTable.stageToLocalCoordinates(Core.input.mouse());
//setup hovering tile //setup hovering tile
if(!Core.scene.hasMouse() && topTable.hit(v.x, v.y, false) == null){ if(!Core.scene.hasMouse() && topTable.hit(v.x, v.y, false) == null){
+1 -1
View File
@@ -489,7 +489,7 @@ public class Block extends BlockStorage{
/** Update table alignment after configuring.*/ /** Update table alignment after configuring.*/
public void updateTableAlign(Tile tile, Table table){ 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); table.setPosition(pos.x, pos.y, Align.top);
} }
+2 -2
View File
@@ -2,7 +2,7 @@ package mindustry.world;
import arc.struct.Array; import arc.struct.Array;
import arc.math.Mathf; import arc.math.Mathf;
import arc.math.geom.Vector2; import arc.math.geom.Vec2;
import arc.util.*; import arc.util.*;
import mindustry.Vars; import mindustry.Vars;
import mindustry.content.Fx; import mindustry.content.Fx;
@@ -83,7 +83,7 @@ public abstract class BlockStorage extends UnlockableContent{
} }
/** Returns offset for stack placement. */ /** Returns offset for stack placement. */
public void getStackOffset(Item item, Tile tile, Vector2 trns){ public void getStackOffset(Item item, Tile tile, Vec2 trns){
} }
+2 -2
View File
@@ -12,7 +12,7 @@ public class Edges{
private static final int maxRadius = 12; private static final int maxRadius = 12;
private static Point2[][] edges = new Point2[maxSize][0]; private static Point2[][] edges = new Point2[maxSize][0];
private static Point2[][] edgeInside = 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{ static{
for(int i = 0; i < maxRadius * 2; i++){ 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))); 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) if(radius < 1 || radius > maxRadius)
throw new RuntimeException("Polygon size must be between 1 and " + maxRadius); throw new RuntimeException("Polygon size must be between 1 and " + maxRadius);
return polygons[(int)(radius * 2) - 1]; return polygons[(int)(radius * 2) - 1];
+2 -2
View File
@@ -449,8 +449,8 @@ public class Tile implements Position, TargetTrait{
} }
@Override @Override
public Vector2 velocity(){ public Vec2 velocity(){
return Vector2.ZERO; return Vec2.ZERO;
} }
@Override @Override
@@ -52,7 +52,7 @@ public class DeflectorWall extends Wall{
bullet.hitbox(rect2); 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)); rect.setSize(size * tilesize + rect2.width*2 + rect2.height*2).setCenter(entity.x, entity.y));
if(position != null){ if(position != null){
@@ -1,7 +1,7 @@
package mindustry.world.blocks.defense.turrets; package mindustry.world.blocks.defense.turrets;
import arc.math.Mathf; import arc.math.Mathf;
import arc.math.geom.Vector2; import arc.math.geom.Vec2;
import mindustry.entities.Predict; import mindustry.entities.Predict;
import mindustry.entities.type.Bullet; import mindustry.entities.type.Bullet;
import mindustry.entities.bullet.BulletType; import mindustry.entities.bullet.BulletType;
@@ -31,7 +31,7 @@ public class ArtilleryTurret extends ItemTurret{
tr.trns(entity.rotation, size * tilesize / 2); 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 dst = entity.dst(predict.x, predict.y);
float maxTraveled = type.lifetime * type.speed; float maxTraveled = type.lifetime * type.speed;
@@ -10,7 +10,7 @@ import arc.graphics.Color;
import arc.graphics.g2d.*; import arc.graphics.g2d.*;
import arc.math.Angles; import arc.math.Angles;
import arc.math.Mathf; import arc.math.Mathf;
import arc.math.geom.Vector2; import arc.math.geom.Vec2;
import arc.util.Time; import arc.util.Time;
import mindustry.content.Fx; import mindustry.content.Fx;
import mindustry.entities.*; import mindustry.entities.*;
@@ -54,8 +54,8 @@ public abstract class Turret extends Block{
public boolean targetAir = true; public boolean targetAir = true;
public boolean targetGround = true; public boolean targetGround = true;
protected Vector2 tr = new Vector2(); protected Vec2 tr = new Vec2();
protected Vector2 tr2 = new Vector2(); protected Vec2 tr2 = new Vec2();
public TextureRegion baseRegion, heatRegion; public TextureRegion baseRegion, heatRegion;
@@ -162,7 +162,7 @@ public abstract class Turret extends Block{
float speed = type.speed; float speed = type.speed;
if(speed < 0.1f) speed = 9999999f; 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()){ if(result.isZero()){
result.set(entity.target.getX(), entity.target.getY()); 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 drawpos = new ItemPos();
private static ItemPos pos1 = new ItemPos(); private static ItemPos pos1 = new ItemPos();
private static ItemPos pos2 = new ItemPos(); private static ItemPos pos2 = new ItemPos();
private final Vector2 tr1 = new Vector2(); private final Vec2 tr1 = new Vec2();
private final Vector2 tr2 = new Vector2(); private final Vec2 tr2 = new Vec2();
private TextureRegion[][] regions = new TextureRegion[7][4]; private TextureRegion[][] regions = new TextureRegion[7][4];
public float speed = 0f; public float speed = 0f;
@@ -283,7 +283,7 @@ public class Conveyor extends Block implements Autotiler{
} }
@Override @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); trns.trns(tile.rotation() * 90 + 180f, tilesize / 2f);
} }
@@ -142,7 +142,7 @@ public class MessageBlock extends Block{
@Override @Override
public void updateTableAlign(Tile tile, Table table){ 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); table.setPosition(pos.x, pos.y, Align.bottom);
} }
@@ -24,7 +24,7 @@ import static mindustry.Vars.*;
public class NuclearReactor extends PowerGenerator{ public class NuclearReactor extends PowerGenerator{
public final int timerFuel = timers++; 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 lightColor = Color.valueOf("7f19ea");
public Color coolColor = new Color(1, 1, 1, 0f); public Color coolColor = new Color(1, 1, 1, 0f);
@@ -22,7 +22,7 @@ public class PowerNode extends PowerBlock{
protected static boolean returnValue = false; protected static boolean returnValue = false;
protected final ObjectSet<PowerGraph> graphs = new ObjectSet<>(); 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 TextureRegion laser, laserEnd;
public float laserRange = 6; public float laserRange = 6;
@@ -1,17 +1,17 @@
package mindustry.desktop; package mindustry.desktop;
import arc.*; import arc.*;
import club.minnced.discord.rpc.*;
import com.codedisaster.steamworks.*;
import arc.Files.*; import arc.Files.*;
import io.anuke.arc.backends.sdl.*; import arc.backend.sdl.*;
import io.anuke.arc.backends.sdl.jni.*;
import arc.struct.*;
import arc.files.*; import arc.files.*;
import arc.func.*; import arc.func.*;
import arc.math.*; import arc.math.*;
import arc.struct.*;
import arc.util.*; import arc.util.*;
import arc.util.serialization.*; import arc.util.serialization.*;
import club.minnced.discord.rpc.*;
import com.codedisaster.steamworks.*;
import io.anuke.arc.backends.sdl.jni.*;
import mindustry.*; import mindustry.*;
import mindustry.core.GameState.*; import mindustry.core.GameState.*;
import mindustry.core.*; import mindustry.core.*;
@@ -21,7 +21,7 @@ import java.util.*;
public class ScriptStubGenerator{ public class ScriptStubGenerator{
public static void main(String[] args){ public static void main(String[] args){
String base = "io.anuke.mindustry"; String base = "mindustry";
Array<String> blacklist = Array.with("plugin", "mod", "net", "io", "tools"); Array<String> blacklist = Array.with("plugin", "mod", "net", "io", "tools");
Array<String> nameBlacklist = Array.with("ClientLauncher", "NetClient", "NetServer", "ClassAccess"); Array<String> nameBlacklist = Array.with("ClientLauncher", "NetClient", "NetServer", "ClassAccess");
Array<Class<?>> whitelist = Array.with(Draw.class, Fill.class, Lines.class, Core.class, TextureAtlas.class, TextureRegion.class, Time.class, System.class, PrintStream.class, Array<Class<?>> whitelist = Array.with(Draw.class, Fill.class, Lines.class, Core.class, TextureAtlas.class, TextureRegion.class, Time.class, System.class, PrintStream.class,
@@ -45,7 +45,7 @@ public class ScriptStubGenerator{
.setScanners(new SubTypesScanner(false), new ResourcesScanner()) .setScanners(new SubTypesScanner(false), new ResourcesScanner())
.setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0]))) .setUrls(ClasspathHelper.forClassLoader(classLoadersList.toArray(new ClassLoader[0])))
.filterInputsBy(new FilterBuilder() .filterInputsBy(new FilterBuilder()
.include(FilterBuilder.prefix("io.anuke.mindustry")) .include(FilterBuilder.prefix("mindustry"))
.include(FilterBuilder.prefix("arc.func")) .include(FilterBuilder.prefix("arc.func"))
.include(FilterBuilder.prefix("arc.struct")) .include(FilterBuilder.prefix("arc.struct"))
.include(FilterBuilder.prefix("arc.scene")) .include(FilterBuilder.prefix("arc.scene"))
@@ -72,7 +72,7 @@ public class ScriptStubGenerator{
//Log.info(result); //Log.info(result);
new Fi("core/assets/scripts/global.js").writeString(result.toString()); new Fi("core/assets/scripts/global.js").writeString(result.toString());
new Fi("core/src/io/anuke/mindustry/mod/ClassAccess.java").writeString(fileTemplate new Fi("core/src/mindustry/mod/ClassAccess.java").writeString(fileTemplate
.replace("$ALLOWED_CLASSES$", classes.toString(", ", type -> type.getName() + ".class")) .replace("$ALLOWED_CLASSES$", classes.toString(", ", type -> type.getName() + ".class"))
.replace("$ALLOWED_CLASS_NAMES$", classes.toString(", ", type -> "\"" + type.getName() + "\""))); .replace("$ALLOWED_CLASS_NAMES$", classes.toString(", ", type -> "\"" + type.getName() + "\"")));
} }