Payload stances changed to commands
This commit is contained in:
@@ -354,15 +354,15 @@ command.rebuild = Rebuild
|
|||||||
command.assist = Assist Player
|
command.assist = Assist Player
|
||||||
command.move = Move
|
command.move = Move
|
||||||
command.boost = Boost
|
command.boost = Boost
|
||||||
|
command.loadUnits = Load Units
|
||||||
|
command.loadBlocks = Load Blocks
|
||||||
|
command.unloadPayload = Unload Payload
|
||||||
stance.stop = Cancel Orders
|
stance.stop = Cancel Orders
|
||||||
stance.shoot = Stance: Shoot
|
stance.shoot = Stance: Shoot
|
||||||
stance.holdfire = Stance: Hold Fire
|
stance.holdfire = Stance: Hold Fire
|
||||||
stance.pursuetarget = Stance: Pursue Target
|
stance.pursuetarget = Stance: Pursue Target
|
||||||
stance.patrol = Stance: Patrol Path
|
stance.patrol = Stance: Patrol Path
|
||||||
stance.ram = Stance: Ram\n[lightgray]Straight line movement, no pathfinding
|
stance.ram = Stance: Ram\n[lightgray]Straight line movement, no pathfinding
|
||||||
stance.loadPayload = Stance: Load Units
|
|
||||||
stance.loadBlocks = Stance: Load Blocks
|
|
||||||
stance.unloadPayload = Stance: Unload Payload
|
|
||||||
openlink = Open Link
|
openlink = Open Link
|
||||||
copylink = Copy Link
|
copylink = Copy Link
|
||||||
back = Back
|
back = Back
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public class UnitCommand{
|
|||||||
|
|
||||||
public static final UnitCommand
|
public static final UnitCommand
|
||||||
|
|
||||||
moveCommand = new UnitCommand("move", "right", u -> null){{
|
moveCommand = new UnitCommand("move", "right", null){{
|
||||||
drawTarget = true;
|
drawTarget = true;
|
||||||
resetTarget = false;
|
resetTarget = false;
|
||||||
}},
|
}},
|
||||||
@@ -31,6 +31,21 @@ public class UnitCommand{
|
|||||||
switchToMove = false;
|
switchToMove = false;
|
||||||
drawTarget = true;
|
drawTarget = true;
|
||||||
resetTarget = false;
|
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. */
|
/** Unique ID number. */
|
||||||
@@ -51,7 +66,7 @@ public class UnitCommand{
|
|||||||
public UnitCommand(String name, String icon, Func<Unit, AIController> controller){
|
public UnitCommand(String name, String icon, Func<Unit, AIController> controller){
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.icon = icon;
|
this.icon = icon;
|
||||||
this.controller = controller;
|
this.controller = controller == null ? u -> null : controller;
|
||||||
|
|
||||||
id = all.size;
|
id = all.size;
|
||||||
all.add(this);
|
all.add(this);
|
||||||
|
|||||||
@@ -16,10 +16,7 @@ public class UnitStance{
|
|||||||
holdFire = new UnitStance("holdfire", "none"),
|
holdFire = new UnitStance("holdfire", "none"),
|
||||||
pursueTarget = new UnitStance("pursuetarget", "right"),
|
pursueTarget = new UnitStance("pursuetarget", "right"),
|
||||||
patrol = new UnitStance("patrol", "refresh"),
|
patrol = new UnitStance("patrol", "refresh"),
|
||||||
ram = new UnitStance("ram", "rightOpen"),
|
ram = new UnitStance("ram", "rightOpen");
|
||||||
loadPayload = new UnitStance("loadPayload", "download"),
|
|
||||||
loadBlocks = new UnitStance("loadBlocks", "down"),
|
|
||||||
unloadPayload = new UnitStance("unloadPayload", "upload");
|
|
||||||
|
|
||||||
/** Unique ID number. */
|
/** Unique ID number. */
|
||||||
public final int id;
|
public final int id;
|
||||||
|
|||||||
@@ -114,12 +114,12 @@ public class CommandAI extends AIController{
|
|||||||
|
|
||||||
if(!net.client() && unit instanceof Payloadc pay){
|
if(!net.client() && unit instanceof Payloadc pay){
|
||||||
//auto-drop everything
|
//auto-drop everything
|
||||||
if(stance == UnitStance.unloadPayload && pay.hasPayload()){
|
if(command == UnitCommand.unloadPayloadCommand && pay.hasPayload()){
|
||||||
Call.payloadDropped(unit, unit.x, unit.y);
|
Call.payloadDropped(unit, unit.x, unit.y);
|
||||||
}
|
}
|
||||||
|
|
||||||
//try to pick up what's under it
|
//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));
|
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){
|
if(target != null){
|
||||||
Call.pickedUnitPayload(unit, target);
|
Call.pickedUnitPayload(unit, target);
|
||||||
@@ -127,7 +127,7 @@ public class CommandAI extends AIController{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//try to pick up a block
|
//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);
|
Building build = world.buildWorld(unit.x, unit.y);
|
||||||
|
|
||||||
if(build != null && state.teams.canInteract(unit.team, build.team)){
|
if(build != null && state.teams.canInteract(unit.team, build.team)){
|
||||||
|
|||||||
@@ -311,7 +311,7 @@ public class TypeIO{
|
|||||||
|
|
||||||
public static @Nullable UnitCommand readCommand(Reads read){
|
public static @Nullable UnitCommand readCommand(Reads read){
|
||||||
int val = read.ub();
|
int val = read.ub();
|
||||||
return val == 255 ? null : UnitCommand.all.get(val);
|
return val == 255 || val >= UnitCommand.all.size ? null : UnitCommand.all.get(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeStance(Writes write, @Nullable UnitStance stance){
|
public static void writeStance(Writes write, @Nullable UnitStance stance){
|
||||||
@@ -321,7 +321,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 ? UnitStance.shoot : UnitStance.all.get(val);
|
return val == 255 || val >= UnitStance.all.size ? UnitStance.shoot : UnitStance.all.get(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void writeEntity(Writes write, Entityc entity){
|
public static void writeEntity(Writes write, Entityc entity){
|
||||||
|
|||||||
@@ -829,6 +829,9 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
if(mineTier > 0){
|
if(mineTier > 0){
|
||||||
cmds.add(UnitCommand.mineCommand);
|
cmds.add(UnitCommand.mineCommand);
|
||||||
}
|
}
|
||||||
|
if(example instanceof Payloadc){
|
||||||
|
cmds.addAll(UnitCommand.loadUnitsCommand, UnitCommand.loadBlocksCommand, UnitCommand.unloadPayloadCommand);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
commands = cmds.toArray();
|
commands = cmds.toArray();
|
||||||
@@ -840,9 +843,6 @@ public class UnitType extends UnlockableContent implements Senseable{
|
|||||||
if(crushDamage > 0){
|
if(crushDamage > 0){
|
||||||
seq.add(UnitStance.ram);
|
seq.add(UnitStance.ram);
|
||||||
}
|
}
|
||||||
if(example instanceof Payloadc){
|
|
||||||
seq.addAll(UnitStance.loadPayload, UnitStance.loadBlocks, UnitStance.unloadPayload);
|
|
||||||
}
|
|
||||||
stances = seq.toArray(UnitStance.class);
|
stances = seq.toArray(UnitStance.class);
|
||||||
}else{
|
}else{
|
||||||
stances = new UnitStance[]{UnitStance.stop};
|
stances = new UnitStance[]{UnitStance.stop};
|
||||||
|
|||||||
Reference in New Issue
Block a user