Payload stances changed to commands

This commit is contained in:
Anuken
2023-09-22 18:32:35 -04:00
parent 9762507db6
commit 06a5201ae8
6 changed files with 29 additions and 17 deletions
+17 -2
View File
@@ -15,7 +15,7 @@ public class UnitCommand{
public static final UnitCommand
moveCommand = new UnitCommand("move", "right", u -> null){{
moveCommand = new UnitCommand("move", "right", null){{
drawTarget = true;
resetTarget = false;
}},
@@ -31,6 +31,21 @@ public class UnitCommand{
switchToMove = false;
drawTarget = true;
resetTarget = false;
}},
loadUnitsCommand = new UnitCommand("loadUnits", "download", null){{
switchToMove = false;
drawTarget = true;
resetTarget = false;
}},
loadBlocksCommand = new UnitCommand("loadBlocks", "down", null){{
switchToMove = false;
drawTarget = true;
resetTarget = false;
}},
unloadPayloadCommand = new UnitCommand("unloadPayload", "upload", null){{
switchToMove = false;
drawTarget = true;
resetTarget = false;
}};
/** Unique ID number. */
@@ -51,7 +66,7 @@ public class UnitCommand{
public UnitCommand(String name, String icon, Func<Unit, AIController> controller){
this.name = name;
this.icon = icon;
this.controller = controller;
this.controller = controller == null ? u -> null : controller;
id = all.size;
all.add(this);
+1 -4
View File
@@ -16,10 +16,7 @@ public class UnitStance{
holdFire = new UnitStance("holdfire", "none"),
pursueTarget = new UnitStance("pursuetarget", "right"),
patrol = new UnitStance("patrol", "refresh"),
ram = new UnitStance("ram", "rightOpen"),
loadPayload = new UnitStance("loadPayload", "download"),
loadBlocks = new UnitStance("loadBlocks", "down"),
unloadPayload = new UnitStance("unloadPayload", "upload");
ram = new UnitStance("ram", "rightOpen");
/** Unique ID number. */
public final int id;
+3 -3
View File
@@ -114,12 +114,12 @@ public class CommandAI extends AIController{
if(!net.client() && unit instanceof Payloadc pay){
//auto-drop everything
if(stance == UnitStance.unloadPayload && pay.hasPayload()){
if(command == UnitCommand.unloadPayloadCommand && pay.hasPayload()){
Call.payloadDropped(unit, unit.x, unit.y);
}
//try to pick up what's under it
if(stance == UnitStance.loadPayload){
if(command == UnitCommand.loadUnitsCommand){
Unit target = Units.closest(unit.team, unit.x, unit.y, unit.type.hitSize * 2f, u -> u.isAI() && u != unit && u.isGrounded() && pay.canPickup(u) && u.within(unit, u.hitSize + unit.hitSize));
if(target != null){
Call.pickedUnitPayload(unit, target);
@@ -127,7 +127,7 @@ public class CommandAI extends AIController{
}
//try to pick up a block
if(stance == UnitStance.loadBlocks && (targetPos == null || unit.within(targetPos, 1f))){
if(command == UnitCommand.loadBlocksCommand && (targetPos == null || unit.within(targetPos, 1f))){
Building build = world.buildWorld(unit.x, unit.y);
if(build != null && state.teams.canInteract(unit.team, build.team)){