Removed redundant 'shoot' unit stance
This commit is contained in:
@@ -12,7 +12,7 @@ import mindustry.input.*;
|
|||||||
import mindustry.type.*;
|
import mindustry.type.*;
|
||||||
|
|
||||||
public class UnitStance extends MappableContent{
|
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). */
|
/** Name of UI icon (from Icon class). */
|
||||||
public String icon;
|
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! */
|
/** 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. */
|
/** 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. */
|
/** If true, this stance can be toggled on or off. */
|
||||||
public boolean toggle = true;
|
public boolean toggle = true;
|
||||||
|
|
||||||
@@ -71,15 +71,12 @@ public class UnitStance extends MappableContent{
|
|||||||
|
|
||||||
public static void loadAll(){
|
public static void loadAll(){
|
||||||
stop = new UnitStance("stop", "cancel", Binding.cancelOrders, false);
|
stop = new UnitStance("stop", "cancel", Binding.cancelOrders, false);
|
||||||
shoot = new UnitStance("shoot", "commandAttack", Binding.unitStanceShoot, false);
|
holdFire = new UnitStance("holdfire", "none", Binding.unitStanceHoldFire);
|
||||||
holdFire = new UnitStance("holdfire", "none", Binding.unitStanceHoldFire, false);
|
|
||||||
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);
|
||||||
mineAuto = new UnitStance("mineauto", "settings", null, false);
|
mineAuto = new UnitStance("mineauto", "settings", null, false);
|
||||||
|
|
||||||
shoot.incompatibleStances.add(holdFire);
|
|
||||||
|
|
||||||
//Only vanilla items are supported for now
|
//Only vanilla items are supported for now
|
||||||
for(Item item : Vars.content.items()){
|
for(Item item : Vars.content.items()){
|
||||||
new ItemUnitStance(item);
|
new ItemUnitStance(item);
|
||||||
|
|||||||
@@ -49,11 +49,6 @@ public class CommandAI extends AIController{
|
|||||||
/** Last command type assigned. Used for detecting command changes. */
|
/** Last command type assigned. Used for detecting command changes. */
|
||||||
protected @Nullable UnitCommand lastCommand;
|
protected @Nullable UnitCommand lastCommand;
|
||||||
|
|
||||||
{
|
|
||||||
//TODO: is this necessary when 'hold fire' can be a toggle?
|
|
||||||
setStance(UnitStance.shoot);
|
|
||||||
}
|
|
||||||
|
|
||||||
public UnitCommand currentCommand(){
|
public UnitCommand currentCommand(){
|
||||||
return command == null ? UnitCommand.moveCommand : command;
|
return command == null ? UnitCommand.moveCommand : command;
|
||||||
}
|
}
|
||||||
@@ -81,6 +76,9 @@ public class CommandAI extends AIController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setStance(UnitStance stance){
|
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.andNot(stance.incompatibleBits);
|
||||||
stances.set(stance.id);
|
stances.set(stance.id);
|
||||||
stanceChanged();
|
stanceChanged();
|
||||||
|
|||||||
@@ -362,7 +362,7 @@ public class TypeIO{
|
|||||||
public static UnitStance readStance(Reads read){
|
public static UnitStance readStance(Reads read){
|
||||||
int val = read.ub();
|
int val = read.ub();
|
||||||
//never returns null
|
//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){
|
public static void writeEntity(Writes write, Entityc entity){
|
||||||
|
|||||||
@@ -1039,7 +1039,7 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
|
|
||||||
if(stances.size == 0){
|
if(stances.size == 0){
|
||||||
if(canAttack){
|
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){
|
if(!flying){
|
||||||
stances.add(UnitStance.ram);
|
stances.add(UnitStance.ram);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user