Skip to content

Commit

Permalink
Fix block placement warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
buthed010203 committed Nov 14, 2023
1 parent f2de21a commit 15175a6
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions core/src/mindustry/world/blocks/ConstructBlock.java
Original file line number Diff line number Diff line change
Expand Up @@ -527,23 +527,17 @@ public void read(Reads read, byte revision){
buildCost = current.buildCost * state.rules.buildCostMultiplier;
}

public boolean shouldDisplayWarning(){
return wasConstructing && closestCore() != null && lastBuilder != null
&& player != null && team == player.team() && progress != lastProgress
&& lastBuilder != player.unit();
}

/** Returns the smallest distance to the core and/or its connected vaults.*/
public int distanceToGreaterCore(){
int lowestDistance = Integer.MAX_VALUE;
//Loop through the core and all connected storage
// BALA WARNING: I dont know whether replacing .and with .add was the correct move but I hope it is
for(Building building : closestCore().proximity.copy().add(closestCore())) {
float lowestDistance = Integer.MAX_VALUE;
for(Building building : closestCore().proximity) {
if (building instanceof StorageBlock.StorageBuild || building instanceof CoreBuild) {
lowestDistance = Math.min(World.toTile(building.tile.dst2(this.tile)), lowestDistance);
lowestDistance = Math.min(building.tile.dst2(this.tile), lowestDistance);
}
}
return (int)Math.sqrt(lowestDistance);
lowestDistance = Math.min(closestCore().tile.dst2(this.tile), lowestDistance); // Check the core itself as well

return World.toTile(Mathf.sqrt(lowestDistance));
}

public void handleBlockWarning() {
Expand Down

0 comments on commit 15175a6

Please sign in to comment.