Ram stance + Mobile command queue support

This commit is contained in:
Anuken
2023-09-21 09:57:57 -04:00
parent 7ce05fde7a
commit a6ec8f4bcc
9 changed files with 54 additions and 16 deletions

View File

@@ -15,7 +15,8 @@ public class UnitStance{
shootStance = new UnitStance("shoot", "commandAttack"),
holdFireStance = new UnitStance("holdfire", "none"),
pursueTarget = new UnitStance("pursuetarget", "right"),
patrol = new UnitStance("patrol", "refresh");
patrol = new UnitStance("patrol", "refresh"),
ram = new UnitStance("ram", "rightOpen");
/** Unique ID number. */
public final int id;

View File

@@ -165,7 +165,7 @@ public class CommandAI extends AIController{
}
targetPos.set(attackTarget);
if(unit.isGrounded() && attackTarget instanceof Building build && build.tile.solid() && unit.pathType() != Pathfinder.costLegs){
if(unit.isGrounded() && attackTarget instanceof Building build && build.tile.solid() && unit.pathType() != Pathfinder.costLegs && stance != UnitStance.ram){
Tile best = build.findClosestEdge(unit, Tile::solid);
if(best != null){
targetPos.set(best);
@@ -177,7 +177,7 @@ public class CommandAI extends AIController{
boolean move = true;
vecOut.set(targetPos);
if(unit.isGrounded()){
if(unit.isGrounded() && stance != UnitStance.ram){
move = Vars.controlPath.getPathPosition(unit, pathId, targetPos, vecOut, noFound);
//if the path is invalid, stop trying and record the end as unreachable
@@ -201,9 +201,9 @@ public class CommandAI extends AIController{
boolean isFinalPoint = targetPos.epsilonEquals(vecOut, 4.1f) && commandQueue.size == 0;
moveTo(vecOut,
attackTarget != null && unit.within(attackTarget, engageRange) ? engageRange :
attackTarget != null && unit.within(attackTarget, engageRange) && stance != UnitStance.ram ? engageRange :
unit.isGrounded() ? 0f :
attackTarget != null ? engageRange :
attackTarget != null && stance != UnitStance.ram ? engageRange :
0f, unit.isFlying() ? 40f : 100f, false, null, isFinalPoint);
}
}

View File

@@ -1285,7 +1285,7 @@ public class UnitTypes{
lowAltitude = true;
ammoType = new PowerAmmoType(900);
stances = new UnitStance[]{UnitStance.stopStance, UnitStance.shootStance, UnitStance.holdFireStance};
stances = new UnitStance[]{UnitStance.stopStance, UnitStance.shootStance, UnitStance.holdFireStance, UnitStance.patrol};
mineTier = 2;
mineSpeed = 3.5f;
@@ -1345,7 +1345,7 @@ public class UnitTypes{
isEnemy = false;
ammoType = new PowerAmmoType(1100);
stances = new UnitStance[]{UnitStance.stopStance, UnitStance.shootStance, UnitStance.holdFireStance};
stances = new UnitStance[]{UnitStance.stopStance, UnitStance.shootStance, UnitStance.holdFireStance, UnitStance.patrol};
weapons.add(
new Weapon("heal-weapon-mount"){{

View File

@@ -307,6 +307,8 @@ public class Teams{
//convert all team tiles to neutral, randomly killing them
for(var b : builds){
if(b.block.privileged) continue;
if(b instanceof CoreBuild){
b.kill();
}else{

View File

@@ -54,8 +54,8 @@ public class MobileInput extends InputHandler implements GestureListener{
public Seq<BuildPlan> removals = new Seq<>();
/** Whether the player is currently shifting all placed tiles. */
public boolean selecting;
/** Whether the player is currently in line-place mode. */
public boolean lineMode, schematicMode, rebuildMode;
/** Various modes that aren't enums for some reason. This should be cleaned up. */
public boolean lineMode, schematicMode, rebuildMode, queueCommandMode;
/** Current place mode. */
public PlaceMode mode = none;
/** Whether no recipe was available when switching to break mode. */
@@ -287,16 +287,24 @@ public class MobileInput extends InputHandler implements GestureListener{
group.fill(t -> {
t.visible(() -> !showCancel() && block == null && !hasSchem());
t.bottom().left();
t.button("@command", Icon.units, Styles.squareTogglet, () -> {
t.button("@command", Icon.units, Styles.clearTogglet, () -> {
commandMode = !commandMode;
}).width(155f).height(50f).margin(12f).checked(b -> commandMode).row();
}).width(155f).height(56f).margin(12f).checked(b -> {
b.setText(queueCommandMode ? bundle.get("command") + "\n" + bundle.get("command.queue") : bundle.get("command"));
return commandMode;
});
t.button(Icon.rightOpen, Styles.clearTogglei, () -> {
queueCommandMode = !queueCommandMode;
}).size(56f).margin(12f).checked(b -> queueCommandMode).visible(() -> commandMode).row();
//for better looking insets
t.rect((x, y, w, h) -> {
if(Core.scene.marginBottom > 0){
Tex.paneRight.draw(x, 0, w, y);
}
}).fillX().row();
}).fillX().colspan(2).row();
});
group.fill(t -> {
@@ -681,7 +689,7 @@ public class MobileInput extends InputHandler implements GestureListener{
selectPlans.add(new BuildPlan(linked.x, linked.y));
}else if((commandMode && selectedUnits.size > 0) || commandBuildings.size > 0){
//handle selecting units with command mode
commandTap(x, y);
commandTap(x, y, queueCommandMode);
}else if(commandMode){
tapCommandUnit();
}else{
@@ -734,6 +742,10 @@ public class MobileInput extends InputHandler implements GestureListener{
boolean locked = locked();
if(!commandMode){
queueCommandMode = false;
}
if(player.dead()){
mode = none;
manualShooting = false;

View File

@@ -836,7 +836,11 @@ public class UnitType extends UnlockableContent implements Senseable{
if(stances.length == 0){
if(canAttack){
stances = new UnitStance[]{UnitStance.stopStance, UnitStance.shootStance, UnitStance.holdFireStance, UnitStance.pursueTarget, UnitStance.patrol};
Seq<UnitStance> seq = Seq.with(UnitStance.stopStance, UnitStance.shootStance, UnitStance.holdFireStance, UnitStance.pursueTarget, UnitStance.patrol);
if(crushDamage > 0){
seq.add(UnitStance.ram);
}
stances = seq.toArray(UnitStance.class);
}else{
stances = new UnitStance[]{UnitStance.stopStance};
}

View File

@@ -48,6 +48,8 @@ public class Styles{
togglet,
/** Partially transparent square button. */
cleart,
/** Clear, square, orange border, toggleable. */
clearTogglet,
/** Similar to flatToggle, but without a darker border. */
fullTogglet,
/** Toggle-able version of flatBorder. */
@@ -219,6 +221,16 @@ public class Styles{
disabled = buttonDisabled;
disabledFontColor = Color.gray;
}};
clearTogglet = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;
down = flatDown;
checked = flatDown;
up = black6;
over = flatOver;
disabled = black;
disabledFontColor = Color.gray;
}};
fullTogglet = new TextButtonStyle(){{
font = Fonts.def;
fontColor = Color.white;

View File

@@ -510,6 +510,7 @@ public class PlacementFragment{
u.table(coms -> {
coms.left();
int scol = 0;
for(var command : commands){
coms.button(Icon.icons.get(command.icon, Icon.cancel), Styles.clearNoneTogglei, () -> {
IntSeq ids = new IntSeq();
@@ -519,7 +520,10 @@ public class PlacementFragment{
Call.setUnitCommand(Vars.player, ids.toArray(), command);
}).checked(i -> currentCommand[0] == command).size(50f).tooltip(command.localized());
if(++scol % 6 == 0) coms.row();
}
}).fillX().padTop(4f).left();
}
@@ -529,9 +533,8 @@ public class PlacementFragment{
u.table(coms -> {
coms.left();
int scol = 0;
for(var stance : stances){
//TODO: patrolling is pointless on mobile since you can't queue commands
if(stance == UnitStance.patrol && mobile) continue;
coms.button(Icon.icons.get(stance.icon, Icon.cancel), Styles.clearNoneTogglei, () -> {
IntSeq ids = new IntSeq();
@@ -541,6 +544,8 @@ public class PlacementFragment{
Call.setUnitStance(Vars.player, ids.toArray(), stance);
}).checked(i -> currentStance[0] == stance).size(50f).tooltip(stance.localized());
if(++scol % 6 == 0) coms.row();
}
}).fillX().padTop(4f).left();
}