Made boosting a stance
This commit is contained in:
@@ -370,7 +370,6 @@ command.repair = Repair
|
||||
command.rebuild = Rebuild
|
||||
command.assist = Assist Player
|
||||
command.move = Move
|
||||
command.boost = Boost
|
||||
command.enterPayload = Enter Payload Block
|
||||
command.loadUnits = Load Units
|
||||
command.loadBlocks = Load Blocks
|
||||
@@ -382,6 +381,7 @@ stance.holdfire = Stance: Hold Fire
|
||||
stance.pursuetarget = Stance: Pursue Target
|
||||
stance.patrol = Stance: Patrol Path
|
||||
stance.ram = Stance: Ram\n[lightgray]Straight line movement, no pathfinding
|
||||
stance.boost = Boost
|
||||
stance.mineauto = Automatic Mining
|
||||
stance.mine = Mine Item: {0}
|
||||
openlink = Open Link
|
||||
@@ -1363,13 +1363,13 @@ keybind.unit_stance_hold_fire.name = Unit Stance: Hold Fire
|
||||
keybind.unit_stance_pursue_target.name = Unit Stance: Pursue Target
|
||||
keybind.unit_stance_patrol.name = Unit Stance: Patrol
|
||||
keybind.unit_stance_ram.name = Unit Stance: Ram
|
||||
keybind.unit_stance_boost.name = Unit Stance: Boost
|
||||
|
||||
keybind.unit_command_move.name = Unit Command: Move
|
||||
keybind.unit_command_repair.name = Unit Command: Repair
|
||||
keybind.unit_command_rebuild.name = Unit Command: Rebuild
|
||||
keybind.unit_command_assist.name = Unit Command: Assist
|
||||
keybind.unit_command_mine.name = Unit Command: Mine
|
||||
keybind.unit_command_boost.name = Unit Command: Boost
|
||||
keybind.unit_command_load_units.name = Unit Command: Load Units
|
||||
keybind.unit_command_load_blocks.name = Unit Command: Load Blocks
|
||||
keybind.unit_command_unload_payload.name = Unit Command: Unload Payload
|
||||
|
||||
@@ -13,7 +13,7 @@ import mindustry.input.*;
|
||||
|
||||
/** Defines a pattern of behavior that an RTS-controlled unit should follow. Shows up in the command UI. */
|
||||
public class UnitCommand extends MappableContent{
|
||||
public static UnitCommand moveCommand, repairCommand, rebuildCommand, assistCommand, mineCommand, boostCommand, enterPayloadCommand, loadUnitsCommand, loadBlocksCommand, unloadPayloadCommand, loopPayloadCommand;
|
||||
public static UnitCommand moveCommand, repairCommand, rebuildCommand, assistCommand, mineCommand, enterPayloadCommand, loadUnitsCommand, loadBlocksCommand, unloadPayloadCommand, loopPayloadCommand;
|
||||
|
||||
/** Name of UI icon (from Icon class). */
|
||||
public final String icon;
|
||||
@@ -84,11 +84,6 @@ public class UnitCommand extends MappableContent{
|
||||
mineCommand = new UnitCommand("mine", "production", Binding.unitCommandMine, u -> new MinerAI()){{
|
||||
refreshOnSelect = true;
|
||||
}};
|
||||
boostCommand = new UnitCommand("boost", "up", Binding.unitCommandBoost, u -> new BoostAI()){{
|
||||
switchToMove = false;
|
||||
drawTarget = true;
|
||||
resetTarget = false;
|
||||
}};
|
||||
enterPayloadCommand = new UnitCommand("enterPayload", "downOpen", Binding.unitCommandEnterPayload, u -> new BoostAI()){{
|
||||
switchToMove = false;
|
||||
drawTarget = true;
|
||||
|
||||
@@ -12,19 +12,22 @@ import mindustry.input.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
public class UnitStance extends MappableContent{
|
||||
public static UnitStance stop, holdFire, pursueTarget, patrol, ram, mineAuto;
|
||||
public static UnitStance stop, holdFire, pursueTarget, patrol, ram, boost, mineAuto;
|
||||
|
||||
/** Name of UI icon (from Icon class). */
|
||||
public String icon;
|
||||
/** Key to press for this stance. */
|
||||
public @Nullable KeyBind keybind;
|
||||
/** Commands that are mutually exclusive to this stance. This is used for convenience, for writing only! */
|
||||
public Seq<UnitCommand> incompatibleCommands = new Seq<>();
|
||||
/** Stances that are mutually exclusive to this stance. This is used for convenience, for writing only! */
|
||||
public Seq<UnitStance> incompatibleStances = new Seq<>();
|
||||
/** Incompatible stances as a bitset for easier operations. This is where incompatibility is actually stored. */
|
||||
public Bits incompatibleBits = new Bits(32);
|
||||
/** If true, this stance can be toggled on or off. */
|
||||
public boolean toggle = true;
|
||||
|
||||
/** Incompatible stances as a bitset for easier operations. This is where incompatibility is actually stored. */
|
||||
public Bits incompatibleStanceBits = new Bits(32), incompatibleCommandBits = new Bits(32);
|
||||
|
||||
public UnitStance(String name, String icon, KeyBind keybind, boolean toggle){
|
||||
super(name);
|
||||
this.icon = icon;
|
||||
@@ -42,9 +45,17 @@ public class UnitStance extends MappableContent{
|
||||
|
||||
for(var stance : incompatibleStances){
|
||||
if(stance == this) continue;
|
||||
incompatibleBits.set(stance.id);
|
||||
stance.incompatibleBits.set(id);
|
||||
incompatibleStanceBits.set(stance.id);
|
||||
stance.incompatibleStanceBits.set(id);
|
||||
}
|
||||
|
||||
for(var command : incompatibleCommands){
|
||||
incompatibleCommandBits.set(command.id);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isCompatible(@Nullable UnitCommand other){
|
||||
return other == null || !incompatibleCommandBits.get(other.id);
|
||||
}
|
||||
|
||||
public String localized(){
|
||||
@@ -75,6 +86,9 @@ public class UnitStance extends MappableContent{
|
||||
pursueTarget = new UnitStance("pursuetarget", "right", Binding.unitStancePursueTarget);
|
||||
patrol = new UnitStance("patrol", "refresh", Binding.unitStancePatrol);
|
||||
ram = new UnitStance("ram", "rightOpen", Binding.unitStanceRam);
|
||||
boost = new UnitStance("boost", "up", Binding.unitStanceBoost){{
|
||||
incompatibleCommands.addAll(UnitCommand.rebuildCommand, UnitCommand.repairCommand, UnitCommand.assistCommand);
|
||||
}};
|
||||
mineAuto = new UnitStance("mineauto", "settings", null, false);
|
||||
|
||||
//Only vanilla items are supported for now
|
||||
|
||||
@@ -79,7 +79,7 @@ public class CommandAI extends AIController{
|
||||
//this happens when an older save reads the default "shoot" stance, or any other removed stance
|
||||
if(stance == UnitStance.stop) return;
|
||||
|
||||
stances.andNot(stance.incompatibleBits);
|
||||
stances.andNot(stance.incompatibleStanceBits);
|
||||
stances.set(stance.id);
|
||||
stanceChanged();
|
||||
}
|
||||
@@ -156,8 +156,17 @@ public class CommandAI extends AIController{
|
||||
commandController.updateUnit();
|
||||
}else{
|
||||
defaultBehavior();
|
||||
//boosting control is not supported, so just don't.
|
||||
unit.updateBoosting(false);
|
||||
if(hasStance(UnitStance.boost) && unit.type.canBoost){
|
||||
//auto land when near target
|
||||
if(attackTarget != null && unit.within(attackTarget, unit.range())){
|
||||
unit.updateBoosting(false);
|
||||
}else{
|
||||
unit.updateBoosting(true, true);
|
||||
}
|
||||
}else{
|
||||
//boosting control is not supported, so just don't.
|
||||
unit.updateBoosting(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -51,6 +51,7 @@ public class Binding{
|
||||
unitStancePursueTarget = KeyBind.add("unit_stance_pursue_target", KeyCode.unset),
|
||||
unitStancePatrol = KeyBind.add("unit_stance_patrol", KeyCode.unset),
|
||||
unitStanceRam = KeyBind.add("unit_stance_ram", KeyCode.unset),
|
||||
unitStanceBoost = KeyBind.add("unit_stance_boost", KeyCode.unset),
|
||||
|
||||
unitCommandMove = KeyBind.add("unit_command_move", KeyCode.unset),
|
||||
unitCommandRepair = KeyBind.add("unit_command_repair", KeyCode.unset),
|
||||
|
||||
@@ -660,7 +660,12 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
}
|
||||
}
|
||||
}else{
|
||||
out.addAll(stances);
|
||||
var command = unit.controller() instanceof CommandAI ai ? ai.command : null;
|
||||
for(var stance : stances){
|
||||
if(stance.isCompatible(command)){
|
||||
out.add(stance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1073,7 +1078,6 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
}
|
||||
|
||||
if(canBoost){
|
||||
commands.add(UnitCommand.boostCommand);
|
||||
|
||||
if(buildSpeed > 0f){
|
||||
commands.add(UnitCommand.rebuildCommand, UnitCommand.assistCommand);
|
||||
@@ -1112,6 +1116,9 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
if(!flying){
|
||||
stances.add(UnitStance.ram);
|
||||
}
|
||||
if(canBoost){
|
||||
stances.add(UnitStance.boost);
|
||||
}
|
||||
}else{
|
||||
stances.addAll(UnitStance.stop, UnitStance.patrol);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user