Ram stance + Mobile command queue support
This commit is contained in:
@@ -347,6 +347,7 @@ open = Open
|
|||||||
customize = Customize Rules
|
customize = Customize Rules
|
||||||
cancel = Cancel
|
cancel = Cancel
|
||||||
command = Command
|
command = Command
|
||||||
|
command.queue = [lightgray][Queuing]
|
||||||
command.mine = Mine
|
command.mine = Mine
|
||||||
command.repair = Repair
|
command.repair = Repair
|
||||||
command.rebuild = Rebuild
|
command.rebuild = Rebuild
|
||||||
@@ -358,6 +359,7 @@ stance.shoot = Stance: Shoot
|
|||||||
stance.holdfire = Stance: Hold Fire
|
stance.holdfire = Stance: Hold Fire
|
||||||
stance.pursuetarget = Stance: Pursue Target
|
stance.pursuetarget = Stance: Pursue Target
|
||||||
stance.patrol = Stance: Patrol Path
|
stance.patrol = Stance: Patrol Path
|
||||||
|
stance.ram = Stance: Ram\n[lightgray]Straight line movement, no pathfinding
|
||||||
openlink = Open Link
|
openlink = Open Link
|
||||||
copylink = Copy Link
|
copylink = Copy Link
|
||||||
back = Back
|
back = Back
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ public class UnitStance{
|
|||||||
shootStance = new UnitStance("shoot", "commandAttack"),
|
shootStance = new UnitStance("shoot", "commandAttack"),
|
||||||
holdFireStance = new UnitStance("holdfire", "none"),
|
holdFireStance = new UnitStance("holdfire", "none"),
|
||||||
pursueTarget = new UnitStance("pursuetarget", "right"),
|
pursueTarget = new UnitStance("pursuetarget", "right"),
|
||||||
patrol = new UnitStance("patrol", "refresh");
|
patrol = new UnitStance("patrol", "refresh"),
|
||||||
|
ram = new UnitStance("ram", "rightOpen");
|
||||||
|
|
||||||
/** Unique ID number. */
|
/** Unique ID number. */
|
||||||
public final int id;
|
public final int id;
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ public class CommandAI extends AIController{
|
|||||||
}
|
}
|
||||||
targetPos.set(attackTarget);
|
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);
|
Tile best = build.findClosestEdge(unit, Tile::solid);
|
||||||
if(best != null){
|
if(best != null){
|
||||||
targetPos.set(best);
|
targetPos.set(best);
|
||||||
@@ -177,7 +177,7 @@ public class CommandAI extends AIController{
|
|||||||
boolean move = true;
|
boolean move = true;
|
||||||
vecOut.set(targetPos);
|
vecOut.set(targetPos);
|
||||||
|
|
||||||
if(unit.isGrounded()){
|
if(unit.isGrounded() && stance != UnitStance.ram){
|
||||||
move = Vars.controlPath.getPathPosition(unit, pathId, targetPos, vecOut, noFound);
|
move = Vars.controlPath.getPathPosition(unit, pathId, targetPos, vecOut, noFound);
|
||||||
|
|
||||||
//if the path is invalid, stop trying and record the end as unreachable
|
//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;
|
boolean isFinalPoint = targetPos.epsilonEquals(vecOut, 4.1f) && commandQueue.size == 0;
|
||||||
|
|
||||||
moveTo(vecOut,
|
moveTo(vecOut,
|
||||||
attackTarget != null && unit.within(attackTarget, engageRange) ? engageRange :
|
attackTarget != null && unit.within(attackTarget, engageRange) && stance != UnitStance.ram ? engageRange :
|
||||||
unit.isGrounded() ? 0f :
|
unit.isGrounded() ? 0f :
|
||||||
attackTarget != null ? engageRange :
|
attackTarget != null && stance != UnitStance.ram ? engageRange :
|
||||||
0f, unit.isFlying() ? 40f : 100f, false, null, isFinalPoint);
|
0f, unit.isFlying() ? 40f : 100f, false, null, isFinalPoint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1285,7 +1285,7 @@ public class UnitTypes{
|
|||||||
lowAltitude = true;
|
lowAltitude = true;
|
||||||
|
|
||||||
ammoType = new PowerAmmoType(900);
|
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;
|
mineTier = 2;
|
||||||
mineSpeed = 3.5f;
|
mineSpeed = 3.5f;
|
||||||
@@ -1345,7 +1345,7 @@ public class UnitTypes{
|
|||||||
isEnemy = false;
|
isEnemy = false;
|
||||||
|
|
||||||
ammoType = new PowerAmmoType(1100);
|
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(
|
weapons.add(
|
||||||
new Weapon("heal-weapon-mount"){{
|
new Weapon("heal-weapon-mount"){{
|
||||||
|
|||||||
@@ -307,6 +307,8 @@ public class Teams{
|
|||||||
|
|
||||||
//convert all team tiles to neutral, randomly killing them
|
//convert all team tiles to neutral, randomly killing them
|
||||||
for(var b : builds){
|
for(var b : builds){
|
||||||
|
if(b.block.privileged) continue;
|
||||||
|
|
||||||
if(b instanceof CoreBuild){
|
if(b instanceof CoreBuild){
|
||||||
b.kill();
|
b.kill();
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
@@ -54,8 +54,8 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
public Seq<BuildPlan> removals = new Seq<>();
|
public Seq<BuildPlan> removals = new Seq<>();
|
||||||
/** Whether the player is currently shifting all placed tiles. */
|
/** Whether the player is currently shifting all placed tiles. */
|
||||||
public boolean selecting;
|
public boolean selecting;
|
||||||
/** Whether the player is currently in line-place mode. */
|
/** Various modes that aren't enums for some reason. This should be cleaned up. */
|
||||||
public boolean lineMode, schematicMode, rebuildMode;
|
public boolean lineMode, schematicMode, rebuildMode, queueCommandMode;
|
||||||
/** Current place mode. */
|
/** Current place mode. */
|
||||||
public PlaceMode mode = none;
|
public PlaceMode mode = none;
|
||||||
/** Whether no recipe was available when switching to break mode. */
|
/** Whether no recipe was available when switching to break mode. */
|
||||||
@@ -287,16 +287,24 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
group.fill(t -> {
|
group.fill(t -> {
|
||||||
t.visible(() -> !showCancel() && block == null && !hasSchem());
|
t.visible(() -> !showCancel() && block == null && !hasSchem());
|
||||||
t.bottom().left();
|
t.bottom().left();
|
||||||
t.button("@command", Icon.units, Styles.squareTogglet, () -> {
|
|
||||||
|
t.button("@command", Icon.units, Styles.clearTogglet, () -> {
|
||||||
commandMode = !commandMode;
|
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
|
//for better looking insets
|
||||||
t.rect((x, y, w, h) -> {
|
t.rect((x, y, w, h) -> {
|
||||||
if(Core.scene.marginBottom > 0){
|
if(Core.scene.marginBottom > 0){
|
||||||
Tex.paneRight.draw(x, 0, w, y);
|
Tex.paneRight.draw(x, 0, w, y);
|
||||||
}
|
}
|
||||||
}).fillX().row();
|
}).fillX().colspan(2).row();
|
||||||
});
|
});
|
||||||
|
|
||||||
group.fill(t -> {
|
group.fill(t -> {
|
||||||
@@ -681,7 +689,7 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
selectPlans.add(new BuildPlan(linked.x, linked.y));
|
selectPlans.add(new BuildPlan(linked.x, linked.y));
|
||||||
}else if((commandMode && selectedUnits.size > 0) || commandBuildings.size > 0){
|
}else if((commandMode && selectedUnits.size > 0) || commandBuildings.size > 0){
|
||||||
//handle selecting units with command mode
|
//handle selecting units with command mode
|
||||||
commandTap(x, y);
|
commandTap(x, y, queueCommandMode);
|
||||||
}else if(commandMode){
|
}else if(commandMode){
|
||||||
tapCommandUnit();
|
tapCommandUnit();
|
||||||
}else{
|
}else{
|
||||||
@@ -734,6 +742,10 @@ public class MobileInput extends InputHandler implements GestureListener{
|
|||||||
|
|
||||||
boolean locked = locked();
|
boolean locked = locked();
|
||||||
|
|
||||||
|
if(!commandMode){
|
||||||
|
queueCommandMode = false;
|
||||||
|
}
|
||||||
|
|
||||||
if(player.dead()){
|
if(player.dead()){
|
||||||
mode = none;
|
mode = none;
|
||||||
manualShooting = false;
|
manualShooting = false;
|
||||||
|
|||||||
@@ -836,7 +836,11 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
|
|
||||||
if(stances.length == 0){
|
if(stances.length == 0){
|
||||||
if(canAttack){
|
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{
|
}else{
|
||||||
stances = new UnitStance[]{UnitStance.stopStance};
|
stances = new UnitStance[]{UnitStance.stopStance};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ public class Styles{
|
|||||||
togglet,
|
togglet,
|
||||||
/** Partially transparent square button. */
|
/** Partially transparent square button. */
|
||||||
cleart,
|
cleart,
|
||||||
|
/** Clear, square, orange border, toggleable. */
|
||||||
|
clearTogglet,
|
||||||
/** Similar to flatToggle, but without a darker border. */
|
/** Similar to flatToggle, but without a darker border. */
|
||||||
fullTogglet,
|
fullTogglet,
|
||||||
/** Toggle-able version of flatBorder. */
|
/** Toggle-able version of flatBorder. */
|
||||||
@@ -219,6 +221,16 @@ public class Styles{
|
|||||||
disabled = buttonDisabled;
|
disabled = buttonDisabled;
|
||||||
disabledFontColor = Color.gray;
|
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(){{
|
fullTogglet = new TextButtonStyle(){{
|
||||||
font = Fonts.def;
|
font = Fonts.def;
|
||||||
fontColor = Color.white;
|
fontColor = Color.white;
|
||||||
|
|||||||
@@ -510,6 +510,7 @@ public class PlacementFragment{
|
|||||||
|
|
||||||
u.table(coms -> {
|
u.table(coms -> {
|
||||||
coms.left();
|
coms.left();
|
||||||
|
int scol = 0;
|
||||||
for(var command : commands){
|
for(var command : commands){
|
||||||
coms.button(Icon.icons.get(command.icon, Icon.cancel), Styles.clearNoneTogglei, () -> {
|
coms.button(Icon.icons.get(command.icon, Icon.cancel), Styles.clearNoneTogglei, () -> {
|
||||||
IntSeq ids = new IntSeq();
|
IntSeq ids = new IntSeq();
|
||||||
@@ -519,7 +520,10 @@ public class PlacementFragment{
|
|||||||
|
|
||||||
Call.setUnitCommand(Vars.player, ids.toArray(), command);
|
Call.setUnitCommand(Vars.player, ids.toArray(), command);
|
||||||
}).checked(i -> currentCommand[0] == command).size(50f).tooltip(command.localized());
|
}).checked(i -> currentCommand[0] == command).size(50f).tooltip(command.localized());
|
||||||
|
|
||||||
|
if(++scol % 6 == 0) coms.row();
|
||||||
}
|
}
|
||||||
|
|
||||||
}).fillX().padTop(4f).left();
|
}).fillX().padTop(4f).left();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -529,9 +533,8 @@ public class PlacementFragment{
|
|||||||
|
|
||||||
u.table(coms -> {
|
u.table(coms -> {
|
||||||
coms.left();
|
coms.left();
|
||||||
|
int scol = 0;
|
||||||
for(var stance : stances){
|
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, () -> {
|
coms.button(Icon.icons.get(stance.icon, Icon.cancel), Styles.clearNoneTogglei, () -> {
|
||||||
IntSeq ids = new IntSeq();
|
IntSeq ids = new IntSeq();
|
||||||
@@ -541,6 +544,8 @@ public class PlacementFragment{
|
|||||||
|
|
||||||
Call.setUnitStance(Vars.player, ids.toArray(), stance);
|
Call.setUnitStance(Vars.player, ids.toArray(), stance);
|
||||||
}).checked(i -> currentStance[0] == stance).size(50f).tooltip(stance.localized());
|
}).checked(i -> currentStance[0] == stance).size(50f).tooltip(stance.localized());
|
||||||
|
|
||||||
|
if(++scol % 6 == 0) coms.row();
|
||||||
}
|
}
|
||||||
}).fillX().padTop(4f).left();
|
}).fillX().padTop(4f).left();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user