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