argh
This commit is contained in:
@@ -45,7 +45,7 @@ public class BaseAI{
|
||||
|
||||
//create AI core unit
|
||||
if(!Groups.unit.contains(u -> u.team() == data.team && u.type() == block.unitType)){
|
||||
Unitc unit = block.unitType.create(data.team);
|
||||
Unit unit = block.unitType.create(data.team);
|
||||
unit.set(data.core());
|
||||
unit.add();
|
||||
Fx.spawn.at(unit);
|
||||
|
||||
@@ -51,7 +51,7 @@ public class BlockIndexer{
|
||||
private Seq<Tile> returnArray = new Seq<>();
|
||||
|
||||
public BlockIndexer(){
|
||||
Events.on(TileChangeEvent.class, event -> {
|
||||
Events.on(BuildinghangeEvent.class, event -> {
|
||||
if(typeMap.get(event.tile.pos()) != null){
|
||||
TileIndex index = typeMap.get(event.tile.pos());
|
||||
for(BlockFlag flag : index.flags){
|
||||
@@ -164,11 +164,11 @@ public class BlockIndexer{
|
||||
return flagMap[team.id][type.ordinal()];
|
||||
}
|
||||
|
||||
public boolean eachBlock(Teamc team, float range, Boolf<Tilec> pred, Cons<Tilec> cons){
|
||||
public boolean eachBlock(Teamc team, float range, Boolf<Building> pred, Cons<Building> cons){
|
||||
return eachBlock(team.team(), team.getX(), team.getY(), range, pred, cons);
|
||||
}
|
||||
|
||||
public boolean eachBlock(Team team, float wx, float wy, float range, Boolf<Tilec> pred, Cons<Tilec> cons){
|
||||
public boolean eachBlock(Team team, float wx, float wy, float range, Boolf<Building> pred, Cons<Building> cons){
|
||||
intSet.clear();
|
||||
|
||||
int tx = world.toTile(wx);
|
||||
@@ -181,7 +181,7 @@ public class BlockIndexer{
|
||||
for(int y = -tileRange + ty; y <= tileRange + ty; y++){
|
||||
if(!Mathf.within(x * tilesize, y * tilesize, wx, wy, range)) continue;
|
||||
|
||||
Tilec other = world.ent(x, y);
|
||||
Building other = world.ent(x, y);
|
||||
|
||||
if(other == null) continue;
|
||||
|
||||
@@ -211,7 +211,7 @@ public class BlockIndexer{
|
||||
return returnArray;
|
||||
}
|
||||
|
||||
public void notifyTileDamaged(Tilec entity){
|
||||
public void notifyTileDamaged(Building entity){
|
||||
if(damagedTiles[(int)entity.team().id] == null){
|
||||
damagedTiles[(int)entity.team().id] = new TileArray();
|
||||
}
|
||||
@@ -220,11 +220,11 @@ public class BlockIndexer{
|
||||
set.add(entity.tile());
|
||||
}
|
||||
|
||||
public Tilec findEnemyTile(Team team, float x, float y, float range, Boolf<Tilec> pred){
|
||||
public Building findEnemyTile(Team team, float x, float y, float range, Boolf<Building> pred){
|
||||
for(Team enemy : activeTeams){
|
||||
if(!team.isEnemy(enemy)) continue;
|
||||
|
||||
Tilec entity = indexer.findTile(enemy, x, y, range, pred, true);
|
||||
Building entity = indexer.findTile(enemy, x, y, range, pred, true);
|
||||
if(entity != null){
|
||||
return entity;
|
||||
}
|
||||
@@ -233,12 +233,12 @@ public class BlockIndexer{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Tilec findTile(Team team, float x, float y, float range, Boolf<Tilec> pred){
|
||||
public Building findTile(Team team, float x, float y, float range, Boolf<Building> pred){
|
||||
return findTile(team, x, y, range, pred, false);
|
||||
}
|
||||
|
||||
public Tilec findTile(Team team, float x, float y, float range, Boolf<Tilec> pred, boolean usePriority){
|
||||
Tilec closest = null;
|
||||
public Building findTile(Team team, float x, float y, float range, Boolf<Building> pred, boolean usePriority){
|
||||
Building closest = null;
|
||||
float dst = 0;
|
||||
float range2 = range * range;
|
||||
|
||||
@@ -249,7 +249,7 @@ public class BlockIndexer{
|
||||
|
||||
for(int tx = rx * quadrantSize; tx < (rx + 1) * quadrantSize && tx < world.width(); tx++){
|
||||
for(int ty = ry * quadrantSize; ty < (ry + 1) * quadrantSize && ty < world.height(); ty++){
|
||||
Tilec e = world.ent(tx, ty);
|
||||
Building e = world.ent(tx, ty);
|
||||
|
||||
if(e == null) continue;
|
||||
|
||||
@@ -390,7 +390,7 @@ public class BlockIndexer{
|
||||
outer:
|
||||
for(int x = quadrantX * quadrantSize; x < world.width() && x < (quadrantX + 1) * quadrantSize; x++){
|
||||
for(int y = quadrantY * quadrantSize; y < world.height() && y < (quadrantY + 1) * quadrantSize; y++){
|
||||
Tilec result = world.ent(x, y);
|
||||
Building result = world.ent(x, y);
|
||||
//when a targetable block is found, mark this quadrant as occupied and stop searching
|
||||
if(result != null && result.team() == team){
|
||||
bits.set(quadrantX, quadrantY);
|
||||
|
||||
@@ -63,7 +63,7 @@ public class Pathfinder implements Runnable{
|
||||
|
||||
Events.on(ResetEvent.class, event -> stop());
|
||||
|
||||
Events.on(TileChangeEvent.class, event -> updateTile(event.tile));
|
||||
Events.on(BuildinghangeEvent.class, event -> updateTile(event.tile));
|
||||
}
|
||||
|
||||
/** Packs a tile into its internal representation. */
|
||||
|
||||
@@ -48,7 +48,7 @@ public class WaveSpawner{
|
||||
|
||||
eachFlyerSpawn((spawnX, spawnY) -> {
|
||||
for(int i = 0; i < spawned; i++){
|
||||
Unitc unit = group.createUnit(state.rules.waveTeam, state.wave - 1);
|
||||
Unit unit = group.createUnit(state.rules.waveTeam, state.wave - 1);
|
||||
unit.set(spawnX + Mathf.range(spread), spawnY + Mathf.range(spread));
|
||||
unit.add();
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class WaveSpawner{
|
||||
for(int i = 0; i < spawned; i++){
|
||||
Tmp.v1.rnd(spread);
|
||||
|
||||
Unitc unit = group.createUnit(state.rules.waveTeam, state.wave - 1);
|
||||
Unit unit = group.createUnit(state.rules.waveTeam, state.wave - 1);
|
||||
unit.set(spawnX + Tmp.v1.x, spawnY + Tmp.v1.y);
|
||||
Time.run(Math.min(i * 5, 60 * 2), () -> spawnEffect(unit));
|
||||
}
|
||||
@@ -85,8 +85,8 @@ public class WaveSpawner{
|
||||
}
|
||||
|
||||
if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam) && !state.teams.playerCores().isEmpty()){
|
||||
Tilec firstCore = state.teams.playerCores().first();
|
||||
for(Tilec core : state.rules.waveTeam.cores()){
|
||||
Building firstCore = state.teams.playerCores().first();
|
||||
for(Building core : state.rules.waveTeam.cores()){
|
||||
Tmp.v1.set(firstCore).sub(core).limit(coreMargin + core.block().size * tilesize);
|
||||
cons.accept(core.x() + Tmp.v1.x, core.y() + Tmp.v1.y, false);
|
||||
}
|
||||
@@ -104,7 +104,7 @@ public class WaveSpawner{
|
||||
}
|
||||
|
||||
if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam)){
|
||||
for(Tilec core : state.teams.get(state.rules.waveTeam).cores){
|
||||
for(Building core : state.teams.get(state.rules.waveTeam).cores){
|
||||
cons.get(core.x(), core.y());
|
||||
}
|
||||
}
|
||||
@@ -124,7 +124,7 @@ public class WaveSpawner{
|
||||
}
|
||||
}
|
||||
|
||||
private void spawnEffect(Unitc unit){
|
||||
private void spawnEffect(Unit unit){
|
||||
Fx.unitSpawn.at(unit.x(), unit.y(), 0f, unit);
|
||||
Time.run(30f, () -> {
|
||||
unit.add();
|
||||
|
||||
@@ -8,58 +8,58 @@ import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
public class FormationAI extends AIController implements FormationMember{
|
||||
public Unitc leader;
|
||||
public Unit leader;
|
||||
|
||||
private Vec3 target = new Vec3();
|
||||
private @Nullable Formation formation;
|
||||
|
||||
public FormationAI(Unitc leader, Formation formation){
|
||||
public FormationAI(Unit leader, Formation formation){
|
||||
this.leader = leader;
|
||||
this.formation = formation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
target.set(unit.x(), unit.y(), 0);
|
||||
target.set(unit.x, unit.y, 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateUnit(){
|
||||
if(leader.dead()){
|
||||
if(leader.dead){
|
||||
unit.resetController();
|
||||
return;
|
||||
}
|
||||
|
||||
unit.controlWeapons(leader.isRotate(), leader.isShooting());
|
||||
unit.controlWeapons(leader.isRotate(), leader.isShooting);
|
||||
// unit.moveAt(Tmp.v1.set(deltaX, deltaY).limit(unit.type().speed));
|
||||
if(leader.isShooting()){
|
||||
if(leader.isShooting){
|
||||
unit.aimLook(leader.aimX(), leader.aimY());
|
||||
}else{
|
||||
if(!unit.moving()){
|
||||
unit.lookAt(unit.vel().angle());
|
||||
unit.lookAt(unit.vel.angle());
|
||||
}else{
|
||||
unit.lookAt(leader.rotation());
|
||||
unit.lookAt(leader.rotation);
|
||||
}
|
||||
}
|
||||
|
||||
Vec2 realtarget = vec.set(target);
|
||||
|
||||
if(unit.isGrounded() && Vars.world.raycast(unit.tileX(), unit.tileY(), leader.tileX(), leader.tileY(), Vars.world::solid)){
|
||||
realtarget.set(Vars.pathfinder.getTargetTile(unit.tileOn(), unit.team(), leader));
|
||||
realtarget.set(Vars.pathfinder.getTargetTile(unit.tileOn(), unit.team, leader));
|
||||
}
|
||||
|
||||
unit.moveAt(realtarget.sub(unit).limit(unit.type().speed));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removed(Unitc unit){
|
||||
public void removed(Unit unit){
|
||||
if(formation != null){
|
||||
formation.removeMember(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBeingControlled(Unitc player){
|
||||
public boolean isBeingControlled(Unit player){
|
||||
return leader == player;
|
||||
}
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class GroundAI extends AIController{
|
||||
targetClosest();
|
||||
}
|
||||
|
||||
Tilec core = unit.closestEnemyCore();
|
||||
Building core = unit.closestEnemyCore();
|
||||
|
||||
if(core != null){
|
||||
if(unit.within(core,unit.range() / 1.1f)){
|
||||
@@ -81,7 +81,7 @@ public class GroundAI extends AIController{
|
||||
Tile tile = unit.tileOn();
|
||||
if(tile == null) return;
|
||||
Tile targetTile = pathfinder.getTargetTile(tile, enemy, FlagTarget.enemyCores);
|
||||
Tilec core = unit.closestCore();
|
||||
Building core = unit.closestCore();
|
||||
|
||||
if(tile == targetTile || core == null || unit.within(core, 120f)) return;
|
||||
|
||||
|
||||
@@ -20,14 +20,14 @@ public class SuicideAI extends GroundAI{
|
||||
targetClosest();
|
||||
}
|
||||
|
||||
Tilec core = unit.closestEnemyCore();
|
||||
Building core = unit.closestEnemyCore();
|
||||
|
||||
boolean rotate = false, shoot = false;
|
||||
|
||||
if(!Units.invalidateTarget(target, unit, unit.range())){
|
||||
rotate = true;
|
||||
shoot = unit.within(target, unit.type().weapons.first().bullet.range() +
|
||||
(target instanceof Tilec ? ((Tilec)target).block().size * Vars.tilesize / 2f : ((Hitboxc)target).hitSize() / 2f));
|
||||
(target instanceof Building ? ((Building)target).block().size * Vars.tilesize / 2f : ((Hitboxc)target).hitSize() / 2f));
|
||||
|
||||
if(unit.type().hasWeapons()){
|
||||
unit.aimLook(Predict.intercept(unit, target, unit.type().weapons.first().bullet.speed));
|
||||
|
||||
Reference in New Issue
Block a user