too many things to list
This commit is contained in:
@@ -450,7 +450,7 @@ public class Pathfinder implements Runnable{
|
||||
* Data for a flow field to some set of destinations.
|
||||
* Concrete subclasses must specify a way to fetch costs and destinations.
|
||||
* */
|
||||
static abstract class Flowfield{
|
||||
public static abstract class Flowfield{
|
||||
/** Refresh rate in milliseconds. Return any number <= 0 to disable. */
|
||||
protected int refreshRate;
|
||||
/** Team this path is for. Set before using. */
|
||||
@@ -459,7 +459,7 @@ public class Pathfinder implements Runnable{
|
||||
protected PathCost cost = costTypes.get(costGround);
|
||||
|
||||
/** costs of getting to a specific tile */
|
||||
int[][] weights;
|
||||
public int[][] weights;
|
||||
/** search IDs of each position - the highest, most recent search is prioritized and overwritten */
|
||||
int[][] searches;
|
||||
/** search frontier, these are Pos objects */
|
||||
|
||||
@@ -23,11 +23,21 @@ public class WaveSpawner{
|
||||
private Seq<Tile> spawns = new Seq<>();
|
||||
private boolean spawning = false;
|
||||
private boolean any = false;
|
||||
private Tile firstSpawn = null;
|
||||
|
||||
public WaveSpawner(){
|
||||
Events.on(WorldLoadEvent.class, e -> reset());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Tile getFirstSpawn(){
|
||||
firstSpawn = null;
|
||||
eachGroundSpawn((cx, cy) -> {
|
||||
firstSpawn = world.tile(cx, cy);
|
||||
});
|
||||
return firstSpawn;
|
||||
}
|
||||
|
||||
public int countSpawns(){
|
||||
return spawns.size;
|
||||
}
|
||||
@@ -47,7 +57,7 @@ public class WaveSpawner{
|
||||
for(SpawnGroup group : state.rules.spawns){
|
||||
if(group.type == null) continue;
|
||||
|
||||
int spawned = group.getUnitsSpawned(state.wave - 1);
|
||||
int spawned = group.getSpawned(state.wave - 1);
|
||||
|
||||
if(group.type.flying){
|
||||
float spread = margin / 1.5f;
|
||||
@@ -89,6 +99,10 @@ public class WaveSpawner{
|
||||
Time.run(40f, () -> Damage.damage(state.rules.waveTeam, x, y, state.rules.dropZoneRadius, 99999999f, true));
|
||||
}
|
||||
|
||||
public void eachGroundSpawn(Intc2 cons){
|
||||
eachGroundSpawn((x, y, shock) -> cons.get(world.toTile(x), world.toTile(y)));
|
||||
}
|
||||
|
||||
private void eachGroundSpawn(SpawnConsumer cons){
|
||||
for(Tile spawn : spawns){
|
||||
cons.accept(spawn.worldx(), spawn.worldy(), true);
|
||||
|
||||
@@ -7,6 +7,7 @@ import mindustry.ai.formations.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.blocks.storage.CoreBlock.*;
|
||||
|
||||
public class FormationAI extends AIController implements FormationMember{
|
||||
public Unit leader;
|
||||
@@ -57,6 +58,30 @@ public class FormationAI extends AIController implements FormationMember{
|
||||
}else{
|
||||
unit.moveAt(realtarget.sub(unit).limit(type.speed));
|
||||
}
|
||||
|
||||
if(unit instanceof Minerc mine && leader instanceof Minerc com){
|
||||
if(mine.validMine(com.mineTile())){
|
||||
mine.mineTile(com.mineTile());
|
||||
|
||||
CoreBuild core = unit.team.core();
|
||||
|
||||
if(core != null && com.mineTile().drop() != null && unit.within(core, unit.type().range) && !unit.acceptsItem(com.mineTile().drop())){
|
||||
if(core.acceptStack(unit.stack.item, unit.stack.amount, unit) > 0){
|
||||
Call.transferItemTo(unit.stack.item, unit.stack.amount, unit.x, unit.y, core);
|
||||
|
||||
unit.clearItem();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
mine.mineTile(null);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if(unit instanceof Builderc build && leader instanceof Builderc com && com.activelyBuilding()){
|
||||
build.clearBuilding();
|
||||
build.addBuild(com.buildPlan());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -24,7 +24,9 @@ public class MinerAI extends AIController{
|
||||
}
|
||||
|
||||
if(mining){
|
||||
targetItem = unit.team.data().mineItems.min(i -> indexer.hasOre(i) && miner.canMine(i), i -> core.items.get(i));
|
||||
if(timer.get(timerTarget2, 60 * 4) || targetItem == null){
|
||||
targetItem = unit.team.data().mineItems.min(i -> indexer.hasOre(i) && miner.canMine(i), i -> core.items.get(i));
|
||||
}
|
||||
|
||||
//core full of the target item, do nothing
|
||||
if(targetItem != null && core.acceptStack(targetItem, 1, unit) == 0){
|
||||
|
||||
@@ -23,7 +23,7 @@ public class RepairAI extends AIController{
|
||||
}
|
||||
|
||||
if(target != null){
|
||||
if(!target.within(unit, unit.type().range * 0.65f)){
|
||||
if(!target.within(unit, unit.type().range * 0.65f) && target instanceof Building){
|
||||
moveTo(target, unit.type().range * 0.65f);
|
||||
}
|
||||
|
||||
@@ -33,12 +33,14 @@ public class RepairAI extends AIController{
|
||||
|
||||
@Override
|
||||
protected void updateTargeting(){
|
||||
target = Units.findDamagedTile(unit.team, unit.x, unit.y);
|
||||
Building target = Units.findDamagedTile(unit.team, unit.x, unit.y);
|
||||
|
||||
if(target instanceof ConstructBuild) target = null;
|
||||
|
||||
if(target == null){
|
||||
super.updateTargeting();
|
||||
}else{
|
||||
this.target = target;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user