mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-10-06 21:07:25 +03:00
Fix strange behavior of MinerAI (#6454)
* Fix strange behavior of MinerAI See: https://discord.com/channels/391020510269669376/396416151032299521/925110542216073216 > Anuke, is the current behavior of miner ai where it wont mine anything if the item that the core has the fewest of has all of its ores covered? The only place the hasOre code is used is miner ai so i assume thats a bug? * Update BlockIndexer.java
This commit is contained in:
parent
84d87e7e9f
commit
692718d4ea
@ -33,7 +33,7 @@ public class BlockIndexer{
|
||||
/** Stores all damaged tile entities by team. */
|
||||
private Seq<Building>[] damagedTiles = new Seq[Team.all.length];
|
||||
/** All ores available on this map. */
|
||||
private ObjectSet<Item> allOres = new ObjectSet<>();
|
||||
private ObjectIntMap<Item> allOres = new ObjectIntMap<>();
|
||||
/** Stores teams that are present here as tiles. */
|
||||
private Seq<Team> activeTeams = new Seq<>(Team.class);
|
||||
/** Maps teams to a map of flagged tiles by flag. */
|
||||
@ -78,8 +78,6 @@ public class BlockIndexer{
|
||||
var drop = tile.drop();
|
||||
|
||||
if(drop != null){
|
||||
allOres.add(drop);
|
||||
|
||||
int qx = (tile.x / quadrantSize);
|
||||
int qy = (tile.y / quadrantSize);
|
||||
|
||||
@ -92,6 +90,7 @@ public class BlockIndexer{
|
||||
ores[drop.id][qx][qy] = new IntSeq(false, 16);
|
||||
}
|
||||
ores[drop.id][qx][qy].add(tile.pos());
|
||||
allOres.increment(drop);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -150,9 +149,11 @@ public class BlockIndexer{
|
||||
//when the drop can be mined, record the ore position
|
||||
if(tile.block() == Blocks.air && !seq.contains(pos)){
|
||||
seq.add(pos);
|
||||
allOres.increment(drop);
|
||||
}else{
|
||||
//otherwise, it likely became blocked, remove it (even if it wasn't there)
|
||||
seq.removeValue(pos);
|
||||
allOres.increment(drop, -1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -177,7 +178,7 @@ public class BlockIndexer{
|
||||
|
||||
/** @return whether this item is present on this map. */
|
||||
public boolean hasOre(Item item){
|
||||
return allOres.contains(item);
|
||||
return allOres.get(item) > 0;
|
||||
}
|
||||
|
||||
/** Returns all damaged tiles by team. */
|
||||
|
Loading…
Reference in New Issue
Block a user