Fixed disappearing blocks / Unit tech tree entries

This commit is contained in:
Anuken
2022-02-07 10:58:22 -05:00
parent bf22b601f7
commit 6bbbd5ab01
11 changed files with 149 additions and 21 deletions

View File

@@ -32,7 +32,7 @@ public class EntityGroup<T extends Entityc> implements Iterable<T>{
/** Makes sure the next ID counter is higher than this number, so future entities cannot possibly use this ID. */
public static void checkNextId(int id){
lastId = id + 1;
lastId = Math.max(lastId, id + 1);
}
public EntityGroup(Class<T> type, boolean spatial, boolean mapping){
@@ -47,6 +47,18 @@ public class EntityGroup<T extends Entityc> implements Iterable<T>{
}
}
/** @return entities with colliding IDs, or an empty array. */
public Seq<T> checkIDCollisions(){
Seq<T> out = new Seq<>();
IntSet ints = new IntSet();
each(u -> {
if(!ints.add(u.id())){
out.add(u);
}
});
return out;
}
public void sort(Comparator<? super T> comp){
array.sort(comp);
}

View File

@@ -173,6 +173,22 @@ public class Units{
return boolResult;
}
public static boolean anyEntities(float x, float y, float width, float height, Boolf<Unit> check){
boolResult = false;
nearby(x, y, width, height, unit -> {
if(boolResult) return;
if(check.get(unit)){
unit.hitboxTile(hitrect);
if(hitrect.overlaps(aeX, aeY, aeW, aeH)){
boolResult = true;
}
}
});
return boolResult;
}
/** Returns the nearest damaged tile. */
public static Building findDamagedTile(Team team, float x, float y){
return indexer.getDamaged(team).min(b -> b.dst2(x, y));