Additional fixes
This commit is contained in:
@@ -2,8 +2,14 @@ package io.anuke.mindustry;
|
|||||||
|
|
||||||
import io.anuke.arc.Application.ApplicationType;
|
import io.anuke.arc.Application.ApplicationType;
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
|
import io.anuke.arc.entities.Entities;
|
||||||
|
import io.anuke.arc.entities.EntityGroup;
|
||||||
|
import io.anuke.arc.entities.impl.EffectEntity;
|
||||||
|
import io.anuke.arc.entities.trait.DrawTrait;
|
||||||
import io.anuke.arc.files.FileHandle;
|
import io.anuke.arc.files.FileHandle;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
|
import io.anuke.arc.scene.ui.layout.Unit;
|
||||||
import io.anuke.mindustry.core.*;
|
import io.anuke.mindustry.core.*;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
@@ -17,13 +23,6 @@ import io.anuke.mindustry.game.Version;
|
|||||||
import io.anuke.mindustry.gen.Serialization;
|
import io.anuke.mindustry.gen.Serialization;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.world.blocks.defense.ForceProjector.ShieldEntity;
|
import io.anuke.mindustry.world.blocks.defense.ForceProjector.ShieldEntity;
|
||||||
import io.anuke.arc.Settings;
|
|
||||||
import io.anuke.arc.entities.Entities;
|
|
||||||
import io.anuke.arc.entities.EntityGroup;
|
|
||||||
import io.anuke.arc.entities.impl.EffectEntity;
|
|
||||||
import io.anuke.arc.entities.trait.DrawTrait;
|
|
||||||
import io.anuke.arc.scene.ui.layout.Unit;
|
|
||||||
import io.anuke.arc.util.Vector2;
|
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
@@ -100,7 +99,6 @@ public class Vars{
|
|||||||
|
|
||||||
public static ContentLoader content;
|
public static ContentLoader content;
|
||||||
public static GameState state;
|
public static GameState state;
|
||||||
public static ThreadHandler threads;
|
|
||||||
|
|
||||||
public static Control control;
|
public static Control control;
|
||||||
public static Logic logic;
|
public static Logic logic;
|
||||||
@@ -167,13 +165,14 @@ public class Vars{
|
|||||||
}
|
}
|
||||||
|
|
||||||
state = new GameState();
|
state = new GameState();
|
||||||
threads = new ThreadHandler();
|
|
||||||
|
|
||||||
mobile = Core.app.getType() == ApplicationType.Android || Core.app.getType() == ApplicationType.iOS || testMobile;
|
mobile = Core.app.getType() == ApplicationType.Android || Core.app.getType() == ApplicationType.iOS || testMobile;
|
||||||
ios = Core.app.getType() == ApplicationType.iOS;
|
ios = Core.app.getType() == ApplicationType.iOS;
|
||||||
android = Core.app.getType() == ApplicationType.Android;
|
android = Core.app.getType() == ApplicationType.Android;
|
||||||
|
|
||||||
dataDirectory = Core.settings.getDataDirectory(appName);
|
Core.settings.setAppName(appName);
|
||||||
|
|
||||||
|
dataDirectory = Core.settings.getDataDirectory();
|
||||||
screenshotDirectory = dataDirectory.child("screenshots/");
|
screenshotDirectory = dataDirectory.child("screenshots/");
|
||||||
customMapDirectory = dataDirectory.child("maps/");
|
customMapDirectory = dataDirectory.child("maps/");
|
||||||
saveDirectory = dataDirectory.child("saves/");
|
saveDirectory = dataDirectory.child("saves/");
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ import io.anuke.arc.collection.*;
|
|||||||
import io.anuke.arc.function.Predicate;
|
import io.anuke.arc.function.Predicate;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.Geometry;
|
import io.anuke.arc.math.geom.Geometry;
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
|
||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.game.EventType.TileChangeEvent;
|
import io.anuke.mindustry.game.EventType.TileChangeEvent;
|
||||||
@@ -174,7 +173,7 @@ public class BlockIndexer{
|
|||||||
|
|
||||||
TileEntity e = other.entity;
|
TileEntity e = other.entity;
|
||||||
|
|
||||||
float ndst = Vector2.dst(x, y, e.x, e.y);
|
float ndst = Mathf.dst(x, y, e.x, e.y);
|
||||||
if(ndst < range && (closest == null || ndst < dst)){
|
if(ndst < range && (closest == null || ndst < dst)){
|
||||||
dst = ndst;
|
dst = ndst;
|
||||||
closest = e;
|
closest = e;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import io.anuke.arc.Events;
|
|||||||
import io.anuke.arc.collection.IntArray;
|
import io.anuke.arc.collection.IntArray;
|
||||||
import io.anuke.arc.collection.Queue;
|
import io.anuke.arc.collection.Queue;
|
||||||
import io.anuke.arc.math.geom.Geometry;
|
import io.anuke.arc.math.geom.Geometry;
|
||||||
import io.anuke.arc.math.geom.GridPoint2;
|
import io.anuke.arc.math.geom.Point2;
|
||||||
import io.anuke.arc.util.Structs;
|
import io.anuke.arc.util.Structs;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.mindustry.game.EventType.TileChangeEvent;
|
import io.anuke.mindustry.game.EventType.TileChangeEvent;
|
||||||
@@ -62,7 +62,7 @@ public class Pathfinder{
|
|||||||
|
|
||||||
Tile target = null;
|
Tile target = null;
|
||||||
float tl = 0f;
|
float tl = 0f;
|
||||||
for(GridPoint2 point : Geometry.d8){
|
for(Point2 point : Geometry.d8){
|
||||||
int dx = tile.x + point.x, dy = tile.y + point.y;
|
int dx = tile.x + point.x, dy = tile.y + point.y;
|
||||||
|
|
||||||
Tile other = world.tile(dx, dy);
|
Tile other = world.tile(dx, dy);
|
||||||
@@ -150,7 +150,7 @@ public class Pathfinder{
|
|||||||
float cost = path.weights[tile.x][tile.y];
|
float cost = path.weights[tile.x][tile.y];
|
||||||
|
|
||||||
if(cost < Float.MAX_VALUE){
|
if(cost < Float.MAX_VALUE){
|
||||||
for(GridPoint2 point : Geometry.d4){
|
for(Point2 point : Geometry.d4){
|
||||||
|
|
||||||
int dx = tile.x + point.x, dy = tile.y + point.y;
|
int dx = tile.x + point.x, dy = tile.y + point.y;
|
||||||
Tile other = world.tile(dx, dy);
|
Tile other = world.tile(dx, dy);
|
||||||
|
|||||||
@@ -359,7 +359,7 @@ public class NetServer implements ApplicationListener{
|
|||||||
player.y = prevy;
|
player.y = prevy;
|
||||||
newx = x;
|
newx = x;
|
||||||
newy = y;
|
newy = y;
|
||||||
}else if(Vector2.dst(x, y, newx, newy) > correctDist){
|
}else if(Mathf.dst(x, y, newx, newy) > correctDist){
|
||||||
Call.onPositionSet(player.con.id, newx, newy); //teleport and correct position when necessary
|
Call.onPositionSet(player.con.id, newx, newy); //teleport and correct position when necessary
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.core;
|
package io.anuke.mindustry.core;
|
||||||
|
|
||||||
|
import io.anuke.arc.ApplicationListener;
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.Graphics;
|
import io.anuke.arc.Graphics;
|
||||||
import io.anuke.arc.entities.Effects;
|
import io.anuke.arc.entities.Effects;
|
||||||
@@ -16,11 +17,9 @@ import io.anuke.arc.graphics.Pixmap;
|
|||||||
import io.anuke.arc.graphics.PixmapIO;
|
import io.anuke.arc.graphics.PixmapIO;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.Lines;
|
import io.anuke.arc.graphics.g2d.Lines;
|
||||||
import io.anuke.arc.graphics.g2d.SpriteBatch;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.Rectangle;
|
import io.anuke.arc.math.geom.Rectangle;
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.arc.scene.utils.Cursors;
|
|
||||||
import io.anuke.arc.util.BufferUtils;
|
import io.anuke.arc.util.BufferUtils;
|
||||||
import io.anuke.arc.util.ScreenUtils;
|
import io.anuke.arc.util.ScreenUtils;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
@@ -37,31 +36,30 @@ import io.anuke.mindustry.entities.units.BaseUnit;
|
|||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.graphics.*;
|
import io.anuke.mindustry.graphics.*;
|
||||||
import io.anuke.mindustry.world.blocks.defense.ForceProjector.ShieldEntity;
|
import io.anuke.mindustry.world.blocks.defense.ForceProjector.ShieldEntity;
|
||||||
|
|
||||||
|
import static io.anuke.arc.Core.*;
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
public class Renderer extends RendererModule{
|
public class Renderer implements ApplicationListener{
|
||||||
public final Surface effectSurface;
|
|
||||||
public final BlockRenderer blocks = new BlockRenderer();
|
public final BlockRenderer blocks = new BlockRenderer();
|
||||||
public final MinimapRenderer minimap = new MinimapRenderer();
|
public final MinimapRenderer minimap = new MinimapRenderer();
|
||||||
public final OverlayRenderer overlays = new OverlayRenderer();
|
public final OverlayRenderer overlays = new OverlayRenderer();
|
||||||
public final FogRenderer fog = new FogRenderer();
|
public final FogRenderer fog = new FogRenderer();
|
||||||
|
|
||||||
|
private Color clearColor;
|
||||||
private int targetscale = baseCameraScale;
|
private int targetscale = baseCameraScale;
|
||||||
private Rectangle rect = new Rectangle(), rect2 = new Rectangle();
|
private Rectangle rect = new Rectangle(), rect2 = new Rectangle();
|
||||||
private Vector2 avgPosition = new Vector2();
|
private Vector2 avgPosition = new Vector2();
|
||||||
|
|
||||||
public Renderer(){
|
public Renderer(){
|
||||||
Core.batch = new SpriteBatch(4096);
|
|
||||||
|
|
||||||
Lines.setCircleVertices(14);
|
Lines.setCircleVertices(14);
|
||||||
|
|
||||||
Shaders.init();
|
Shaders.init();
|
||||||
|
|
||||||
Core.cameraScale = baseCameraScale;
|
|
||||||
Effects.setEffectProvider((effect, color, x, y, rotation, data) -> {
|
Effects.setEffectProvider((effect, color, x, y, rotation, data) -> {
|
||||||
if(effect == Fx.none) return;
|
if(effect == Fx.none) return;
|
||||||
if(Core.settings.getBool("effects")){
|
if(Core.settings.getBool("effects")){
|
||||||
Rectangle view = rect.setSize(camera.viewportWidth, camera.viewportHeight)
|
Rectangle view = rect.setSize(camera.width, camera.height)
|
||||||
.setCenter(camera.position.x, camera.position.y);
|
.setCenter(camera.position.x, camera.position.y);
|
||||||
Rectangle pos = rect2.setSize(effect.size).setCenter(x, y);
|
Rectangle pos = rect2.setSize(effect.size).setCenter(x, y);
|
||||||
|
|
||||||
@@ -78,7 +76,7 @@ public class Renderer extends RendererModule{
|
|||||||
if(data instanceof Entity){
|
if(data instanceof Entity){
|
||||||
entity.setParent((Entity) data);
|
entity.setParent((Entity) data);
|
||||||
}
|
}
|
||||||
threads.runGraphics(() -> effectGroup.add(entity));
|
effectGroup.add(entity);
|
||||||
}else{
|
}else{
|
||||||
GroundEffectEntity entity = Pools.obtain(GroundEffectEntity.class, GroundEffectEntity::new);
|
GroundEffectEntity entity = Pools.obtain(GroundEffectEntity.class, GroundEffectEntity::new);
|
||||||
entity.effect = effect;
|
entity.effect = effect;
|
||||||
@@ -90,30 +88,13 @@ public class Renderer extends RendererModule{
|
|||||||
if(data instanceof Entity){
|
if(data instanceof Entity){
|
||||||
entity.setParent((Entity) data);
|
entity.setParent((Entity) data);
|
||||||
}
|
}
|
||||||
threads.runGraphics(() -> groundEffectGroup.add(entity));
|
groundEffectGroup.add(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Cursors.cursorScaling = 3;
|
|
||||||
Cursors.outlineColor = Color.valueOf("444444");
|
|
||||||
|
|
||||||
Cursors.arrow = Cursors.loadCursor("cursor");
|
|
||||||
Cursors.hand = Cursors.loadCursor("hand");
|
|
||||||
Cursors.ibeam = Cursors.loadCursor("ibar");
|
|
||||||
Cursors.restoreCursor();
|
|
||||||
Cursors.loadCustom("drill");
|
|
||||||
Cursors.loadCustom("unload");
|
|
||||||
|
|
||||||
clearColor = new Color(0f, 0f, 0f, 1f);
|
clearColor = new Color(0f, 0f, 0f, 1f);
|
||||||
|
|
||||||
effectSurface = Graphics.createSurface(Core.cameraScale);
|
|
||||||
pixelSurface = Graphics.createSurface(Core.cameraScale);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void init(){
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -185,9 +166,9 @@ public class Renderer extends RendererModule{
|
|||||||
@Override
|
@Override
|
||||||
public void draw(){
|
public void draw(){
|
||||||
camera.update();
|
camera.update();
|
||||||
if(Float.isNaN(Core.camera.position.x) || Float.isNaN(Core.camera.position.y)){
|
if(Float.isNaN(camera.position.x) || Float.isNaN(camera.position.y)){
|
||||||
Core.camera.position.x = players[0].x;
|
camera.position.x = players[0].x;
|
||||||
Core.camera.position.y = players[0].y;
|
camera.position.y = players[0].y;
|
||||||
}
|
}
|
||||||
|
|
||||||
Graphics.clear(clearColor);
|
Graphics.clear(clearColor);
|
||||||
@@ -377,24 +358,24 @@ public class Renderer extends RendererModule{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void takeMapScreenshot(){
|
public void takeMapScreenshot(){
|
||||||
float vpW = Core.camera.viewportWidth, vpH = Core.camera.viewportHeight;
|
float vpW = camera.width, vpH = camera.height;
|
||||||
int w = world.width()*tilesize, h = world.height()*tilesize;
|
int w = world.width()*tilesize, h = world.height()*tilesize;
|
||||||
int pw = pixelSurface.width(), ph = pixelSurface.height();
|
int pw = pixelSurface.width(), ph = pixelSurface.height();
|
||||||
showFog = false;
|
showFog = false;
|
||||||
disableUI = true;
|
disableUI = true;
|
||||||
pixelSurface.setSize(w, h, true);
|
pixelSurface.setSize(w, h, true);
|
||||||
Graphics.getEffectSurface().setSize(w, h, true);
|
Graphics.getEffectSurface().setSize(w, h, true);
|
||||||
Core.camera.viewportWidth = w;
|
camera.width = w;
|
||||||
Core.camera.viewportHeight = h;
|
camera.height = h;
|
||||||
Core.camera.position.x = w/2f + tilesize/2f;
|
camera.position.x = w/2f + tilesize/2f;
|
||||||
Core.camera.position.y = h/2f + tilesize/2f;
|
camera.position.y = h/2f + tilesize/2f;
|
||||||
|
|
||||||
draw();
|
draw();
|
||||||
|
|
||||||
showFog = true;
|
showFog = true;
|
||||||
disableUI = false;
|
disableUI = false;
|
||||||
Core.camera.viewportWidth = vpW;
|
camera.width = vpW;
|
||||||
Core.camera.viewportHeight = vpH;
|
camera.height = vpH;
|
||||||
|
|
||||||
pixelSurface.getBuffer().begin();
|
pixelSurface.getBuffer().begin();
|
||||||
byte[] lines = ScreenUtils.getFrameBufferPixels(0, 0, w, h, true);
|
byte[] lines = ScreenUtils.getFrameBufferPixels(0, 0, w, h, true);
|
||||||
|
|||||||
@@ -3,15 +3,16 @@ package io.anuke.mindustry.core;
|
|||||||
import io.anuke.arc.ApplicationListener;
|
import io.anuke.arc.ApplicationListener;
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.Events;
|
import io.anuke.arc.Events;
|
||||||
import io.anuke.arc.Graphics;
|
import io.anuke.arc.Graphics.Cursor;
|
||||||
|
import io.anuke.arc.Graphics.Cursor.SystemCursor;
|
||||||
import io.anuke.arc.function.Consumer;
|
import io.anuke.arc.function.Consumer;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.graphics.Colors;
|
import io.anuke.arc.graphics.Colors;
|
||||||
import io.anuke.arc.graphics.g2d.BitmapFont;
|
import io.anuke.arc.graphics.g2d.BitmapFont;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
|
||||||
import io.anuke.arc.input.KeyCode;
|
import io.anuke.arc.input.KeyCode;
|
||||||
import io.anuke.arc.math.Interpolation;
|
import io.anuke.arc.math.Interpolation;
|
||||||
import io.anuke.arc.scene.Group;
|
import io.anuke.arc.scene.Group;
|
||||||
|
import io.anuke.arc.scene.Scene;
|
||||||
import io.anuke.arc.scene.Skin;
|
import io.anuke.arc.scene.Skin;
|
||||||
import io.anuke.arc.scene.actions.Actions;
|
import io.anuke.arc.scene.actions.Actions;
|
||||||
import io.anuke.arc.scene.ui.Dialog;
|
import io.anuke.arc.scene.ui.Dialog;
|
||||||
@@ -27,7 +28,6 @@ import io.anuke.arc.freetype.*;
|
|||||||
import io.anuke.mindustry.editor.MapEditorDialog;
|
import io.anuke.mindustry.editor.MapEditorDialog;
|
||||||
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
import io.anuke.mindustry.game.EventType.ResizeEvent;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.input.InputHandler;
|
|
||||||
import io.anuke.mindustry.ui.dialogs.*;
|
import io.anuke.mindustry.ui.dialogs.*;
|
||||||
import io.anuke.mindustry.ui.fragments.*;
|
import io.anuke.mindustry.ui.fragments.*;
|
||||||
|
|
||||||
@@ -67,7 +67,19 @@ public class UI implements ApplicationListener{
|
|||||||
public SectorsDialog sectors;
|
public SectorsDialog sectors;
|
||||||
public MissionDialog missions;
|
public MissionDialog missions;
|
||||||
|
|
||||||
|
public Cursor drillCursor, unloadCursor;
|
||||||
|
|
||||||
public UI(){
|
public UI(){
|
||||||
|
Skin skin = new Skin(Core.atlas);
|
||||||
|
generateFonts();
|
||||||
|
skin.load(Core.files.internal("ui/uiskin.json"));
|
||||||
|
|
||||||
|
for(BitmapFont font : skin.getAll(BitmapFont.class).values()){
|
||||||
|
font.setUseIntegerPositions(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Core.scene = new Scene(skin);
|
||||||
|
|
||||||
Dialog.setShowAction(() -> sequence(
|
Dialog.setShowAction(() -> sequence(
|
||||||
alpha(0f),
|
alpha(0f),
|
||||||
originCenter(),
|
originCenter(),
|
||||||
@@ -88,12 +100,24 @@ public class UI implements ApplicationListener{
|
|||||||
|
|
||||||
TooltipManager.getInstance().animations = false;
|
TooltipManager.getInstance().animations = false;
|
||||||
|
|
||||||
Core.settings.setErrorHandler(() -> Time.run(1f, () -> showError("[crimson]Failed to access local storage.\nSettings will not be saved.")));
|
Core.settings.setErrorHandler(e -> Time.run(1f, () -> showError("Failed to access local storage.\nSettings will not be saved.")));
|
||||||
|
|
||||||
Dialog.closePadR = -1;
|
|
||||||
Dialog.closePadT = 5;
|
|
||||||
|
|
||||||
Colors.put("accent", Palette.accent);
|
Colors.put("accent", Palette.accent);
|
||||||
|
|
||||||
|
loadCursors();
|
||||||
|
}
|
||||||
|
|
||||||
|
void loadCursors(){
|
||||||
|
int cursorScaling = 3;
|
||||||
|
Color outlineColor = Color.valueOf("444444");
|
||||||
|
|
||||||
|
drillCursor = Core.graphics.newCursor("drill", cursorScaling, outlineColor);
|
||||||
|
unloadCursor = Core.graphics.newCursor("unload", cursorScaling, outlineColor);
|
||||||
|
SystemCursor.arrow.set(Core.graphics.newCursor("cursor", cursorScaling, outlineColor));
|
||||||
|
SystemCursor.hand.set(Core.graphics.newCursor("hand", cursorScaling, outlineColor));
|
||||||
|
SystemCursor.ibeam.set(Core.graphics.newCursor("ibeam", cursorScaling, outlineColor));
|
||||||
|
|
||||||
|
Core.graphics.restoreCursor();
|
||||||
}
|
}
|
||||||
|
|
||||||
void generateFonts(){
|
void generateFonts(){
|
||||||
@@ -110,42 +134,13 @@ public class UI implements ApplicationListener{
|
|||||||
skin.getFont("default-font").setOwnsTexture(false);
|
skin.getFont("default-font").setOwnsTexture(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loadSkin(){
|
|
||||||
skin = new Skin(Core.atlas);
|
|
||||||
generateFonts();
|
|
||||||
skin.load(Core.files.internal("ui/uiskin.json"));
|
|
||||||
|
|
||||||
for(BitmapFont font : skin.getAll(BitmapFont.class).values()){
|
|
||||||
font.setUseIntegerPositions(true);
|
|
||||||
//font.getData().setScale(Vars.fontScale);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(){
|
public void update(){
|
||||||
if(disableUI) return;
|
if(disableUI) return;
|
||||||
|
|
||||||
if(Graphics.drawing()) Graphics.end();
|
Core.scene.act();
|
||||||
|
Core.scene.draw();
|
||||||
act();
|
Core.graphics.batch().flush();
|
||||||
|
|
||||||
Graphics.begin();
|
|
||||||
|
|
||||||
for(int i = 0; i < players.length; i++){
|
|
||||||
InputHandler input = control.input(i);
|
|
||||||
|
|
||||||
if(input.isCursorVisible()){
|
|
||||||
Draw.color();
|
|
||||||
|
|
||||||
float scl = Unit.dp.scl(3f);
|
|
||||||
|
|
||||||
Draw.rect("controller-cursor", input.getMouseX(), Core.graphics.getHeight() - input.getMouseY(), 16 * scl, 16 * scl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Graphics.end();
|
|
||||||
Draw.color();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -186,14 +181,12 @@ public class UI implements ApplicationListener{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void resize(int width, int height){
|
public void resize(int width, int height){
|
||||||
super.resize(width, height);
|
Core.scene.resize(width, height);
|
||||||
|
|
||||||
Events.fire(new ResizeEvent());
|
Events.fire(new ResizeEvent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void dispose(){
|
public void dispose(){
|
||||||
super.dispose();
|
|
||||||
generator.dispose();
|
generator.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import io.anuke.arc.collection.Array;
|
|||||||
import io.anuke.arc.collection.ObjectMap;
|
import io.anuke.arc.collection.ObjectMap;
|
||||||
import io.anuke.arc.entities.EntityQuery;
|
import io.anuke.arc.entities.EntityQuery;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.GridPoint2;
|
import io.anuke.arc.math.geom.Point2;
|
||||||
import io.anuke.arc.util.Log;
|
import io.anuke.arc.util.Log;
|
||||||
import io.anuke.arc.util.Structs;
|
import io.anuke.arc.util.Structs;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
@@ -338,7 +338,7 @@ public class World implements ApplicationListener{
|
|||||||
/**
|
/**
|
||||||
* Raycast, but with world coordinates.
|
* Raycast, but with world coordinates.
|
||||||
*/
|
*/
|
||||||
public GridPoint2 raycastWorld(float x, float y, float x2, float y2){
|
public Point2 raycastWorld(float x, float y, float x2, float y2){
|
||||||
return raycast(Math.round(x / tilesize), Math.round(y / tilesize),
|
return raycast(Math.round(x / tilesize), Math.round(y / tilesize),
|
||||||
Math.round(x2 / tilesize), Math.round(y2 / tilesize));
|
Math.round(x2 / tilesize), Math.round(y2 / tilesize));
|
||||||
}
|
}
|
||||||
@@ -348,7 +348,7 @@ public class World implements ApplicationListener{
|
|||||||
*
|
*
|
||||||
* @return null if no collisions found, block position otherwise.
|
* @return null if no collisions found, block position otherwise.
|
||||||
*/
|
*/
|
||||||
public GridPoint2 raycast(int x0f, int y0f, int x1, int y1){
|
public Point2 raycast(int x0f, int y0f, int x1, int y1){
|
||||||
int x0 = x0f;
|
int x0 = x0f;
|
||||||
int y0 = y0f;
|
int y0 = y0f;
|
||||||
int dx = Math.abs(x1 - x0);
|
int dx = Math.abs(x1 - x0);
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class MapView extends Element implements GestureListener{
|
|||||||
|
|
||||||
for(int i = 0; i < MapEditor.brushSizes.length; i++){
|
for(int i = 0; i < MapEditor.brushSizes.length; i++){
|
||||||
float size = MapEditor.brushSizes[i];
|
float size = MapEditor.brushSizes[i];
|
||||||
brushPolygons[i] = Geometry.pixelCircle(size, (index, x, y) -> Vector2.dst(x, y, index, index) <= index - 0.5f);
|
brushPolygons[i] = Geometry.pixelCircle(size, (index, x, y) -> Mathf.dst(x, y, index, index) <= index - 0.5f);
|
||||||
}
|
}
|
||||||
|
|
||||||
Core.input.addProcessor(0, new GestureDetector(20, 0.5f, 2, 0.15f, this));
|
Core.input.addProcessor(0, new GestureDetector(20, 0.5f, 2, 0.15f, this));
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ public class Damage{
|
|||||||
for(int dx = -trad; dx <= trad; dx++){
|
for(int dx = -trad; dx <= trad; dx++){
|
||||||
for(int dy = -trad; dy <= trad; dy++){
|
for(int dy = -trad; dy <= trad; dy++){
|
||||||
Tile tile = world.tile(Math.round(x / tilesize) + dx, Math.round(y / tilesize) + dy);
|
Tile tile = world.tile(Math.round(x / tilesize) + dx, Math.round(y / tilesize) + dy);
|
||||||
if(tile != null && tile.entity != null && (team == null || state.teams.areEnemies(team, tile.getTeam())) && Vector2.dst(dx, dy, 0, 0) <= trad){
|
if(tile != null && tile.entity != null && (team == null || state.teams.areEnemies(team, tile.getTeam())) && Mathf.dst(dx, dy, 0, 0) <= trad){
|
||||||
float amount = calculateDamage(x, y, tile.worldx(), tile.worldy(), radius, damage);
|
float amount = calculateDamage(x, y, tile.worldx(), tile.worldy(), radius, damage);
|
||||||
tile.entity.damage(amount);
|
tile.entity.damage(amount);
|
||||||
}
|
}
|
||||||
@@ -189,7 +189,7 @@ public class Damage{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static float calculateDamage(float x, float y, float tx, float ty, float radius, float damage){
|
private static float calculateDamage(float x, float y, float tx, float ty, float radius, float damage){
|
||||||
float dist = Vector2.dst(x, y, tx, ty);
|
float dist = Mathf.dst(x, y, tx, ty);
|
||||||
float falloff = 0.4f;
|
float falloff = 0.4f;
|
||||||
float scaled = Mathf.lerp(1f - dist / radius, 1f, falloff);
|
float scaled = Mathf.lerp(1f - dist / radius, 1f, falloff);
|
||||||
return damage * scaled;
|
return damage * scaled;
|
||||||
|
|||||||
@@ -3,24 +3,20 @@ package io.anuke.mindustry.entities;
|
|||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.Graphics;
|
import io.anuke.arc.collection.Bits;
|
||||||
import io.anuke.arc.collection.Queue;
|
import io.anuke.arc.collection.Queue;
|
||||||
import io.anuke.arc.entities.Effects;
|
import io.anuke.arc.entities.Effects;
|
||||||
import io.anuke.arc.entities.EntityGroup;
|
import io.anuke.arc.entities.EntityGroup;
|
||||||
import io.anuke.arc.entities.EntityQuery;
|
import io.anuke.arc.entities.EntityQuery;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.*;
|
||||||
import io.anuke.arc.graphics.g2d.GlyphLayout;
|
import io.anuke.arc.math.Angles;
|
||||||
import io.anuke.arc.graphics.g2d.Lines;
|
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.Geometry;
|
import io.anuke.arc.math.geom.Geometry;
|
||||||
import io.anuke.arc.math.geom.Rectangle;
|
import io.anuke.arc.math.geom.Rectangle;
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.arc.util.Bits;
|
import io.anuke.arc.util.*;
|
||||||
import io.anuke.arc.util.Interval;
|
import io.anuke.arc.util.pooling.Pools;
|
||||||
import io.anuke.arc.util.Time;
|
|
||||||
import io.anuke.arc.util.Timer;
|
|
||||||
import io.anuke.mindustry.content.Mechs;
|
import io.anuke.mindustry.content.Mechs;
|
||||||
import io.anuke.mindustry.content.fx.UnitFx;
|
import io.anuke.mindustry.content.fx.UnitFx;
|
||||||
import io.anuke.mindustry.entities.effect.ScorchDecal;
|
import io.anuke.mindustry.entities.effect.ScorchDecal;
|
||||||
@@ -292,7 +288,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
float x = snappedX(), y = snappedY();
|
float x = snappedX(), y = snappedY();
|
||||||
float scl = mech.flying ? 1f : boostHeat / 2f;
|
float scl = mech.flying ? 1f : boostHeat / 2f;
|
||||||
|
|
||||||
Draw.rect(mech.iconRegion, x + offsetX * scl, y + offsetY * scl, rotation - 90);
|
Draw.rect(mech.iconRegion, x + offsetX * scl, y + offsetY * scl).rot(rotation - 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -326,10 +322,10 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
Draw.rect(mech.legRegion,
|
Draw.rect(mech.legRegion,
|
||||||
x + Angles.trnsx(baseRotation, ft * i + boostTrnsY, -boostTrnsX * i),
|
x + Angles.trnsx(baseRotation, ft * i + boostTrnsY, -boostTrnsX * i),
|
||||||
y + Angles.trnsy(baseRotation, ft * i + boostTrnsY, -boostTrnsX * i),
|
y + Angles.trnsy(baseRotation, ft * i + boostTrnsY, -boostTrnsX * i),
|
||||||
mech.legRegion.getWidth() * i, mech.legRegion.getHeight() - Mathf.clamp(ft * i, 0, 2), baseRotation - 90 + boostAng * i);
|
mech.legRegion.getWidth() * i, mech.legRegion.getHeight() - Mathf.clamp(ft * i, 0, 2)).rot(baseRotation - 90 + boostAng * i);
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.rect(mech.baseRegion, x, y, baseRotation - 90);
|
Draw.rect(mech.baseRegion, x, y).rot(baseRotation - 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(floor.isLiquid){
|
if(floor.isLiquid){
|
||||||
@@ -338,7 +334,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
Draw.tint(Color.WHITE);
|
Draw.tint(Color.WHITE);
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.rect(mech.region, x, y, rotation - 90);
|
Draw.rect(mech.region, x, y).rot(rotation - 90);
|
||||||
|
|
||||||
mech.draw(this);
|
mech.draw(this);
|
||||||
|
|
||||||
@@ -347,7 +343,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
float w = i > 0 ? -mech.weapon.equipRegion.getWidth() : mech.weapon.equipRegion.getWidth();
|
float w = i > 0 ? -mech.weapon.equipRegion.getWidth() : mech.weapon.equipRegion.getWidth();
|
||||||
Draw.rect(mech.weapon.equipRegion,
|
Draw.rect(mech.weapon.equipRegion,
|
||||||
x + Angles.trnsx(tra, (mech.weaponOffsetX + mech.spreadX(this)) * i, trY),
|
x + Angles.trnsx(tra, (mech.weaponOffsetX + mech.spreadX(this)) * i, trY),
|
||||||
y + Angles.trnsy(tra, (mech.weaponOffsetX + mech.spreadX(this)) * i, trY), w, mech.weapon.equipRegion.getHeight(), rotation - 90);
|
y + Angles.trnsy(tra, (mech.weaponOffsetX + mech.spreadX(this)) * i, trY), w, mech.weapon.equipRegion.getHeight()).rot(rotation - 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
float backTrns = 4f, itemSize = 5f;
|
float backTrns = 4f, itemSize = 5f;
|
||||||
@@ -361,7 +357,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
Draw.rect(stack.item.region,
|
Draw.rect(stack.item.region,
|
||||||
x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT),
|
x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT),
|
||||||
y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT),
|
y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT),
|
||||||
itemSize, itemSize, rotation);
|
itemSize, itemSize).rot(rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -374,7 +370,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
|
|
||||||
Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Time.time(), healthf() * 5f, 1f - healthf()));
|
Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Time.time(), healthf() * 5f, 1f - healthf()));
|
||||||
Draw.alpha(hitTime / hitDuration);
|
Draw.alpha(hitTime / hitDuration);
|
||||||
Draw.rect(getPowerCellRegion(), x + Angles.trnsx(rotation, mech.cellTrnsY, 0f), y + Angles.trnsy(rotation, mech.cellTrnsY, 0f), rotation - 90);
|
Draw.rect(getPowerCellRegion(), x + Angles.trnsx(rotation, mech.cellTrnsY, 0f), y + Angles.trnsy(rotation, mech.cellTrnsY, 0f)).rot(rotation - 90);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -388,7 +384,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
float wobblyness = 0.6f;
|
float wobblyness = 0.6f;
|
||||||
if(!state.isPaused()) trail.update(x + Angles.trnsx(rotation + 180f, 5f) + Mathf.range(wobblyness),
|
if(!state.isPaused()) trail.update(x + Angles.trnsx(rotation + 180f, 5f) + Mathf.range(wobblyness),
|
||||||
y + Angles.trnsy(rotation + 180f, 5f) + Mathf.range(wobblyness));
|
y + Angles.trnsy(rotation + 180f, 5f) + Mathf.range(wobblyness));
|
||||||
trail.draw(Hue.mix(mech.trailColor, mech.trailColorTo, mech.flying ? 0f : boostHeat, Tmp.c1), 5f * (isFlying() ? 1f : boostHeat));
|
trail.draw(Tmp.c1.set(mech.trailColor).lerp(mech.trailColorTo, mech.flying ? 0f : boostHeat), 5f * (isFlying() ? 1f : boostHeat));
|
||||||
}else{
|
}else{
|
||||||
trail.clear();
|
trail.clear();
|
||||||
}
|
}
|
||||||
@@ -403,17 +399,17 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void drawName(){
|
public void drawName(){
|
||||||
|
BitmapFont font = Core.scene.skin.getFont("default-font");
|
||||||
GlyphLayout layout = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
|
GlyphLayout layout = Pools.obtain(GlyphLayout.class, GlyphLayout::new);
|
||||||
|
|
||||||
boolean ints = Core.font.usesIntegerPositions();
|
boolean ints = font.usesIntegerPositions();
|
||||||
Core.font.setUseIntegerPositions(false);
|
font.setUseIntegerPositions(false);
|
||||||
Draw.tscl(0.25f / io.anuke.arc.scene.ui.layout.Unit.dp.scl(1f));
|
font.getData().setScale(0.25f / io.anuke.arc.scene.ui.layout.Unit.dp.scl(1f));
|
||||||
layout.setText(Core.font, name);
|
layout.setText(font, name);
|
||||||
Draw.color(0f, 0f, 0f, 0.3f);
|
Fill.rect().center(x, y + 8 - layout.height / 2, layout.width + 2, layout.height + 3).color(0f, 0f, 0f, 0.3f);
|
||||||
Draw.rect("blank", x, y + 8 - layout.height / 2, layout.width + 2, layout.height + 3);
|
font.setColor(color);
|
||||||
Draw.color();
|
|
||||||
Draw.tcolor(color);
|
font.draw(name, x, y + 8, 0, Align.center, false);
|
||||||
Draw.text(name, x, y + 8);
|
|
||||||
|
|
||||||
if(isAdmin){
|
if(isAdmin){
|
||||||
float s = 3f;
|
float s = 3f;
|
||||||
@@ -425,8 +421,8 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
|
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
Pools.free(layout);
|
Pools.free(layout);
|
||||||
Draw.tscl(1f);
|
font.getData().setScale(1f);
|
||||||
Core.font.setUseIntegerPositions(ints);
|
font.setUseIntegerPositions(ints);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Draw all current build requests. Does not draw the beam effect, only the positions. */
|
/** Draw all current build requests. Does not draw the beam effect, only the positions. */
|
||||||
@@ -438,9 +434,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
Block block = world.tile(request.x, request.y).target().block();
|
Block block = world.tile(request.x, request.y).target().block();
|
||||||
|
|
||||||
//draw removal request
|
//draw removal request
|
||||||
Lines.stroke(2f);
|
Lines.stroke(2f, Palette.removeBack);
|
||||||
|
|
||||||
Draw.color(Palette.removeBack);
|
|
||||||
|
|
||||||
float rad = Mathf.absin(Time.time(), 7f, 1f) + block.size * tilesize / 2f - 1;
|
float rad = Mathf.absin(Time.time(), 7f, 1f) + block.size * tilesize / 2f - 1;
|
||||||
|
|
||||||
@@ -457,9 +451,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
rad);
|
rad);
|
||||||
}else{
|
}else{
|
||||||
//draw place request
|
//draw place request
|
||||||
Lines.stroke(2f);
|
Lines.stroke(2f, Palette.accentBack);
|
||||||
|
|
||||||
Draw.color(Palette.accentBack);
|
|
||||||
|
|
||||||
float rad = Mathf.absin(Time.time(), 7f, 1f) - 2f + request.recipe.result.size * tilesize / 2f;
|
float rad = Mathf.absin(Time.time(), 7f, 1f) - 2f + request.recipe.result.size * tilesize / 2f;
|
||||||
|
|
||||||
@@ -566,7 +558,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
protected void updateMech(){
|
protected void updateMech(){
|
||||||
Tile tile = world.tileWorld(x, y);
|
Tile tile = world.tileWorld(x, y);
|
||||||
|
|
||||||
isBoosting = Core.input.keyDown("dash") && !mech.flying;
|
isBoosting = Core.input.keyDown(Binding.dash) && !mech.flying;
|
||||||
|
|
||||||
//if player is in solid block
|
//if player is in solid block
|
||||||
if(tile != null && tile.solid()){
|
if(tile != null && tile.solid()){
|
||||||
@@ -586,7 +578,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
}
|
}
|
||||||
|
|
||||||
//drop from carrier on key press
|
//drop from carrier on key press
|
||||||
if(!ui.chatfrag.chatOpen() && Core.input.keyTap("drop_unit")){
|
if(!ui.chatfrag.chatOpen() && Core.input.keyTap(Binding.drop_unit)){
|
||||||
if(!mech.flying){
|
if(!mech.flying){
|
||||||
if(getCarrier() != null){
|
if(getCarrier() != null){
|
||||||
Call.dropSelf(this);
|
Call.dropSelf(this);
|
||||||
@@ -604,10 +596,8 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
|
|
||||||
movement.setZero();
|
movement.setZero();
|
||||||
|
|
||||||
String section = control.input(playerIndex).section;
|
float xa = Core.input.axis(Binding.move_x);
|
||||||
|
float ya = Core.input.axis(Binding.move_y);
|
||||||
float xa = Core.input.axis(section, "move_x");
|
|
||||||
float ya = Core.input.axis(section, "move_y");
|
|
||||||
if(!Core.input.keyDown(Binding.gridMode)){
|
if(!Core.input.keyDown(Binding.gridMode)){
|
||||||
movement.y += ya * speed;
|
movement.y += ya * speed;
|
||||||
movement.x += xa * speed;
|
movement.x += xa * speed;
|
||||||
@@ -879,7 +869,7 @@ public class Player extends Unit implements BuilderTrait, CarryTrait, ShooterTra
|
|||||||
public void write(DataOutput buffer) throws IOException{
|
public void write(DataOutput buffer) throws IOException{
|
||||||
super.writeSave(buffer, !isLocal);
|
super.writeSave(buffer, !isLocal);
|
||||||
TypeIO.writeStringData(buffer, name); //TODO writing strings is very inefficient
|
TypeIO.writeStringData(buffer, name); //TODO writing strings is very inefficient
|
||||||
buffer.writeByte(Bits.toByte(isAdmin) | (Bits.toByte(dead) << 1) | (Bits.toByte(isBoosting) << 2));
|
buffer.writeByte(Pack.byteValue(isAdmin) | (Pack.byteValue(dead) << 1) | (Pack.byteValue(isBoosting) << 2));
|
||||||
buffer.writeInt(Color.rgba8888(color));
|
buffer.writeInt(Color.rgba8888(color));
|
||||||
buffer.writeByte(mech.id);
|
buffer.writeByte(mech.id);
|
||||||
buffer.writeInt(mining == null ? -1 : mining.pos());
|
buffer.writeInt(mining == null ? -1 : mining.pos());
|
||||||
|
|||||||
@@ -9,8 +9,7 @@ import io.anuke.arc.entities.EntityGroup;
|
|||||||
import io.anuke.arc.entities.impl.BaseEntity;
|
import io.anuke.arc.entities.impl.BaseEntity;
|
||||||
import io.anuke.arc.entities.trait.HealthTrait;
|
import io.anuke.arc.entities.trait.HealthTrait;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.GridPoint2;
|
import io.anuke.arc.math.geom.Point2;
|
||||||
import io.anuke.arc.math.geom.Position;
|
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.arc.util.Interval;
|
import io.anuke.arc.util.Interval;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
@@ -170,8 +169,8 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
|||||||
public void removeFromProximity(){
|
public void removeFromProximity(){
|
||||||
tile.block().onProximityRemoved(tile);
|
tile.block().onProximityRemoved(tile);
|
||||||
|
|
||||||
GridPoint2[] nearby = Edges.getEdges(tile.block().size);
|
Point2[] nearby = Edges.getEdges(tile.block().size);
|
||||||
for(GridPoint2 point : nearby){
|
for(Point2 point : nearby){
|
||||||
Tile other = world.tile(tile.x + point.x, tile.y + point.y);
|
Tile other = world.tile(tile.x + point.x, tile.y + point.y);
|
||||||
//remove this tile from all nearby tile's proximities
|
//remove this tile from all nearby tile's proximities
|
||||||
if(other != null){
|
if(other != null){
|
||||||
@@ -188,8 +187,8 @@ public class TileEntity extends BaseEntity implements TargetTrait, HealthTrait{
|
|||||||
tmpTiles.clear();
|
tmpTiles.clear();
|
||||||
proximity.clear();
|
proximity.clear();
|
||||||
|
|
||||||
GridPoint2[] nearby = Edges.getEdges(tile.block().size);
|
Point2[] nearby = Edges.getEdges(tile.block().size);
|
||||||
for(GridPoint2 point : nearby){
|
for(Point2 point : nearby){
|
||||||
Tile other = world.tile(tile.x + point.x, tile.y + point.y);
|
Tile other = world.tile(tile.x + point.x, tile.y + point.y);
|
||||||
|
|
||||||
if(other == null) continue;
|
if(other == null) continue;
|
||||||
|
|||||||
@@ -320,7 +320,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
public void drawStats(){
|
public void drawStats(){
|
||||||
Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Time.time(), healthf()*5f, 1f - healthf()));
|
Draw.color(Color.BLACK, team.color, healthf() + Mathf.absin(Time.time(), healthf()*5f, 1f - healthf()));
|
||||||
Draw.alpha(hitTime);
|
Draw.alpha(hitTime);
|
||||||
Draw.rect(getPowerCellRegion(), x, y, rotation - 90);
|
Draw.rect(getPowerCellRegion(), x, y).rot(rotation - 90);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -336,7 +336,7 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void drawShadow(float offsetX, float offsetY){
|
public void drawShadow(float offsetX, float offsetY){
|
||||||
Draw.rect(getIconRegion(), x + offsetX, y + offsetY, rotation - 90);
|
Draw.rect(getIconRegion(), x + offsetX, y + offsetY).rot(rotation - 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void drawView(){
|
public void drawView(){
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import io.anuke.arc.entities.EntityGroup;
|
|||||||
import io.anuke.arc.entities.EntityQuery;
|
import io.anuke.arc.entities.EntityQuery;
|
||||||
import io.anuke.arc.function.Consumer;
|
import io.anuke.arc.function.Consumer;
|
||||||
import io.anuke.arc.function.Predicate;
|
import io.anuke.arc.function.Predicate;
|
||||||
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.Geometry;
|
import io.anuke.arc.math.geom.Geometry;
|
||||||
import io.anuke.arc.math.geom.Rectangle;
|
import io.anuke.arc.math.geom.Rectangle;
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
|
||||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||||
import io.anuke.mindustry.entities.units.BaseUnit;
|
import io.anuke.mindustry.entities.units.BaseUnit;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
@@ -165,7 +165,7 @@ public class Units{
|
|||||||
if(e.isDead() || !predicate.test(e))
|
if(e.isDead() || !predicate.test(e))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float dist = Vector2.dst(e.x, e.y, x, y);
|
float dist = Mathf.dst(e.x, e.y, x, y);
|
||||||
if(dist < range){
|
if(dist < range){
|
||||||
if(result == null || dist < cdist){
|
if(result == null || dist < cdist){
|
||||||
result = e;
|
result = e;
|
||||||
@@ -188,7 +188,7 @@ public class Units{
|
|||||||
if(!predicate.test(e))
|
if(!predicate.test(e))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
float dist = Vector2.dst(e.x, e.y, x, y);
|
float dist = Mathf.dst(e.x, e.y, x, y);
|
||||||
if(dist < range){
|
if(dist < range){
|
||||||
if(result == null || dist < cdist){
|
if(result == null || dist < cdist){
|
||||||
result = e;
|
result = e;
|
||||||
|
|||||||
@@ -1,16 +1,17 @@
|
|||||||
package io.anuke.mindustry.entities.bullet;
|
package io.anuke.mindustry.entities.bullet;
|
||||||
|
|
||||||
|
import io.anuke.arc.Core;
|
||||||
|
import io.anuke.arc.entities.Effects;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
|
import io.anuke.arc.math.Angles;
|
||||||
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.mindustry.entities.Damage;
|
import io.anuke.mindustry.entities.Damage;
|
||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.entities.traits.TargetTrait;
|
import io.anuke.mindustry.entities.traits.TargetTrait;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.arc.entities.Effects;
|
|
||||||
import io.anuke.arc.util.Time;
|
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
|
||||||
import io.anuke.arc.util.Angles;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A BulletType for most ammo-based bullets shot from turrets and units.
|
* A BulletType for most ammo-based bullets shot from turrets and units.
|
||||||
@@ -56,9 +57,9 @@ public class BasicBulletType extends BulletType{
|
|||||||
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
float height = bulletHeight * ((1f - bulletShrink) + bulletShrink * b.fout());
|
||||||
|
|
||||||
Draw.color(backColor);
|
Draw.color(backColor);
|
||||||
Draw.rect(backRegion, b.x, b.y, bulletWidth, height, b.angle() - 90);
|
Draw.rect(backRegion, b.x, b.y, bulletWidth, height).rot(b.angle() - 90);
|
||||||
Draw.color(frontColor);
|
Draw.color(frontColor);
|
||||||
Draw.rect(frontRegion, b.x, b.y, bulletWidth, height, b.angle() - 90);
|
Draw.rect(frontRegion, b.x, b.y, bulletWidth, height).rot(b.angle() - 90);
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,17 @@
|
|||||||
package io.anuke.mindustry.entities.bullet;
|
package io.anuke.mindustry.entities.bullet;
|
||||||
|
|
||||||
import io.anuke.arc.math.Vector2;
|
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
|
import io.anuke.arc.entities.EntityGroup;
|
||||||
|
import io.anuke.arc.entities.impl.BulletEntity;
|
||||||
|
import io.anuke.arc.entities.trait.Entity;
|
||||||
|
import io.anuke.arc.entities.trait.SolidTrait;
|
||||||
|
import io.anuke.arc.entities.trait.VelocityTrait;
|
||||||
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
|
import io.anuke.arc.util.Interval;
|
||||||
|
import io.anuke.arc.util.Time;
|
||||||
|
import io.anuke.arc.util.pooling.Pools;
|
||||||
import io.anuke.mindustry.entities.Unit;
|
import io.anuke.mindustry.entities.Unit;
|
||||||
import io.anuke.mindustry.entities.effect.Lightning;
|
import io.anuke.mindustry.entities.effect.Lightning;
|
||||||
import io.anuke.mindustry.entities.traits.AbsorbTrait;
|
import io.anuke.mindustry.entities.traits.AbsorbTrait;
|
||||||
@@ -10,15 +19,6 @@ import io.anuke.mindustry.entities.traits.SyncTrait;
|
|||||||
import io.anuke.mindustry.entities.traits.TeamTrait;
|
import io.anuke.mindustry.entities.traits.TeamTrait;
|
||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.arc.util.Time;
|
|
||||||
import io.anuke.arc.entities.EntityGroup;
|
|
||||||
import io.anuke.arc.entities.impl.BulletEntity;
|
|
||||||
import io.anuke.arc.entities.trait.Entity;
|
|
||||||
import io.anuke.arc.entities.trait.SolidTrait;
|
|
||||||
import io.anuke.arc.entities.trait.VelocityTrait;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
|
||||||
import io.anuke.arc.util.Pooling;
|
|
||||||
import io.anuke.arc.util.Timer;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
@@ -28,7 +28,7 @@ import static io.anuke.mindustry.Vars.*;
|
|||||||
|
|
||||||
public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncTrait, AbsorbTrait{
|
public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncTrait, AbsorbTrait{
|
||||||
private static Vector2 vector = new Vector2();
|
private static Vector2 vector = new Vector2();
|
||||||
public Timer timer = new Timer(3);
|
public Interval timer = new Interval(3);
|
||||||
private float lifeScl;
|
private float lifeScl;
|
||||||
private Team team;
|
private Team team;
|
||||||
private Object data;
|
private Object data;
|
||||||
@@ -62,7 +62,7 @@ public class Bullet extends BulletEntity<BulletType> implements TeamTrait, SyncT
|
|||||||
|
|
||||||
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).getVelocity() : Vector2.Zero);
|
bullet.velocity.add(owner instanceof VelocityTrait ? ((VelocityTrait) owner).getVelocity() : Vector2.ZERO);
|
||||||
}
|
}
|
||||||
|
|
||||||
bullet.team = team;
|
bullet.team = team;
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
package io.anuke.mindustry.entities.bullet;
|
package io.anuke.mindustry.entities.bullet;
|
||||||
|
|
||||||
|
import io.anuke.arc.entities.Effects;
|
||||||
|
import io.anuke.arc.entities.Effects.Effect;
|
||||||
|
import io.anuke.arc.entities.impl.BaseBulletType;
|
||||||
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.mindustry.content.StatusEffects;
|
import io.anuke.mindustry.content.StatusEffects;
|
||||||
import io.anuke.mindustry.content.fx.BulletFx;
|
import io.anuke.mindustry.content.fx.BulletFx;
|
||||||
import io.anuke.mindustry.game.Content;
|
import io.anuke.mindustry.game.Content;
|
||||||
import io.anuke.mindustry.type.ContentType;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.StatusEffect;
|
import io.anuke.mindustry.type.StatusEffect;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.arc.entities.Effects;
|
|
||||||
import io.anuke.arc.entities.Effects.Effect;
|
|
||||||
import io.anuke.arc.entities.impl.BaseBulletType;
|
|
||||||
import io.anuke.arc.util.Vector2;
|
|
||||||
|
|
||||||
public abstract class BulletType extends Content implements BaseBulletType<Bullet>{
|
public abstract class BulletType extends Content implements BaseBulletType<Bullet>{
|
||||||
public float lifetime;
|
public float lifetime;
|
||||||
|
|||||||
@@ -1,18 +1,18 @@
|
|||||||
package io.anuke.mindustry.entities.bullet;
|
package io.anuke.mindustry.entities.bullet;
|
||||||
|
|
||||||
|
import io.anuke.arc.entities.Effects;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.math.GridPoint2;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
|
import io.anuke.arc.graphics.g2d.Fill;
|
||||||
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.math.geom.Geometry;
|
||||||
|
import io.anuke.arc.math.geom.Point2;
|
||||||
import io.anuke.mindustry.content.fx.BulletFx;
|
import io.anuke.mindustry.content.fx.BulletFx;
|
||||||
import io.anuke.mindustry.content.fx.Fx;
|
import io.anuke.mindustry.content.fx.Fx;
|
||||||
import io.anuke.mindustry.entities.effect.Fire;
|
import io.anuke.mindustry.entities.effect.Fire;
|
||||||
import io.anuke.mindustry.entities.effect.Puddle;
|
import io.anuke.mindustry.entities.effect.Puddle;
|
||||||
import io.anuke.mindustry.type.Liquid;
|
import io.anuke.mindustry.type.Liquid;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.arc.entities.Effects;
|
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
|
||||||
import io.anuke.arc.graphics.Fill;
|
|
||||||
import io.anuke.arc.util.Geometry;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.tilesize;
|
import static io.anuke.mindustry.Vars.tilesize;
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
@@ -60,7 +60,7 @@ public class LiquidBulletType extends BulletType{
|
|||||||
if(liquid.temperature <= 0.5f && liquid.flammability < 0.3f){
|
if(liquid.temperature <= 0.5f && liquid.flammability < 0.3f){
|
||||||
float intensity = 400f;
|
float intensity = 400f;
|
||||||
Fire.extinguish(world.tileWorld(hitx, hity), intensity);
|
Fire.extinguish(world.tileWorld(hitx, hity), intensity);
|
||||||
for(GridPoint2 p : Geometry.d4){
|
for(Point2 p : Geometry.d4){
|
||||||
Fire.extinguish(world.tileWorld(hitx + p.x * tilesize, hity + p.y * tilesize), intensity);
|
Fire.extinguish(world.tileWorld(hitx + p.x * tilesize, hity + p.y * tilesize), intensity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
package io.anuke.mindustry.entities.effect;
|
package io.anuke.mindustry.entities.effect;
|
||||||
|
|
||||||
import io.anuke.mindustry.Vars;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
|
||||||
import io.anuke.arc.entities.Effects;
|
import io.anuke.arc.entities.Effects;
|
||||||
import io.anuke.arc.entities.Effects.Effect;
|
import io.anuke.arc.entities.Effects.Effect;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.entities.Effects.EffectRenderer;
|
||||||
import io.anuke.arc.entities.impl.EffectEntity;
|
import io.anuke.arc.entities.impl.EffectEntity;
|
||||||
import io.anuke.arc.Effects.EffectRenderer;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.util.Time;
|
||||||
|
import io.anuke.mindustry.Vars;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A ground effect contains an effect that is rendered on the ground layer as opposed to the top layer.
|
* A ground effect contains an effect that is rendered on the ground layer as opposed to the top layer.
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import io.anuke.mindustry.type.Item;
|
|||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.effectGroup;
|
import static io.anuke.mindustry.Vars.effectGroup;
|
||||||
import static io.anuke.mindustry.Vars.threads;
|
|
||||||
|
|
||||||
public class ItemTransfer extends TimedEntity implements DrawTrait{
|
public class ItemTransfer extends TimedEntity implements DrawTrait{
|
||||||
private Vector2 from = new Vector2();
|
private Vector2 from = new Vector2();
|
||||||
@@ -86,7 +85,7 @@ public class ItemTransfer extends TimedEntity implements DrawTrait{
|
|||||||
@Override
|
@Override
|
||||||
public void removed(){
|
public void removed(){
|
||||||
if(done != null){
|
if(done != null){
|
||||||
threads.run(done);
|
done.run();
|
||||||
}
|
}
|
||||||
Pools.free(this);
|
Pools.free(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,24 @@
|
|||||||
package io.anuke.mindustry.entities.effect;
|
package io.anuke.mindustry.entities.effect;
|
||||||
|
|
||||||
import io.anuke.arc.graphics.Color;
|
|
||||||
import io.anuke.arc.math.geom.Rectangle;
|
|
||||||
import io.anuke.arc.collection.Array;
|
|
||||||
import io.anuke.arc.util.IntSet;
|
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
|
import io.anuke.arc.collection.Array;
|
||||||
|
import io.anuke.arc.collection.IntSet;
|
||||||
|
import io.anuke.arc.entities.EntityGroup;
|
||||||
|
import io.anuke.arc.entities.impl.TimedEntity;
|
||||||
|
import io.anuke.arc.entities.trait.DrawTrait;
|
||||||
|
import io.anuke.arc.entities.trait.TimeTrait;
|
||||||
|
import io.anuke.arc.graphics.Color;
|
||||||
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
|
import io.anuke.arc.graphics.g2d.Lines;
|
||||||
|
import io.anuke.arc.math.Angles;
|
||||||
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.math.RandomXS128;
|
||||||
|
import io.anuke.arc.math.geom.Geometry;
|
||||||
|
import io.anuke.arc.math.geom.Position;
|
||||||
|
import io.anuke.arc.math.geom.Rectangle;
|
||||||
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
|
import io.anuke.arc.util.pooling.Pools;
|
||||||
import io.anuke.mindustry.content.bullets.TurretBullets;
|
import io.anuke.mindustry.content.bullets.TurretBullets;
|
||||||
import io.anuke.mindustry.entities.Unit;
|
import io.anuke.mindustry.entities.Unit;
|
||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
@@ -14,13 +27,6 @@ import io.anuke.mindustry.entities.traits.SyncTrait;
|
|||||||
import io.anuke.mindustry.game.Team;
|
import io.anuke.mindustry.game.Team;
|
||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.arc.entities.EntityGroup;
|
|
||||||
import io.anuke.arc.entities.impl.TimedEntity;
|
|
||||||
import io.anuke.arc.entities.trait.DrawTrait;
|
|
||||||
import io.anuke.arc.entities.trait.PosTrait;
|
|
||||||
import io.anuke.arc.entities.trait.TimeTrait;
|
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
|
||||||
import io.anuke.arc.graphics.g2d.Lines;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
@@ -30,7 +36,7 @@ import static io.anuke.mindustry.Vars.bulletGroup;
|
|||||||
public class Lightning extends TimedEntity implements DrawTrait, SyncTrait, TimeTrait{
|
public class Lightning extends TimedEntity implements DrawTrait, SyncTrait, TimeTrait{
|
||||||
public static final float lifetime = 10f;
|
public static final float lifetime = 10f;
|
||||||
|
|
||||||
private static final SeedRandom random = new SeedRandom();
|
private static final RandomXS128 random = new RandomXS128();
|
||||||
private static final Rectangle rect = new Rectangle();
|
private static final Rectangle rect = new Rectangle();
|
||||||
private static final Array<Unit> entities = new Array<>();
|
private static final Array<Unit> entities = new Array<>();
|
||||||
private static final IntSet hit = new IntSet();
|
private static final IntSet hit = new IntSet();
|
||||||
@@ -38,7 +44,7 @@ public class Lightning extends TimedEntity implements DrawTrait, SyncTrait, Time
|
|||||||
private static final float hitRange = 30f;
|
private static final float hitRange = 30f;
|
||||||
private static int lastSeed = 0;
|
private static int lastSeed = 0;
|
||||||
|
|
||||||
private Array<PosTrait> lines = new Array<>();
|
private Array<Position> lines = new Array<>();
|
||||||
private Color color = Palette.lancerLaser;
|
private Color color = Palette.lancerLaser;
|
||||||
|
|
||||||
/**For pooling use only. Do not call directly!*/
|
/**For pooling use only. Do not call directly!*/
|
||||||
@@ -126,8 +132,10 @@ public class Lightning extends TimedEntity implements DrawTrait, SyncTrait, Time
|
|||||||
public void draw(){
|
public void draw(){
|
||||||
float lx = x, ly = y;
|
float lx = x, ly = y;
|
||||||
Draw.color(color, Color.WHITE, fin());
|
Draw.color(color, Color.WHITE, fin());
|
||||||
|
//TODO this is really, really bad rendering
|
||||||
|
/*
|
||||||
for(int i = 0; i < lines.size; i++){
|
for(int i = 0; i < lines.size; i++){
|
||||||
PosTrait v = lines.get(i);
|
Position v = lines.get(i);
|
||||||
|
|
||||||
float f = (float) i / lines.size;
|
float f = (float) i / lines.size;
|
||||||
|
|
||||||
@@ -142,11 +150,10 @@ public class Lightning extends TimedEntity implements DrawTrait, SyncTrait, Time
|
|||||||
Lines.line(lx, ly, v.getX(), v.getY());
|
Lines.line(lx, ly, v.getX(), v.getY());
|
||||||
|
|
||||||
Lines.stroke(3f * fout() * (1f - f));
|
Lines.stroke(3f * fout() * (1f - f));
|
||||||
// Lines.lineAngleCenter(lx, ly, Angles.angle(lx, ly, v.getX(), v.getY()) + 90f, 20f);
|
|
||||||
|
|
||||||
lx = v.getX();
|
lx = v.getX();
|
||||||
ly = v.getY();
|
ly = v.getY();
|
||||||
}
|
}*/
|
||||||
Draw.color();
|
Draw.color();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,23 @@
|
|||||||
package io.anuke.mindustry.entities.effect;
|
package io.anuke.mindustry.entities.effect;
|
||||||
|
|
||||||
import io.anuke.arc.graphics.Color;
|
|
||||||
import io.anuke.arc.math.GridPoint2;
|
|
||||||
import io.anuke.arc.math.geom.Rectangle;
|
|
||||||
import io.anuke.arc.util.IntMap;
|
|
||||||
import io.anuke.arc.util.Pool.Poolable;
|
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
|
import io.anuke.arc.collection.IntMap;
|
||||||
|
import io.anuke.arc.entities.Effects;
|
||||||
|
import io.anuke.arc.entities.EntityGroup;
|
||||||
|
import io.anuke.arc.entities.impl.SolidEntity;
|
||||||
|
import io.anuke.arc.entities.trait.DrawTrait;
|
||||||
|
import io.anuke.arc.graphics.Color;
|
||||||
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
|
import io.anuke.arc.graphics.g2d.Fill;
|
||||||
|
import io.anuke.arc.math.Angles;
|
||||||
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.math.geom.Geometry;
|
||||||
|
import io.anuke.arc.math.geom.Point2;
|
||||||
|
import io.anuke.arc.math.geom.Rectangle;
|
||||||
|
import io.anuke.arc.util.Time;
|
||||||
|
import io.anuke.arc.util.pooling.Pool.Poolable;
|
||||||
|
import io.anuke.arc.util.pooling.Pools;
|
||||||
import io.anuke.mindustry.content.Liquids;
|
import io.anuke.mindustry.content.Liquids;
|
||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
import io.anuke.mindustry.content.bullets.TurretBullets;
|
import io.anuke.mindustry.content.bullets.TurretBullets;
|
||||||
@@ -19,18 +30,6 @@ import io.anuke.mindustry.gen.Call;
|
|||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.type.Liquid;
|
import io.anuke.mindustry.type.Liquid;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.arc.entities.Effects;
|
|
||||||
import io.anuke.arc.util.Time;
|
|
||||||
import io.anuke.arc.entities.EntityGroup;
|
|
||||||
import io.anuke.arc.entities.impl.SolidEntity;
|
|
||||||
import io.anuke.arc.entities.trait.DrawTrait;
|
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
|
||||||
import io.anuke.arc.graphics.Fill;
|
|
||||||
import io.anuke.arc.graphics.Hue;
|
|
||||||
import io.anuke.arc.util.Angles;
|
|
||||||
import io.anuke.arc.util.Geometry;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
|
||||||
import io.anuke.arc.util.Pooling;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
@@ -183,7 +182,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
|||||||
|
|
||||||
if(amount >= maxLiquid / 1.5f && generation < maxGeneration){
|
if(amount >= maxLiquid / 1.5f && generation < maxGeneration){
|
||||||
float deposited = Math.min((amount - maxLiquid / 1.5f) / 4f, 0.3f) * Time.delta();
|
float deposited = Math.min((amount - maxLiquid / 1.5f) / 4f, 0.3f) * Time.delta();
|
||||||
for(GridPoint2 point : Geometry.d4){
|
for(Point2 point : Geometry.d4){
|
||||||
Tile other = world.tile(tile.x + point.x, tile.y + point.y);
|
Tile other = world.tile(tile.x + point.x, tile.y + point.y);
|
||||||
if(other != null && other.block() == Blocks.air && !other.hasCliffs()){
|
if(other != null && other.block() == Blocks.air && !other.hasCliffs()){
|
||||||
deposit(other, tile, liquid, deposited, generation + 1);
|
deposit(other, tile, liquid, deposited, generation + 1);
|
||||||
@@ -232,7 +231,7 @@ public class Puddle extends SolidEntity implements SaveTrait, Poolable, DrawTrai
|
|||||||
float smag = onLiquid ? 0.8f : 0f;
|
float smag = onLiquid ? 0.8f : 0f;
|
||||||
float sscl = 20f;
|
float sscl = 20f;
|
||||||
|
|
||||||
Draw.color(Hue.shift(tmp.set(liquid.color), 2, -0.05f));
|
Draw.color(tmp.set(liquid.color).shiftValue(-0.05f));
|
||||||
Fill.circle(x + Mathf.sin(Time.time() + seeds * 532, sscl, smag), y + Mathf.sin(Time.time() + seeds * 53, sscl, smag), f * 8f);
|
Fill.circle(x + Mathf.sin(Time.time() + seeds * 532, sscl, smag), y + Mathf.sin(Time.time() + seeds * 53, sscl, smag), f * 8f);
|
||||||
Angles.randLenVectors(id, 3, f * 6f, (ex, ey) -> {
|
Angles.randLenVectors(id, 3, f * 6f, (ex, ey) -> {
|
||||||
Fill.circle(x + ex + Mathf.sin(Time.time() + seeds * 532, sscl, smag),
|
Fill.circle(x + ex + Mathf.sin(Time.time() + seeds * 532, sscl, smag),
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package io.anuke.mindustry.entities.effect;
|
package io.anuke.mindustry.entities.effect;
|
||||||
|
|
||||||
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
|
|
||||||
@@ -20,11 +21,11 @@ public class RubbleDecal extends Decal{
|
|||||||
public void drawDecal(){
|
public void drawDecal(){
|
||||||
String region = "rubble-" + size + "-" + Mathf.randomSeed(id, 0, 1);
|
String region = "rubble-" + size + "-" + Mathf.randomSeed(id, 0, 1);
|
||||||
|
|
||||||
if(!Draw.hasRegion(region)){
|
if(!Core.atlas.has(region)){
|
||||||
remove();
|
remove();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.rect(region, x, y, Mathf.randomSeed(id, 0, 4) * 90);
|
Draw.rect(region, x, y).rot(Mathf.randomSeed(id, 0, 4) * 90);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
package io.anuke.mindustry.entities.effect;
|
package io.anuke.mindustry.entities.effect;
|
||||||
|
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.mindustry.world.Tile;
|
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.util.Angles;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
|
import io.anuke.arc.math.Angles;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.mindustry.world.Tile;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
@@ -35,7 +36,8 @@ public class ScorchDecal extends Decal{
|
|||||||
TextureRegion region = regions[Mathf.randomSeed(id - i, 0, scorches - 1)];
|
TextureRegion region = regions[Mathf.randomSeed(id - i, 0, scorches - 1)];
|
||||||
float rotation = Mathf.randomSeed(id + i, 0, 360);
|
float rotation = Mathf.randomSeed(id + i, 0, 360);
|
||||||
float space = 1.5f + Mathf.randomSeed(id + i + 1, 0, 20) / 10f;
|
float space = 1.5f + Mathf.randomSeed(id + i + 1, 0, 20) / 10f;
|
||||||
Draw.grect(region, x + Angles.trnsx(rotation, space), y + Angles.trnsy(rotation, space), rotation - 90);
|
Draw.rect(region, x + Angles.trnsx(rotation, space), y + Angles.trnsy(rotation, space) + region.getHeight()/2f)
|
||||||
|
.origin(region.getWidth()/2f, 0).rot(rotation - 90);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,18 @@
|
|||||||
package io.anuke.mindustry.entities.traits;
|
package io.anuke.mindustry.entities.traits;
|
||||||
|
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.Events;
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.Array;
|
||||||
import io.anuke.arc.util.Queue;
|
import io.anuke.arc.collection.Queue;
|
||||||
|
import io.anuke.arc.entities.Effects;
|
||||||
|
import io.anuke.arc.entities.trait.Entity;
|
||||||
|
import io.anuke.arc.graphics.Color;
|
||||||
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
|
import io.anuke.arc.graphics.g2d.Fill;
|
||||||
|
import io.anuke.arc.graphics.g2d.Lines;
|
||||||
|
import io.anuke.arc.math.Angles;
|
||||||
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
import io.anuke.mindustry.content.fx.BlockFx;
|
import io.anuke.mindustry.content.fx.BlockFx;
|
||||||
@@ -21,16 +30,6 @@ import io.anuke.mindustry.world.Pos;
|
|||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.BuildBlock;
|
import io.anuke.mindustry.world.blocks.BuildBlock;
|
||||||
import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity;
|
import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity;
|
||||||
import io.anuke.arc.entities.Effects;
|
|
||||||
import io.anuke.arc.Events;
|
|
||||||
import io.anuke.arc.util.Time;
|
|
||||||
import io.anuke.arc.entities.trait.Entity;
|
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
|
||||||
import io.anuke.arc.graphics.Fill;
|
|
||||||
import io.anuke.arc.graphics.g2d.Lines;
|
|
||||||
import io.anuke.arc.graphics.Shapes;
|
|
||||||
import io.anuke.arc.util.Angles;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
@@ -322,7 +321,7 @@ public interface BuilderTrait extends Entity{
|
|||||||
tmptr[3].set(tile.drawx() + sz, tile.drawy() + sz);
|
tmptr[3].set(tile.drawx() + sz, tile.drawy() + sz);
|
||||||
|
|
||||||
Arrays.sort(tmptr, (a, b) -> -Float.compare(Angles.angleDist(Angles.angle(unit.x, unit.y, a.x, a.y), ang),
|
Arrays.sort(tmptr, (a, b) -> -Float.compare(Angles.angleDist(Angles.angle(unit.x, unit.y, a.x, a.y), ang),
|
||||||
Angles.angleDist(Angles.angle(unit.x, unit.y, b.x, b.y), ang)));
|
Angles.angleDist(Angles.angle(unit.x, unit.y, b.x, b.y), ang)));
|
||||||
|
|
||||||
float x1 = tmptr[0].x, y1 = tmptr[0].y,
|
float x1 = tmptr[0].x, y1 = tmptr[0].y,
|
||||||
x3 = tmptr[1].x, y3 = tmptr[1].y;
|
x3 = tmptr[1].x, y3 = tmptr[1].y;
|
||||||
@@ -354,10 +353,11 @@ public interface BuilderTrait extends Entity{
|
|||||||
float ey = tile.worldy() + Mathf.sin(Time.time() + 48, swingScl + 2f, swingMag);
|
float ey = tile.worldy() + Mathf.sin(Time.time() + 48, swingScl + 2f, swingMag);
|
||||||
|
|
||||||
Draw.color(Color.LIGHT_GRAY, Color.WHITE, 1f - flashScl + Mathf.absin(Time.time(), 0.5f, flashScl));
|
Draw.color(Color.LIGHT_GRAY, Color.WHITE, 1f - flashScl + Mathf.absin(Time.time(), 0.5f, flashScl));
|
||||||
|
//TODO better laser drawing functions
|
||||||
Shapes.laser("minelaser", "minelaser-end", px, py, ex, ey);
|
Shapes.laser("minelaser", "minelaser-end", px, py, ex, ey);
|
||||||
|
|
||||||
if(unit instanceof Player && ((Player) unit).isLocal){
|
if(unit instanceof Player && ((Player) unit).isLocal){
|
||||||
Draw.color(Palette.accent);
|
Lines.stroke(1f, Palette.accent);
|
||||||
Lines.poly(tile.worldx(), tile.worldy(), 4, tilesize / 2f * Mathf.sqrt2, Time.time());
|
Lines.poly(tile.worldx(), tile.worldy(), 4, tilesize / 2f * Mathf.sqrt2, Time.time());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
package io.anuke.mindustry.entities.traits;
|
package io.anuke.mindustry.entities.traits;
|
||||||
|
|
||||||
import io.anuke.mindustry.type.Weapon;
|
|
||||||
import io.anuke.arc.entities.trait.VelocityTrait;
|
import io.anuke.arc.entities.trait.VelocityTrait;
|
||||||
import io.anuke.arc.util.Timer;
|
import io.anuke.arc.util.Interval;
|
||||||
|
import io.anuke.mindustry.type.Weapon;
|
||||||
|
|
||||||
public interface ShooterTrait extends VelocityTrait, TeamTrait, InventoryTrait{
|
public interface ShooterTrait extends VelocityTrait, TeamTrait, InventoryTrait{
|
||||||
|
|
||||||
Timer getTimer();
|
Interval getTimer();
|
||||||
|
|
||||||
int getShootTimer(boolean left);
|
int getShootTimer(boolean left);
|
||||||
|
|
||||||
|
|||||||
@@ -33,8 +33,7 @@ public interface SyncTrait extends Entity, TypeTrait{
|
|||||||
|
|
||||||
if(isClipped()){
|
if(isClipped()){
|
||||||
//move off screen when no longer in bounds
|
//move off screen when no longer in bounds
|
||||||
Tmp.r1.setSize(Core.camera.viewportWidth * Core.camera.zoom * NetClient.viewScale,
|
Tmp.r1.setSize(Core.camera.width * NetClient.viewScale, Core.camera.height * NetClient.viewScale)
|
||||||
Core.camera.viewportHeight * Core.camera.zoom * NetClient.viewScale)
|
|
||||||
.setCenter(Core.camera.position.x, Core.camera.position.y);
|
.setCenter(Core.camera.position.x, Core.camera.position.y);
|
||||||
|
|
||||||
if(!Tmp.r1.contains(getX(), getY()) && !Tmp.r1.contains(getInterpolator().last.x, getInterpolator().last.y)){
|
if(!Tmp.r1.contains(getX(), getY()) && !Tmp.r1.contains(getInterpolator().last.x, getInterpolator().last.y)){
|
||||||
|
|||||||
@@ -1,9 +1,19 @@
|
|||||||
package io.anuke.mindustry.entities.units;
|
package io.anuke.mindustry.entities.units;
|
||||||
|
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
|
||||||
import io.anuke.arc.math.geom.Rectangle;
|
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
|
import io.anuke.arc.Core;
|
||||||
|
import io.anuke.arc.entities.Effects;
|
||||||
|
import io.anuke.arc.entities.EntityGroup;
|
||||||
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
|
import io.anuke.arc.math.Angles;
|
||||||
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.math.geom.Geometry;
|
||||||
|
import io.anuke.arc.math.geom.Rectangle;
|
||||||
|
import io.anuke.arc.util.Interval;
|
||||||
|
import io.anuke.arc.util.Time;
|
||||||
|
import io.anuke.arc.util.Timer;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.content.fx.ExplosionFx;
|
import io.anuke.mindustry.content.fx.ExplosionFx;
|
||||||
import io.anuke.mindustry.entities.Damage;
|
import io.anuke.mindustry.entities.Damage;
|
||||||
@@ -24,11 +34,6 @@ import io.anuke.mindustry.type.Weapon;
|
|||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.units.CommandCenter.CommandCenterEntity;
|
import io.anuke.mindustry.world.blocks.units.CommandCenter.CommandCenterEntity;
|
||||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||||
import io.anuke.arc.entities.Effects;
|
|
||||||
import io.anuke.arc.util.Time;
|
|
||||||
import io.anuke.arc.entities.EntityGroup;
|
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
|
||||||
import io.anuke.arc.util.*;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
@@ -46,7 +51,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
protected static final int timerShootRight = timerIndex++;
|
protected static final int timerShootRight = timerIndex++;
|
||||||
|
|
||||||
protected UnitType type;
|
protected UnitType type;
|
||||||
protected Timer timer = new Timer(5);
|
protected Interval timer = new Interval(5);
|
||||||
protected StateMachine state = new StateMachine();
|
protected StateMachine state = new StateMachine();
|
||||||
protected TargetTrait target;
|
protected TargetTrait target;
|
||||||
|
|
||||||
@@ -211,7 +216,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
Draw.rect(stack.item.region,
|
Draw.rect(stack.item.region,
|
||||||
x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT),
|
x + Angles.trnsx(rotation + 180f + angT, backTrns + lenT),
|
||||||
y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT),
|
y + Angles.trnsy(rotation + 180f + angT, backTrns + lenT),
|
||||||
itemSize, itemSize, rotation);
|
itemSize, itemSize).rot(rotation);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -222,7 +227,7 @@ public abstract class BaseUnit extends Unit implements ShooterTrait{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Timer getTimer(){
|
public Interval getTimer(){
|
||||||
return timer;
|
return timer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
package io.anuke.mindustry.entities.units;
|
package io.anuke.mindustry.entities.units;
|
||||||
|
|
||||||
import io.anuke.arc.math.Vector2;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
|
import io.anuke.arc.math.Angles;
|
||||||
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.math.geom.Geometry;
|
||||||
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
|
import io.anuke.arc.util.Time;
|
||||||
import io.anuke.mindustry.entities.Predict;
|
import io.anuke.mindustry.entities.Predict;
|
||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.entities.traits.CarriableTrait;
|
import io.anuke.mindustry.entities.traits.CarriableTrait;
|
||||||
@@ -10,9 +15,6 @@ import io.anuke.mindustry.net.Net;
|
|||||||
import io.anuke.mindustry.type.AmmoType;
|
import io.anuke.mindustry.type.AmmoType;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||||
import io.anuke.arc.util.Time;
|
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
|
||||||
import io.anuke.arc.util.*;
|
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.world;
|
import static io.anuke.mindustry.Vars.world;
|
||||||
|
|
||||||
@@ -75,8 +77,8 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
|||||||
}else{
|
}else{
|
||||||
attack(150f);
|
attack(150f);
|
||||||
|
|
||||||
if((Mathf.angNear(angleTo(target), rotation, 15f) || !getWeapon().getAmmo().bullet.keepVelocity) //bombers don't care about rotation
|
if((Angles.near(angleTo(target), rotation, 15f) || !getWeapon().getAmmo().bullet.keepVelocity) //bombers don't care about rotation
|
||||||
&& distanceTo(target) < Math.max(getWeapon().getAmmo().getRange(), type.range)){
|
&& dst(target) < Math.max(getWeapon().getAmmo().getRange(), type.range)){
|
||||||
AmmoType ammo = getWeapon().getAmmo();
|
AmmoType ammo = getWeapon().getAmmo();
|
||||||
|
|
||||||
Vector2 to = Predict.intercept(FlyingUnit.this, target, ammo.bullet.speed);
|
Vector2 to = Predict.intercept(FlyingUnit.this, target, ammo.bullet.speed);
|
||||||
@@ -162,7 +164,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
|||||||
public void draw(){
|
public void draw(){
|
||||||
Draw.alpha(hitTime / hitDuration);
|
Draw.alpha(hitTime / hitDuration);
|
||||||
|
|
||||||
Draw.rect(type.name, x, y, rotation - 90);
|
Draw.rect(type.name, x, y).rot(rotation - 90);
|
||||||
|
|
||||||
drawItems();
|
drawItems();
|
||||||
|
|
||||||
@@ -235,7 +237,7 @@ public abstract class FlyingUnit extends BaseUnit implements CarryTrait{
|
|||||||
|
|
||||||
vec.set(target.getX() - x, target.getY() - y);
|
vec.set(target.getX() - x, target.getY() - y);
|
||||||
|
|
||||||
float length = circleLength <= 0.001f ? 1f : Mathf.clamp((distanceTo(target) - circleLength) / 100f, -1f, 1f);
|
float length = circleLength <= 0.001f ? 1f : Mathf.clamp((dst(target) - circleLength) / 100f, -1f, 1f);
|
||||||
|
|
||||||
vec.setLength(type.speed * Time.delta() * length);
|
vec.setLength(type.speed * Time.delta() * length);
|
||||||
if(length < 0) vec.rotate(180f);
|
if(length < 0) vec.rotate(180f);
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
|
|
||||||
public void update(){
|
public void update(){
|
||||||
TileEntity core = getClosestEnemyCore();
|
TileEntity core = getClosestEnemyCore();
|
||||||
float dst = core == null ? 0 : distanceTo(core);
|
float dst = core == null ? 0 : dst(core);
|
||||||
|
|
||||||
if(core != null && dst < getWeapon().getAmmo().getRange() / 1.1f){
|
if(core != null && dst < getWeapon().getAmmo().getRange() / 1.1f){
|
||||||
target = core;
|
target = core;
|
||||||
@@ -57,7 +57,7 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
public void update(){
|
public void update(){
|
||||||
TileEntity target = getClosestCore();
|
TileEntity target = getClosestCore();
|
||||||
if(target != null){
|
if(target != null){
|
||||||
if(distanceTo(target) > 400f){
|
if(dst(target) > 400f){
|
||||||
moveAwayFromCore();
|
moveAwayFromCore();
|
||||||
}else{
|
}else{
|
||||||
patrol();
|
patrol();
|
||||||
@@ -188,7 +188,7 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!Units.invalidateTarget(target, this)){
|
if(!Units.invalidateTarget(target, this)){
|
||||||
if(distanceTo(target) < getWeapon().getAmmo().getRange()){
|
if(dst(target) < getWeapon().getAmmo().getRange()){
|
||||||
rotate(angleTo(target));
|
rotate(angleTo(target));
|
||||||
|
|
||||||
if(Mathf.angNear(angleTo(target), rotation, 13f)){
|
if(Mathf.angNear(angleTo(target), rotation, 13f)){
|
||||||
@@ -292,7 +292,7 @@ public abstract class GroundUnit extends BaseUnit{
|
|||||||
Tile targetTile = world.pathfinder.getTargetTile(enemy, tile);
|
Tile targetTile = world.pathfinder.getTargetTile(enemy, tile);
|
||||||
TileEntity core = getClosestCore();
|
TileEntity core = getClosestCore();
|
||||||
|
|
||||||
if(tile == targetTile || core == null || distanceTo(core) < 90f) return;
|
if(tile == targetTile || core == null || dst(core) < 90f) return;
|
||||||
|
|
||||||
float angle = angleTo(targetTile);
|
float angle = angleTo(targetTile);
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,7 @@
|
|||||||
package io.anuke.mindustry.entities.units;
|
package io.anuke.mindustry.entities.units;
|
||||||
|
|
||||||
import io.anuke.arc.math.Vector2;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.util.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.threads;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to group entities together, for formations and such.
|
* Used to group entities together, for formations and such.
|
||||||
@@ -16,9 +14,9 @@ public class Squad{
|
|||||||
private long lastUpdated;
|
private long lastUpdated;
|
||||||
|
|
||||||
protected void update(){
|
protected void update(){
|
||||||
if(threads.getFrameID() != lastUpdated){
|
if(Core.graphics.getFrameId() != lastUpdated){
|
||||||
direction.setZero();
|
direction.setZero();
|
||||||
lastUpdated = threads.getFrameID();
|
lastUpdated = Core.graphics.getFrameId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package io.anuke.mindustry.entities.units;
|
package io.anuke.mindustry.entities.units;
|
||||||
|
|
||||||
import io.anuke.arc.util.Bundles;
|
import io.anuke.arc.Core;
|
||||||
|
|
||||||
public enum UnitCommand{
|
public enum UnitCommand{
|
||||||
attack, retreat, patrol;
|
attack, retreat, patrol;
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
package io.anuke.mindustry.entities.units;
|
package io.anuke.mindustry.entities.units;
|
||||||
|
|
||||||
|
import io.anuke.arc.Core;
|
||||||
|
import io.anuke.arc.collection.ObjectSet;
|
||||||
|
import io.anuke.arc.function.Supplier;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.arc.collection.ObjectSet;
|
import io.anuke.arc.scene.ui.layout.Table;
|
||||||
|
import io.anuke.arc.util.Log;
|
||||||
|
import io.anuke.arc.util.Strings;
|
||||||
import io.anuke.mindustry.content.Items;
|
import io.anuke.mindustry.content.Items;
|
||||||
import io.anuke.mindustry.content.Weapons;
|
import io.anuke.mindustry.content.Weapons;
|
||||||
import io.anuke.mindustry.entities.traits.TypeTrait;
|
import io.anuke.mindustry.entities.traits.TypeTrait;
|
||||||
@@ -12,12 +17,6 @@ import io.anuke.mindustry.type.ContentType;
|
|||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.type.Weapon;
|
import io.anuke.mindustry.type.Weapon;
|
||||||
import io.anuke.mindustry.ui.ContentDisplay;
|
import io.anuke.mindustry.ui.ContentDisplay;
|
||||||
import io.anuke.arc.function.Supplier;
|
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
|
||||||
import io.anuke.arc.scene.ui.layout.Table;
|
|
||||||
import io.anuke.arc.util.Bundles;
|
|
||||||
import io.anuke.arc.util.Log;
|
|
||||||
import io.anuke.arc.util.Strings;
|
|
||||||
|
|
||||||
public class UnitType extends UnlockableContent{
|
public class UnitType extends UnlockableContent{
|
||||||
protected final Supplier<? extends BaseUnit> constructor;
|
protected final Supplier<? extends BaseUnit> constructor;
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package io.anuke.mindustry.entities.units.types;
|
package io.anuke.mindustry.entities.units.types;
|
||||||
|
|
||||||
import io.anuke.arc.math.Vector2;
|
|
||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
|
import io.anuke.arc.Core;
|
||||||
|
import io.anuke.arc.entities.Effects;
|
||||||
|
import io.anuke.arc.math.Angles;
|
||||||
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.mindustry.Vars;
|
import io.anuke.mindustry.Vars;
|
||||||
import io.anuke.mindustry.content.fx.UnitFx;
|
import io.anuke.mindustry.content.fx.UnitFx;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
@@ -15,14 +18,13 @@ import io.anuke.mindustry.entities.units.UnitState;
|
|||||||
import io.anuke.mindustry.gen.Call;
|
import io.anuke.mindustry.gen.Call;
|
||||||
import io.anuke.mindustry.net.Net;
|
import io.anuke.mindustry.net.Net;
|
||||||
import io.anuke.mindustry.type.AmmoType;
|
import io.anuke.mindustry.type.AmmoType;
|
||||||
import io.anuke.arc.entities.Effects;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.headless;
|
||||||
|
import static io.anuke.mindustry.Vars.players;
|
||||||
|
|
||||||
public class AlphaDrone extends FlyingUnit {
|
public class AlphaDrone extends FlyingUnit {
|
||||||
static final float followDistance = 80f;
|
static final float followDistance = 80f;
|
||||||
@@ -44,7 +46,7 @@ public class AlphaDrone extends FlyingUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
target = last;
|
target = last;
|
||||||
if(distanceTo(leader) < followDistance){
|
if(dst(leader) < followDistance){
|
||||||
targetClosest();
|
targetClosest();
|
||||||
}else{
|
}else{
|
||||||
target = null;
|
target = null;
|
||||||
@@ -53,7 +55,7 @@ public class AlphaDrone extends FlyingUnit {
|
|||||||
if(target != null){
|
if(target != null){
|
||||||
attack(50f);
|
attack(50f);
|
||||||
|
|
||||||
if((Mathf.angNear(angleTo(target), rotation, 15f) && distanceTo(target) < getWeapon().getAmmo().getRange())){
|
if((Angles.near(angleTo(target), rotation, 15f) && dst(target) < getWeapon().getAmmo().getRange())){
|
||||||
AmmoType ammo = getWeapon().getAmmo();
|
AmmoType ammo = getWeapon().getAmmo();
|
||||||
|
|
||||||
Vector2 to = Predict.intercept(AlphaDrone.this, target, ammo.bullet.speed);
|
Vector2 to = Predict.intercept(AlphaDrone.this, target, ammo.bullet.speed);
|
||||||
@@ -61,7 +63,7 @@ public class AlphaDrone extends FlyingUnit {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!leader.isShooting && distanceTo(leader) < 7f){
|
if(!leader.isShooting && dst(leader) < 7f){
|
||||||
Call.onAlphaDroneFade(AlphaDrone.this);
|
Call.onAlphaDroneFade(AlphaDrone.this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,11 @@
|
|||||||
package io.anuke.mindustry.entities.units.types;
|
package io.anuke.mindustry.entities.units.types;
|
||||||
|
|
||||||
import io.anuke.arc.util.Queue;
|
import io.anuke.arc.Events;
|
||||||
|
import io.anuke.arc.collection.Queue;
|
||||||
|
import io.anuke.arc.entities.EntityGroup;
|
||||||
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.math.geom.Geometry;
|
||||||
|
import io.anuke.arc.util.Structs;
|
||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
@@ -20,11 +25,6 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
import io.anuke.mindustry.world.blocks.BuildBlock;
|
import io.anuke.mindustry.world.blocks.BuildBlock;
|
||||||
import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity;
|
import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity;
|
||||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||||
import io.anuke.arc.Events;
|
|
||||||
import io.anuke.arc.entities.EntityGroup;
|
|
||||||
import io.anuke.arc.util.Geometry;
|
|
||||||
import io.anuke.arc.math.Mathf;
|
|
||||||
import io.anuke.arc.util.Structs;
|
|
||||||
|
|
||||||
import java.io.DataInput;
|
import java.io.DataInput;
|
||||||
import java.io.DataOutput;
|
import java.io.DataOutput;
|
||||||
@@ -63,7 +63,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
if(core == null) return;
|
if(core == null) return;
|
||||||
|
|
||||||
if((entity.progress() < 1f || entity.progress() > 0f) && entity.tile.block() instanceof BuildBlock){ //building is valid
|
if((entity.progress() < 1f || entity.progress() > 0f) && entity.tile.block() instanceof BuildBlock){ //building is valid
|
||||||
if(!isBuilding() && distanceTo(target) < placeDistance * 0.9f){ //within distance, begin placing
|
if(!isBuilding() && dst(target) < placeDistance * 0.9f){ //within distance, begin placing
|
||||||
if(isBreaking){
|
if(isBreaking){
|
||||||
getPlaceQueue().addLast(new BuildRequest(entity.tile.x, entity.tile.y));
|
getPlaceQueue().addLast(new BuildRequest(entity.tile.x, entity.tile.y));
|
||||||
}else{
|
}else{
|
||||||
@@ -158,7 +158,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
if(target instanceof Tile){
|
if(target instanceof Tile){
|
||||||
moveTo(type.range / 1.5f);
|
moveTo(type.range / 1.5f);
|
||||||
|
|
||||||
if(distanceTo(target) < type.range && mineTile != target){
|
if(dst(target) < type.range && mineTile != target){
|
||||||
setMineTile((Tile) target);
|
setMineTile((Tile) target);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -196,7 +196,7 @@ public class Drone extends FlyingUnit implements BuilderTrait{
|
|||||||
|
|
||||||
TileEntity tile = (TileEntity) target;
|
TileEntity tile = (TileEntity) target;
|
||||||
|
|
||||||
if(distanceTo(target) < type.range){
|
if(dst(target) < type.range){
|
||||||
if(tile.tile.block().acceptStack(inventory.getItem().item, inventory.getItem().amount, tile.tile, Drone.this) == inventory.getItem().amount){
|
if(tile.tile.block().acceptStack(inventory.getItem().item, inventory.getItem().amount, tile.tile, Drone.this) == inventory.getItem().amount){
|
||||||
Call.transferItemTo(inventory.getItem().item, inventory.getItem().amount, x, y, tile.tile);
|
Call.transferItemTo(inventory.getItem().item, inventory.getItem().amount, x, y, tile.tile);
|
||||||
inventory.clearItem();
|
inventory.clearItem();
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ public class BlockRenderer{
|
|||||||
threads.runGraphics(() -> {
|
threads.runGraphics(() -> {
|
||||||
int avgx = Mathf.scl(camera.position.x, tilesize);
|
int avgx = Mathf.scl(camera.position.x, tilesize);
|
||||||
int avgy = Mathf.scl(camera.position.y, tilesize);
|
int avgy = Mathf.scl(camera.position.y, tilesize);
|
||||||
int rangex = (int) (camera.viewportWidth * camera.zoom / tilesize / 2) + 2;
|
int rangex = (int) (camera.width / tilesize / 2) + 2;
|
||||||
int rangey = (int) (camera.viewportHeight * camera.zoom / tilesize / 2) + 2;
|
int rangey = (int) (camera.height / tilesize / 2) + 2;
|
||||||
|
|
||||||
if(Math.abs(avgx - event.tile.x) <= rangex && Math.abs(avgy - event.tile.y) <= rangey){
|
if(Math.abs(avgx - event.tile.x) <= rangex && Math.abs(avgy - event.tile.y) <= rangey){
|
||||||
lastCamY = lastCamX = -99; //invalidate camera position so blocks get updated
|
lastCamY = lastCamX = -99; //invalidate camera position so blocks get updated
|
||||||
@@ -79,8 +79,8 @@ public class BlockRenderer{
|
|||||||
int avgx = Mathf.scl(camera.position.x, tilesize);
|
int avgx = Mathf.scl(camera.position.x, tilesize);
|
||||||
int avgy = Mathf.scl(camera.position.y, tilesize);
|
int avgy = Mathf.scl(camera.position.y, tilesize);
|
||||||
|
|
||||||
int rangex = (int) (camera.viewportWidth * camera.zoom / tilesize / 2) + 2;
|
int rangex = (int) (camera.width / tilesize / 2) + 2;
|
||||||
int rangey = (int) (camera.viewportHeight * camera.zoom / tilesize / 2) + 2;
|
int rangey = (int) (camera.height / tilesize / 2) + 2;
|
||||||
|
|
||||||
if(avgx == lastCamX && avgy == lastCamY && lastRangeX == rangex && lastRangeY == rangey){
|
if(avgx == lastCamX && avgy == lastCamY && lastRangeX == rangex && lastRangeY == rangey){
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -80,7 +80,7 @@ public enum CacheLayer{
|
|||||||
Graphics.shader(shader);
|
Graphics.shader(shader);
|
||||||
Graphics.begin();
|
Graphics.begin();
|
||||||
Draw.rect(renderer.effectSurface.texture(), Core.camera.position.x, Core.camera.position.y,
|
Draw.rect(renderer.effectSurface.texture(), Core.camera.position.x, Core.camera.position.y,
|
||||||
Core.camera.viewportWidth * Core.camera.zoom, -Core.camera.viewportHeight * Core.camera.zoom);
|
Core.camera.width , -Core.camera.height );
|
||||||
Graphics.end();
|
Graphics.end();
|
||||||
Graphics.shader();
|
Graphics.shader();
|
||||||
renderer.blocks.beginFloor();
|
renderer.blocks.beginFloor();
|
||||||
|
|||||||
@@ -46,8 +46,8 @@ public class FloorRenderer{
|
|||||||
|
|
||||||
OrthographicCamera camera = Core.camera;
|
OrthographicCamera camera = Core.camera;
|
||||||
|
|
||||||
int crangex = (int) (camera.viewportWidth * camera.zoom / (chunksize * tilesize)) + 1;
|
int crangex = (int) (camera.width / (chunksize * tilesize)) + 1;
|
||||||
int crangey = (int) (camera.viewportHeight * camera.zoom / (chunksize * tilesize)) + 1;
|
int crangey = (int) (camera.height / (chunksize * tilesize)) + 1;
|
||||||
|
|
||||||
int camx = Mathf.scl(camera.position.x, chunksize * tilesize);
|
int camx = Mathf.scl(camera.position.x, chunksize * tilesize);
|
||||||
int camy = Mathf.scl(camera.position.y, chunksize * tilesize);
|
int camy = Mathf.scl(camera.position.y, chunksize * tilesize);
|
||||||
@@ -123,8 +123,8 @@ public class FloorRenderer{
|
|||||||
|
|
||||||
OrthographicCamera camera = Core.camera;
|
OrthographicCamera camera = Core.camera;
|
||||||
|
|
||||||
int crangex = (int) (camera.viewportWidth * camera.zoom / (chunksize * tilesize)) + 1;
|
int crangex = (int) (camera.width / (chunksize * tilesize)) + 1;
|
||||||
int crangey = (int) (camera.viewportHeight * camera.zoom / (chunksize * tilesize)) + 1;
|
int crangey = (int) (camera.height / (chunksize * tilesize)) + 1;
|
||||||
|
|
||||||
layer.begin();
|
layer.begin();
|
||||||
|
|
||||||
|
|||||||
@@ -94,8 +94,8 @@ public class FogRenderer implements Disposable{
|
|||||||
public void draw(){
|
public void draw(){
|
||||||
if(buffer == null) return;
|
if(buffer == null) return;
|
||||||
|
|
||||||
float vw = Core.camera.viewportWidth * Core.camera.zoom;
|
float vw = Core.camera.width ;
|
||||||
float vh = Core.camera.viewportHeight * Core.camera.zoom;
|
float vh = Core.camera.height ;
|
||||||
|
|
||||||
float px = Core.camera.position.x - vw / 2f;
|
float px = Core.camera.position.x - vw / 2f;
|
||||||
float py = Core.camera.position.y - vh / 2f;
|
float py = Core.camera.position.y - vh / 2f;
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class OverlayRenderer{
|
|||||||
|
|
||||||
for(Player player : playerGroup.all()){
|
for(Player player : playerGroup.all()){
|
||||||
if(Core.settings.getBool("indicators") && player != players[0] && player.getTeam() == players[0].getTeam()){
|
if(Core.settings.getBool("indicators") && player != players[0] && player.getTeam() == players[0].getTeam()){
|
||||||
if(!rect.setSize(Core.camera.viewportWidth * Core.camera.zoom * 0.9f, Core.camera.viewportHeight * Core.camera.zoom * 0.9f)
|
if(!rect.setSize(Core.camera.width * 0.9f, Core.camera.height * 0.9f)
|
||||||
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x, player.y)){
|
.setCenter(Core.camera.position.x, Core.camera.position.y).contains(player.x, player.y)){
|
||||||
|
|
||||||
Tmp.v1.set(player.x, player.y).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
Tmp.v1.set(player.x, player.y).sub(Core.camera.position.x, Core.camera.position.y).setLength(indicatorLength);
|
||||||
@@ -87,7 +87,7 @@ public class OverlayRenderer{
|
|||||||
if(buildFadeTime > 0.005f){
|
if(buildFadeTime > 0.005f){
|
||||||
for(Team enemy : state.teams.enemiesOf(player.getTeam())){
|
for(Team enemy : state.teams.enemiesOf(player.getTeam())){
|
||||||
for(Tile core : state.teams.get(enemy).cores){
|
for(Tile core : state.teams.get(enemy).cores){
|
||||||
float dst = Vector2.dst(player.x, player.y, core.drawx(), core.drawy());
|
float dst = Mathf.dst(player.x, player.y, core.drawx(), core.drawy());
|
||||||
if(dst < state.mode.enemyCoreBuildRadius * 1.5f){
|
if(dst < state.mode.enemyCoreBuildRadius * 1.5f){
|
||||||
Draw.color(Color.DARK_GRAY);
|
Draw.color(Color.DARK_GRAY);
|
||||||
Lines.poly(core.drawx(), core.drawy() - 2, 200, state.mode.enemyCoreBuildRadius);
|
Lines.poly(core.drawx(), core.drawy() - 2, 200, state.mode.enemyCoreBuildRadius);
|
||||||
|
|||||||
@@ -175,10 +175,10 @@ public class Shaders{
|
|||||||
shader.setUniformf("u_dp", Unit.dp.scl(1f));
|
shader.setUniformf("u_dp", Unit.dp.scl(1f));
|
||||||
shader.setUniformf("u_time", Time.time() / Unit.dp.scl(1f));
|
shader.setUniformf("u_time", Time.time() / Unit.dp.scl(1f));
|
||||||
shader.setUniformf("u_offset",
|
shader.setUniformf("u_offset",
|
||||||
Core.camera.position.x - Core.camera.viewportWidth / 2 * Core.camera.zoom,
|
Core.camera.position.x - Core.camera.width / 2 ,
|
||||||
Core.camera.position.y - Core.camera.viewportHeight / 2 * Core.camera.zoom);
|
Core.camera.position.y - Core.camera.height / 2 );
|
||||||
shader.setUniformf("u_texsize", Core.camera.viewportWidth * Core.camera.zoom,
|
shader.setUniformf("u_texsize", Core.camera.width ,
|
||||||
Core.camera.viewportHeight * Core.camera.zoom);
|
Core.camera.height );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -191,10 +191,10 @@ public class Shaders{
|
|||||||
@Override
|
@Override
|
||||||
public void apply(){
|
public void apply(){
|
||||||
shader.setUniformf("camerapos",
|
shader.setUniformf("camerapos",
|
||||||
Core.camera.position.x - Core.camera.viewportWidth / 2 * Core.camera.zoom,
|
Core.camera.position.x - Core.camera.width / 2 ,
|
||||||
Core.camera.position.y - Core.camera.viewportHeight / 2 * Core.camera.zoom);
|
Core.camera.position.y - Core.camera.height / 2 );
|
||||||
shader.setUniformf("screensize", Core.camera.viewportWidth* Core.camera.zoom,
|
shader.setUniformf("screensize", Core.camera.width,
|
||||||
Core.camera.viewportHeight * Core.camera.zoom);
|
Core.camera.height );
|
||||||
shader.setUniformf("time", Time.time());
|
shader.setUniformf("time", Time.time());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ public class Trail{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void update(float curx, float cury){
|
public void update(float curx, float cury){
|
||||||
if(Vector2.dst(curx, cury, lastX, lastY) >= maxJump){
|
if(Mathf.dst(curx, cury, lastX, lastY) >= maxJump){
|
||||||
points.clear();
|
points.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +0,0 @@
|
|||||||
package io.anuke.mindustry.input;
|
|
||||||
|
|
||||||
import io.anuke.arc.scene.utils.Cursors;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Type of cursor for displaying on desktop.
|
|
||||||
*/
|
|
||||||
public enum CursorType{
|
|
||||||
normal(Cursors::restoreCursor),
|
|
||||||
hand(Cursors::setHand),
|
|
||||||
drill(() -> Cursors.set("drill")),
|
|
||||||
unload(() -> Cursors.set("unload"));
|
|
||||||
|
|
||||||
private final Runnable call;
|
|
||||||
|
|
||||||
CursorType(Runnable call){
|
|
||||||
this.call = call;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the current system cursor to this.
|
|
||||||
*/
|
|
||||||
void set(){
|
|
||||||
call.run();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -235,7 +235,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
|
|
||||||
if(Core.input.keyRelease(Binding.break_block) || Core.input.keyRelease(Binding.select)){
|
if(Core.input.keyRelease(Binding.break_block) || Core.input.keyRelease(Binding.select)){
|
||||||
|
|
||||||
if(mode == placing){ //touch up while placing, place everything in selection
|
if(mode == placing && recipe != null){ //touch up while placing, place everything in selection
|
||||||
NormalizeResult result = PlaceUtils.normalizeArea(selectX, selectY, cursorX, cursorY, rotation, true, maxLength);
|
NormalizeResult result = PlaceUtils.normalizeArea(selectX, selectY, cursorX, cursorY, rotation, true, maxLength);
|
||||||
|
|
||||||
for(int i = 0; i <= result.getLength(); i += recipe.result.size){
|
for(int i = 0; i <= result.getLength(); i += recipe.result.size){
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ package io.anuke.mindustry.input;
|
|||||||
import io.anuke.annotations.Annotations.Loc;
|
import io.anuke.annotations.Annotations.Loc;
|
||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.Graphics;
|
|
||||||
import io.anuke.arc.entities.Effects;
|
import io.anuke.arc.entities.Effects;
|
||||||
import io.anuke.arc.graphics.Color;
|
import io.anuke.arc.graphics.Color;
|
||||||
import io.anuke.arc.input.InputProcessor;
|
import io.anuke.arc.input.InputProcessor;
|
||||||
|
import io.anuke.arc.math.Angles;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.arc.scene.ui.layout.Table;
|
import io.anuke.arc.scene.ui.layout.Table;
|
||||||
@@ -39,7 +39,6 @@ public abstract class InputHandler implements InputProcessor{
|
|||||||
final static float backTrns = 3f;
|
final static float backTrns = 3f;
|
||||||
|
|
||||||
public final Player player;
|
public final Player player;
|
||||||
public final String section;
|
|
||||||
public final OverlayFragment frag = new OverlayFragment(this);
|
public final OverlayFragment frag = new OverlayFragment(this);
|
||||||
|
|
||||||
public Recipe recipe;
|
public Recipe recipe;
|
||||||
@@ -48,7 +47,6 @@ public abstract class InputHandler implements InputProcessor{
|
|||||||
|
|
||||||
public InputHandler(Player player){
|
public InputHandler(Player player){
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.section = "player_" + (player.playerIndex + 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//methods to override
|
//methods to override
|
||||||
@@ -89,7 +87,7 @@ public abstract class InputHandler implements InputProcessor{
|
|||||||
tile.block().getStackOffset(item, tile, stackTrns);
|
tile.block().getStackOffset(item, tile, stackTrns);
|
||||||
|
|
||||||
ItemTransfer.create(item,
|
ItemTransfer.create(item,
|
||||||
player.x + Mathf.trnsx(player.rotation + 180f, backTrns), player.y + Mathf.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 Vector2(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;
|
||||||
|
|
||||||
@@ -226,7 +224,7 @@ public abstract class InputHandler implements InputProcessor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
boolean canTapPlayer(float x, float y){
|
boolean canTapPlayer(float x, float y){
|
||||||
return Vector2.dst(x, y, player.x, player.y) <= playerSelectRange && player.inventory.hasItem();
|
return Mathf.dst(x, y, player.x, player.y) <= playerSelectRange && player.inventory.hasItem();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**Tries to begin mining a tile, returns true if successful.*/
|
/**Tries to begin mining a tile, returns true if successful.*/
|
||||||
@@ -334,7 +332,7 @@ public abstract class InputHandler implements InputProcessor{
|
|||||||
for(Tile tile : state.teams.get(player.getTeam()).cores){
|
for(Tile tile : state.teams.get(player.getTeam()).cores){
|
||||||
if(tile.dst(x * tilesize, y * tilesize) < coreBuildRange){
|
if(tile.dst(x * tilesize, y * tilesize) < coreBuildRange){
|
||||||
return Build.validPlace(player.getTeam(), x, y, type, rotation) &&
|
return Build.validPlace(player.getTeam(), x, y, type, rotation) &&
|
||||||
Vector2.dst(player.x, player.y, x * tilesize, y * tilesize) < Player.placeDistance;
|
Mathf.dst(player.x, player.y, x * tilesize, y * tilesize) < Player.placeDistance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -342,7 +340,7 @@ public abstract class InputHandler implements InputProcessor{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean validBreak(int x, int y){
|
public boolean validBreak(int x, int y){
|
||||||
return Build.validBreak(player.getTeam(), x, y) && Vector2.dst(player.x, player.y, x * tilesize, y * tilesize) < Player.placeDistance;
|
return Build.validBreak(player.getTeam(), x, y) && Mathf.dst(player.x, player.y, x * tilesize, y * tilesize) < Player.placeDistance;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void placeBlock(int x, int y, Recipe recipe, int rotation){
|
public void placeBlock(int x, int y, Recipe recipe, int rotation){
|
||||||
|
|||||||
@@ -636,7 +636,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
panY = (screenY - Core.graphics.getHeight()) + edgePan;
|
panY = (screenY - Core.graphics.getHeight()) + edgePan;
|
||||||
}
|
}
|
||||||
|
|
||||||
vector.set(panX, panY).scl((Core.camera.viewportWidth * Core.camera.zoom) / Core.graphics.getWidth());
|
vector.set(panX, panY).scl((Core.camera.width ) / Core.graphics.getWidth());
|
||||||
vector.limit(maxPanSpeed);
|
vector.limit(maxPanSpeed);
|
||||||
|
|
||||||
//pan view
|
//pan view
|
||||||
@@ -667,7 +667,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
float dx = deltaX * Core.camera.zoom / Core.cameraScale, dy = deltaY * Core.camera.zoom / Core.cameraScale;
|
float dx = deltaX / Core.cameraScale, dy = deltaY / Core.cameraScale;
|
||||||
|
|
||||||
if(selecting){ //pan all requests
|
if(selecting){ //pan all requests
|
||||||
for(PlaceRequest req : selection){
|
for(PlaceRequest req : selection){
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ public class FortressGenerator{
|
|||||||
for(IntPositionConsumer i : passes){
|
for(IntPositionConsumer i : passes){
|
||||||
for(int x = 0; x < gen.width; x++){
|
for(int x = 0; x < gen.width; x++){
|
||||||
for(int y = 0; y < gen.height; y++){
|
for(int y = 0; y < gen.height; y++){
|
||||||
if(Vector2.dst(x, y, enemyX, enemyY) > coreDst){
|
if(Mathf.dst(x, y, enemyX, enemyY) > coreDst){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -339,7 +339,7 @@ public class WorldGenerator{
|
|||||||
|
|
||||||
if(detailed && spawnpoints != null){
|
if(detailed && spawnpoints != null){
|
||||||
for(GridPoint2 p : spawnpoints){
|
for(GridPoint2 p : spawnpoints){
|
||||||
float dst = Vector2.dst2(p.x, p.y, localX, localY);
|
float dst = Mathf.dst2(p.x, p.y, localX, localY);
|
||||||
minDst = Math.min(minDst, dst);
|
minDst = Math.min(minDst, dst);
|
||||||
|
|
||||||
if(dst < lerpDst){
|
if(dst < lerpDst){
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
package io.anuke.mindustry.world;
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
|
import io.anuke.arc.Graphics.Cursor;
|
||||||
|
import io.anuke.arc.Graphics.Cursor.SystemCursor;
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.Array;
|
||||||
import io.anuke.arc.collection.EnumSet;
|
import io.anuke.arc.collection.EnumSet;
|
||||||
import io.anuke.arc.collection.IntArray;
|
import io.anuke.arc.collection.IntArray;
|
||||||
@@ -24,7 +26,6 @@ import io.anuke.mindustry.game.UnlockableContent;
|
|||||||
import io.anuke.mindustry.graphics.CacheLayer;
|
import io.anuke.mindustry.graphics.CacheLayer;
|
||||||
import io.anuke.mindustry.graphics.Layer;
|
import io.anuke.mindustry.graphics.Layer;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.input.CursorType;
|
|
||||||
import io.anuke.mindustry.type.ContentType;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.Item;
|
import io.anuke.mindustry.type.Item;
|
||||||
import io.anuke.mindustry.type.ItemStack;
|
import io.anuke.mindustry.type.ItemStack;
|
||||||
@@ -282,8 +283,8 @@ public class Block extends BaseBlock {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Returns whether or not a hand cursor should be shown over this block. */
|
/** Returns whether or not a hand cursor should be shown over this block. */
|
||||||
public CursorType getCursor(Tile tile){
|
public Cursor getCursor(Tile tile){
|
||||||
return configurable ? CursorType.hand : CursorType.normal;
|
return configurable ? SystemCursor.hand : SystemCursor.arrow;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,8 +1,11 @@
|
|||||||
package io.anuke.mindustry.world;
|
package io.anuke.mindustry.world;
|
||||||
|
|
||||||
import io.anuke.arc.math.GridPoint2;
|
import io.anuke.arc.Core;
|
||||||
|
import io.anuke.arc.Events;
|
||||||
|
import io.anuke.arc.math.Mathf;
|
||||||
|
import io.anuke.arc.math.geom.Geometry;
|
||||||
|
import io.anuke.arc.math.geom.Point2;
|
||||||
import io.anuke.arc.math.geom.Rectangle;
|
import io.anuke.arc.math.geom.Rectangle;
|
||||||
import io.anuke.arc.math.Vector2;
|
|
||||||
import io.anuke.mindustry.content.blocks.Blocks;
|
import io.anuke.mindustry.content.blocks.Blocks;
|
||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.game.EventType.BlockBuildBeginEvent;
|
import io.anuke.mindustry.game.EventType.BlockBuildBeginEvent;
|
||||||
@@ -10,8 +13,6 @@ import io.anuke.mindustry.game.Team;
|
|||||||
import io.anuke.mindustry.type.ContentType;
|
import io.anuke.mindustry.type.ContentType;
|
||||||
import io.anuke.mindustry.type.Recipe;
|
import io.anuke.mindustry.type.Recipe;
|
||||||
import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity;
|
import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity;
|
||||||
import io.anuke.arc.Events;
|
|
||||||
import io.anuke.arc.util.Geometry;
|
|
||||||
|
|
||||||
import static io.anuke.mindustry.Vars.*;
|
import static io.anuke.mindustry.Vars.*;
|
||||||
|
|
||||||
@@ -120,7 +121,7 @@ public class Build{
|
|||||||
//check for enemy cores
|
//check for enemy cores
|
||||||
for(Team enemy : state.teams.enemiesOf(team)){
|
for(Team enemy : state.teams.enemiesOf(team)){
|
||||||
for(Tile core : state.teams.get(enemy).cores){
|
for(Tile core : state.teams.get(enemy).cores){
|
||||||
if(Vector2.dst(x*tilesize + type.offset(), y*tilesize + type.offset(), core.drawx(), core.drawy()) < state.mode.enemyCoreBuildRadius + type.size*tilesize/2f){
|
if(Mathf.dst(x*tilesize + type.offset(), y*tilesize + type.offset(), core.drawx(), core.drawy()) < state.mode.enemyCoreBuildRadius + type.size*tilesize/2f){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -169,17 +170,17 @@ public class Build{
|
|||||||
|
|
||||||
private static boolean contactsGround(int x, int y, Block block){
|
private static boolean contactsGround(int x, int y, Block block){
|
||||||
if(block.isMultiblock()){
|
if(block.isMultiblock()){
|
||||||
for(GridPoint2 point : Edges.getInsideEdges(block.size)){
|
for(Point2 point : Edges.getInsideEdges(block.size)){
|
||||||
Tile tile = world.tile(x + point.x, y + point.y);
|
Tile tile = world.tile(x + point.x, y + point.y);
|
||||||
if(tile != null && !tile.floor().isLiquid) return true;
|
if(tile != null && !tile.floor().isLiquid) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(GridPoint2 point : Edges.getEdges(block.size)){
|
for(Point2 point : Edges.getEdges(block.size)){
|
||||||
Tile tile = world.tile(x + point.x, y + point.y);
|
Tile tile = world.tile(x + point.x, y + point.y);
|
||||||
if(tile != null && !tile.floor().isLiquid) return true;
|
if(tile != null && !tile.floor().isLiquid) return true;
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
for(GridPoint2 point : Geometry.d4){
|
for(Point2 point : Geometry.d4){
|
||||||
Tile tile = world.tile(x + point.x, y + point.y);
|
Tile tile = world.tile(x + point.x, y + point.y);
|
||||||
if(tile != null && !tile.floor().isLiquid) return true;
|
if(tile != null && !tile.floor().isLiquid) return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package io.anuke.mindustry.world;
|
|||||||
|
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.Geometry;
|
import io.anuke.arc.math.geom.Geometry;
|
||||||
import io.anuke.arc.math.geom.GridPoint2;
|
import io.anuke.arc.math.geom.Point2;
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
@@ -12,8 +12,8 @@ import static io.anuke.mindustry.Vars.world;
|
|||||||
public class Edges{
|
public class Edges{
|
||||||
private static final int maxSize = 11;
|
private static final int maxSize = 11;
|
||||||
private static final int maxRadius = 12;
|
private static final int maxRadius = 12;
|
||||||
private static GridPoint2[][] edges = new GridPoint2[maxSize][0];
|
private static Point2[][] edges = new Point2[maxSize][0];
|
||||||
private static GridPoint2[][] edgeInside = new GridPoint2[maxSize][0];
|
private static Point2[][] edgeInside = new Point2[maxSize][0];
|
||||||
private static Vector2[][] polygons = new Vector2[maxRadius * 2][0];
|
private static Vector2[][] polygons = new Vector2[maxRadius * 2][0];
|
||||||
|
|
||||||
static{
|
static{
|
||||||
@@ -24,28 +24,28 @@ public class Edges{
|
|||||||
for(int i = 0; i < maxSize; i++){
|
for(int i = 0; i < maxSize; i++){
|
||||||
int bot = -(int) (i / 2f) - 1;
|
int bot = -(int) (i / 2f) - 1;
|
||||||
int top = (int) (i / 2f + 0.5f) + 1;
|
int top = (int) (i / 2f + 0.5f) + 1;
|
||||||
edges[i] = new GridPoint2[(i + 1) * 4];
|
edges[i] = new Point2[(i + 1) * 4];
|
||||||
|
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
|
||||||
for(int j = 0; j < i + 1; j++){
|
for(int j = 0; j < i + 1; j++){
|
||||||
//bottom
|
//bottom
|
||||||
edges[i][idx++] = new GridPoint2(bot + 1 + j, bot);
|
edges[i][idx++] = new Point2(bot + 1 + j, bot);
|
||||||
//top
|
//top
|
||||||
edges[i][idx++] = new GridPoint2(bot + 1 + j, top);
|
edges[i][idx++] = new Point2(bot + 1 + j, top);
|
||||||
//left
|
//left
|
||||||
edges[i][idx++] = new GridPoint2(bot, bot + j + 1);
|
edges[i][idx++] = new Point2(bot, bot + j + 1);
|
||||||
//right
|
//right
|
||||||
edges[i][idx++] = new GridPoint2(top, bot + j + 1);
|
edges[i][idx++] = new Point2(top, bot + j + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
Arrays.sort(edges[i], (e1, e2) -> Float.compare(Mathf.atan2(e1.x, e1.y), Mathf.atan2(e2.x, e2.y)));
|
Arrays.sort(edges[i], (e1, e2) -> Float.compare(Mathf.atan2(e1.x, e1.y), Mathf.atan2(e2.x, e2.y)));
|
||||||
|
|
||||||
edgeInside[i] = new GridPoint2[edges[i].length];
|
edgeInside[i] = new Point2[edges[i].length];
|
||||||
|
|
||||||
for(int j = 0; j < edges[i].length; j++){
|
for(int j = 0; j < edges[i].length; j++){
|
||||||
GridPoint2 point = edges[i][j];
|
Point2 point = edges[i][j];
|
||||||
edgeInside[i][j] = new GridPoint2(Mathf.clamp(point.x, -(int) ((i) / 2f), (int) (i / 2f + 0.5f)),
|
edgeInside[i][j] = new Point2(Mathf.clamp(point.x, -(int) ((i) / 2f), (int) (i / 2f + 0.5f)),
|
||||||
Mathf.clamp(point.y, -(int) ((i) / 2f), (int) (i / 2f + 0.5f)));
|
Mathf.clamp(point.y, -(int) ((i) / 2f), (int) (i / 2f + 0.5f)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -64,13 +64,13 @@ public class Edges{
|
|||||||
return polygons[(int) (radius * 2) - 1];
|
return polygons[(int) (radius * 2) - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GridPoint2[] getEdges(int size){
|
public static Point2[] getEdges(int size){
|
||||||
if(size < 0 || size > maxSize) throw new RuntimeException("Block size must be between 0 and " + maxSize);
|
if(size < 0 || size > maxSize) throw new RuntimeException("Block size must be between 0 and " + maxSize);
|
||||||
|
|
||||||
return edges[size - 1];
|
return edges[size - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GridPoint2[] getInsideEdges(int size){
|
public static Point2[] getInsideEdges(int size){
|
||||||
if(size < 0 || size > maxSize) throw new RuntimeException("Block size must be between 0 and " + maxSize);
|
if(size < 0 || size > maxSize) throw new RuntimeException("Block size must be between 0 and " + maxSize);
|
||||||
|
|
||||||
return edgeInside[size - 1];
|
return edgeInside[size - 1];
|
||||||
|
|||||||
@@ -4,6 +4,8 @@ import io.anuke.annotations.Annotations.Loc;
|
|||||||
import io.anuke.annotations.Annotations.Remote;
|
import io.anuke.annotations.Annotations.Remote;
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.Graphics;
|
import io.anuke.arc.Graphics;
|
||||||
|
import io.anuke.arc.Graphics.Cursor;
|
||||||
|
import io.anuke.arc.Graphics.Cursor.SystemCursor;
|
||||||
import io.anuke.arc.entities.Effects;
|
import io.anuke.arc.entities.Effects;
|
||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
@@ -20,7 +22,6 @@ import io.anuke.mindustry.gen.Call;
|
|||||||
import io.anuke.mindustry.graphics.Layer;
|
import io.anuke.mindustry.graphics.Layer;
|
||||||
import io.anuke.mindustry.graphics.Palette;
|
import io.anuke.mindustry.graphics.Palette;
|
||||||
import io.anuke.mindustry.graphics.Shaders;
|
import io.anuke.mindustry.graphics.Shaders;
|
||||||
import io.anuke.mindustry.input.CursorType;
|
|
||||||
import io.anuke.mindustry.type.ItemStack;
|
import io.anuke.mindustry.type.ItemStack;
|
||||||
import io.anuke.mindustry.type.Recipe;
|
import io.anuke.mindustry.type.Recipe;
|
||||||
import io.anuke.mindustry.world.BarType;
|
import io.anuke.mindustry.world.BarType;
|
||||||
@@ -88,8 +89,8 @@ public class BuildBlock extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CursorType getCursor(Tile tile){
|
public Cursor getCursor(Tile tile){
|
||||||
return CursorType.hand;
|
return SystemCursor.hand;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -129,7 +130,7 @@ public class BuildBlock extends Block{
|
|||||||
if(entity.previous == null) return;
|
if(entity.previous == null) return;
|
||||||
|
|
||||||
for(TextureRegion region : entity.previous.getBlockIcon()){
|
for(TextureRegion region : entity.previous.getBlockIcon()){
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy(), entity.previous.rotate ? tile.getRotation() * 90 : 0);
|
Draw.rect(region, tile.drawx(), tile.drawy()).rot(entity.previous.rotate ? tile.getRotation() * 90 : 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -149,9 +150,8 @@ public class BuildBlock extends Block{
|
|||||||
Shaders.blockbuild.progress = entity.progress;
|
Shaders.blockbuild.progress = entity.progress;
|
||||||
Shaders.blockbuild.apply();
|
Shaders.blockbuild.apply();
|
||||||
|
|
||||||
Draw.rect(region, tile.drawx(), tile.drawy(), target.rotate ? tile.getRotation() * 90 : 0);
|
Draw.rect(region, tile.drawx(), tile.drawy()).rot(target.rotate ? tile.getRotation() * 90 : 0);
|
||||||
|
Draw.flush();
|
||||||
Graphics.flush();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import io.anuke.mindustry.content.fx.BlockFx;
|
|||||||
import io.anuke.mindustry.entities.Player;
|
import io.anuke.mindustry.entities.Player;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.entities.Units;
|
import io.anuke.mindustry.entities.Units;
|
||||||
import io.anuke.mindustry.input.CursorType;
|
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.arc.entities.Effects;
|
import io.anuke.arc.entities.Effects;
|
||||||
import io.anuke.arc.entities.Effects.Effect;
|
import io.anuke.arc.entities.Effects.Effect;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class MendProjector extends Block{
|
|||||||
|
|
||||||
for(int x = -tileRange + tile.x; x <= tileRange + tile.x; x++){
|
for(int x = -tileRange + tile.x; x <= tileRange + tile.x; x++){
|
||||||
for(int y = -tileRange + tile.y; y <= tileRange + tile.y; y++){
|
for(int y = -tileRange + tile.y; y <= tileRange + tile.y; y++){
|
||||||
if(Vector2.dst(x, y, tile.x, tile.y) > realRange) continue;
|
if(Mathf.dst(x, y, tile.x, tile.y) > realRange) continue;
|
||||||
|
|
||||||
Tile other = world.tile(x, y);
|
Tile other = world.tile(x, y);
|
||||||
|
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ public class OverdriveProjector extends Block{
|
|||||||
|
|
||||||
for(int x = -tileRange + tile.x; x <= tileRange + tile.x; x++){
|
for(int x = -tileRange + tile.x; x <= tileRange + tile.x; x++){
|
||||||
for(int y = -tileRange + tile.y; y <= tileRange + tile.y; y++){
|
for(int y = -tileRange + tile.y; y <= tileRange + tile.y; y++){
|
||||||
if(Vector2.dst(x, y, tile.x, tile.y) > realRange) continue;
|
if(Mathf.dst(x, y, tile.x, tile.y) > realRange) continue;
|
||||||
|
|
||||||
Tile other = world.tile(x, y);
|
Tile other = world.tile(x, y);
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package io.anuke.mindustry.world.blocks.defense.turrets;
|
package io.anuke.mindustry.world.blocks.defense.turrets;
|
||||||
|
|
||||||
import io.anuke.arc.Core;
|
import io.anuke.arc.Core;
|
||||||
import io.anuke.arc.Graphics;
|
|
||||||
import io.anuke.arc.collection.Array;
|
import io.anuke.arc.collection.Array;
|
||||||
import io.anuke.arc.collection.EnumSet;
|
import io.anuke.arc.collection.EnumSet;
|
||||||
import io.anuke.arc.entities.Effects;
|
import io.anuke.arc.entities.Effects;
|
||||||
@@ -12,6 +11,7 @@ import io.anuke.arc.graphics.Color;
|
|||||||
import io.anuke.arc.graphics.g2d.Draw;
|
import io.anuke.arc.graphics.g2d.Draw;
|
||||||
import io.anuke.arc.graphics.g2d.Lines;
|
import io.anuke.arc.graphics.g2d.Lines;
|
||||||
import io.anuke.arc.graphics.g2d.TextureRegion;
|
import io.anuke.arc.graphics.g2d.TextureRegion;
|
||||||
|
import io.anuke.arc.math.Angles;
|
||||||
import io.anuke.arc.math.Mathf;
|
import io.anuke.arc.math.Mathf;
|
||||||
import io.anuke.arc.math.geom.Vector2;
|
import io.anuke.arc.math.geom.Vector2;
|
||||||
import io.anuke.arc.util.Time;
|
import io.anuke.arc.util.Time;
|
||||||
@@ -129,9 +129,7 @@ public abstract class Turret extends Block{
|
|||||||
@Override
|
@Override
|
||||||
public void draw(Tile tile){
|
public void draw(Tile tile){
|
||||||
Draw.rect(baseRegion, tile.drawx(), tile.drawy());
|
Draw.rect(baseRegion, tile.drawx(), tile.drawy());
|
||||||
Draw.color(tile.getTeam().color, Color.WHITE, 0.45f);
|
Draw.rect(baseTopRegion, tile.drawx(), tile.drawy()).color(tile.getTeam().color, Color.WHITE, 0.45f);
|
||||||
Draw.rect(baseTopRegion, tile.drawx(), tile.drawy());
|
|
||||||
Draw.color();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -145,8 +143,6 @@ public abstract class Turret extends Block{
|
|||||||
if(heatRegion != Core.atlas.find("error")){
|
if(heatRegion != Core.atlas.find("error")){
|
||||||
heatDrawer.accept(tile, entity);
|
heatDrawer.accept(tile, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
Draw.color();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -174,8 +170,7 @@ public abstract class Turret extends Block{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||||
Draw.color(Palette.placing);
|
Lines.stroke(1f, Palette.placing);
|
||||||
Lines.stroke(1f);
|
|
||||||
Lines.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range);
|
Lines.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -296,7 +291,7 @@ public abstract class Turret extends Block{
|
|||||||
|
|
||||||
AmmoType type = peekAmmo(tile);
|
AmmoType type = peekAmmo(tile);
|
||||||
|
|
||||||
tr.trns(entity.rotation, size * tilesize / 2, Mathf.range(xRand));
|
tr.trns(entity.rotation, size * tilesize / 2f, Mathf.range(xRand));
|
||||||
|
|
||||||
for(int i = 0; i < shots; i++){
|
for(int i = 0; i < shots; i++){
|
||||||
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy + type.inaccuracy) + (i-shots/2) * spread);
|
bullet(tile, ammo.bullet, entity.rotation + Mathf.range(inaccuracy + type.inaccuracy) + (i-shots/2) * spread);
|
||||||
@@ -344,7 +339,7 @@ public abstract class Turret extends Block{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class TurretEntity extends TileEntity{
|
public static class TurretEntity extends TileEntity{
|
||||||
public Array<AmmoEntry> ammo = new ThreadArray<>();
|
public Array<AmmoEntry> ammo = new Array<>();
|
||||||
public int totalAmmo;
|
public int totalAmmo;
|
||||||
public float reload;
|
public float reload;
|
||||||
public float rotation = 90;
|
public float rotation = 90;
|
||||||
|
|||||||
@@ -225,12 +225,12 @@ public class PowerNode extends PowerBlock{
|
|||||||
if(link.block() instanceof PowerNode){
|
if(link.block() instanceof PowerNode){
|
||||||
TileEntity oe = link.entity();
|
TileEntity oe = link.entity();
|
||||||
|
|
||||||
return Vector2.dst(tile.drawx(), tile.drawy(), link.drawx(), link.drawy()) <= Math.max(laserRange * tilesize,
|
return Mathf.dst(tile.drawx(), tile.drawy(), link.drawx(), link.drawy()) <= Math.max(laserRange * tilesize,
|
||||||
((PowerNode) link.block()).laserRange * tilesize)
|
((PowerNode) link.block()).laserRange * tilesize)
|
||||||
+ (link.block().size - 1) * tilesize / 2f + (tile.block().size - 1) * tilesize / 2f &&
|
+ (link.block().size - 1) * tilesize / 2f + (tile.block().size - 1) * tilesize / 2f &&
|
||||||
(!checkMaxNodes || (oe.power.links.size < ((PowerNode) link.block()).maxNodes || oe.power.links.contains(tile.pos())));
|
(!checkMaxNodes || (oe.power.links.size < ((PowerNode) link.block()).maxNodes || oe.power.links.contains(tile.pos())));
|
||||||
}else{
|
}else{
|
||||||
return Vector2.dst(tile.drawx(), tile.drawy(), link.drawx(), link.drawy())
|
return Mathf.dst(tile.drawx(), tile.drawy(), link.drawx(), link.drawy())
|
||||||
<= laserRange * tilesize + (link.block().size - 1) * tilesize;
|
<= laserRange * tilesize + (link.block().size - 1) * tilesize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user