Unit payload enter command snapping
This commit is contained in:
@@ -24,6 +24,8 @@ public class UnitCommand extends MappableContent{
|
||||
public boolean drawTarget = false;
|
||||
/** Whether to reset targets when switching to or from this command. */
|
||||
public boolean resetTarget = true;
|
||||
/** Whether to snap the command destination to ally buildings. */
|
||||
public boolean snapToBuilding = false;
|
||||
/** */
|
||||
public boolean exactArrival = false;
|
||||
/** If true, this command refreshes the list of stances when selected TODO: do not use, this will likely be removed later!*/
|
||||
@@ -90,6 +92,7 @@ public class UnitCommand extends MappableContent{
|
||||
switchToMove = false;
|
||||
drawTarget = true;
|
||||
resetTarget = false;
|
||||
snapToBuilding = true;
|
||||
}};
|
||||
loadUnitsCommand = new UnitCommand("loadUnits", "upload", Binding.unit_command_load_units, null){{
|
||||
switchToMove = false;
|
||||
|
||||
@@ -501,6 +501,12 @@ public class CommandAI extends AIController{
|
||||
|
||||
//this is an allocation, but it's relatively rarely called anyway, and outside mutations must be prevented
|
||||
targetPos = lastTargetPos = pos.cpy();
|
||||
if(command != null && command.snapToBuilding){
|
||||
var build = world.buildWorld(targetPos.x, targetPos.y);
|
||||
if(build != null && build.team == unit.team){
|
||||
targetPos.set(build);
|
||||
}
|
||||
}
|
||||
attackTarget = null;
|
||||
this.stopWhenInRange = stopWhenInRange;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user