Moved rotation to Building
This commit is contained in:
@@ -74,8 +74,8 @@ public class Block extends UnlockableContent{
|
||||
public boolean solidifes;
|
||||
/** whether this is rotateable */
|
||||
public boolean rotate;
|
||||
/** for static blocks only: if true, rotation is saved in world data. */
|
||||
public boolean saveRotation;
|
||||
/** for static blocks only: if true, tile data() is saved in world data. */
|
||||
public boolean saveData;
|
||||
/** whether you can break this with rightclick */
|
||||
public boolean breakable;
|
||||
/** whether to add this block to brokenblocks */
|
||||
|
||||
@@ -22,7 +22,7 @@ public class Build{
|
||||
return;
|
||||
}
|
||||
|
||||
Tile tile = world.Building(x, y);
|
||||
Tile tile = world.tileBuilding(x, y);
|
||||
//this should never happen, but it doesn't hurt to check for links
|
||||
float prevPercent = 1f;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class Build{
|
||||
prevPercent = tile.build.healthf();
|
||||
}
|
||||
|
||||
int rotation = tile.rotation();
|
||||
int rotation = tile.build != null ? tile.build.rotation : 0;
|
||||
Block previous = tile.block();
|
||||
Block sub = BuildBlock.get(previous.size);
|
||||
|
||||
@@ -146,7 +146,7 @@ public class Build{
|
||||
&& tile.floor().placeableOn
|
||||
&& (!type.requiresWater || tile.floor().liquidDrop == Liquids.water)
|
||||
&& (((type.canReplace(tile.block()) || (tile.block instanceof BuildBlock && tile.<BuildEntity>bc().cblock == type))
|
||||
&& !(type == tile.block() && rotation == tile.rotation() && type.rotate)) || tile.block().alwaysReplace || tile.block() == Blocks.air)
|
||||
&& !(type == tile.block() && (tile.build != null && rotation == tile.build.rotation) && type.rotate)) || tile.block().alwaysReplace || tile.block() == Blocks.air)
|
||||
&& tile.block().isMultiblock() == type.isMultiblock() && type.canPlaceOn(tile, team);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class CachedTile extends Tile{
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void changeEntity(Team team, Prov<Building> entityprov){
|
||||
protected void changeEntity(Team team, Prov<Building> entityprov, int rotation){
|
||||
build = null;
|
||||
|
||||
Block block = block();
|
||||
|
||||
@@ -21,6 +21,8 @@ import static mindustry.Vars.*;
|
||||
public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
static final ObjectSet<Building> tileSet = new ObjectSet<>();
|
||||
|
||||
/** Extra data for very specific blocks. */
|
||||
public byte data;
|
||||
/** Tile traversal cost. */
|
||||
public short cost = 1;
|
||||
/** Tile entity, usually null. */
|
||||
@@ -29,8 +31,6 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
protected @NonNull Block block;
|
||||
protected @NonNull Floor floor;
|
||||
protected @NonNull Floor overlay;
|
||||
/** Rotation of blocks, or other data. Not guaranteed to be in any specific range. */
|
||||
protected byte rotation;
|
||||
protected boolean changing = false;
|
||||
|
||||
public Tile(int x, int y){
|
||||
@@ -47,7 +47,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
this.block = wall;
|
||||
|
||||
//update entity and create it if needed
|
||||
changeEntity(Team.derelict, wall::newEntity);
|
||||
changeEntity(Team.derelict, wall::newEntity, 0);
|
||||
changed();
|
||||
}
|
||||
|
||||
@@ -183,9 +183,8 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
changing = true;
|
||||
|
||||
this.block = type;
|
||||
this.rotation = rotation == 0 ? 0 : (byte)Mathf.mod(rotation, 4);
|
||||
preChanged();
|
||||
changeEntity(team, entityprov);
|
||||
changeEntity(team, entityprov, (byte)Mathf.mod(rotation, 4));
|
||||
|
||||
if(build != null){
|
||||
build.team(team);
|
||||
@@ -304,18 +303,6 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
setFloorNet(floor, Blocks.air);
|
||||
}
|
||||
|
||||
public byte rotation(){
|
||||
return rotation;
|
||||
}
|
||||
|
||||
public int rotdeg(){
|
||||
return rotation * 90;
|
||||
}
|
||||
|
||||
public void rotation(int rotation){
|
||||
this.rotation = (byte)rotation;
|
||||
}
|
||||
|
||||
public short overlayID(){
|
||||
return overlay.id;
|
||||
}
|
||||
@@ -443,23 +430,6 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
return null;
|
||||
}
|
||||
|
||||
// ▲ ▲ ▼ ▼ ◀ ▶ ◀ ▶ B A
|
||||
public @Nullable Building front(){
|
||||
return getNearbyEntity((rotation + 4) % 4);
|
||||
}
|
||||
|
||||
public @Nullable Building right(){
|
||||
return getNearbyEntity((rotation + 3) % 4);
|
||||
}
|
||||
|
||||
public @Nullable Building back(){
|
||||
return getNearbyEntity((rotation + 2) % 4);
|
||||
}
|
||||
|
||||
public @Nullable Building left(){
|
||||
return getNearbyEntity((rotation + 1) % 4);
|
||||
}
|
||||
|
||||
public boolean interactable(Team team){
|
||||
return state.teams.canInteract(team, team());
|
||||
}
|
||||
@@ -469,7 +439,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
|
||||
public int staticDarkness(){
|
||||
return block.solid && block.fillsTile && !block.synthetic() ? rotation : 0;
|
||||
return block.solid && block.fillsTile && !block.synthetic() ? data : 0;
|
||||
}
|
||||
|
||||
public void updateOcclusion(){
|
||||
@@ -548,7 +518,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
}
|
||||
|
||||
protected void changeEntity(Team team, Prov<Building> entityprov){
|
||||
protected void changeEntity(Team team, Prov<Building> entityprov, int rotation){
|
||||
if(build != null){
|
||||
int size = build.block.size;
|
||||
build.remove();
|
||||
@@ -571,7 +541,7 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
||||
}
|
||||
|
||||
if(block.hasEntity()){
|
||||
build = entityprov.get().init(this, team, block.update);
|
||||
build = entityprov.get().init(this, team, block.update, rotation);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -147,7 +147,7 @@ public interface Autotiler{
|
||||
|
||||
default boolean blends(Tile tile, int rotation, int direction){
|
||||
Building other = tile.getNearbyEntity(Mathf.mod(rotation - direction, 4));
|
||||
return other != null && other.team() == tile.team() && blends(tile, rotation, other.tileX(), other.tileY(), other.rotation(), other.block());
|
||||
return other != null && other.team() == tile.team() && blends(tile, rotation, other.tileX(), other.tileY(), other.rotation, other.block());
|
||||
}
|
||||
|
||||
default boolean blendsArmored(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
|
||||
|
||||
@@ -154,7 +154,7 @@ public class BuildBlock extends Block{
|
||||
if(control.input.buildWasAutoPaused && !control.input.isBuilding && player.isBuilder()){
|
||||
control.input.isBuilding = true;
|
||||
}
|
||||
player.builder().addBuild(new BuildPlan(tile.x, tile.y, tile.rotation(), cblock), false);
|
||||
player.builder().addBuild(new BuildPlan(tile.x, tile.y, rotation, cblock), false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,7 +170,7 @@ public class BuildBlock extends Block{
|
||||
@Override
|
||||
public void draw(){
|
||||
if(!(previous == null || cblock == null || previous == cblock) && Core.atlas.isFound(previous.icon(Cicon.full))){
|
||||
Draw.rect(previous.icon(Cicon.full), x, y, previous.rotate ? tile.rotdeg() : 0);
|
||||
Draw.rect(previous.icon(Cicon.full), x, y, previous.rotate ? rotdeg() : 0);
|
||||
}
|
||||
|
||||
Draw.draw(Layer.blockBuilding, () -> {
|
||||
@@ -183,7 +183,7 @@ public class BuildBlock extends Block{
|
||||
Shaders.blockbuild.region = region;
|
||||
Shaders.blockbuild.progress = progress;
|
||||
|
||||
Draw.rect(region, x, y, target.rotate ? tile.rotdeg() : 0);
|
||||
Draw.rect(region, x, y, target.rotate ? rotdeg() : 0);
|
||||
Draw.flush();
|
||||
}
|
||||
}
|
||||
@@ -214,7 +214,7 @@ public class BuildBlock extends Block{
|
||||
builderID = builder.id();
|
||||
|
||||
if(progress >= 1f || state.rules.infiniteResources){
|
||||
constructed(tile, cblock, builderID, tile.rotation(), builder.team(), configured);
|
||||
constructed(tile, cblock, builderID, (byte)rotation, builder.team(), configured);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -65,9 +65,9 @@ public class MendProjector extends Block{
|
||||
heat = Mathf.lerpDelta(heat, consValid() || cheating() ? 1f : 0f, 0.08f);
|
||||
charge += heat * delta();
|
||||
|
||||
phaseHeat = Mathf.lerpDelta(phaseHeat, Mathf.num(cons().optionalValid()), 0.1f);
|
||||
phaseHeat = Mathf.lerpDelta(phaseHeat, Mathf.num(cons.optionalValid()), 0.1f);
|
||||
|
||||
if(cons().optionalValid() && timer(timerUse, useTime) && efficiency() > 0){
|
||||
if(cons.optionalValid() && timer(timerUse, useTime) && efficiency() > 0){
|
||||
consume();
|
||||
}
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ public class OverdriveProjector extends Block{
|
||||
charge += heat * Time.delta;
|
||||
|
||||
if(hasBoost){
|
||||
phaseHeat = Mathf.lerpDelta(phaseHeat, Mathf.num(cons().optionalValid()), 0.1f);
|
||||
phaseHeat = Mathf.lerpDelta(phaseHeat, Mathf.num(cons.optionalValid()), 0.1f);
|
||||
}
|
||||
|
||||
if(timer(timerUse, useTime) && efficiency() > 0){
|
||||
|
||||
@@ -18,7 +18,7 @@ public class ArmoredConveyor extends Conveyor{
|
||||
public class ArmoredConveyorEntity extends ConveyorEntity{
|
||||
@Override
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
return super.acceptItem(source, item) && (source.block() instanceof Conveyor || Edges.getFacingEdge(source.tile(), tile).relativeTo(tile) == tile.rotation());
|
||||
return super.acceptItem(source, item) && (source.block() instanceof Conveyor || Edges.getFacingEdge(source.tile(), tile).relativeTo(tile) == rotation);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
cont.get(Geometry.d4(req.rotation - 2)) &&
|
||||
req.tile() != null &&
|
||||
req.tile().block() instanceof Conveyor &&
|
||||
Mathf.mod(req.tile().rotation() - req.rotation, 2) == 1 ? Blocks.junction : this;
|
||||
Mathf.mod(req.tile().build.rotation - req.rotation, 2) == 1 ? Blocks.junction : this;
|
||||
}
|
||||
|
||||
public class ConveyorEntity extends Building{
|
||||
@@ -114,7 +114,6 @@ public class Conveyor extends Block implements Autotiler{
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
byte rotation = tile.rotation();
|
||||
int frame = clogHeat <= 0.5f ? (int)(((Time.time() * speed * 8f * timeScale())) % 4) : 0;
|
||||
|
||||
//draw extra conveyors facing this one for non-square tiling purposes
|
||||
@@ -155,16 +154,16 @@ public class Conveyor extends Block implements Autotiler{
|
||||
public void onProximityUpdate(){
|
||||
super.onProximityUpdate();
|
||||
|
||||
int[] bits = buildBlending(tile, rotation(), null, true);
|
||||
int[] bits = buildBlending(tile, rotation, null, true);
|
||||
blendbits = bits[0];
|
||||
blendsclx = bits[1];
|
||||
blendscly = bits[2];
|
||||
blending = bits[4];
|
||||
|
||||
if(tile.front() != null && tile.front() != null){
|
||||
next = tile.front();
|
||||
if(front() != null && front() != null){
|
||||
next = front();
|
||||
nextc = next instanceof ConveyorEntity && next.team() == team ? (ConveyorEntity)next : null;
|
||||
aligned = nextc != null && tile.rotation() == next.tile().rotation();
|
||||
aligned = nextc != null && rotation == next.rotation;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,7 +178,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
float mspeed = speed * tilesize / 2.4f;
|
||||
float centerSpeed = 0.1f;
|
||||
float centerDstScl = 3f;
|
||||
float tx = Geometry.d4[tile.rotation()].x, ty = Geometry.d4[tile.rotation()].y;
|
||||
float tx = Geometry.d4[rotation].x, ty = Geometry.d4[rotation].y;
|
||||
|
||||
float centerx = 0f, centery = 0f;
|
||||
|
||||
@@ -263,7 +262,7 @@ public class Conveyor extends Block implements Autotiler{
|
||||
|
||||
@Override
|
||||
public void getStackOffset(Item item, Vec2 trns){
|
||||
trns.trns(tile.rotdeg() + 180f, tilesize / 2f);
|
||||
trns.trns(rotdeg() + 180f, tilesize / 2f);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -290,15 +289,15 @@ public class Conveyor extends Block implements Autotiler{
|
||||
public boolean acceptItem(Building source, Item item){
|
||||
if(len >= capacity) return false;
|
||||
Tile facing = Edges.getFacingEdge(source.tile(), tile);
|
||||
int direction = Math.abs(facing.relativeTo(tile.x, tile.y) - tile.rotation());
|
||||
return (((direction == 0) && minitem >= itemSpace) || ((direction % 2 == 1) && minitem > 0.7f)) && !(source.block().rotate && (source.rotation() + 2) % 4 == tile.rotation());
|
||||
int direction = Math.abs(facing.relativeTo(tile.x, tile.y) - rotation);
|
||||
return (((direction == 0) && minitem >= itemSpace) || ((direction % 2 == 1) && minitem > 0.7f)) && !(source.block().rotate && (source.rotation + 2) % 4 == rotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handleItem(Building source, Item item){
|
||||
if(len >= capacity) return;
|
||||
|
||||
byte r = tile.rotation();
|
||||
int r = rotation;
|
||||
Tile facing = Edges.getFacingEdge(source.tile(), tile);
|
||||
int ang = ((facing.relativeTo(tile.x, tile.y) - r));
|
||||
float x = (ang == -1 || ang == 3) ? 1 : (ang == 1 || ang == -3) ? -1 : 0;
|
||||
|
||||
@@ -108,12 +108,12 @@ public class OverflowGate extends Block{
|
||||
}else if(bc && !ac){
|
||||
to = b;
|
||||
}else{
|
||||
if(tile.rotation() == 0){
|
||||
if(rotation == 0){
|
||||
to = a;
|
||||
if(flip) tile.rotation((byte) 1);
|
||||
if(flip) rotation =1;
|
||||
}else{
|
||||
to = b;
|
||||
if(flip) tile.rotation((byte) 0);
|
||||
if(flip) rotation = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,15 +66,15 @@ public class PayloadConveyor extends Block{
|
||||
public void onProximityUpdate(){
|
||||
super.onProximityUpdate();
|
||||
|
||||
Building accept = nearby(Geometry.d4(rotation()).x * size, Geometry.d4(rotation()).y * size);
|
||||
Building accept = nearby(Geometry.d4(rotation).x * size, Geometry.d4(rotation).y * size);
|
||||
//next block must be aligned and of the same size
|
||||
if(accept != null && (
|
||||
//same size
|
||||
(accept.block().size == size && tileX() + Geometry.d4(rotation()).x * size == accept.tileX() && tileY() + Geometry.d4(rotation()).y * size == accept.tileY()) ||
|
||||
(accept.block().size == size && tileX() + Geometry.d4(rotation).x * size == accept.tileX() && tileY() + Geometry.d4(rotation).y * size == accept.tileY()) ||
|
||||
|
||||
//differing sizes
|
||||
(accept.block().size > size &&
|
||||
(rotation() % 2 == 0 ? //check orientation
|
||||
(rotation % 2 == 0 ? //check orientation
|
||||
Math.abs(accept.y - y) <= (accept.block().size * tilesize - size * tilesize)/2f : //check Y alignment
|
||||
Math.abs(accept.x - x) <= (accept.block().size * tilesize - size * tilesize)/2f //check X alignment
|
||||
)))){
|
||||
@@ -84,8 +84,8 @@ public class PayloadConveyor extends Block{
|
||||
}
|
||||
|
||||
int ntrns = 1 + size/2;
|
||||
Tile next = tile.getNearby(Geometry.d4(rotation()).x * ntrns, Geometry.d4(rotation()).y * ntrns);
|
||||
blocked = (next != null && next.solid()) || (this.next != null && (this.next.rotation() + 2)%4 == rotation());
|
||||
Tile next = tile.getNearby(Geometry.d4(rotation).x * ntrns, Geometry.d4(rotation).y * ntrns);
|
||||
blocked = (next != null && next.solid()) || (this.next != null && (this.next.rotation + 2)%4 == rotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -161,7 +161,7 @@ public class PayloadConveyor extends Block{
|
||||
Draw.rect(clipped, x + Tmp.v1.x, y + Tmp.v1.y, rot);
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(blends(i) && i != rotation()){
|
||||
if(blends(i) && i != rotation){
|
||||
Draw.alpha(1f - Interp.pow5In.apply(fract()));
|
||||
//prev from back
|
||||
Tmp.v1.set(- s/2f + clipped.getWidth()/2f*Draw.scl, - s/2f + clipped.getHeight()/2f*Draw.scl).rotate(i * 90 + 180);
|
||||
@@ -242,7 +242,7 @@ public class PayloadConveyor extends Block{
|
||||
}
|
||||
|
||||
boolean blends(int direction){
|
||||
if(direction == rotation()){
|
||||
if(direction == rotation){
|
||||
return !blocked || next != null;
|
||||
}else{
|
||||
return PayloadAcceptor.blends(this, direction);
|
||||
|
||||
@@ -37,7 +37,7 @@ public class PayloadRouter extends PayloadConveyor{
|
||||
public void moved(){
|
||||
int rotations = 0;
|
||||
do{
|
||||
tile.rotation((tile.rotation() + 1) % 4);
|
||||
rotation = (rotation + 1) % 4;
|
||||
onProximityUpdate();
|
||||
}while((blocked || next == null) && ++rotations < 4);
|
||||
}
|
||||
|
||||
@@ -71,10 +71,10 @@ public class Router extends Block{
|
||||
}
|
||||
|
||||
Building getTileTarget(Item item, Tile from, boolean set){
|
||||
int counter = tile.rotation();
|
||||
int counter = rotation;
|
||||
for(int i = 0; i < proximity.size; i++){
|
||||
Building other = proximity.get((i + counter) % proximity.size);
|
||||
if(set) tile.rotation((byte)((tile.rotation() + 1) % proximity.size));
|
||||
if(set) rotation = ((byte)((rotation + 1) % proximity.size));
|
||||
if(other.tile() == from && from.block() == Blocks.overflowGate) continue;
|
||||
if(other.acceptItem(this, item)){
|
||||
return other;
|
||||
|
||||
@@ -117,12 +117,12 @@ public class Sorter extends Block{
|
||||
}else if(!bc){
|
||||
return null;
|
||||
}else{
|
||||
if(rotation() == 0){
|
||||
if(rotation == 0){
|
||||
to = a;
|
||||
if(flip) rotation((byte)1);
|
||||
if(flip) this.rotation = (byte)1;
|
||||
}else{
|
||||
to = b;
|
||||
if(flip) rotation((byte)0);
|
||||
if(flip) this.rotation = (byte)0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -104,25 +104,26 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
if((blendprox & (1 << i)) == 0){
|
||||
Draw.rect(edgeRegion, x, y, (rotation() - i) * 90);
|
||||
Draw.rect(edgeRegion, x, y, (rotation - i) * 90);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.z(Layer.blockOver);
|
||||
|
||||
if(link == -1) return;
|
||||
Building from = world.build(link);
|
||||
|
||||
if(link == -1 || from == null) return;
|
||||
|
||||
//offset
|
||||
Tile from = world.tile(link);
|
||||
Tmp.v1.set(from);
|
||||
Tmp.v2.set(tile);
|
||||
Tmp.v1.interpolate(Tmp.v2, 1f - cooldown, Interp.linear);
|
||||
|
||||
//rotation
|
||||
float a = (from.rotation()%4) * 90;
|
||||
float b = (tile.rotation()%4) * 90;
|
||||
if((from.rotation()%4) == 3 && (tile.rotation()%4) == 0) a = -1 * 90;
|
||||
if((from.rotation()%4) == 0 && (tile.rotation()%4) == 3) a = 4 * 90;
|
||||
float a = (from.rotation%4) * 90;
|
||||
float b = (rotation%4) * 90;
|
||||
if((from.rotation%4) == 3 && (rotation%4) == 0) a = -1 * 90;
|
||||
if((from.rotation%4) == 0 && (rotation%4) == 3) a = 4 * 90;
|
||||
|
||||
//stack
|
||||
Draw.rect(stackRegion, Tmp.v1.x, Tmp.v1.y, Mathf.lerp(a, b, Interp.smooth.apply(1f - Mathf.clamp(cooldown * 2, 0f, 1f))));
|
||||
@@ -141,14 +142,14 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
|
||||
state = stateMove;
|
||||
|
||||
int[] bits = buildBlending(tile, tile.rotation(), null, true);
|
||||
if(bits[0] == 0 && blends(tile, tile.rotation(), 0) && !blends(tile, tile.rotation(), 2)) state = stateLoad; // a 0 that faces into a conveyor with none behind it
|
||||
if(bits[0] == 0 && !blends(tile, tile.rotation(), 0) && blends(tile, tile.rotation(), 2)) state = stateUnload; // a 0 that faces into none with a conveyor behind it
|
||||
int[] bits = buildBlending(tile, rotation, null, true);
|
||||
if(bits[0] == 0 && blends(tile, rotation, 0) && !blends(tile, rotation, 2)) state = stateLoad; // a 0 that faces into a conveyor with none behind it
|
||||
if(bits[0] == 0 && !blends(tile, rotation, 0) && blends(tile, rotation, 2)) state = stateUnload; // a 0 that faces into none with a conveyor behind it
|
||||
|
||||
blendprox = 0;
|
||||
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(blends(tile, rotation(), i)){
|
||||
if(blends(tile, rotation, i)){
|
||||
blendprox |= (1 << i);
|
||||
}
|
||||
}
|
||||
@@ -253,7 +254,7 @@ public class StackConveyor extends Block implements Autotiler{
|
||||
return !((state != stateLoad) // not a loading dock
|
||||
|| (items.total() > 0 && !items.has(item)) // incompatible items
|
||||
|| (items.total() >= getMaximumAccepted(item)) // filled to capacity
|
||||
|| (tile.front() == source));
|
||||
|| (front() == source));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -18,7 +18,7 @@ public class Cliff extends Block{
|
||||
|
||||
@Override
|
||||
public void drawBase(Tile tile){
|
||||
int r = tile.rotation();
|
||||
int r = tile.data;
|
||||
for(int i = 0; i < 8; i++){
|
||||
if((r & (1 << i)) != 0){
|
||||
Draw.color(Tmp.c1.set(tile.floor().mapColor).mul(1.3f + (i >= 4 ? -0.4f : 0.3f)));
|
||||
|
||||
@@ -71,7 +71,7 @@ public class BlockLoader extends PayloadAcceptor{
|
||||
|
||||
//draw input
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(blends(i) && i != rotation()){
|
||||
if(blends(i) && i != rotation){
|
||||
Draw.rect(inRegion, x, y, i * 90);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,15 +25,16 @@ public class ArmoredConduit extends Conduit{
|
||||
super.draw();
|
||||
|
||||
// draw the cap when a conduit would normally leak
|
||||
Building next = tile.front();
|
||||
Building next = front();
|
||||
if(next != null && next.team() == team && next.block().hasLiquids) return;
|
||||
|
||||
Draw.rect(capRegion, x, y, tile.rotdeg());
|
||||
Draw.rect(capRegion, x, y, rotdeg());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Building source, Liquid liquid, float amount){
|
||||
return super.acceptLiquid(source, liquid, amount) && (source.block() instanceof Conduit) || Edges.getFacingEdge(source.tile(), tile).absoluteRelativeTo(tile.x, tile.y) == tile.rotation();
|
||||
return super.acceptLiquid(source, liquid, amount) && (source.block() instanceof Conduit) ||
|
||||
Edges.getFacingEdge(source.tile(), tile).absoluteRelativeTo(tile.x, tile.y) == rotation;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
cont.get(Geometry.d4(req.rotation - 2)) &&
|
||||
req.tile() != null &&
|
||||
req.tile().block() instanceof Conduit &&
|
||||
Mathf.mod(req.tile().rotation() - req.rotation, 2) == 1 ? Blocks.liquidJunction : this;
|
||||
Mathf.mod(req.build().rotation - req.rotation, 2) == 1 ? Blocks.liquidJunction : this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -79,7 +79,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
@Override
|
||||
public void draw(){
|
||||
float rotation = rotdeg();
|
||||
int r = rotation();
|
||||
int r = this.rotation;
|
||||
|
||||
//draw extra conduits facing this one for tiling purposes
|
||||
Draw.z(Layer.blockUnder);
|
||||
@@ -114,7 +114,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
public void onProximityUpdate(){
|
||||
super.onProximityUpdate();
|
||||
|
||||
int[] bits = buildBlending(tile, rotation(), null, true);
|
||||
int[] bits = buildBlending(tile, rotation, null, true);
|
||||
blendbits = bits[0];
|
||||
xscl = bits[1];
|
||||
yscl = bits[2];
|
||||
@@ -125,7 +125,7 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
public boolean acceptLiquid(Building source, Liquid liquid, float amount){
|
||||
noSleep();
|
||||
return liquids.get(liquid) + amount < liquidCapacity && (liquids.current() == liquid || liquids.currentAmount() < 0.2f)
|
||||
&& ((source.relativeTo(tile.x, tile.y) + 2) % 4 != tile.rotation());
|
||||
&& ((source.relativeTo(tile.x, tile.y) + 2) % 4 != rotation);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -46,17 +46,17 @@ public class PowerDiode extends Block{
|
||||
@Override
|
||||
public void draw(){
|
||||
Draw.rect(region, x, y, 0);
|
||||
Draw.rect(arrow, x, y, rotate ? tile.rotdeg() : 0);
|
||||
Draw.rect(arrow, x, y, rotate ? rotdeg() : 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
super.updateTile();
|
||||
|
||||
if(tile.front() == null || tile.back() == null || !tile.back().block().hasPower || !tile.front().block().hasPower || tile.back().team() != tile.front().team()) return;
|
||||
if(front() == null || back() == null || !back().block().hasPower || !front().block().hasPower || back().team() != front().team()) return;
|
||||
|
||||
PowerGraph backGraph = tile.back().power.graph;
|
||||
PowerGraph frontGraph = tile.front().power.graph;
|
||||
PowerGraph backGraph = back().power.graph;
|
||||
PowerGraph frontGraph = front().power.graph;
|
||||
if(backGraph == frontGraph) return;
|
||||
|
||||
// 0f - 1f of battery capacity in use
|
||||
|
||||
@@ -259,7 +259,7 @@ public class Drill extends Block{
|
||||
|
||||
float speed = 1f;
|
||||
|
||||
if(cons().optionalValid()){
|
||||
if(cons.optionalValid()){
|
||||
speed = liquidBoostIntensity;
|
||||
}
|
||||
|
||||
|
||||
@@ -34,12 +34,12 @@ public class PayloadAcceptor extends Block{
|
||||
|
||||
//if size is the same, block must either be facing this one, or not be rotating
|
||||
((accept.block().size == size &&
|
||||
((accept.tileX() + Geometry.d4(accept.rotation()).x * size == tile.tileX() && accept.tileY() + Geometry.d4(accept.rotation()).y * size == tile.tileY())
|
||||
((accept.tileX() + Geometry.d4(accept.rotation).x * size == tile.tileX() && accept.tileY() + Geometry.d4(accept.rotation).y * size == tile.tileY())
|
||||
|| !accept.block().rotate || (accept.block().rotate && !accept.block().outputFacing))) ||
|
||||
|
||||
//if the other block is smaller, check alignment
|
||||
(accept.block().size < size &&
|
||||
(accept.rotation() % 2 == 0 ? //check orientation; make sure it's aligned properly with this block.
|
||||
(accept.rotation % 2 == 0 ? //check orientation; make sure it's aligned properly with this block.
|
||||
Math.abs(accept.y - tile.y) <= (size * tilesize - accept.block().size * tilesize)/2f : //check Y alignment
|
||||
Math.abs(accept.x - tile.x) <= (size * tilesize - accept.block().size * tilesize)/2f //check X alignment
|
||||
)) && (!accept.block().rotate || accept.front() == tile || !accept.block().outputFacing) //make sure it's facing this block
|
||||
|
||||
@@ -86,7 +86,7 @@ public class Reconstructor extends UnitBlock{
|
||||
@Override
|
||||
public boolean acceptPayload(Building source, Payload payload){
|
||||
return this.payload == null
|
||||
&& relativeTo(source) != rotation()
|
||||
&& relativeTo(source) != rotation
|
||||
&& payload instanceof UnitPayload
|
||||
&& hasUpgrade(((UnitPayload)payload).unit.type());
|
||||
}
|
||||
@@ -102,7 +102,7 @@ public class Reconstructor extends UnitBlock{
|
||||
|
||||
//draw input
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(blends(i) && i != rotation()){
|
||||
if(blends(i) && i != rotation){
|
||||
Draw.rect(inRegion, x, y, i * 90);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user