mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-06 08:57:45 +07:00
Payload stances changed to commands
This commit is contained in:
parent
9762507db6
commit
06a5201ae8
@ -354,15 +354,15 @@ command.rebuild = Rebuild
|
||||
command.assist = Assist Player
|
||||
command.move = Move
|
||||
command.boost = Boost
|
||||
command.loadUnits = Load Units
|
||||
command.loadBlocks = Load Blocks
|
||||
command.unloadPayload = Unload Payload
|
||||
stance.stop = Cancel Orders
|
||||
stance.shoot = Stance: Shoot
|
||||
stance.holdfire = Stance: Hold Fire
|
||||
stance.pursuetarget = Stance: Pursue Target
|
||||
stance.patrol = Stance: Patrol Path
|
||||
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
|
||||
copylink = Copy Link
|
||||
back = Back
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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)){
|
||||
|
@ -311,7 +311,7 @@ public class TypeIO{
|
||||
|
||||
public static @Nullable UnitCommand readCommand(Reads read){
|
||||
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){
|
||||
@ -321,7 +321,7 @@ public class TypeIO{
|
||||
public static UnitStance readStance(Reads read){
|
||||
int val = read.ub();
|
||||
//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){
|
||||
|
@ -829,6 +829,9 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
if(mineTier > 0){
|
||||
cmds.add(UnitCommand.mineCommand);
|
||||
}
|
||||
if(example instanceof Payloadc){
|
||||
cmds.addAll(UnitCommand.loadUnitsCommand, UnitCommand.loadBlocksCommand, UnitCommand.unloadPayloadCommand);
|
||||
}
|
||||
}
|
||||
|
||||
commands = cmds.toArray();
|
||||
@ -840,9 +843,6 @@ public class UnitType extends UnlockableContent implements Senseable{
|
||||
if(crushDamage > 0){
|
||||
seq.add(UnitStance.ram);
|
||||
}
|
||||
if(example instanceof Payloadc){
|
||||
seq.addAll(UnitStance.loadPayload, UnitStance.loadBlocks, UnitStance.unloadPayload);
|
||||
}
|
||||
stances = seq.toArray(UnitStance.class);
|
||||
}else{
|
||||
stances = new UnitStance[]{UnitStance.stop};
|
||||
|
Loading…
Reference in New Issue
Block a user