mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-12-06 02:40:23 -08:00
Better logic integration with commands
This commit is contained in:
parent
61a11c9f5b
commit
a7c898a08f
5 changed files with 6 additions and 4 deletions
|
|
@ -1716,9 +1716,9 @@ lenum.config = Building configuration, e.g. sorter item.
|
||||||
lenum.enabled = Whether the block is enabled.
|
lenum.enabled = Whether the block is enabled.
|
||||||
|
|
||||||
laccess.color = Illuminator color.
|
laccess.color = Illuminator color.
|
||||||
laccess.controller = Unit controller. If processor controlled, returns processor.\nIf in a formation, returns leader.\nOtherwise, returns the unit itself.
|
laccess.controller = Unit controller. If processor controlled, returns processor.\nOtherwise, returns the unit itself.
|
||||||
laccess.dead = Whether a unit/building is dead or no longer valid.
|
laccess.dead = Whether a unit/building is dead or no longer valid.
|
||||||
laccess.controlled = Returns:\n[accent]@ctrlProcessor[] if unit controller is processor\n[accent]@ctrlPlayer[] if unit/building controller is player\nOtherwise, 0.
|
laccess.controlled = Returns:\n[accent]@ctrlProcessor[] if unit controller is processor\n[accent]@ctrlPlayer[] if unit/building controller is player\n[accent]@ctrlCommand[] if unit controller is a player command\nOtherwise, 0.
|
||||||
laccess.progress = Action progress, 0 to 1.\nReturns production, turret reload or construction progress.
|
laccess.progress = Action progress, 0 to 1.\nReturns production, turret reload or construction progress.
|
||||||
lacess.speed = Top speed of a unit, in tiles/sec.
|
lacess.speed = Top speed of a unit, in tiles/sec.
|
||||||
|
|
||||||
|
|
|
||||||
Binary file not shown.
|
|
@ -210,6 +210,7 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
|
||||||
case controlled -> !isValid() ? 0 :
|
case controlled -> !isValid() ? 0 :
|
||||||
controller instanceof LogicAI ? ctrlProcessor :
|
controller instanceof LogicAI ? ctrlProcessor :
|
||||||
controller instanceof Player ? ctrlPlayer :
|
controller instanceof Player ? ctrlPlayer :
|
||||||
|
controller instanceof CommandAI command && command.hasCommand() ? ctrlCommand :
|
||||||
0;
|
0;
|
||||||
case payloadCount -> ((Object)this) instanceof Payloadc pay ? pay.payloads().size : 0;
|
case payloadCount -> ((Object)this) instanceof Payloadc pay ? pay.payloads().size : 0;
|
||||||
case size -> hitSize / tilesize;
|
case size -> hitSize / tilesize;
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ import static mindustry.Vars.*;
|
||||||
|
|
||||||
/** Stores global constants for logic processors. */
|
/** Stores global constants for logic processors. */
|
||||||
public class GlobalConstants{
|
public class GlobalConstants{
|
||||||
public static final int ctrlProcessor = 1, ctrlPlayer = 2;
|
public static final int ctrlProcessor = 1, ctrlPlayer = 2, ctrlCommand = 3;
|
||||||
public static final ContentType[] lookableContent = {ContentType.block, ContentType.unit, ContentType.item, ContentType.liquid};
|
public static final ContentType[] lookableContent = {ContentType.block, ContentType.unit, ContentType.item, ContentType.liquid};
|
||||||
/** Global random state. */
|
/** Global random state. */
|
||||||
public static final Rand rand = new Rand();
|
public static final Rand rand = new Rand();
|
||||||
|
|
@ -51,6 +51,7 @@ public class GlobalConstants{
|
||||||
|
|
||||||
put("@ctrlProcessor", ctrlProcessor);
|
put("@ctrlProcessor", ctrlProcessor);
|
||||||
put("@ctrlPlayer", ctrlPlayer);
|
put("@ctrlPlayer", ctrlPlayer);
|
||||||
|
put("@ctrlCommand", ctrlCommand);
|
||||||
|
|
||||||
//store base content
|
//store base content
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -338,7 +338,7 @@ public class LExecutor{
|
||||||
/** Checks is a unit is valid for logic AI control, and returns the controller. */
|
/** Checks is a unit is valid for logic AI control, and returns the controller. */
|
||||||
@Nullable
|
@Nullable
|
||||||
public static LogicAI checkLogicAI(LExecutor exec, Object unitObj){
|
public static LogicAI checkLogicAI(LExecutor exec, Object unitObj){
|
||||||
if(unitObj instanceof Unit unit && unit.isValid() && exec.obj(varUnit) == unit && unit.team == exec.team && !unit.isPlayer()){
|
if(unitObj instanceof Unit unit && unit.isValid() && exec.obj(varUnit) == unit && unit.team == exec.team && !unit.isPlayer() && !(unit.isCommandable() && unit.command().hasCommand())){
|
||||||
if(unit.controller() instanceof LogicAI la){
|
if(unit.controller() instanceof LogicAI la){
|
||||||
la.controller = exec.building(varThis);
|
la.controller = exec.building(varThis);
|
||||||
return la;
|
return la;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue