From adcbcec706c1d6035694e94c7df440bf7d6e66ab Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 2 Jul 2025 00:56:59 -0400 Subject: [PATCH] Removed redundant 'shoot' unit stance --- core/src/mindustry/ai/UnitStance.java | 9 +++------ core/src/mindustry/ai/types/CommandAI.java | 8 +++----- core/src/mindustry/io/TypeIO.java | 2 +- core/src/mindustry/type/UnitType.java | 2 +- 4 files changed, 8 insertions(+), 13 deletions(-) diff --git a/core/src/mindustry/ai/UnitStance.java b/core/src/mindustry/ai/UnitStance.java index 94c1a2f0d3..656751f1a8 100644 --- a/core/src/mindustry/ai/UnitStance.java +++ b/core/src/mindustry/ai/UnitStance.java @@ -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 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); diff --git a/core/src/mindustry/ai/types/CommandAI.java b/core/src/mindustry/ai/types/CommandAI.java index d5fae5d7db..1bf6b45c99 100644 --- a/core/src/mindustry/ai/types/CommandAI.java +++ b/core/src/mindustry/ai/types/CommandAI.java @@ -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(); diff --git a/core/src/mindustry/io/TypeIO.java b/core/src/mindustry/io/TypeIO.java index 21a546c064..e8770f0675 100644 --- a/core/src/mindustry/io/TypeIO.java +++ b/core/src/mindustry/io/TypeIO.java @@ -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){ diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index 7b5d213724..4a782b3002 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -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); }