Fixed #2040 / Fixed #2039 / Fixed #2038 / Fixed #2037 / Fixed #2035

This commit is contained in:
Anuken
2020-05-12 09:34:26 -04:00
parent 7f3f1d7d76
commit f6d8658ee2
16 changed files with 111 additions and 113 deletions

View File

@@ -184,39 +184,8 @@ abstract class TileComp implements Posc, Teamc, Healthc, Tilec, Timerc, QuadTree
return relativeTo(tile.x, tile.y);
}
/** Return relative rotation to a coordinate. Returns -1 if the coordinate is not near this tile. */
public byte relativeTo(int cx, int cy){
int x = tile.x, y = tile.y;
if(x == cx && y == cy - 1) return 1;
if(x == cx && y == cy + 1) return 3;
if(x == cx - 1 && y == cy) return 0;
if(x == cx + 1 && y == cy) return 2;
return -1;
}
public byte absoluteRelativeTo(int cx, int cy){
int x = tile.x, y = tile.y;
//very straightforward for odd sizes
if(block.size % 2 == 1){
if(Math.abs(x - cx) > Math.abs(y - cy)){
if(x <= cx - 1) return 0;
if(x >= cx + 1) return 2;
}else{
if(y <= cy - 1) return 1;
if(y >= cy + 1) return 3;
}
}else{ //need offsets here
if(Math.abs(x - cx + 0.5f) > Math.abs(y - cy + 0.5f)){
if(x+0.5f <= cx - 1) return 0;
if(x+0.5f >= cx + 1) return 2;
}else{
if(y+0.5f <= cy - 1) return 1;
if(y+0.5f >= cy + 1) return 3;
}
}
return -1;
return tile.absoluteRelativeTo(cx, cy);
}
public @Nullable Tilec front(){

View File

@@ -153,8 +153,8 @@ public class DesktopInput extends InputHandler{
if(block.saveConfig && block.lastConfig != null){
brequest.set(cursorX, cursorY, rotation, block);
brequest.config = block.lastConfig;
block.drawRequestConfig(brequest, allRequests());
brequest.config = null;
}
}

View File

@@ -508,7 +508,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
protected void drawRequest(BuildRequest request){
request.block.drawRequest(request, allRequests(), validPlace(request.x, request.y, request.block, request.rotation));
if(request.block.saveConfig && request.block.lastConfig != null){
if(request.block.saveConfig && request.block.lastConfig != null && !request.hasConfig){
Object conf = request.config;
request.config = request.block.lastConfig;
request.block.drawRequestConfig(request, allRequests());

View File

@@ -11,6 +11,7 @@ import arc.scene.actions.*;
import arc.scene.event.*;
import arc.scene.ui.*;
import arc.scene.ui.layout.*;
import arc.scene.ui.layout.Stack;
import arc.struct.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
@@ -22,6 +23,8 @@ import mindustry.net.*;
import mindustry.type.*;
import mindustry.ui.*;
import java.util.*;
import static mindustry.Vars.*;
public class BlockInventoryFragment extends Fragment{
@@ -94,6 +97,9 @@ public class BlockInventoryFragment extends Fragment{
private void rebuild(boolean actions){
IntSet container = new IntSet();
Arrays.fill(shrinkHoldTimes, 0);
holdTime = emptyTime = 0f;
table.clearChildren();
table.clearActions();
table.background(Tex.inventory);

View File

@@ -80,18 +80,26 @@ public class Tile implements Position, QuadTreeObject{
}
public byte absoluteRelativeTo(int cx, int cy){
if(x == cx && y <= cy - 1) return 1;
if(x == cx && y >= cy + 1) return 3;
if(x <= cx - 1 && y == cy) return 0;
if(x >= cx + 1 && y == cy) return 2;
return -1;
}
public static byte absoluteRelativeTo(int x, int y, int cx, int cy){
if(x == cx && y <= cy - 1) return 1;
if(x == cx && y >= cy + 1) return 3;
if(x <= cx - 1 && y == cy) return 0;
if(x >= cx + 1 && y == cy) return 2;
//very straightforward for odd sizes
if(block.size % 2 == 1){
if(Math.abs(x - cx) > Math.abs(y - cy)){
if(x <= cx - 1) return 0;
if(x >= cx + 1) return 2;
}else{
if(y <= cy - 1) return 1;
if(y >= cy + 1) return 3;
}
}else{ //need offsets here
if(Math.abs(x - cx + 0.5f) > Math.abs(y - cy + 0.5f)){
if(x+0.5f <= cx - 1) return 0;
if(x+0.5f >= cx + 1) return 2;
}else{
if(y+0.5f <= cy - 1) return 1;
if(y+0.5f >= cy + 1) return 3;
}
}
return -1;
}

View File

@@ -237,7 +237,7 @@ public class ItemBridge extends Block{
float opacity = Core.settings.getInt("bridgeopacity") / 100f;
if(Mathf.zero(opacity)) return;
int i = tile.absoluteRelativeTo(other.x, other.y);
int i = relativeTo(other.x, other.y);
Draw.color(Color.white, Color.black, Mathf.absin(Time.time(), 6f, 0.07f));
Draw.alpha(Math.max(uptime, 0.25f) * opacity);
@@ -275,8 +275,8 @@ public class ItemBridge extends Block{
Tile other = world.tile(link);
if(linkValid(tile, other)){
int rel = tile.absoluteRelativeTo(other.x, other.y);
int rel2 = tile.relativeTo(source.tileX(), source.tileY());
int rel = relativeTo(other.x, other.y);
int rel2 = relativeTo(source.tileX(), source.tileY());
if(rel == rel2) return false;
}else{
@@ -292,21 +292,21 @@ public class ItemBridge extends Block{
Tile other = world.tile(link);
if(!linkValid(tile, other)){
Tile edge = Edges.getFacingEdge(to.tile(), tile);
int i = tile.absoluteRelativeTo(edge.x, edge.y);
int i = relativeTo(edge.x, edge.y);
IntSetIterator it = incoming.iterator();
while(it.hasNext){
int v = it.next();
if(tile.absoluteRelativeTo(Point2.x(v), Point2.y(v)) == i){
if(relativeTo(Point2.x(v), Point2.y(v)) == i){
return false;
}
}
return true;
}
int rel = tile.absoluteRelativeTo(other.x, other.y);
int rel2 = tile.relativeTo(to.tileX(), to.tileY());
int rel = relativeTo(other.x, other.y);
int rel2 = relativeTo(to.tileX(), to.tileY());
return rel != rel2;
}
@@ -318,8 +318,8 @@ public class ItemBridge extends Block{
Tile other = world.tile(link);
if(linkValid(tile, other)){
int rel = tile.absoluteRelativeTo(other.x, other.y);
int rel2 = tile.relativeTo(source.tileX(), source.tileY());
int rel = relativeTo(other.x, other.y);
int rel2 = relativeTo(source.tileX(), source.tileY());
if(rel == rel2) return false;
}else if(!(source.block() instanceof ItemBridge && ((ItemBridgeEntity)source).link == tile.pos())){
@@ -334,21 +334,21 @@ public class ItemBridge extends Block{
Tile other = world.tile(link);
if(!linkValid(tile, other)){
Tile edge = Edges.getFacingEdge(to.tile(), tile);
int i = tile.absoluteRelativeTo(edge.x, edge.y);
int i = relativeTo(edge.x, edge.y);
IntSetIterator it = incoming.iterator();
while(it.hasNext){
int v = it.next();
if(tile.absoluteRelativeTo(Point2.x(v), Point2.y(v)) == i){
if(relativeTo(Point2.x(v), Point2.y(v)) == i){
return false;
}
}
return true;
}
int rel = tile.absoluteRelativeTo(other.x, other.y);
int rel2 = tile.relativeTo(to.tileX(), to.tileY());
int rel = relativeTo(other.x, other.y);
int rel2 = relativeTo(to.tileX(), to.tileY());
return rel != rel2;
}

View File

@@ -63,13 +63,13 @@ public class Junction extends Block{
@Override
public void handleItem(Tilec source, Item item){
int relative = source.relativeTo(tile.x, tile.y);
int relative = source.relativeTo(tile);
buffer.accept(relative, item);
}
@Override
public boolean acceptItem(Tilec source, Item item){
int relative = source.relativeTo(tile.x, tile.y);
int relative = source.relativeTo(tile);
if(relative == -1 || !buffer.accepts(relative)) return false;
Tilec to = nearby(relative);

View File

@@ -92,7 +92,7 @@ public class Sorter extends Block{
}
Tilec getTileTarget(Item item, Tilec source, boolean flip){
int dir = source.absoluteRelativeTo(tile.x, tile.y);
int dir = source.relativeTo(tile.x, tile.y);
if(dir == -1) return null;
Tilec to;

View File

@@ -106,7 +106,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
public boolean acceptLiquid(Tilec source, Liquid liquid, float amount){
noSleep();
return liquids.get(liquid) + amount < liquidCapacity && (liquids.current() == liquid || liquids.currentAmount() < 0.2f)
&& ((source.absoluteRelativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation());
&& ((source.relativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation());
}
@Override

View File

@@ -37,7 +37,7 @@ public class LiquidJunction extends LiquidBlock{
@Override
public Tilec getLiquidDestination(Tilec source, Liquid liquid){
int dir = source.absoluteRelativeTo(tile.x, tile.y);
int dir = source.relativeTo(tile.x, tile.y);
dir = (dir + 4) % 4;
Tilec next = nearby(dir);
if(next == null || (!next.acceptLiquid(this, liquid, 0f) && !(next.block() instanceof LiquidJunction))){

View File

@@ -3,7 +3,6 @@ package mindustry.world.blocks.production;
import arc.*;
import arc.graphics.*;
import arc.graphics.g2d.*;
import mindustry.annotations.Annotations.*;
import mindustry.type.*;
import mindustry.ui.*;
import mindustry.world.*;
@@ -13,7 +12,6 @@ import mindustry.world.meta.*;
import static mindustry.Vars.*;
public class Pump extends LiquidBlock{
public @Load("pump-liquid") TextureRegion liquidRegion;
public final int timerContentCheck = timers++;
/** Pump amount, total. */

View File

@@ -5,6 +5,7 @@ import arc.graphics.g2d.*;
import arc.math.*;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import mindustry.annotations.Annotations.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.graphics.*;
@@ -24,6 +25,8 @@ public class SolidPump extends Pump{
/** Attribute that is checked when calculating output. */
public @Nullable Attribute attribute;
public @Load("@-rotator") TextureRegion rotatorRegion;
public SolidPump(String name){
super(name);
hasPower = true;
@@ -94,8 +97,8 @@ public class SolidPump extends Pump{
Draw.alpha(liquids.total() / liquidCapacity);
Draw.rect(liquidRegion, x, y);
Draw.color();
Draw.rect(name + "-rotator", x, y, pumpTime * rotateSpeed);
Draw.rect(name + "-top", x, y);
Draw.rect(rotatorRegion, x, y, pumpTime * rotateSpeed);
Draw.rect(topRegion, x, y);
}
@Override