Fixed plans being canceled by blocked units

This commit is contained in:
Anuken
2024-10-30 19:17:36 -04:00
parent 1558783b7d
commit 1d68f99c75
5 changed files with 48 additions and 29 deletions

View File

@@ -157,22 +157,28 @@ public class Build{
result.placeBegan(tile, previous, unit);
}
/** Returns whether a tile can be placed at this location by this team. */
/** @return whether a tile can be placed at this location by this team. */
public static boolean validPlace(Block type, Team team, int x, int y, int rotation){
return validPlace(type, team, x, y, rotation, true);
}
/** Returns whether a tile can be placed at this location by this team. */
/** @return whether a tile can be placed at this location by this team. */
public static boolean validPlace(Block type, Team team, int x, int y, int rotation, boolean checkVisible){
return validPlaceIgnoreUnits(type, team, x, y, rotation, checkVisible) && checkNoUnitOverlap(type, x, y);
}
/** @return whether a tile can be placed at this location by this team. */
public static boolean checkNoUnitOverlap(Block type, int x, int y){
return (!type.solid && !type.solidifes) || !Units.anyEntities(x * tilesize + type.offset - type.size * tilesize / 2f, y * tilesize + type.offset - type.size * tilesize / 2f, type.size * tilesize, type.size * tilesize);
}
/** Returns whether a tile can be placed at this location by this team. Ignores units at this location. */
public static boolean validPlaceIgnoreUnits(Block type, Team team, int x, int y, int rotation, boolean checkVisible){
//the wave team can build whatever they want as long as it's visible - banned blocks are not applicable
if(type == null || (!state.rules.editor && (checkVisible && (!type.environmentBuildable() || (!type.isPlaceable() && !(state.rules.waves && team == state.rules.waveTeam && type.isVisible())))))){
return false;
}
if((type.solid || type.solidifes) && Units.anyEntities(x * tilesize + type.offset - type.size*tilesize/2f, y * tilesize + type.offset - type.size*tilesize/2f, type.size * tilesize, type.size*tilesize)){
return false;
}
if(!state.rules.editor){
//find closest core, if it doesn't match the team, placing is not legal
if(state.rules.polygonCoreProtection){