Package mindustry.ai

Class Pathfinder.Flowfield

java.lang.Object
mindustry.ai.Pathfinder.Flowfield
Direct Known Subclasses:
Pathfinder.EnemyCoreField, Pathfinder.PositionTarget
Enclosing class:
Pathfinder

public abstract static class Pathfinder.Flowfield extends Object
Data for a flow field to some set of destinations. Concrete subclasses must specify a way to fetch costs and destinations.
  • Field Details

    • refreshRate

      protected int refreshRate
      Refresh rate in milliseconds. <= 0 to disable.
    • team

      protected Team team
      Team this path is for. Set before using.
    • cost

      protected Pathfinder.PathCost cost
      Function for calculating path cost. Set before using.
    • hasComplete

      protected volatile boolean hasComplete
      Whether there are valid weights in the complete array.
    • dirty

      protected boolean dirty
      If 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[] weights
      costs of getting to a specific tile
    • searches

      public short[] searches
      search IDs of each position - the highest, most recent search is prioritized and overwritten
    • completeWeights

      public int[] completeWeights
      the last "complete" weights of this tilemap.
    • resolution

      public final int resolution
      Scaling 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

      @Nullable public Tile getNextTile(Tile from, boolean diagonals)
      Returns:
      the next tile to travel to for this flowfield. Main thread only.
    • getNextTile

      @Nullable public Tile getNextTile(Tile from)
      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.