Package mindustry.ai.types
Class CommandAI
java.lang.Object
mindustry.entities.units.AIController
mindustry.ai.types.CommandAI
- All Implemented Interfaces:
UnitController
-
Field Summary
FieldsModifier and TypeFieldDescriptionmindustry.gen.Teamcprotected static final intprotected booleanCurrent command this unit is following.protected AIControllerCurrent controller instance based on command.arc.struct.Seq<arc.math.geom.Position>Group of units that were all commanded to reach the same point.intprotected UnitCommandLast command type assigned.protected arc.math.geom.Vec2protected static final intprotected static final boolean[]protected floatintID of unit read as target.arc.struct.BitsStance, usually related to firing mode.protected booleanprotected booleanarc.math.geom.Vec2protected floatprotected static final UnitPayloadprotected intprotected static final intprotected static final intprotected static final intarc.struct.IntSeqAll encountered unreachable buildings of this AI.protected static final arc.math.geom.Vec2protected static final arc.math.geom.Vec2Fields inherited from class mindustry.entities.units.AIController
bomberTarget, fallback, noTargetTime, rotateBackTimer, target, timer, timerTarget, timerTarget2, timerTarget3, timerTarget4, unit, vec -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidafterRead(mindustry.gen.Unit unit) voidvoidcommand(UnitCommand command) Attempts to assign a command to this unit.voidcommandPosition(arc.math.geom.Vec2 pos) voidcommandPosition(arc.math.geom.Vec2 pos, boolean stopWhenInRange) voidcommandQueue(arc.math.geom.Position location) voidcommandTarget(mindustry.gen.Teamc moveTo) voidcommandTarget(mindustry.gen.Teamc moveTo, boolean stopAtTarget) voidvoiddisableStance(UnitStance stance) mindustry.gen.TeamcfindMainTarget(float x, float y, float range, boolean air, boolean ground) mindustry.gen.TeamcfindTarget(float x, float y, float range, boolean air, boolean ground) booleanbooleanhasStance(UnitStance stance) voidhit(mindustry.gen.Bullet bullet) voidinit()Called after this controller is assigned a unit.booleanbooleanbooleanbooleannearAttackTarget(float x, float y, float range) voidremoved(mindustry.gen.Unit unit) booleanretarget()voidsetStance(UnitStance stance) voidsetStance(UnitStance stance, boolean enabled) voidbooleanvoidCalled when the parent CommandAI changes its stance.voidMethods inherited from class mindustry.entities.units.AIController
alterPathfind, checkTarget, circle, circle, circleAttack, faceMovement, faceTarget, fallback, getClosestSpawner, invalid, moveTo, moveTo, moveTo, moveTo, pathfind, pathfind, pathfind, prefSpeed, resetTimers, shouldShoot, stopShooting, target, targetFlag, targetInvalidated, unit, unit, unloadPayloads, updateMovement, updateTargeting, updateVisuals, updateWeapons, useFallbackMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface mindustry.entities.units.UnitController
isValidController
-
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
-
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
Group of units that were all commanded to reach the same point. -
groupIndex
public int groupIndex -
unreachableBuildings
public arc.struct.IntSeq unreachableBuildingsAll encountered unreachable buildings of this AI. Why a sequence? Because contains() is very rarely called on it. -
readAttackTarget
public int readAttackTargetID 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 -
command
Current command this unit is following. -
stances
public arc.struct.Bits stancesStance, usually related to firing mode. Each bit is a stance ID. -
commandController
Current controller instance based on command. -
lastCommand
Last command type assigned. Used for detecting command changes.
-
-
Constructor Details
-
CommandAI
public CommandAI()
-
-
Method Details
-
currentCommand
-
command
Attempts to assign a command to this unit. If not supported by the unit type, does nothing. -
hasStance
-
setStance
-
setStance
-
disableStance
-
stanceChanged
public void stanceChanged()Description copied from class:AIControllerCalled when the parent CommandAI changes its stance.- Overrides:
stanceChangedin classAIController
-
init
public void init()Description copied from class:AIControllerCalled after this controller is assigned a unit.- Overrides:
initin classAIController
-
isLogicControllable
public boolean isLogicControllable()- Specified by:
isLogicControllablein interfaceUnitController- Overrides:
isLogicControllablein classAIController- Returns:
- whether logic AI can take over
-
isAttacking
public boolean isAttacking() -
updateUnit
public void updateUnit()- Specified by:
updateUnitin interfaceUnitController- Overrides:
updateUnitin classAIController
-
clearCommands
public void clearCommands() -
findMainTarget
public mindustry.gen.Teamc findMainTarget(float x, float y, float range, boolean air, boolean ground) - Overrides:
findMainTargetin classAIController
-
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:
afterReadin interfaceUnitController- Overrides:
afterReadin classAIController
-
shouldFire
public boolean shouldFire()- Overrides:
shouldFirein classAIController- 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:
keepStatein classAIController- 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:
findTargetin classAIController
-
nearAttackTarget
public boolean nearAttackTarget(float x, float y, float range) -
retarget
public boolean retarget()- Overrides:
retargetin classAIController
-
hasCommand
public boolean hasCommand() -
setupLastPos
public void setupLastPos() -
commandPosition
public void commandPosition(arc.math.geom.Vec2 pos) - Overrides:
commandPositionin classAIController
-
commandPosition
public void commandPosition(arc.math.geom.Vec2 pos, boolean stopWhenInRange) -
commandTarget
public void commandTarget(mindustry.gen.Teamc moveTo) - Overrides:
commandTargetin classAIController
-
commandTarget
public void commandTarget(mindustry.gen.Teamc moveTo, boolean stopAtTarget)
-