|
|
|
@@ -90,33 +90,6 @@ public class Build{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(type.isMultiblock()){
|
|
|
|
|
if(((type.canReplace(tile.block()) || tile.block.alwaysReplace) || (tile.block instanceof ConstructBlock && tile.<ConstructBuild>bc().cblock == type)) &&
|
|
|
|
|
type.canPlaceOn(tile, team) && tile.interactable(team)){
|
|
|
|
|
|
|
|
|
|
//if the block can be replaced but the sizes differ, check all the spaces around the block to make sure it can fit
|
|
|
|
|
if(type.size != tile.block().size){
|
|
|
|
|
int offsetx = -(type.size - 1) / 2;
|
|
|
|
|
int offsety = -(type.size - 1) / 2;
|
|
|
|
|
|
|
|
|
|
//this does not check *all* the conditions for placeability yet
|
|
|
|
|
for(int dx = 0; dx < type.size; dx++){
|
|
|
|
|
for(int dy = 0; dy < type.size; dy++){
|
|
|
|
|
int wx = dx + offsetx + x, wy = dy + offsety + y;
|
|
|
|
|
|
|
|
|
|
Tile check = world.tile(wx, wy);
|
|
|
|
|
if(check == null ||
|
|
|
|
|
(check.floor().isDeep() && !type.floating && !type.requiresWater && !type.placeableLiquid) ||
|
|
|
|
|
!check.interactable(team) ||
|
|
|
|
|
(!check.block.alwaysReplace && check.block != tile.block && !(check.block.size == 1 && type.canReplace(check.block)))) return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//make sure that the new block can fit the old one
|
|
|
|
|
return type.bounds(x, y, Tmp.r1).grow(0.01f).contains(tile.block.bounds(tile.centerX(), tile.centerY(), Tmp.r2));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(!type.requiresWater && !contactsShallows(tile.x, tile.y, type) && !type.placeableLiquid){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
@@ -127,31 +100,27 @@ public class Build{
|
|
|
|
|
|
|
|
|
|
int offsetx = -(type.size - 1) / 2;
|
|
|
|
|
int offsety = -(type.size - 1) / 2;
|
|
|
|
|
|
|
|
|
|
for(int dx = 0; dx < type.size; dx++){
|
|
|
|
|
for(int dy = 0; dy < type.size; dy++){
|
|
|
|
|
Tile other = world.tile(x + dx + offsetx, y + dy + offsety);
|
|
|
|
|
int wx = dx + offsetx + tile.x, wy = dy + offsety + tile.y;
|
|
|
|
|
|
|
|
|
|
Tile check = world.tile(wx, wy);
|
|
|
|
|
if(
|
|
|
|
|
other == null ||
|
|
|
|
|
!other.block().alwaysReplace ||
|
|
|
|
|
!other.floor().placeableOn ||
|
|
|
|
|
(other.floor().isDeep() && !type.floating && !type.requiresWater && !type.placeableLiquid) ||
|
|
|
|
|
(type.requiresWater && tile.floor().liquidDrop != Liquids.water)
|
|
|
|
|
){
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
check == null || //nothing there
|
|
|
|
|
(check.floor().isDeep() && !type.floating && !type.requiresWater && !type.placeableLiquid) || //deep water
|
|
|
|
|
(type == check.block() && check.build != null && rotation == check.build.rotation && type.rotate) || //same block, same rotation
|
|
|
|
|
!check.interactable(team) || //cannot interact
|
|
|
|
|
!check.floor().placeableOn || //solid wall
|
|
|
|
|
!((type.canReplace(check.block()) || //can replace type
|
|
|
|
|
(check.block instanceof ConstructBlock && check.<ConstructBuild>bc().cblock == type && check.centerX() == tile.x && check.centerY() == tile.y)) && //same type in construction
|
|
|
|
|
type.bounds(tile.x, tile.y, Tmp.r1).grow(0.01f).contains(check.block.bounds(check.centerX(), check.centerY(), Tmp.r2))) || //no replacement
|
|
|
|
|
(type.requiresWater && check.floor().liquidDrop != Liquids.water) //requires water but none found
|
|
|
|
|
) return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}else{
|
|
|
|
|
return tile.interactable(team)
|
|
|
|
|
&& (contactsShallows(tile.x, tile.y, type) || type.requiresWater || type.placeableLiquid)
|
|
|
|
|
&& (!tile.floor().isDeep() || type.floating || type.requiresWater || type.placeableLiquid)
|
|
|
|
|
&& tile.floor().placeableOn
|
|
|
|
|
&& (!type.requiresWater || tile.floor().liquidDrop == Liquids.water)
|
|
|
|
|
&& (((type.canReplace(tile.block()) || (tile.block instanceof ConstructBlock && tile.<ConstructBuild>bc().cblock == type))
|
|
|
|
|
&& !(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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean contactsGround(int x, int y, Block block){
|
|
|
|
|