mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-01-11 07:39:39 +07:00
Crash fix / New pump/conduit placement restrictions
This commit is contained in:
parent
1fa769b3e7
commit
9a5495d8b2
@ -180,7 +180,13 @@ public class WaveSpawner{
|
||||
}
|
||||
|
||||
private void setQuad(int quadx, int quady, boolean valid){
|
||||
if(quadrants == null) quadrants = new GridBits(quadWidth(), quadHeight());
|
||||
if(quadrants == null){
|
||||
quadrants = new GridBits(quadWidth(), quadHeight());
|
||||
}
|
||||
|
||||
if(!Mathf.inBounds(quadx, quady, quadWidth(), quadHeight())){
|
||||
return;
|
||||
}
|
||||
|
||||
quadrants.set(quadx, quady, valid);
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.anuke.mindustry.world;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.math.Rectangle;
|
||||
import com.badlogic.gdx.math.Vector2;
|
||||
import io.anuke.mindustry.content.blocks.Blocks;
|
||||
@ -10,6 +11,7 @@ import io.anuke.mindustry.type.Recipe;
|
||||
import io.anuke.mindustry.world.blocks.BuildBlock.BuildEntity;
|
||||
import io.anuke.ucore.core.Events;
|
||||
import io.anuke.ucore.entities.Entities;
|
||||
import io.anuke.ucore.util.Geometry;
|
||||
|
||||
import static io.anuke.mindustry.Vars.*;
|
||||
|
||||
@ -154,6 +156,10 @@ public class Build{
|
||||
return true;
|
||||
}
|
||||
|
||||
if(!contactsGround(tile.x, tile.y, type)){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!type.canPlaceOn(tile)){
|
||||
return false;
|
||||
}
|
||||
@ -173,6 +179,7 @@ public class Build{
|
||||
return true;
|
||||
}else{
|
||||
return (tile.getTeam() == Team.none || tile.getTeam() == team)
|
||||
&& contactsGround(tile.x, tile.y, type)
|
||||
&& (!tile.floor().isLiquid || type.floating)
|
||||
&& tile.floor().placeableOn && !tile.hasCliffs()
|
||||
&& ((type.canReplace(tile.block())
|
||||
@ -181,6 +188,27 @@ public class Build{
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean contactsGround(int x, int y, Block block){
|
||||
if(block.isMultiblock()){
|
||||
for(GridPoint2 point : Edges.getInsideEdges(block.size)){
|
||||
Tile tile = world.tile(x + point.x, y + point.y);
|
||||
if(tile != null && !tile.floor().isLiquid) return true;
|
||||
}
|
||||
|
||||
for(GridPoint2 point : Edges.getEdges(block.size)){
|
||||
Tile tile = world.tile(x + point.x, y + point.y);
|
||||
if(tile != null && !tile.floor().isLiquid) return true;
|
||||
}
|
||||
}else{
|
||||
for(GridPoint2 point : Geometry.d4){
|
||||
Tile tile = world.tile(x + point.x, y + point.y);
|
||||
if(tile != null && !tile.floor().isLiquid) return true;
|
||||
}
|
||||
return world.tile(x, y) != null && !world.tile(x, y).floor().isLiquid;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**Returns whether the tile at this position is breakable by this team*/
|
||||
public static boolean validBreak(Team team, int x, int y){
|
||||
Tile tile = world.tile(x, y);
|
||||
|
@ -23,6 +23,7 @@ public class Conduit extends LiquidBlock{
|
||||
super(name);
|
||||
rotate = true;
|
||||
solid = false;
|
||||
floating = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user