Removed redundant 'shoot' unit stance

This commit is contained in:
Anuken
2025-07-02 00:56:59 -04:00
parent 9e392c7caf
commit adcbcec706
4 changed files with 8 additions and 13 deletions

View File

@@ -12,7 +12,7 @@ import mindustry.input.*;
import mindustry.type.*;
public class UnitStance extends MappableContent{
public static UnitStance stop, shoot, holdFire, pursueTarget, patrol, ram, mineAuto;
public static UnitStance stop, holdFire, pursueTarget, patrol, ram, mineAuto;
/** Name of UI icon (from Icon class). */
public String icon;
@@ -21,7 +21,7 @@ public class UnitStance extends MappableContent{
/** 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(1);
public Bits incompatibleBits = new Bits(32);
/** If true, this stance can be toggled on or off. */
public boolean toggle = true;
@@ -71,15 +71,12 @@ public class UnitStance extends MappableContent{
public static void loadAll(){
stop = new UnitStance("stop", "cancel", Binding.cancelOrders, false);
shoot = new UnitStance("shoot", "commandAttack", Binding.unitStanceShoot, false);
holdFire = new UnitStance("holdfire", "none", Binding.unitStanceHoldFire, false);
holdFire = new UnitStance("holdfire", "none", Binding.unitStanceHoldFire);
pursueTarget = new UnitStance("pursuetarget", "right", Binding.unitStancePursueTarget);
patrol = new UnitStance("patrol", "refresh", Binding.unitStancePatrol);
ram = new UnitStance("ram", "rightOpen", Binding.unitStanceRam);
mineAuto = new UnitStance("mineauto", "settings", null, false);
shoot.incompatibleStances.add(holdFire);
//Only vanilla items are supported for now
for(Item item : Vars.content.items()){
new ItemUnitStance(item);

View File

@@ -49,11 +49,6 @@ public class CommandAI extends AIController{
/** Last command type assigned. Used for detecting command changes. */
protected @Nullable UnitCommand lastCommand;
{
//TODO: is this necessary when 'hold fire' can be a toggle?
setStance(UnitStance.shoot);
}
public UnitCommand currentCommand(){
return command == null ? UnitCommand.moveCommand : command;
}
@@ -81,6 +76,9 @@ public class CommandAI extends AIController{
}
public void setStance(UnitStance stance){
//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.set(stance.id);
stanceChanged();

View File

@@ -362,7 +362,7 @@ public class TypeIO{
public static UnitStance readStance(Reads read){
int val = read.ub();
//never returns null
return val == 255 || val >= content.unitStances().size ? UnitStance.shoot : content.unitStance(val);
return val == 255 || val >= content.unitStances().size ? UnitStance.stop : content.unitStance(val);
}
public static void writeEntity(Writes write, Entityc entity){

View File

@@ -1039,7 +1039,7 @@ public class UnitType extends UnlockableContent implements Senseable{
if(stances.size == 0){
if(canAttack){
stances.addAll(UnitStance.stop, UnitStance.shoot, UnitStance.holdFire, UnitStance.pursueTarget, UnitStance.patrol);
stances.addAll(UnitStance.stop, UnitStance.holdFire, UnitStance.pursueTarget, UnitStance.patrol);
if(!flying){
stances.add(UnitStance.ram);
}