Boost unit rebuild/assist commands

This commit is contained in:
Anuken
2024-06-13 10:51:59 -04:00
parent 87584ebd0b
commit 2357e8768b
3 changed files with 17 additions and 2 deletions

View File

@@ -47,6 +47,8 @@ public class BuilderAI extends AIController{
if(target != null && shouldShoot()){
unit.lookAt(target);
}else if(!unit.type.flying){
unit.lookAt(unit.prefRotation());
}
unit.updateBuilding = true;
@@ -55,6 +57,8 @@ public class BuilderAI extends AIController{
following = assistFollowing;
}
boolean moving = false;
if(following != null){
retreatTimer = 0f;
//try to follow and mimic someone
@@ -83,6 +87,7 @@ public class BuilderAI extends AIController{
var core = unit.closestCore();
if(core != null && !unit.within(core, retreatDst)){
moveTo(core, retreatDst);
moving = true;
}
}
}
@@ -114,7 +119,8 @@ public class BuilderAI extends AIController{
if(valid){
//move toward the plan
moveTo(req.tile(), unit.type.buildRange - 20f);
moveTo(req.tile(), unit.type.buildRange - 20f, 20f);
moving = !unit.within(req.tile(), unit.type.buildRange - 10f);
}else{
//discard invalid plan
unit.plans.removeFirst();
@@ -124,6 +130,7 @@ public class BuilderAI extends AIController{
if(assistFollowing != null){
moveTo(assistFollowing, assistFollowing.type.hitSize + unit.type.hitSize/2f + 60f);
moving = !unit.within(assistFollowing, assistFollowing.type.hitSize + unit.type.hitSize/2f + 65f);
}
//follow someone and help them build
@@ -186,6 +193,10 @@ public class BuilderAI extends AIController{
}
}
}
if(!unit.type.flying){
unit.updateBoosting(moving || unit.floorOn().isDuct || unit.floorOn().damageTaken > 0f);
}
}
protected boolean nearEnemy(int x, int y){

View File

@@ -99,7 +99,7 @@ public class StatusEffect extends UnlockableContent{
boolean reacts = false;
for(var e : opposites.toSeq().sort()){
stats.add(Stat.opposites, e.emoji() + "" + e);
stats.add(Stat.opposites, e.emoji() + e);
}
if(reactive){

View File

@@ -828,6 +828,10 @@ public class UnitType extends UnlockableContent implements Senseable{
if(canBoost){
cmds.add(UnitCommand.boostCommand);
if(buildSpeed > 0f){
cmds.add(UnitCommand.rebuildCommand, UnitCommand.assistCommand);
}
}
//healing, mining and building is only supported for flying units; pathfinding to ambiguously reachable locations is hard.