Removed Tile#bc(), use Tile.build instead
This commit is contained in:
@@ -26,8 +26,7 @@ import static mindustry.Vars.*;
|
||||
|
||||
/** A block in the process of construction. */
|
||||
public class ConstructBlock extends Block{
|
||||
public static final int maxSize = 16;
|
||||
private static final ConstructBlock[] consBlocks = new ConstructBlock[maxSize];
|
||||
private static final ConstructBlock[] consBlocks = new ConstructBlock[maxBlockSize];
|
||||
|
||||
private static long lastTime = 0;
|
||||
private static int pitchSeq = 0;
|
||||
@@ -46,7 +45,7 @@ public class ConstructBlock extends Block{
|
||||
|
||||
/** Returns a ConstructBlock by size. */
|
||||
public static ConstructBlock get(int size){
|
||||
if(size > maxSize) throw new IllegalArgumentException("No. Don't place ConstructBlock of size greater than " + maxSize);
|
||||
if(size > maxBlockSize) throw new IllegalArgumentException("No. Don't place ConstructBlock of size greater than " + maxBlockSize);
|
||||
return consBlocks[size - 1];
|
||||
}
|
||||
|
||||
@@ -147,6 +146,7 @@ public class ConstructBlock extends Block{
|
||||
*/
|
||||
public Block previous;
|
||||
public Object lastConfig;
|
||||
public boolean wasConstructing;
|
||||
|
||||
@Nullable
|
||||
public Unit lastBuilder;
|
||||
@@ -218,6 +218,7 @@ public class ConstructBlock extends Block{
|
||||
}
|
||||
|
||||
public void construct(Unit builder, @Nullable Building core, float amount, Object config){
|
||||
wasConstructing = true;
|
||||
if(cblock == null){
|
||||
kill();
|
||||
return;
|
||||
@@ -252,6 +253,7 @@ public class ConstructBlock extends Block{
|
||||
}
|
||||
|
||||
public void deconstruct(Unit builder, @Nullable Building core, float amount){
|
||||
wasConstructing = false;
|
||||
float deconstructMultiplier = state.rules.deconstructRefundMultiplier;
|
||||
|
||||
if(builder.isPlayer()){
|
||||
@@ -331,6 +333,7 @@ public class ConstructBlock extends Block{
|
||||
}
|
||||
|
||||
public void setConstruct(Block previous, Block block){
|
||||
wasConstructing = true;
|
||||
this.cblock = block;
|
||||
this.previous = previous;
|
||||
this.accumulator = new float[block.requirements.length];
|
||||
@@ -340,6 +343,7 @@ public class ConstructBlock extends Block{
|
||||
|
||||
public void setDeconstruct(Block previous){
|
||||
if(previous == null) return;
|
||||
wasConstructing = false;
|
||||
this.previous = previous;
|
||||
this.progress = 1f;
|
||||
if(previous.buildCost >= 0.01f){
|
||||
|
||||
@@ -120,7 +120,7 @@ public class ItemBridge extends Block{
|
||||
|
||||
return ((other.block() == tile.block() && tile.block() == this) || (!(tile.block() instanceof ItemBridge) && other.block() == this))
|
||||
&& (other.team() == tile.team() || tile.block() != this)
|
||||
&& (!checkDouble || other.<ItemBridgeBuild>bc().link != tile.pos());
|
||||
&& (!checkDouble || ((ItemBridgeBuild)other.build).link != tile.pos());
|
||||
}
|
||||
|
||||
public Tile findLink(int x, int y){
|
||||
@@ -238,7 +238,7 @@ public class ItemBridge extends Block{
|
||||
while(it.hasNext){
|
||||
int i = it.next();
|
||||
Tile other = world.tile(i);
|
||||
if(!linkValid(tile, other, false) || other.<ItemBridgeBuild>bc().link != tile.pos()){
|
||||
if(!linkValid(tile, other, false) || ((ItemBridgeBuild)other.build).link != tile.pos()){
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -302,8 +302,7 @@ public class MassDriver extends Block{
|
||||
|
||||
protected boolean shooterValid(Tile other){
|
||||
if(other == null) return true;
|
||||
if(!(other.block() instanceof MassDriver)) return false;
|
||||
MassDriverBuild entity = other.bc();
|
||||
if(!(other.build instanceof MassDriverBuild entity)) return false;
|
||||
return entity.link == tile.pos() && tile.dst(other) <= range;
|
||||
}
|
||||
|
||||
|
||||
@@ -43,7 +43,8 @@ public class Sorter extends Block{
|
||||
|
||||
@Override
|
||||
public int minimapColor(Tile tile){
|
||||
return tile.<SorterBuild>bc().sortItem == null ? 0 : tile.<SorterBuild>bc().sortItem.color.rgba();
|
||||
var build = (SorterBuild)tile.build;
|
||||
return build == null || build.sortItem == null ? 0 : build.sortItem.color.rgba();
|
||||
}
|
||||
|
||||
public class SorterBuild extends Building{
|
||||
|
||||
@@ -58,9 +58,8 @@ public class CoreBlock extends StorageBlock{
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void playerSpawn(Tile tile, Player player){
|
||||
if(player == null || tile == null) return;
|
||||
if(player == null || tile == null || !(tile.build instanceof CoreBuild entity)) return;
|
||||
|
||||
CoreBuild entity = tile.bc();
|
||||
CoreBlock block = (CoreBlock)tile.block();
|
||||
Fx.spawn.at(entity);
|
||||
|
||||
|
||||
@@ -27,8 +27,8 @@ public class UnitBlock extends PayloadAcceptor{
|
||||
|
||||
@Remote(called = Loc.server)
|
||||
public static void unitBlockSpawn(Tile tile){
|
||||
if(!(tile.build instanceof UnitBuild)) return;
|
||||
tile.<UnitBuild>bc().spawned();
|
||||
if(!(tile.build instanceof UnitBuild build)) return;
|
||||
build.spawned();
|
||||
}
|
||||
|
||||
public class UnitBuild extends PayloadAcceptorBuild<UnitPayload>{
|
||||
|
||||
Reference in New Issue
Block a user