Cached Block#offset()
This commit is contained in:
@@ -62,7 +62,7 @@ public class BaseRegistry{
|
|||||||
|
|
||||||
//calculate averages
|
//calculate averages
|
||||||
if(tile.block instanceof Drill || tile.block instanceof Pump){
|
if(tile.block instanceof Drill || tile.block instanceof Pump){
|
||||||
Tmp.v1.add(tile.x*tilesize + tile.block.offset(), tile.y*tilesize + tile.block.offset());
|
Tmp.v1.add(tile.x*tilesize + tile.block.offset, tile.y*tilesize + tile.block.offset);
|
||||||
drills ++;
|
drills ++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,14 +112,14 @@ public class MapRenderer implements Disposable{
|
|||||||
|
|
||||||
if(wall.rotate){
|
if(wall.rotate){
|
||||||
mesh.draw(idxWall, region,
|
mesh.draw(idxWall, region,
|
||||||
wx * tilesize + wall.offset(), wy * tilesize + wall.offset(),
|
wx * tilesize + wall.offset, wy * tilesize + wall.offset,
|
||||||
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, tile.rotdeg() - 90);
|
region.getWidth() * Draw.scl, region.getHeight() * Draw.scl, tile.rotdeg() - 90);
|
||||||
}else{
|
}else{
|
||||||
float width = region.getWidth() * Draw.scl, height = region.getHeight() * Draw.scl;
|
float width = region.getWidth() * Draw.scl, height = region.getHeight() * Draw.scl;
|
||||||
|
|
||||||
mesh.draw(idxWall, region,
|
mesh.draw(idxWall, region,
|
||||||
wx * tilesize + wall.offset() + (tilesize - width) / 2f,
|
wx * tilesize + wall.offset + (tilesize - width) / 2f,
|
||||||
wy * tilesize + wall.offset() + (tilesize - height) / 2f,
|
wy * tilesize + wall.offset + (tilesize - height) / 2f,
|
||||||
width, height);
|
width, height);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -87,7 +87,7 @@ abstract class PayloadComp implements Posc, Rotc, Hitboxc{
|
|||||||
/** @return whether the tile has been successfully placed. */
|
/** @return whether the tile has been successfully placed. */
|
||||||
boolean dropBlock(BlockPayload payload){
|
boolean dropBlock(BlockPayload payload){
|
||||||
Building tile = payload.entity;
|
Building tile = payload.entity;
|
||||||
int tx = Vars.world.toTile(x - tile.block().offset()), ty = Vars.world.toTile(y - tile.block().offset());
|
int tx = Vars.world.toTile(x - tile.block().offset), ty = Vars.world.toTile(y - tile.block().offset);
|
||||||
Tile on = Vars.world.tile(tx, ty);
|
Tile on = Vars.world.tile(tx, ty);
|
||||||
if(on != null && Build.validPlace(tile.block(), tile.team(), tx, ty, tile.rotation())){
|
if(on != null && Build.validPlace(tile.block(), tile.team(), tx, ty, tile.rotation())){
|
||||||
int rot = (int)((rotation + 45f) / 90f) % 4;
|
int rot = (int)((rotation + 45f) / 90f) % 4;
|
||||||
|
|||||||
@@ -117,11 +117,11 @@ public class BuildPlan{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float drawx(){
|
public float drawx(){
|
||||||
return x*tilesize + block.offset();
|
return x*tilesize + block.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public float drawy(){
|
public float drawy(){
|
||||||
return y*tilesize + block.offset();
|
return y*tilesize + block.offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
public BuildPlan configure(Object config){
|
public BuildPlan configure(Object config){
|
||||||
|
|||||||
@@ -601,7 +601,7 @@ public class Schematics implements Loadable{
|
|||||||
});
|
});
|
||||||
|
|
||||||
//rotate actual request, centered on its multiblock position
|
//rotate actual request, centered on its multiblock position
|
||||||
float wx = (req.x - ox) * tilesize + req.block.offset(), wy = (req.y - oy) * tilesize + req.block.offset();
|
float wx = (req.x - ox) * tilesize + req.block.offset, wy = (req.y - oy) * tilesize + req.block.offset;
|
||||||
float x = wx;
|
float x = wx;
|
||||||
if(direction >= 0){
|
if(direction >= 0){
|
||||||
wx = -wy;
|
wx = -wy;
|
||||||
@@ -610,8 +610,8 @@ public class Schematics implements Loadable{
|
|||||||
wx = wy;
|
wx = wy;
|
||||||
wy = -x;
|
wy = -x;
|
||||||
}
|
}
|
||||||
req.x = (short)(world.toTile(wx - req.block.offset()) + ox);
|
req.x = (short)(world.toTile(wx - req.block.offset) + ox);
|
||||||
req.y = (short)(world.toTile(wy - req.block.offset()) + oy);
|
req.y = (short)(world.toTile(wy - req.block.offset) + oy);
|
||||||
req.rotation = (byte)Mathf.mod(req.rotation + direction, 4);
|
req.rotation = (byte)Mathf.mod(req.rotation + direction, 4);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -114,11 +114,11 @@ public class BlockRenderer implements Disposable{
|
|||||||
if(brokenFade > 0.001f){
|
if(brokenFade > 0.001f){
|
||||||
for(BlockPlan block : state.teams.get(player.team()).blocks){
|
for(BlockPlan block : state.teams.get(player.team()).blocks){
|
||||||
Block b = content.block(block.block);
|
Block b = content.block(block.block);
|
||||||
if(!camera.bounds(Tmp.r1).grow(tilesize * 2f).overlaps(Tmp.r2.setSize(b.size * tilesize).setCenter(block.x * tilesize + b.offset(), block.y * tilesize + b.offset()))) continue;
|
if(!camera.bounds(Tmp.r1).grow(tilesize * 2f).overlaps(Tmp.r2.setSize(b.size * tilesize).setCenter(block.x * tilesize + b.offset, block.y * tilesize + b.offset))) continue;
|
||||||
|
|
||||||
Draw.alpha(0.33f * brokenFade);
|
Draw.alpha(0.33f * brokenFade);
|
||||||
Draw.mixcol(Color.white, 0.2f + Mathf.absin(Time.globalTime(), 6f, 0.2f));
|
Draw.mixcol(Color.white, 0.2f + Mathf.absin(Time.globalTime(), 6f, 0.2f));
|
||||||
Draw.rect(b.icon(Cicon.full), block.x * tilesize + b.offset(), block.y * tilesize + b.offset(), b.rotate ? block.rotation * 90 : 0f);
|
Draw.rect(b.icon(Cicon.full), block.x * tilesize + b.offset, block.y * tilesize + b.offset, b.rotate ? block.rotation * 90 : 0f);
|
||||||
}
|
}
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -68,8 +68,8 @@ public class Drawf{
|
|||||||
Point2 p = Geometry.d8edge[i];
|
Point2 p = Geometry.d8edge[i];
|
||||||
float offset = -Math.max(block.size - 1, 0) / 2f * tilesize;
|
float offset = -Math.max(block.size - 1, 0) / 2f * tilesize;
|
||||||
Draw.rect("block-select",
|
Draw.rect("block-select",
|
||||||
x*tilesize + block.offset() + offset * p.x,
|
x*tilesize + block.offset + offset * p.x,
|
||||||
y*tilesize + block.offset() + offset * p.y, i * 90);
|
y*tilesize + block.offset + offset * p.y, i * 90);
|
||||||
}
|
}
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -431,7 +431,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
});
|
});
|
||||||
|
|
||||||
//rotate actual request, centered on its multiblock position
|
//rotate actual request, centered on its multiblock position
|
||||||
float wx = (req.x - ox) * tilesize + req.block.offset(), wy = (req.y - oy) * tilesize + req.block.offset();
|
float wx = (req.x - ox) * tilesize + req.block.offset, wy = (req.y - oy) * tilesize + req.block.offset;
|
||||||
float x = wx;
|
float x = wx;
|
||||||
if(direction >= 0){
|
if(direction >= 0){
|
||||||
wx = -wy;
|
wx = -wy;
|
||||||
@@ -440,8 +440,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
wx = wy;
|
wx = wy;
|
||||||
wy = -x;
|
wy = -x;
|
||||||
}
|
}
|
||||||
req.x = world.toTile(wx - req.block.offset()) + ox;
|
req.x = world.toTile(wx - req.block.offset) + ox;
|
||||||
req.y = world.toTile(wy - req.block.offset()) + oy;
|
req.y = world.toTile(wy - req.block.offset) + oy;
|
||||||
req.rotation = Mathf.mod(req.rotation + direction, 4);
|
req.rotation = Mathf.mod(req.rotation + direction, 4);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -450,12 +450,12 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
int origin = (x ? schemOriginX() : schemOriginY()) * tilesize;
|
int origin = (x ? schemOriginX() : schemOriginY()) * tilesize;
|
||||||
|
|
||||||
requests.each(req -> {
|
requests.each(req -> {
|
||||||
float value = -((x ? req.x : req.y) * tilesize - origin + req.block.offset()) + origin;
|
float value = -((x ? req.x : req.y) * tilesize - origin + req.block.offset) + origin;
|
||||||
|
|
||||||
if(x){
|
if(x){
|
||||||
req.x = (int)((value - req.block.offset()) / tilesize);
|
req.x = (int)((value - req.block.offset) / tilesize);
|
||||||
}else{
|
}else{
|
||||||
req.y = (int)((value - req.block.offset()) / tilesize);
|
req.y = (int)((value - req.block.offset) / tilesize);
|
||||||
}
|
}
|
||||||
|
|
||||||
req.pointConfig(p -> {
|
req.pointConfig(p -> {
|
||||||
@@ -505,10 +505,10 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
if(!req.breaking){
|
if(!req.breaking){
|
||||||
r1.setSize(req.block.size * tilesize);
|
r1.setSize(req.block.size * tilesize);
|
||||||
r1.setCenter(other.worldx() + req.block.offset(), other.worldy() + req.block.offset());
|
r1.setCenter(other.worldx() + req.block.offset, other.worldy() + req.block.offset);
|
||||||
}else{
|
}else{
|
||||||
r1.setSize(other.block().size * tilesize);
|
r1.setSize(other.block().size * tilesize);
|
||||||
r1.setCenter(other.worldx() + other.block().offset(), other.worldy() + other.block().offset());
|
r1.setCenter(other.worldx() + other.block().offset, other.worldy() + other.block().offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
return r2.overlaps(r1);
|
return r2.overlaps(r1);
|
||||||
@@ -797,10 +797,6 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
&& tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= miningRange;
|
&& tile.block() == Blocks.air && player.dst(tile.worldx(), tile.worldy()) <= miningRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
Building entAt(float x, float y){
|
|
||||||
return world.build(tileX(x), tileY(y));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Returns the tile at the specified MOUSE coordinates. */
|
/** Returns the tile at the specified MOUSE coordinates. */
|
||||||
Tile tileAt(float x, float y){
|
Tile tileAt(float x, float y){
|
||||||
return world.tile(tileX(x), tileY(y));
|
return world.tile(tileX(x), tileY(y));
|
||||||
@@ -817,7 +813,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
int tileX(float cursorX){
|
int tileX(float cursorX){
|
||||||
Vec2 vec = Core.input.mouseWorld(cursorX, 0);
|
Vec2 vec = Core.input.mouseWorld(cursorX, 0);
|
||||||
if(selectedBlock()){
|
if(selectedBlock()){
|
||||||
vec.sub(block.offset(), block.offset());
|
vec.sub(block.offset, block.offset);
|
||||||
}
|
}
|
||||||
return world.toTile(vec.x);
|
return world.toTile(vec.x);
|
||||||
}
|
}
|
||||||
@@ -825,7 +821,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
int tileY(float cursorY){
|
int tileY(float cursorY){
|
||||||
Vec2 vec = Core.input.mouseWorld(0, cursorY);
|
Vec2 vec = Core.input.mouseWorld(0, cursorY);
|
||||||
if(selectedBlock()){
|
if(selectedBlock()){
|
||||||
vec.sub(block.offset(), block.offset());
|
vec.sub(block.offset, block.offset);
|
||||||
}
|
}
|
||||||
return world.toTile(vec.y);
|
return world.toTile(vec.y);
|
||||||
}
|
}
|
||||||
@@ -989,15 +985,15 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
|
|
||||||
Draw.color(!valid ? Pal.removeBack : Pal.accentBack);
|
Draw.color(!valid ? Pal.removeBack : Pal.accentBack);
|
||||||
Draw.rect(Core.atlas.find("place-arrow"),
|
Draw.rect(Core.atlas.find("place-arrow"),
|
||||||
x * tilesize + block.offset() + dx*trns,
|
x * tilesize + block.offset + dx*trns,
|
||||||
y * tilesize + block.offset() - 1 + dy*trns,
|
y * tilesize + block.offset - 1 + dy*trns,
|
||||||
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
|
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
|
||||||
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
|
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
|
||||||
|
|
||||||
Draw.color(!valid ? Pal.remove : Pal.accent);
|
Draw.color(!valid ? Pal.remove : Pal.accent);
|
||||||
Draw.rect(Core.atlas.find("place-arrow"),
|
Draw.rect(Core.atlas.find("place-arrow"),
|
||||||
x * tilesize + block.offset() + dx*trns,
|
x * tilesize + block.offset + dx*trns,
|
||||||
y * tilesize + block.offset() + dy*trns,
|
y * tilesize + block.offset + dy*trns,
|
||||||
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
|
Core.atlas.find("place-arrow").getWidth() * Draw.scl,
|
||||||
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
|
Core.atlas.find("place-arrow").getHeight() * Draw.scl, rotation * 90 - 90);
|
||||||
}
|
}
|
||||||
@@ -1054,7 +1050,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
for(int i = 0; i < points.size; i++){
|
for(int i = 0; i < points.size; i++){
|
||||||
Point2 point = points.get(i);
|
Point2 point = points.get(i);
|
||||||
|
|
||||||
if(block != null && Tmp.r2.setSize(block.size * tilesize).setCenter(point.x * tilesize + block.offset(), point.y * tilesize + block.offset()).overlaps(Tmp.r3)){
|
if(block != null && Tmp.r2.setSize(block.size * tilesize).setCenter(point.x * tilesize + block.offset, point.y * tilesize + block.offset).overlaps(Tmp.r3)){
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1069,7 +1065,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
|||||||
line.last = next == null;
|
line.last = next == null;
|
||||||
cons.get(line);
|
cons.get(line);
|
||||||
|
|
||||||
Tmp.r3.setSize(block.size * tilesize).setCenter(point.x * tilesize + block.offset(), point.y * tilesize + block.offset());
|
Tmp.r3.setSize(block.size * tilesize).setCenter(point.x * tilesize + block.offset, point.y * tilesize + block.offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
/** Returns whether this block overlaps any selection requests. */
|
/** Returns whether this block overlaps any selection requests. */
|
||||||
boolean checkOverlapPlacement(int x, int y, Block block){
|
boolean checkOverlapPlacement(int x, int y, Block block){
|
||||||
r2.setSize(block.size * tilesize);
|
r2.setSize(block.size * tilesize);
|
||||||
r2.setCenter(x * tilesize + block.offset(), y * tilesize + block.offset());
|
r2.setCenter(x * tilesize + block.offset, y * tilesize + block.offset);
|
||||||
|
|
||||||
for(BuildPlan req : selectRequests){
|
for(BuildPlan req : selectRequests){
|
||||||
Tile other = req.tile();
|
Tile other = req.tile();
|
||||||
@@ -103,7 +103,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
if(other == null || req.breaking) continue;
|
if(other == null || req.breaking) continue;
|
||||||
|
|
||||||
r1.setSize(req.block.size * tilesize);
|
r1.setSize(req.block.size * tilesize);
|
||||||
r1.setCenter(other.worldx() + req.block.offset(), other.worldy() + req.block.offset());
|
r1.setCenter(other.worldx() + req.block.offset, other.worldy() + req.block.offset);
|
||||||
|
|
||||||
if(r2.overlaps(r1)){
|
if(r2.overlaps(r1)){
|
||||||
return true;
|
return true;
|
||||||
@@ -116,7 +116,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
if(other == null || req.breaking) continue;
|
if(other == null || req.breaking) continue;
|
||||||
|
|
||||||
r1.setSize(req.block.size * tilesize);
|
r1.setSize(req.block.size * tilesize);
|
||||||
r1.setCenter(other.worldx() + req.block.offset(), other.worldy() + req.block.offset());
|
r1.setCenter(other.worldx() + req.block.offset, other.worldy() + req.block.offset);
|
||||||
|
|
||||||
if(r2.overlaps(r1)){
|
if(r2.overlaps(r1)){
|
||||||
return true;
|
return true;
|
||||||
@@ -137,11 +137,11 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
if(!req.breaking){
|
if(!req.breaking){
|
||||||
r1.setSize(req.block.size * tilesize);
|
r1.setSize(req.block.size * tilesize);
|
||||||
r1.setCenter(other.worldx() + req.block.offset(), other.worldy() + req.block.offset());
|
r1.setCenter(other.worldx() + req.block.offset, other.worldy() + req.block.offset);
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
r1.setSize(other.block().size * tilesize);
|
r1.setSize(other.block().size * tilesize);
|
||||||
r1.setCenter(other.worldx() + other.block().offset(), other.worldy() + other.block().offset());
|
r1.setCenter(other.worldx() + other.block().offset, other.worldy() + other.block().offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(r2.overlaps(r1)) return req;
|
if(r2.overlaps(r1)) return req;
|
||||||
@@ -538,7 +538,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
Fx.tapBlock.at(cursor.worldx(), cursor.worldy(), 1f);
|
Fx.tapBlock.at(cursor.worldx(), cursor.worldy(), 1f);
|
||||||
}else if(block != null){
|
}else if(block != null){
|
||||||
updateLine(lineStartX, lineStartY, cursor.x, cursor.y);
|
updateLine(lineStartX, lineStartY, cursor.x, cursor.y);
|
||||||
Fx.tapBlock.at(cursor.worldx() + block.offset(), cursor.worldy() + block.offset(), block.size);
|
Fx.tapBlock.at(cursor.worldx() + block.offset, cursor.worldy() + block.offset, block.size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ public class Placement{
|
|||||||
public static NormalizeDrawResult normalizeDrawArea(Block block, int startx, int starty, int endx, int endy, boolean snap, int maxLength, float scaling){
|
public static NormalizeDrawResult normalizeDrawArea(Block block, int startx, int starty, int endx, int endy, boolean snap, int maxLength, float scaling){
|
||||||
normalizeArea(startx, starty, endx, endy, 0, snap, maxLength);
|
normalizeArea(startx, starty, endx, endy, 0, snap, maxLength);
|
||||||
|
|
||||||
float offset = block.offset();
|
float offset = block.offset;
|
||||||
|
|
||||||
drawResult.x = result.x * tilesize;
|
drawResult.x = result.x * tilesize;
|
||||||
drawResult.y = result.y * tilesize;
|
drawResult.y = result.y * tilesize;
|
||||||
|
|||||||
@@ -96,6 +96,8 @@ public class Block extends UnlockableContent{
|
|||||||
public boolean floating = false;
|
public boolean floating = false;
|
||||||
/** multiblock size */
|
/** multiblock size */
|
||||||
public int size = 1;
|
public int size = 1;
|
||||||
|
/** multiblock offset */
|
||||||
|
public float offset = 0f;
|
||||||
/** Whether to draw this block in the expanded draw range. */
|
/** Whether to draw this block in the expanded draw range. */
|
||||||
public boolean expanded = false;
|
public boolean expanded = false;
|
||||||
/** Max of timers used. */
|
/** Max of timers used. */
|
||||||
@@ -242,7 +244,7 @@ public class Block extends UnlockableContent{
|
|||||||
float width = layout.width;
|
float width = layout.width;
|
||||||
|
|
||||||
font.setColor(color);
|
font.setColor(color);
|
||||||
float dx = x * tilesize + offset(), dy = y * tilesize + offset() + size * tilesize / 2f + 3;
|
float dx = x * tilesize + offset, dy = y * tilesize + offset + size * tilesize / 2f + 3;
|
||||||
font.draw(text, dx, dy + layout.height + 1, Align.center);
|
font.draw(text, dx, dy + layout.height + 1, Align.center);
|
||||||
dy -= 1f;
|
dy -= 1f;
|
||||||
Lines.stroke(2f, Color.darkGray);
|
Lines.stroke(2f, Color.darkGray);
|
||||||
@@ -470,13 +472,8 @@ public class Block extends UnlockableContent{
|
|||||||
return entityType.get();
|
return entityType.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Offset for placing and drawing multiblocks. */
|
|
||||||
public float offset(){
|
|
||||||
return ((size + 1) % 2) * tilesize / 2f;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Rect bounds(int x, int y, Rect rect){
|
public Rect bounds(int x, int y, Rect rect){
|
||||||
return rect.setSize(size * tilesize).setCenter(x * tilesize + offset(), y * tilesize + offset());
|
return rect.setSize(size * tilesize).setCenter(x * tilesize + offset, y * tilesize + offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMultiblock(){
|
public boolean isMultiblock(){
|
||||||
@@ -604,6 +601,8 @@ public class Block extends UnlockableContent{
|
|||||||
health = size * size * 40;
|
health = size * size * 40;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
offset = ((size + 1) % 2) * tilesize / 2f;
|
||||||
|
|
||||||
buildCost = 0f;
|
buildCost = 0f;
|
||||||
for(ItemStack stack : requirements){
|
for(ItemStack stack : requirements){
|
||||||
buildCost += stack.amount * stack.item.cost;
|
buildCost += stack.amount * stack.item.cost;
|
||||||
|
|||||||
@@ -73,11 +73,11 @@ public class Build{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if((type.solid || type.solidifes) && Units.anyEntities(x * tilesize + type.offset() - type.size*tilesize/2f, y * tilesize + type.offset() - type.size*tilesize/2f, type.size * tilesize, type.size*tilesize)){
|
if((type.solid || type.solidifes) && Units.anyEntities(x * tilesize + type.offset - type.size*tilesize/2f, y * tilesize + type.offset - type.size*tilesize/2f, type.size * tilesize, type.size*tilesize)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(state.teams.eachEnemyCore(team, core -> Mathf.dst(x * tilesize + type.offset(), y * tilesize + type.offset(), core.x, core.y) < state.rules.enemyCoreBuildRadius + type.size * tilesize / 2f)){
|
if(state.teams.eachEnemyCore(team, core -> Mathf.dst(x * tilesize + type.offset, y * tilesize + type.offset, core.x, core.y) < state.rules.enemyCoreBuildRadius + type.size * tilesize / 2f)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -121,11 +121,11 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float drawx(){
|
public float drawx(){
|
||||||
return block().offset() + worldx();
|
return block().offset + worldx();
|
||||||
}
|
}
|
||||||
|
|
||||||
public float drawy(){
|
public float drawy(){
|
||||||
return block().offset() + worldy();
|
return block().offset + worldy();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isDarkened(){
|
public boolean isDarkened(){
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class MendProjector 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){
|
||||||
Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent);
|
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class MendEntity extends Building{
|
public class MendEntity extends Building{
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ public class OverdriveProjector 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){
|
||||||
Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent);
|
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class PointDefenseTurret 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){
|
||||||
Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent);
|
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ public class TractorBeamTurret 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){
|
||||||
Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.accent);
|
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -128,7 +128,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){
|
||||||
Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.placing);
|
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.placing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static abstract class AmmoEntry{
|
public static abstract class AmmoEntry{
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ public class MassDriver extends Block{
|
|||||||
|
|
||||||
//if so, draw a dotted line towards it while it is in range
|
//if so, draw a dotted line towards it while it is in range
|
||||||
float sin = Mathf.absin(Time.time(), 6f, 1f);
|
float sin = Mathf.absin(Time.time(), 6f, 1f);
|
||||||
Tmp.v1.set(x * tilesize + offset(), y * tilesize + offset()).sub(selected.x, selected.y).limit((size / 2f + 1) * tilesize + sin + 0.5f);
|
Tmp.v1.set(x * tilesize + offset, y * tilesize + offset).sub(selected.x, selected.y).limit((size / 2f + 1) * tilesize + sin + 0.5f);
|
||||||
float x2 = x * tilesize - Tmp.v1.x, y2 = y * tilesize - Tmp.v1.y,
|
float x2 = x * tilesize - Tmp.v1.x, y2 = y * tilesize - Tmp.v1.y,
|
||||||
x1 = selected.x + Tmp.v1.x, y1 = selected.y + Tmp.v1.y;
|
x1 = selected.x + Tmp.v1.x, y1 = selected.y + Tmp.v1.y;
|
||||||
int segs = (int)(selected.dst(x * tilesize, y * tilesize) / tilesize);
|
int segs = (int)(selected.dst(x * tilesize, y * tilesize) / tilesize);
|
||||||
|
|||||||
@@ -119,7 +119,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
|
|
||||||
Lines.stroke(1f);
|
Lines.stroke(1f);
|
||||||
Draw.color(Pal.placing);
|
Draw.color(Pal.placing);
|
||||||
Drawf.circles(x * tilesize + offset(), y * tilesize + offset(), laserRange * tilesize);
|
Drawf.circles(x * tilesize + offset, y * tilesize + offset, laserRange * tilesize);
|
||||||
|
|
||||||
getPotentialLinks(tile, other -> {
|
getPotentialLinks(tile, other -> {
|
||||||
Drawf.square(other.x, other.y, other.block().size * tilesize / 2f + 2f, Pal.place);
|
Drawf.square(other.x, other.y, other.block().size * tilesize / 2f + 2f, Pal.place);
|
||||||
@@ -167,13 +167,13 @@ public class PowerNode extends PowerBlock{
|
|||||||
|
|
||||||
public boolean overlaps(@Nullable Tile src, @Nullable Tile other){
|
public boolean overlaps(@Nullable Tile src, @Nullable Tile other){
|
||||||
if(src == null || other == null) return true;
|
if(src == null || other == null) return true;
|
||||||
return Intersector.overlaps(Tmp.cr1.set(src.worldx() + offset(), src.worldy() + offset(), laserRange * tilesize), Tmp.r1.setSize(size * tilesize).setCenter(other.worldx() + offset(), other.worldy() + offset()));
|
return Intersector.overlaps(Tmp.cr1.set(src.worldx() + offset, src.worldy() + offset, laserRange * tilesize), Tmp.r1.setSize(size * tilesize).setCenter(other.worldx() + offset, other.worldy() + offset));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void getPotentialLinks(Tile tile, Cons<Building> others){
|
protected void getPotentialLinks(Tile tile, Cons<Building> others){
|
||||||
Boolf<Building> valid = other -> other != null && other.tile() != tile && other.power() != null &&
|
Boolf<Building> valid = other -> other != null && other.tile() != tile && other.power() != null &&
|
||||||
((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) &&
|
((!other.block().outputsPower && other.block().consumesPower) || (other.block().outputsPower && !other.block().consumesPower) || other.block() instanceof PowerNode) &&
|
||||||
overlaps(tile.x * tilesize + offset(), tile.y * tilesize + offset(), other.tile(), laserRange * tilesize) && other.team() == player.team()
|
overlaps(tile.x * tilesize + offset, tile.y * tilesize + offset, other.tile(), laserRange * tilesize) && other.team() == player.team()
|
||||||
&& !other.proximity().contains(e -> e.tile() == tile) && !graphs.contains(other.power().graph);
|
&& !other.proximity().contains(e -> e.tile() == tile) && !graphs.contains(other.power().graph);
|
||||||
|
|
||||||
tempTileEnts.clear();
|
tempTileEnts.clear();
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ public class Drill extends Block{
|
|||||||
|
|
||||||
if(returnItem != null){
|
if(returnItem != null){
|
||||||
float width = drawPlaceText(Core.bundle.formatFloat("bar.drillspeed", 60f / (drillTime + hardnessDrillMultiplier * returnItem.hardness) * returnCount, 2), x, y, valid);
|
float width = drawPlaceText(Core.bundle.formatFloat("bar.drillspeed", 60f / (drillTime + hardnessDrillMultiplier * returnItem.hardness) * returnCount, 2), x, y, valid);
|
||||||
float dx = x * tilesize + offset() - width/2f - 4f, dy = y * tilesize + offset() + size * tilesize / 2f + 5;
|
float dx = x * tilesize + offset - width/2f - 4f, dy = y * tilesize + offset + size * tilesize / 2f + 5;
|
||||||
Draw.mixcol(Color.darkGray, 1f);
|
Draw.mixcol(Color.darkGray, 1f);
|
||||||
Draw.rect(returnItem.icon(Cicon.small), dx, dy - 1);
|
Draw.rect(returnItem.icon(Cicon.small), dx, dy - 1);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ public class Pump extends LiquidBlock{
|
|||||||
|
|
||||||
if(liquidDrop != null){
|
if(liquidDrop != null){
|
||||||
float width = drawPlaceText(Core.bundle.formatFloat("bar.pumpspeed", tiles * pumpAmount / size / size * 60f, 0), x, y, valid);
|
float width = drawPlaceText(Core.bundle.formatFloat("bar.pumpspeed", tiles * pumpAmount / size / size * 60f, 0), x, y, valid);
|
||||||
float dx = x * tilesize + offset() - width/2f - 4f, dy = y * tilesize + offset() + size * tilesize / 2f + 5;
|
float dx = x * tilesize + offset - width/2f - 4f, dy = y * tilesize + offset + size * tilesize / 2f + 5;
|
||||||
Draw.mixcol(Color.darkGray, 1f);
|
Draw.mixcol(Color.darkGray, 1f);
|
||||||
Draw.rect(liquidDrop.icon(Cicon.small), dx, dy - 1);
|
Draw.rect(liquidDrop.icon(Cicon.small), dx, dy - 1);
|
||||||
Draw.reset();
|
Draw.reset();
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ public class RepairPoint 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){
|
||||||
Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), repairRadius, Pal.accent);
|
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, repairRadius, Pal.accent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class ResupplyPoint 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){
|
||||||
Drawf.dashCircle(x * tilesize + offset(), y * tilesize + offset(), range, Pal.placing);
|
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, range, Pal.placing);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ResupplyPointEntity extends Building{
|
public class ResupplyPointEntity extends Building{
|
||||||
|
|||||||
Reference in New Issue
Block a user