Package mindustry.entities.units
Class AIController
java.lang.Object
mindustry.entities.units.AIController
- All Implemented Interfaces:
UnitController
- Direct Known Subclasses:
AssemblerAI
,BoostAI
,BuilderAI
,CargoAI
,CommandAI
,DefenderAI
,DroneCenter.EffectDroneAI
,FlyingAI
,GroundAI
,HugAI
,LogicAI
,MinerAI
,MissileAI
,RepairAI
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected mindustry.gen.Teamc
protected AIController
protected float
protected static final float
protected mindustry.gen.Teamc
main target that is being facedprotected arc.util.Interval
protected static final int
protected static final int
protected static final int
protected static final int
protected mindustry.gen.Unit
protected static final arc.math.geom.Vec2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
afterRead
(mindustry.gen.Unit unit) arc.math.geom.Vec2
alterPathfind
(arc.math.geom.Vec2 vec) boolean
checkTarget
(mindustry.gen.Teamc target, float x, float y, float range) void
circle
(arc.math.geom.Position target, float circleLength) void
circle
(arc.math.geom.Position target, float circleLength, float speed) void
circleAttack
(float circleLength) void
commandPosition
(arc.math.geom.Vec2 pos) void
commandTarget
(mindustry.gen.Teamc moveTo) void
void
For ground units: Looks at the target, or the movement position.fallback()
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) void
init()
Called after this controller is assigned a unit.boolean
invalid
(mindustry.gen.Teamc target) boolean
boolean
void
moveTo
(arc.math.geom.Position target, float circleLength) void
moveTo
(arc.math.geom.Position target, float circleLength, float smooth) void
moveTo
(arc.math.geom.Position target, float circleLength, float smooth, boolean keepDistance, arc.math.geom.Vec2 offset) void
moveTo
(arc.math.geom.Position target, float circleLength, float smooth, boolean keepDistance, arc.math.geom.Vec2 offset, boolean arrive) void
pathfind
(int pathTarget) void
pathfind
(int pathTarget, boolean stopAtTargetTile) float
protected void
boolean
retarget()
boolean
boolean
void
mindustry.gen.Teamc
target
(float x, float y, float range, boolean air, boolean ground) mindustry.gen.Teamc
targetFlag
(float x, float y, BlockFlag flag, boolean enemy) void
mindustry.gen.Unit
unit()
void
unit
(mindustry.gen.Unit unit) void
void
void
void
void
void
boolean
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
hit, isValidController, removed
-
Field Details
-
vec
protected static final arc.math.geom.Vec2 vec -
rotateBackTimer
protected static final float rotateBackTimer- See Also:
-
timerTarget
protected static final int timerTarget- See Also:
-
timerTarget2
protected static final int timerTarget2- See Also:
-
timerTarget3
protected static final int timerTarget3- See Also:
-
timerTarget4
protected static final int timerTarget4- See Also:
-
unit
protected mindustry.gen.Unit unit -
timer
protected arc.util.Interval timer -
fallback
-
noTargetTime
protected float noTargetTime -
target
@Nullable protected mindustry.gen.Teamc targetmain target that is being faced -
bomberTarget
@Nullable protected mindustry.gen.Teamc bomberTarget
-
-
Constructor Details
-
AIController
public AIController()
-
-
Method Details
-
resetTimers
protected void resetTimers() -
updateUnit
public void updateUnit()- Specified by:
updateUnit
in interfaceUnitController
-
keepState
public boolean keepState()- Returns:
- whether controller state should not be reset after reading. Do not override unless you know exactly what you are doing.
-
afterRead
public void afterRead(mindustry.gen.Unit unit) - Specified by:
afterRead
in interfaceUnitController
-
isLogicControllable
public boolean isLogicControllable()- Specified by:
isLogicControllable
in interfaceUnitController
- Returns:
- whether logic AI can take over
-
stopShooting
public void stopShooting() -
fallback
-
useFallback
public boolean useFallback() -
updateVisuals
public void updateVisuals() -
updateMovement
public void updateMovement() -
updateTargeting
public void updateTargeting() -
faceTarget
public void faceTarget()For ground units: Looks at the target, or the movement position. Does not apply to non-omni units. -
faceMovement
public void faceMovement() -
invalid
public boolean invalid(mindustry.gen.Teamc target) -
pathfind
public void pathfind(int pathTarget) -
pathfind
public void pathfind(int pathTarget, boolean stopAtTargetTile) -
alterPathfind
public arc.math.geom.Vec2 alterPathfind(arc.math.geom.Vec2 vec) -
targetInvalidated
public void targetInvalidated() -
updateWeapons
public void updateWeapons() -
checkTarget
public boolean checkTarget(mindustry.gen.Teamc target, float x, float y, float range) -
shouldFire
public boolean shouldFire()- Returns:
- whether the unit should actually fire bullets (as opposed to just targeting something)
-
shouldShoot
public boolean shouldShoot() -
targetFlag
-
target
public mindustry.gen.Teamc target(float x, float y, float range, boolean air, boolean ground) -
retarget
public boolean retarget() -
findMainTarget
public mindustry.gen.Teamc findMainTarget(float x, float y, float range, boolean air, boolean ground) -
findTarget
public mindustry.gen.Teamc findTarget(float x, float y, float range, boolean air, boolean ground) -
commandTarget
public void commandTarget(mindustry.gen.Teamc moveTo) -
commandPosition
public void commandPosition(arc.math.geom.Vec2 pos) -
init
public void init()Called after this controller is assigned a unit. -
getClosestSpawner
-
unloadPayloads
public void unloadPayloads() -
circleAttack
public void circleAttack(float circleLength) -
circle
public void circle(arc.math.geom.Position target, float circleLength) -
circle
public void circle(arc.math.geom.Position target, float circleLength, float speed) -
moveTo
public void moveTo(arc.math.geom.Position target, float circleLength) -
moveTo
public void moveTo(arc.math.geom.Position target, float circleLength, float smooth) -
moveTo
public void moveTo(arc.math.geom.Position target, float circleLength, float smooth, boolean keepDistance, @Nullable arc.math.geom.Vec2 offset) -
moveTo
public void moveTo(arc.math.geom.Position target, float circleLength, float smooth, boolean keepDistance, @Nullable arc.math.geom.Vec2 offset, boolean arrive) -
prefSpeed
public float prefSpeed() -
unit
public void unit(mindustry.gen.Unit unit) - Specified by:
unit
in interfaceUnitController
-
unit
public mindustry.gen.Unit unit()- Specified by:
unit
in interfaceUnitController
-