More plugin customization / Renamed Rectangle

This commit is contained in:
Anuken
2019-12-26 22:44:15 -05:00
parent 6080a7e4bc
commit d6d6dc29dc
35 changed files with 166 additions and 90 deletions

View File

@@ -22,8 +22,8 @@ import static mindustry.Vars.*;
/** Utility class for damaging in an area. */
public class Damage{
private static Rectangle rect = new Rectangle();
private static Rectangle hitrect = new Rectangle();
private static Rect rect = new Rect();
private static Rect hitrect = new Rect();
private static Vec2 tr = new Vec2();
private static GridBits bits = new GridBits(30, 30);
private static IntQueue propagation = new IntQueue();
@@ -127,7 +127,7 @@ public class Damage{
Cons<Unit> cons = e -> {
e.hitbox(hitrect);
Rectangle other = hitrect;
Rect other = hitrect;
other.y -= expand;
other.x -= expand;
other.width += expand * 2;

View File

@@ -17,11 +17,11 @@ public class EntityCollisions{
private static final float seg = 1f;
//tile collisions
private Rectangle tmp = new Rectangle();
private Rect tmp = new Rect();
private Vec2 vector = new Vec2();
private Vec2 l1 = new Vec2();
private Rectangle r1 = new Rectangle();
private Rectangle r2 = new Rectangle();
private Rect r1 = new Rect();
private Rect r2 = new Rect();
//entity collisions
private Array<SolidTrait> arrOut = new Array<>();
@@ -57,7 +57,7 @@ public class EntityCollisions{
public void moveDelta(SolidTrait entity, float deltax, float deltay, boolean x){
Rectangle rect = r1;
Rect rect = r1;
entity.hitboxTile(rect);
entity.hitboxTile(r2);
rect.x += deltax;
@@ -84,7 +84,7 @@ public class EntityCollisions{
entity.setY(entity.getY() + rect.y - r2.y);
}
public boolean overlapsTile(Rectangle rect){
public boolean overlapsTile(Rect rect){
rect.getCenter(vector);
int r = 1;

View File

@@ -19,13 +19,13 @@ public class EntityGroup<T extends Entity>{
private final Array<T> entitiesToRemove = new Array<>(false, 32);
private final Array<T> entitiesToAdd = new Array<>(false, 32);
private final Array<T> intersectArray = new Array<>();
private final Rectangle intersectRect = new Rectangle();
private final Rect intersectRect = new Rect();
private IntMap<T> map;
private QuadTree tree;
private Cons<T> removeListener;
private Cons<T> addListener;
private final Rectangle viewport = new Rectangle();
private final Rect viewport = new Rect();
private int count = 0;
public EntityGroup(int id, Class<T> type, boolean useTree){
@@ -34,7 +34,7 @@ public class EntityGroup<T extends Entity>{
this.type = type;
if(useTree){
tree = new QuadTree<>(new Rectangle(0, 0, 0, 0));
tree = new QuadTree<>(new Rect(0, 0, 0, 0));
}
}
@@ -180,7 +180,7 @@ public class EntityGroup<T extends Entity>{
/** Resizes the internal quadtree, if it is enabled.*/
public void resize(float x, float y, float w, float h){
if(useTree){
tree = new QuadTree<>(new Rectangle(x, y, w, h));
tree = new QuadTree<>(new Rect(x, y, w, h));
}
}

View File

@@ -12,7 +12,7 @@ import static mindustry.Vars.*;
/** Utility class for unit and team interactions.*/
public class Units{
private static Rectangle hitrect = new Rectangle();
private static Rect hitrect = new Rect();
private static Unit result;
private static float cdist;
private static boolean boolResult;
@@ -188,7 +188,7 @@ public class Units{
}
/** Iterates over all units in a rectangle. */
public static void nearby(Rectangle rect, Cons<Unit> cons){
public static void nearby(Rect rect, Cons<Unit> cons){
nearby(rect.x, rect.y, rect.width, rect.height, cons);
}
@@ -208,7 +208,7 @@ public class Units{
}
/** Iterates over all units that are enemies of this team. */
public static void nearbyEnemies(Team team, Rectangle rect, Cons<Unit> cons){
public static void nearbyEnemies(Team team, Rect rect, Cons<Unit> cons){
nearbyEnemies(team, rect.x, rect.y, rect.width, rect.height, cons);
}

View File

@@ -1,13 +1,13 @@
package mindustry.entities.bullet;
import arc.math.geom.Rectangle;
import arc.math.geom.Rect;
import arc.util.Time;
import mindustry.content.Fx;
import mindustry.entities.Units;
import mindustry.entities.type.Bullet;
public class FlakBulletType extends BasicBulletType{
protected static Rectangle rect = new Rectangle();
protected static Rect rect = new Rect();
protected float explodeRange = 30f;
public FlakBulletType(float speed, float damage){

View File

@@ -28,7 +28,7 @@ public class Lightning extends TimedEntity implements DrawTrait, TimeTrait{
public static final float lifetime = 10f;
private static final RandomXS128 random = new RandomXS128();
private static final Rectangle rect = new Rectangle();
private static final Rect rect = new Rect();
private static final Array<Unit> entities = new Array<>();
private static final IntSet hit = new IntSet();
private static final int maxChain = 8;

View File

@@ -27,8 +27,8 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
private static final float maxLiquid = 70f;
private static final int maxGeneration = 2;
private static final Color tmp = new Color();
private static final Rectangle rect = new Rectangle();
private static final Rectangle rect2 = new Rectangle();
private static final Rect rect = new Rect();
private static final Rect rect2 = new Rect();
private static int seeds;
private int loadedPosition = -1;
@@ -151,13 +151,13 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
}
@Override
public void hitbox(Rectangle rectangle){
rectangle.setCenter(x, y).setSize(tilesize);
public void hitbox(Rect rect){
rect.setCenter(x, y).setSize(tilesize);
}
@Override
public void hitboxTile(Rectangle rectangle){
rectangle.setCenter(x, y).setSize(0f);
public void hitboxTile(Rect rect){
rect.setCenter(x, y).setSize(0f);
}
@Override

View File

@@ -343,7 +343,7 @@ public interface BuilderTrait extends Entity, TeamTrait{
return this;
}
public Rectangle bounds(Rectangle rect){
public Rect bounds(Rect rect){
if(breaking){
return rect.set(-100f, -100f, 0f, 0f);
}else{

View File

@@ -7,9 +7,9 @@ import mindustry.Vars;
public interface SolidTrait extends QuadTreeObject, MoveTrait, VelocityTrait, Entity, Position{
void hitbox(Rectangle rectangle);
void hitbox(Rect rect);
void hitboxTile(Rectangle rectangle);
void hitboxTile(Rect rect);
Vec2 lastPosition();

View File

@@ -352,13 +352,13 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
}
@Override
public void hitbox(Rectangle rectangle){
rectangle.setSize(type.hitsize).setCenter(x, y);
public void hitbox(Rect rect){
rect.setSize(type.hitsize).setCenter(x, y);
}
@Override
public void hitboxTile(Rectangle rectangle){
rectangle.setSize(type.hitsizeTile).setCenter(x, y);
public void hitboxTile(Rect rect){
rect.setSize(type.hitsizeTile).setCenter(x, y);
}
@Override

View File

@@ -246,13 +246,13 @@ public class Bullet extends SolidEntity implements DamageTrait, ScaleTrait, Pool
}
@Override
public void hitbox(Rectangle rectangle){
rectangle.setSize(type.hitSize).setCenter(x, y);
public void hitbox(Rect rect){
rect.setSize(type.hitSize).setCenter(x, y);
}
@Override
public void hitboxTile(Rectangle rectangle){
rectangle.setSize(type.hitSize).setCenter(x, y);
public void hitboxTile(Rect rect){
rect.setSize(type.hitSize).setCenter(x, y);
}
@Override

View File

@@ -41,7 +41,7 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
private static final int timerShootRight = 1;
private static final float liftoffBoost = 0.2f;
private static final Rectangle rect = new Rectangle();
private static final Rect rect = new Rect();
//region instance variables
@@ -93,13 +93,13 @@ public class Player extends Unit implements BuilderMinerTrait, ShooterTrait{
}
@Override
public void hitbox(Rectangle rectangle){
rectangle.setSize(mech.hitsize).setCenter(x, y);
public void hitbox(Rect rect){
rect.setSize(mech.hitsize).setCenter(x, y);
}
@Override
public void hitboxTile(Rectangle rectangle){
rectangle.setSize(mech.hitsize * 2f / 3f).setCenter(x, y);
public void hitboxTile(Rect rect){
rect.setSize(mech.hitsize * 2f / 3f).setCenter(x, y);
}
@Override