Class CommandAI

All Implemented Interfaces:
UnitController

public class CommandAI extends AIController
  • Field Details

    • maxCommandQueueSize

      protected static final int maxCommandQueueSize
      See Also:
    • avoidInterval

      protected static final int avoidInterval
      See Also:
    • vecOut

      protected static final arc.math.geom.Vec2 vecOut
    • vecMovePos

      protected static final arc.math.geom.Vec2 vecMovePos
    • noFound

      protected static final boolean[] noFound
    • tmpPayload

      protected static final UnitPayload tmpPayload
    • transferStateNone

      protected static final int transferStateNone
      See Also:
    • transferStateLoad

      protected static final int transferStateLoad
      See Also:
    • transferStateUnload

      protected static final int transferStateUnload
      See Also:
    • commandQueue

      public arc.struct.Seq<arc.math.geom.Position> commandQueue
    • targetPos

      @Nullable public arc.math.geom.Vec2 targetPos
    • attackTarget

      @Nullable public mindustry.gen.Teamc attackTarget
    • group

      @Nullable public UnitGroup group
      Group of units that were all commanded to reach the same point.
    • groupIndex

      public int groupIndex
    • unreachableBuildings

      public arc.struct.IntSeq unreachableBuildings
      All encountered unreachable buildings of this AI. Why a sequence? Because contains() is very rarely called on it.
    • readAttackTarget

      public int readAttackTarget
      ID of unit read as target. This is set up after reading. Do not access!
    • stopAtTarget

      protected boolean stopAtTarget
    • stopWhenInRange

      protected boolean stopWhenInRange
    • lastTargetPos

      protected arc.math.geom.Vec2 lastTargetPos
    • blockingUnit

      protected boolean blockingUnit
    • timeSpentBlocked

      protected float timeSpentBlocked
    • payloadPickupCooldown

      protected float payloadPickupCooldown
    • transferState

      protected int transferState
    • stance

      public UnitStance stance
      Stance, usually related to firing mode.
    • command

      public UnitCommand command
      Current command this unit is following.
    • commandController

      @Nullable protected AIController commandController
      Current controller instance based on command.
    • lastCommand

      @Nullable protected UnitCommand lastCommand
      Last command type assigned. Used for detecting command changes.
  • Constructor Details

    • CommandAI

      public CommandAI()
  • Method Details

    • currentCommand

      public UnitCommand currentCommand()
    • command

      public void command(UnitCommand command)
      Attempts to assign a command to this unit. If not supported by the unit type, does nothing.
    • isLogicControllable

      public boolean isLogicControllable()
      Specified by:
      isLogicControllable in interface UnitController
      Overrides:
      isLogicControllable in class AIController
      Returns:
      whether logic AI can take over
    • isAttacking

      public boolean isAttacking()
    • updateUnit

      public void updateUnit()
      Specified by:
      updateUnit in interface UnitController
      Overrides:
      updateUnit in class AIController
    • clearCommands

      public void clearCommands()
    • findMainTarget

      public mindustry.gen.Teamc findMainTarget(float x, float y, float range, boolean air, boolean ground)
      Overrides:
      findMainTarget in class AIController
    • defaultBehavior

      public void defaultBehavior()
    • removed

      public void removed(mindustry.gen.Unit unit)
    • commandQueue

      public void commandQueue(arc.math.geom.Position location)
    • afterRead

      public void afterRead(mindustry.gen.Unit unit)
      Specified by:
      afterRead in interface UnitController
      Overrides:
      afterRead in class AIController
    • shouldFire

      public boolean shouldFire()
      Overrides:
      shouldFire in class AIController
      Returns:
      whether the unit should actually fire bullets (as opposed to just targeting something)
    • hit

      public void hit(mindustry.gen.Bullet bullet)
    • keepState

      public boolean keepState()
      Overrides:
      keepState in class AIController
      Returns:
      whether controller state should not be reset after reading. Do not override unless you know exactly what you are doing.
    • findTarget

      public mindustry.gen.Teamc findTarget(float x, float y, float range, boolean air, boolean ground)
      Overrides:
      findTarget in class AIController
    • nearAttackTarget

      public boolean nearAttackTarget(float x, float y, float range)
    • retarget

      public boolean retarget()
      Overrides:
      retarget in class AIController
    • hasCommand

      public boolean hasCommand()
    • setupLastPos

      public void setupLastPos()
    • commandPosition

      public void commandPosition(arc.math.geom.Vec2 pos)
      Overrides:
      commandPosition in class AIController
    • commandPosition

      public void commandPosition(arc.math.geom.Vec2 pos, boolean stopWhenInRange)
    • commandTarget

      public void commandTarget(mindustry.gen.Teamc moveTo)
      Overrides:
      commandTarget in class AIController
    • commandTarget

      public void commandTarget(mindustry.gen.Teamc moveTo, boolean stopAtTarget)