Merging changes from private branch

This commit is contained in:
Anuken
2025-04-04 11:47:35 -04:00
parent cf5c6d0905
commit b7dbe54d76
161 changed files with 2484 additions and 1137 deletions

View File

@@ -21,11 +21,12 @@ public class AIController implements UnitController{
protected Unit unit;
protected Interval timer = new Interval(4);
protected AIController fallback;
protected @Nullable AIController fallback;
protected float noTargetTime;
/** main target that is being faced */
protected Teamc target;
protected @Nullable Teamc target;
protected @Nullable Teamc bomberTarget;
{
resetTimers();
@@ -124,15 +125,27 @@ public class AIController implements UnitController{
}
public void pathfind(int pathTarget){
int costType = unit.pathType();
pathfind(pathTarget, true);
}
public void pathfind(int pathTarget, boolean stopAtTargetTile){
int costType = unit.type.flowfieldPathType;
Tile tile = unit.tileOn();
if(tile == null) return;
Tile targetTile = pathfinder.getTargetTile(tile, pathfinder.getField(unit.team, costType, pathTarget));
Tile targetTile = pathfinder.getField(unit.team, costType, pathTarget).getNextTile(tile);
if(tile == targetTile || !unit.canPass(targetTile.x, targetTile.y)) return;
if((tile == targetTile && stopAtTargetTile) || !unit.canPass(targetTile.x, targetTile.y)) return;
unit.movePref(vec.trns(unit.angleTo(targetTile.worldx(), targetTile.worldy()), prefSpeed()));
unit.movePref(alterPathfind(vec.set(targetTile.worldx(), targetTile.worldy()).sub(tile.worldx(), tile.worldy()).setLength(prefSpeed())));
}
public Vec2 alterPathfind(Vec2 vec){
return vec;
}
public void targetInvalidated(){
//TODO: try this for normal units, reset the target timer
}
public void updateWeapons(){
@@ -146,6 +159,9 @@ public class AIController implements UnitController{
noTargetTime += Time.delta;
if(invalid(target)){
if(target != null && !target.isAdded()){
targetInvalidated();
}
target = null;
}else{
noTargetTime = 0f;
@@ -185,6 +201,13 @@ public class AIController implements UnitController{
if(mount.target != null){
shoot = mount.target.within(mountX, mountY, wrange + (mount.target instanceof Sized s ? s.hitSize()/2f : 0f)) && shouldShoot();
if(unit.type.autoDropBombs && !shoot){
if(bomberTarget == null || !bomberTarget.isAdded() || !bomberTarget.within(unit, unit.hitSize/2f + ((Sized)bomberTarget).hitSize()/2f)){
bomberTarget = Units.closestTarget(unit.team, unit.x, unit.y, unit.hitSize, u -> !u.isFlying(), t -> true);
}
shoot = bomberTarget != null;
}
Vec2 to = Predict.intercept(unit, mount.target, weapon.bullet.speed);
mount.aimX = to.x;
mount.aimY = to.y;