Package mindustry.ai
Class Pathfinder.Flowfield
java.lang.Object
mindustry.ai.Pathfinder.Flowfield
- Direct Known Subclasses:
Pathfinder.EnemyCoreField
,Pathfinder.PositionTarget
- Enclosing class:
- Pathfinder
Data for a flow field to some set of destinations.
Concrete subclasses must specify a way to fetch costs and destinations.
-
Field Summary
FieldsModifier and TypeFieldDescriptionint[]
the last "complete" weights of this tilemap.protected Pathfinder.PathCost
Function for calculating path cost.protected boolean
If true, this flow field needs updating.protected boolean
Whether there are valid weights in the complete array.final int
protected int
Refresh rate in milliseconds.final int
Scaling factor.short[]
search IDs of each position - the highest, most recent search is prioritized and overwrittenprotected Team
Team this path is for.int[]
costs of getting to a specific tilefinal int
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionint
getCost
(int[] tiles, int pos) getNextTile
(Tile from) getNextTile
(Tile from, boolean diagonals) protected abstract void
getPositions
(arc.struct.IntSeq out) Gets targets to pathfind towards.boolean
boolean
boolean
protected boolean
passable
(int pos) void
-
Field Details
-
refreshRate
protected int refreshRateRefresh rate in milliseconds. <= 0 to disable. -
team
Team this path is for. Set before using. -
cost
Function for calculating path cost. Set before using. -
hasComplete
protected volatile boolean hasCompleteWhether there are valid weights in the complete array. -
dirty
protected boolean dirtyIf true, this flow field needs updating. This flag is only set to false once the flow field finishes and the weights are copied over. -
weights
public int[] weightscosts of getting to a specific tile -
searches
public short[] searchessearch IDs of each position - the highest, most recent search is prioritized and overwritten -
completeWeights
public int[] completeWeightsthe last "complete" weights of this tilemap. -
resolution
public final int resolutionScaling factor. For example, resolution = 2 means tiles are twice as large. -
width
public final int width -
height
public final int height
-
-
Constructor Details
-
Flowfield
public Flowfield() -
Flowfield
public Flowfield(int resolution)
-
-
Method Details
-
getCost
public int getCost(int[] tiles, int pos) -
hasTargets
public boolean hasTargets() -
getNextTile
- Returns:
- the next tile to travel to for this flowfield. Main thread only.
-
getNextTile
- Returns:
- the next tile to travel to for this flowfield. Main thread only.
-
hasCompleteWeights
public boolean hasCompleteWeights() -
updateTargetPositions
public void updateTargetPositions() -
needsRefresh
public boolean needsRefresh()- Returns:
- whether this flow field should be refreshed after the current block update
-
passable
protected boolean passable(int pos) -
getPositions
protected abstract void getPositions(arc.struct.IntSeq out) Gets targets to pathfind towards. This must run on the main thread.
-