Removed all tmps, multithreading now functional
This commit is contained in:
@@ -25,7 +25,6 @@ public class Mindustry extends ModuleCore {
|
||||
BundleLoader.load();
|
||||
BlockLoader.load();
|
||||
|
||||
|
||||
logic = new Logic();
|
||||
|
||||
if(!multithread) module(logic);
|
||||
|
||||
@@ -79,8 +79,8 @@ public class Pathfind{
|
||||
if(projectLen < 8 || !onLine(projection, prev.worldx(), prev.worldy(), target.worldx(), target.worldy())){
|
||||
canProject = false;
|
||||
}else{
|
||||
projection.add(v1.set(Angles.angle(prev.worldx(), prev.worldy(),
|
||||
target.worldx(), target.worldy()), projectLen));
|
||||
projection.add(v1.set(projectLen, 0).rotate(Angles.angle(prev.worldx(), prev.worldy(),
|
||||
target.worldx(), target.worldy())));
|
||||
}
|
||||
|
||||
float dst = Vector2.dst(enemy.x, enemy.y, target.worldx(), target.worldy());
|
||||
|
||||
@@ -3,16 +3,15 @@ package io.anuke.mindustry.ai;
|
||||
import com.badlogic.gdx.ai.pfa.DefaultGraphPath;
|
||||
import com.badlogic.gdx.ai.pfa.SmoothableGraphPath;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
public class SmoothGraphPath extends DefaultGraphPath<Tile> implements SmoothableGraphPath<Tile, Vector2>{
|
||||
private Vector2 vector = new Vector2();
|
||||
|
||||
@Override
|
||||
public Vector2 getNodePosition(int index){
|
||||
Tile tile = nodes.get(index);
|
||||
return Tmp.v3.set(tile.worldx(), tile.worldy());
|
||||
return vector.set(tile.worldx(), tile.worldy());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -50,6 +50,7 @@ public class Renderer extends RendererModule{
|
||||
private int targetscale = baseCameraScale;
|
||||
private FloatArray shieldHits = new FloatArray();
|
||||
private Array<Callable> shieldDraws = new Array<>();
|
||||
private Rectangle rect = new Rectangle(), rect2 = new Rectangle();
|
||||
private BlockRenderer blocks = new BlockRenderer();
|
||||
|
||||
public Renderer() {
|
||||
@@ -58,9 +59,9 @@ public class Renderer extends RendererModule{
|
||||
Core.cameraScale = baseCameraScale;
|
||||
Effects.setEffectProvider((name, color, x, y, rotation) -> {
|
||||
if(Settings.getBool("effects")){
|
||||
Rectangle view = Tmp.r1.setSize(camera.viewportWidth, camera.viewportHeight)
|
||||
Rectangle view = rect.setSize(camera.viewportWidth, camera.viewportHeight)
|
||||
.setCenter(camera.position.x, camera.position.y);
|
||||
Rectangle pos = Tmp.r2.setSize(name.size).setCenter(x, y);
|
||||
Rectangle pos = rect2.setSize(name.size).setCenter(x, y);
|
||||
if(view.overlaps(pos)){
|
||||
new EffectEntity(name, color, rotation).set(x, y).add();
|
||||
}
|
||||
@@ -242,7 +243,8 @@ public class Renderer extends RendererModule{
|
||||
Draw.color(Color.RED);
|
||||
for(Enemy enemy : enemyGroup.all()) {
|
||||
|
||||
if (Tmp.r1.setSize(camera.viewportWidth, camera.viewportHeight).setCenter(camera.position.x, camera.position.y).overlaps(enemy.hitbox.getRect(enemy.x, enemy.y))) {
|
||||
if (rect.setSize(camera.viewportWidth, camera.viewportHeight).setCenter(camera.position.x, camera.position.y)
|
||||
.overlaps(enemy.hitbox.getRect(enemy.x, enemy.y))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@ import io.anuke.ucore.entities.SolidEntity;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Angles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
import io.anuke.ucore.util.Translator;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
@@ -290,10 +289,10 @@ public class Player extends SyncEntity{
|
||||
|
||||
i.time += 1f / i.spacing * Timers.delta();
|
||||
|
||||
Mathf.lerp2(Tmp.v2.set(i.last), i.target, i.time);
|
||||
Mathf.lerp2(movement.set(i.last), i.target, i.time);
|
||||
|
||||
x = Tmp.v2.x;
|
||||
y = Tmp.v2.y;
|
||||
x = movement.x;
|
||||
y = movement.y;
|
||||
|
||||
if(i.target.dst(x, y) > 128){
|
||||
set(i.target.x, i.target.y);
|
||||
|
||||
@@ -50,6 +50,7 @@ public abstract class SyncEntity extends DestructibleEntity{
|
||||
public class Interpolator {
|
||||
public Vector2 target = new Vector2();
|
||||
public Vector2 last = new Vector2();
|
||||
public Vector2 vec = new Vector2();
|
||||
public float targetrot;
|
||||
public float spacing = 1f;
|
||||
public float time;
|
||||
|
||||
@@ -4,19 +4,18 @@ import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.ObjectSet;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||
import io.anuke.mindustry.graphics.Fx;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.core.Effects;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.Entity;
|
||||
import io.anuke.ucore.entities.SolidEntity;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
import static io.anuke.mindustry.Vars.enemyGroup;
|
||||
|
||||
public class TeslaOrb extends Entity{
|
||||
private Array<Vector2> points = new Array<>();
|
||||
@@ -25,6 +24,7 @@ public class TeslaOrb extends Entity{
|
||||
private float range = 0;
|
||||
private float lifetime = 30f;
|
||||
private float life = 0f;
|
||||
private Vector2 vector = new Vector2();
|
||||
|
||||
public TeslaOrb(float x, float y, float range, int damage){
|
||||
set(x, y);
|
||||
@@ -83,7 +83,7 @@ public class TeslaOrb extends Entity{
|
||||
|
||||
float range = 1f;
|
||||
|
||||
Vector2 previous = Tmp.v1.set(x, y);
|
||||
Vector2 previous = vector.set(x, y);
|
||||
|
||||
for(Vector2 enemy : points){
|
||||
|
||||
|
||||
@@ -154,10 +154,10 @@ public class Enemy extends SyncEntity {
|
||||
|
||||
i.time += 1f / i.spacing * Timers.delta();
|
||||
|
||||
Mathf.lerp2(Tmp.v2.set(i.last), i.target, i.time);
|
||||
Mathf.lerp2(i.vec.set(i.last), i.target, i.time);
|
||||
|
||||
x = Tmp.v2.x;
|
||||
y = Tmp.v2.y;
|
||||
x = i.vec.x;
|
||||
y = i.vec.y;
|
||||
|
||||
angle = Mathf.lerpAngDelta(angle, i.targetrot, 0.6f);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -60,6 +59,10 @@ public class EnemyType {
|
||||
protected final int timerReload = timeid ++;
|
||||
protected final int timerReset = timeid ++;
|
||||
|
||||
protected final Vector2 shift = new Vector2();
|
||||
protected final Vector2 move = new Vector2();
|
||||
protected final Vector2 calc = new Vector2();
|
||||
|
||||
public EnemyType(String name){
|
||||
this.id = lastid++;
|
||||
this.name = name;
|
||||
@@ -158,14 +161,14 @@ public class EnemyType {
|
||||
Vector2 vec;
|
||||
|
||||
if(nearCore){
|
||||
vec = Tmp.v1.setZero();
|
||||
vec = move.setZero();
|
||||
if(targetCore) enemy.target = core.entity;
|
||||
}else{
|
||||
vec = world.pathfinder().find(enemy);
|
||||
vec.sub(enemy.x, enemy.y).limit(speed);
|
||||
}
|
||||
|
||||
Vector2 shift = Tmp.v3.setZero();
|
||||
shift.setZero();
|
||||
float shiftRange = enemy.hitbox.width + 2f;
|
||||
float avoidRange = shiftRange + 4f;
|
||||
float attractRange = avoidRange + 7f;
|
||||
@@ -180,11 +183,11 @@ public class EnemyType {
|
||||
float scl = Mathf.clamp(1.4f - dst / shiftRange) * mass * 1f/mass;
|
||||
shift.add((enemy.x - other.x) * scl, (enemy.y - other.y) * scl);
|
||||
}else if(dst < avoidRange){
|
||||
Tmp.v2.set((enemy.x - other.x), (enemy.y - other.y)).setLength(avoidSpeed);
|
||||
shift.add(Tmp.v2.scl(1.1f));
|
||||
calc.set((enemy.x - other.x), (enemy.y - other.y)).setLength(avoidSpeed);
|
||||
shift.add(calc.scl(1.1f));
|
||||
}else if(dst < attractRange && !nearCore){
|
||||
Tmp.v2.set((enemy.x - other.x), (enemy.y - other.y)).setLength(avoidSpeed);
|
||||
shift.add(Tmp.v2.scl(-1));
|
||||
calc.set((enemy.x - other.x), (enemy.y - other.y)).setLength(avoidSpeed);
|
||||
shift.add(calc.scl(-1));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
package io.anuke.mindustry.entities.enemies.types;
|
||||
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.entities.Bullet;
|
||||
import io.anuke.mindustry.entities.BulletType;
|
||||
import io.anuke.mindustry.entities.TileEntity;
|
||||
import io.anuke.mindustry.entities.enemies.Enemy;
|
||||
import io.anuke.mindustry.entities.enemies.EnemyType;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
|
||||
@@ -26,15 +24,16 @@ public class BlastType extends EnemyType {
|
||||
public void behavior(Enemy enemy){
|
||||
|
||||
float range = 10f;
|
||||
Vector2 offset = Tmp.v3.setZero();
|
||||
float ox = 0, oy = 0;
|
||||
|
||||
if(enemy.target instanceof TileEntity){
|
||||
TileEntity e = (TileEntity)enemy.target;
|
||||
range = (e.tile.block().width * tilesize) /2f + 8f;
|
||||
offset.set(e.tile.block().getPlaceOffset());
|
||||
ox = e.tile.block().getPlaceOffset().x;
|
||||
oy = e.tile.block().getPlaceOffset().y;
|
||||
}
|
||||
|
||||
if(enemy.target != null && enemy.target.distanceTo(enemy.x - offset.x, enemy.y - offset.y) < range){
|
||||
if(enemy.target != null && enemy.target.distanceTo(enemy.x - ox, enemy.y - oy) < range){
|
||||
explode(enemy);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,19 @@
|
||||
package io.anuke.mindustry.graphics;
|
||||
|
||||
import com.badlogic.gdx.graphics.Color;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.utils.FloatArray;
|
||||
|
||||
import io.anuke.ucore.core.Core;
|
||||
import io.anuke.ucore.core.Settings;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Shader;
|
||||
import io.anuke.ucore.scene.ui.layout.Unit;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
public class Shaders{
|
||||
public static final Outline outline = new Outline();
|
||||
public static final Shield shield = new Shield();
|
||||
|
||||
private static final Vector2 vec = new Vector2();
|
||||
|
||||
public static class Outline extends Shader{
|
||||
public Color color = new Color();
|
||||
@@ -26,7 +27,7 @@ public class Shaders{
|
||||
public void apply(){
|
||||
shader.setUniformf("u_color", color);
|
||||
shader.setUniformf("u_lighten", lighten);
|
||||
shader.setUniformf("u_texsize", Tmp.v1.set(region.getTexture().getWidth(), region.getTexture().getHeight()));
|
||||
shader.setUniformf("u_texsize", vec.set(region.getTexture().getWidth(), region.getTexture().getHeight()));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,8 +53,8 @@ public class Shaders{
|
||||
shader.setUniformf("u_color", color);
|
||||
shader.setUniformf("u_time", Timers.time() / Unit.dp.scl(1f));
|
||||
shader.setUniformf("u_scaling", scaling);
|
||||
shader.setUniformf("u_offset", Tmp.v1.set(Core.camera.position.x, Core.camera.position.y));
|
||||
shader.setUniformf("u_texsize", Tmp.v1.set(region.getTexture().getWidth() / scale,
|
||||
shader.setUniformf("u_offset", vec.set(Core.camera.position.x, Core.camera.position.y));
|
||||
shader.setUniformf("u_texsize", vec.set(region.getTexture().getWidth() / scale,
|
||||
region.getTexture().getHeight() / scale));
|
||||
}
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@ import io.anuke.ucore.core.Sounds;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.SolidEntity;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -36,6 +35,8 @@ public abstract class InputHandler extends InputAdapter{
|
||||
public PlaceMode lastPlaceMode = placeMode;
|
||||
public PlaceMode lastBreakMode = breakMode;
|
||||
|
||||
private Rectangle rect = new Rectangle();
|
||||
|
||||
public abstract void update();
|
||||
public abstract float getCursorX();
|
||||
public abstract float getCursorY();
|
||||
@@ -93,21 +94,21 @@ public abstract class InputHandler extends InputAdapter{
|
||||
}
|
||||
}
|
||||
|
||||
Tmp.r2.setSize(type.width * tilesize, type.height * tilesize);
|
||||
rect.setSize(type.width * tilesize, type.height * tilesize);
|
||||
Vector2 offset = type.getPlaceOffset();
|
||||
Tmp.r2.setCenter(offset.x + x * tilesize, offset.y + y * tilesize);
|
||||
rect.setCenter(offset.x + x * tilesize, offset.y + y * tilesize);
|
||||
|
||||
for(SolidEntity e : Entities.getNearby(enemyGroup, x * tilesize, y * tilesize, tilesize * 2f)){
|
||||
Rectangle rect = e.hitbox.getRect(e.x, e.y);
|
||||
|
||||
if(Tmp.r2.overlaps(rect)){
|
||||
if(this.rect.overlaps(rect)){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if(type.solid || type.solidifes) {
|
||||
for (Player player : playerGroup.all()) {
|
||||
if (!player.isAndroid && Tmp.r2.overlaps(player.hitbox.getRect(player.x, player.y))) {
|
||||
if (!player.isAndroid && rect.overlaps(player.hitbox.getRect(player.x, player.y))) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@ import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.graphics.Lines;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
import io.anuke.ucore.util.Translator;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -44,8 +44,8 @@ public enum PlaceMode{
|
||||
|
||||
if(control.input().recipe.result.rotate){
|
||||
Draw.color(Colors.get("placeRotate"));
|
||||
Tmp.v1.set(7, 0).rotate(control.input().rotation * 90);
|
||||
Lines.line(x, y, x + Tmp.v1.x, y + Tmp.v1.y);
|
||||
tr.trns(control.input().rotation * 90, 7, 0);
|
||||
Lines.line(x, y, x + tr.x, y + tr.y);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,8 +293,8 @@ public enum PlaceMode{
|
||||
if(control.input().recipe.result.rotate){
|
||||
float cx = tx * t, cy = ty * t;
|
||||
Draw.color(Colors.get("placeRotate"));
|
||||
Tmp.v1.set(7, 0).rotate(rotation * 90);
|
||||
Lines.line(cx, cy, cx + Tmp.v1.x, cy + Tmp.v1.y);
|
||||
tr.trns(rotation * 90, 7, 0);
|
||||
Lines.line(cx, cy, cx + tr.x, cy + tr.y);
|
||||
}
|
||||
Draw.reset();
|
||||
}
|
||||
@@ -368,6 +368,8 @@ public enum PlaceMode{
|
||||
public boolean showCancel;
|
||||
public boolean delete = false;
|
||||
public boolean both = false;
|
||||
|
||||
private static final Translator tr = new Translator();
|
||||
|
||||
public void draw(int tilex, int tiley, int endx, int endy){
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.badlogic.gdx.input.GestureDetector;
|
||||
import com.badlogic.gdx.input.GestureDetector.GestureListener;
|
||||
import com.badlogic.gdx.math.Bresenham2;
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import com.badlogic.gdx.scenes.scene2d.utils.ScissorStack;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
@@ -43,6 +44,8 @@ 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 Rectangle rect = new Rectangle();
|
||||
|
||||
private boolean drawing;
|
||||
private int lastx, lasty;
|
||||
@@ -214,7 +217,7 @@ public class MapView extends Element implements GestureListener{
|
||||
float px = ((float)x / editor.texture().getWidth()) * sclwidth + offsetx*zoom - sclwidth/2 + getWidth()/2;
|
||||
float py = (float)((float)(editor.texture().getHeight() - 1 - y) / editor.texture().getHeight()) * sclheight
|
||||
+ offsety*zoom - sclheight/2 + getHeight()/2;
|
||||
return Tmp.v1.set(px, py);
|
||||
return vec.set(px, py);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -229,7 +232,7 @@ public class MapView extends Element implements GestureListener{
|
||||
image.setImageSize(editor.pixmap().getWidth(), editor.pixmap().getHeight());
|
||||
|
||||
batch.flush();
|
||||
boolean pop = ScissorStack.pushScissors(Tmp.r1.set(x + width/2 - size/2, y + height/2 - size/2, size, size));
|
||||
boolean pop = ScissorStack.pushScissors(rect.set(x + width/2 - size/2, y + height/2 - size/2, size, size));
|
||||
|
||||
batch.draw(editor.texture(), centerx - sclwidth/2, centery - sclheight/2, sclwidth, sclheight);
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package io.anuke.mindustry.ui.dialogs;
|
||||
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.game.Difficulty;
|
||||
import io.anuke.mindustry.game.GameMode;
|
||||
import io.anuke.mindustry.world.Map;
|
||||
@@ -16,7 +17,6 @@ import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.scene.utils.Elements;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@@ -133,13 +133,15 @@ public class LevelDialog extends FloatingDialog{
|
||||
});
|
||||
}).width(images+16).padBottom(-10f).grow().get();
|
||||
}
|
||||
|
||||
Vector2 hit = new Vector2();
|
||||
|
||||
image.addListener(new ClickListener(){
|
||||
public void clicked(InputEvent event, float x, float y){
|
||||
image.localToStageCoordinates(Tmp.v1.set(x, y));
|
||||
image.localToStageCoordinates(hit.set(x, y));
|
||||
if(delete[0] != null && (delete[0].getClickListener().isOver() || delete[0].getClickListener().isPressed()
|
||||
|| (Core.scene.hit(Tmp.v1.x, Tmp.v1.y, true) != null &&
|
||||
Core.scene.hit(Tmp.v1.x, Tmp.v1.y, true).isDescendantOf(delete[0])))){
|
||||
|| (Core.scene.hit(hit.x, hit.y, true) != null &&
|
||||
Core.scene.hit(hit.x, hit.y, true).isDescendantOf(delete[0])))){
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package io.anuke.mindustry.ui.fragments;
|
||||
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.files.FileHandle;
|
||||
import io.anuke.mindustry.Vars;
|
||||
import io.anuke.mindustry.entities.Player;
|
||||
import io.anuke.mindustry.net.Net;
|
||||
import io.anuke.ucore.scene.builders.button;
|
||||
@@ -50,7 +49,7 @@ public class DebugFragment implements Fragment {
|
||||
row();
|
||||
new button("infammo", "toggle", () -> infiniteAmmo = !infiniteAmmo);
|
||||
row();
|
||||
new button("wave", () -> logic.runWave());
|
||||
new button("wave", () -> state.wavetime = 0f);
|
||||
row();
|
||||
new button("clear", () -> {
|
||||
enemyGroup.clear();
|
||||
@@ -58,9 +57,7 @@ public class DebugFragment implements Fragment {
|
||||
netClient.clearRecieved();
|
||||
});
|
||||
row();
|
||||
new button("spawn", () -> {try{ Net.connect("localhost", Vars.port); }catch (Exception e){e.printStackTrace();}});
|
||||
row();
|
||||
new button("stuff", () -> netClient.test());
|
||||
new button("spawn", () -> {});
|
||||
row();
|
||||
}}.end();
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ public class HudFragment implements Fragment{
|
||||
|
||||
private void playButton(float uheight){
|
||||
new imagebutton("icon-play", 30f, () -> {
|
||||
logic.runWave();
|
||||
state.wavetime = 0f;
|
||||
}).height(uheight).fillX().right().padTop(-8f).padBottom(-12f).padRight(-36).width(40f).update(l->{
|
||||
boolean vis = state.enemies <= 0 && (Net.server() || !Net.active());
|
||||
boolean paused = state.is(State.paused) || !vis;
|
||||
|
||||
@@ -19,7 +19,6 @@ import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.scene.ui.layout.Table;
|
||||
import io.anuke.ucore.util.Bundles;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
import static io.anuke.mindustry.Vars.state;
|
||||
import static io.anuke.mindustry.Vars.tilesize;
|
||||
@@ -30,6 +29,7 @@ public class Block{
|
||||
private static ObjectMap<String, Block> map = new ObjectMap<>();
|
||||
|
||||
protected static TextureRegion temp = new TextureRegion();
|
||||
protected Vector2 offset = new Vector2();
|
||||
|
||||
/**internal name*/
|
||||
public final String name;
|
||||
@@ -272,7 +272,7 @@ public class Block{
|
||||
|
||||
/**Offset for placing and drawing multiblocks.*/
|
||||
public Vector2 getPlaceOffset(){
|
||||
return Tmp.v3.set(((width + 1) % 2) * tilesize/2, ((height + 1) % 2) * tilesize/2);
|
||||
return offset.set(((width + 1) % 2) * tilesize/2, ((height + 1) % 2) * tilesize/2);
|
||||
}
|
||||
|
||||
public boolean isMultiblock(){
|
||||
|
||||
@@ -11,7 +11,6 @@ import io.anuke.ucore.core.Effects.Effect;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.entities.SolidEntity;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@@ -20,6 +19,8 @@ import java.io.IOException;
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
public class Door extends Wall{
|
||||
protected final Rectangle rect = new Rectangle();
|
||||
|
||||
protected Effect openfx = Fx.dooropen;
|
||||
protected Effect closefx = Fx.doorclose;
|
||||
|
||||
@@ -65,13 +66,13 @@ public class Door extends Wall{
|
||||
boolean anyEntities(Tile tile){
|
||||
int x = tile.x, y = tile.y;
|
||||
Block type = tile.block();
|
||||
Tmp.r2.setSize(type.width * tilesize, type.height * tilesize);
|
||||
Tmp.r2.setCenter(tile.drawx(), tile.drawy());
|
||||
rect.setSize(type.width * tilesize, type.height * tilesize);
|
||||
rect.setCenter(tile.drawx(), tile.drawy());
|
||||
|
||||
for(SolidEntity e : Entities.getNearby(enemyGroup, x * tilesize, y * tilesize, tilesize * 2f)){
|
||||
Rectangle rect = e.hitbox.getRect(e.x, e.y);
|
||||
|
||||
if(Tmp.r2.overlaps(rect)){
|
||||
if(rect.overlaps(rect)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -79,7 +80,7 @@ public class Door extends Wall{
|
||||
for(SolidEntity e : Entities.getNearby(playerGroup, x * tilesize, y * tilesize, tilesize * 2f)){
|
||||
Rectangle rect = e.hitbox.getRect(e.x, e.y);
|
||||
|
||||
if(Tmp.r2.overlaps(rect)){
|
||||
if(rect.overlaps(rect)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,10 +9,7 @@ import io.anuke.mindustry.world.Layer;
|
||||
import io.anuke.mindustry.world.Tile;
|
||||
import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Bits;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
import io.anuke.ucore.util.*;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@@ -31,6 +28,9 @@ public class Conveyor extends Block{
|
||||
private static final float itemSpace = 0.135f;
|
||||
private static final float offsetScl = 128f*3f;
|
||||
private static final float itemSize = 4f;
|
||||
|
||||
private final Translator tr1 = new Translator();
|
||||
private final Translator tr2 = new Translator();
|
||||
|
||||
public float speed = 0.02f;
|
||||
|
||||
@@ -76,13 +76,13 @@ public class Conveyor extends Block{
|
||||
ItemPos pos = drawpos.set(entity.convey.get(i));
|
||||
|
||||
if(pos.item == null) continue;
|
||||
|
||||
Tmp.v1.set(tilesize, 0).rotate(rotation * 90);
|
||||
Tmp.v2.set(-tilesize / 2, pos.x*tilesize/2).rotate(rotation * 90);
|
||||
|
||||
tr1.trns(rotation * 90, tilesize, 0);
|
||||
tr2.trns(rotation * 90, -tilesize / 2, pos.x*tilesize/2);
|
||||
|
||||
Draw.rect(pos.item.region,
|
||||
tile.x * tilesize + Tmp.v1.x * pos.y + Tmp.v2.x,
|
||||
tile.y * tilesize + Tmp.v1.y * pos.y + Tmp.v2.y, itemSize, itemSize);
|
||||
tile.x * tilesize + tr1.x * pos.y + tr2.x,
|
||||
tile.y * tilesize + tr1.y * pos.y + tr2.y, itemSize, itemSize);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@ import io.anuke.ucore.core.Timers;
|
||||
import io.anuke.ucore.graphics.Draw;
|
||||
import io.anuke.ucore.util.Mathf;
|
||||
import io.anuke.ucore.util.Strings;
|
||||
import io.anuke.ucore.util.Tmp;
|
||||
import io.anuke.ucore.util.Translator;
|
||||
|
||||
import java.io.DataInputStream;
|
||||
import java.io.DataOutputStream;
|
||||
@@ -25,6 +25,8 @@ import static io.anuke.mindustry.Vars.tilesize;
|
||||
public class NuclearReactor extends LiquidPowerGenerator{
|
||||
protected final int timerFuel = timers++;
|
||||
|
||||
protected final Translator tr = new Translator();
|
||||
|
||||
protected Item generateItem;
|
||||
protected int itemCapacity = 30;
|
||||
protected Color coolColor = new Color(1, 1, 1, 0f);
|
||||
@@ -137,15 +139,15 @@ public class NuclearReactor extends LiquidPowerGenerator{
|
||||
|
||||
for(int i = 0; i < 20; i ++){
|
||||
Timers.run(Mathf.random(50), ()->{
|
||||
Tmp.v1.setToRandomDirection().setLength(Mathf.random(40f));
|
||||
Effects.effect(Fx.explosion, Tmp.v1.x + tile.worldx(), Tmp.v1.y + tile.worldy());
|
||||
tr.rnd(Mathf.random(40f));
|
||||
Effects.effect(Fx.explosion, tr.x + tile.worldx(), tr.y + tile.worldy());
|
||||
});
|
||||
}
|
||||
|
||||
for(int i = 0; i < 70; i ++){
|
||||
Timers.run(Mathf.random(80), ()->{
|
||||
Tmp.v1.setToRandomDirection().setLength(Mathf.random(120f));
|
||||
Effects.effect(Fx.nuclearsmoke, Tmp.v1.x + tile.worldx(), Tmp.v1.y + tile.worldy());
|
||||
tr.rnd(Mathf.random(120f));
|
||||
Effects.effect(Fx.nuclearsmoke, tr.x + tile.worldx(), tr.y + tile.worldy());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user