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.Teamc
protected static final int
protected boolean
Current command this unit is following.protected AIController
Current controller instance based on command.arc.struct.Seq<arc.math.geom.Position>
Group of units that were all commanded to reach the same point.int
protected UnitCommand
Last command type assigned.protected arc.math.geom.Vec2
protected static final int
protected static final boolean[]
protected float
int
ID of unit read as target.Stance, usually related to firing mode.protected boolean
protected boolean
arc.math.geom.Vec2
protected float
protected static final UnitPayload
protected int
protected static final int
protected static final int
protected static final int
arc.struct.IntSeq
All encountered unreachable buildings of this AI.protected static final arc.math.geom.Vec2
protected static final arc.math.geom.Vec2
Fields 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 TypeMethodDescriptionvoid
afterRead
(mindustry.gen.Unit unit) void
void
command
(UnitCommand command) Attempts to assign a command to this unit.void
commandPosition
(arc.math.geom.Vec2 pos) void
commandPosition
(arc.math.geom.Vec2 pos, boolean stopWhenInRange) void
commandQueue
(arc.math.geom.Position location) void
commandTarget
(mindustry.gen.Teamc moveTo) void
commandTarget
(mindustry.gen.Teamc moveTo, boolean stopAtTarget) void
mindustry.gen.Teamc
findMainTarget
(float x, float y, float range, boolean air, boolean ground) mindustry.gen.Teamc
findTarget
(float x, float y, float range, boolean air, boolean ground) boolean
void
hit
(mindustry.gen.Bullet bullet) boolean
boolean
boolean
boolean
nearAttackTarget
(float x, float y, float range) void
removed
(mindustry.gen.Unit unit) boolean
retarget()
void
boolean
void
Methods inherited from class mindustry.entities.units.AIController
alterPathfind, checkTarget, circle, circle, circleAttack, faceMovement, faceTarget, fallback, getClosestSpawner, init, invalid, moveTo, moveTo, moveTo, moveTo, pathfind, pathfind, prefSpeed, resetTimers, shouldShoot, stopShooting, target, targetFlag, targetInvalidated, unit, unit, unloadPayloads, updateMovement, updateTargeting, updateVisuals, updateWeapons, useFallback
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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 -
stance
Stance, usually related to firing mode. -
command
Current command this unit is following. -
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. -
isLogicControllable
public boolean isLogicControllable()- Specified by:
isLogicControllable
in interfaceUnitController
- Overrides:
isLogicControllable
in classAIController
- Returns:
- whether logic AI can take over
-
isAttacking
public boolean isAttacking() -
updateUnit
public void updateUnit()- Specified by:
updateUnit
in interfaceUnitController
- Overrides:
updateUnit
in classAIController
-
clearCommands
public void clearCommands() -
findMainTarget
public mindustry.gen.Teamc findMainTarget(float x, float y, float range, boolean air, boolean ground) - Overrides:
findMainTarget
in 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:
afterRead
in interfaceUnitController
- Overrides:
afterRead
in classAIController
-
shouldFire
public boolean shouldFire()- Overrides:
shouldFire
in 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:
keepState
in 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:
findTarget
in classAIController
-
nearAttackTarget
public boolean nearAttackTarget(float x, float y, float range) -
retarget
public boolean retarget()- Overrides:
retarget
in classAIController
-
hasCommand
public boolean hasCommand() -
setupLastPos
public void setupLastPos() -
commandPosition
public void commandPosition(arc.math.geom.Vec2 pos) - Overrides:
commandPosition
in classAIController
-
commandPosition
public void commandPosition(arc.math.geom.Vec2 pos, boolean stopWhenInRange) -
commandTarget
public void commandTarget(mindustry.gen.Teamc moveTo) - Overrides:
commandTarget
in classAIController
-
commandTarget
public void commandTarget(mindustry.gen.Teamc moveTo, boolean stopAtTarget)
-