Interface Unit

All Known Subinterfaces:
InteractableUnit
All Known Implementing Classes:
Actor, Effect, HintArrow, Npc, Player, Projectile, SceneObject, TileItem, WorldEntity

public interface Unit
Positioned object in a game world.
  • Method Summary

    Modifier and Type
    Method
    Description
    default Rect
    Returns the area this unit occupies.
    Returns this unit's world coordinate.
    default List<Coord>
    Returns the direct greedy/dumb walk path from this unit to a coordinate in the currently loaded world.
    default List<Coord>
    Returns the direct greedy/dumb walk path from this unit to an area in the currently loaded world.
    default List<Coord>
    Returns the direct greedy/dumb walk path from this unit to another unit in the currently loaded world.
    default int
    Returns Chebyshev tile distance from this unit's occupied area to a coordinate.
    default int
    Returns Chebyshev tile distance from this unit's occupied area to an area.
    default int
    Returns Chebyshev tile distance between this unit and another unit.
    Returns this unit's fine coordinate, representing its model location.
    default boolean
    Returns whether line of sight is clear from this unit to a coordinate in the currently loaded world.
    default boolean
    Returns whether line of sight is clear from this unit to an area in the currently loaded world.
    default boolean
    Returns whether line of sight is clear from this unit to another unit in the currently loaded world.
    default boolean
    Returns whether a direct line of walk is clear from this unit to a coordinate in the currently loaded world.
    default boolean
    Returns whether a direct line of walk is clear from this unit to an area in the currently loaded world.
    default boolean
    Returns whether a direct line of walk is clear from this unit to another unit in the currently loaded world.
    default int
    Returns Manhattan/taxicab tile distance from this unit's occupied area to a coordinate.
    default int
    Returns Manhattan/taxicab tile distance from this unit's occupied area to an area.
    default int
    Returns Manhattan/taxicab tile distance between this unit and another unit.
    map()
    Returns this unit's map coordinate relative to the loaded world area.
    default boolean
    pathInDirection(int x, int y)
    Returns whether this unit has an open one-tile path in the supplied direction in the currently loaded world.
    Returns the world this unit belongs to.
  • Method Details

    • world

      World world()
      Returns the world this unit belongs to.
    • coord

      Coord coord()
      Returns this unit's world coordinate.
    • fine

      Coord.Fine fine()
      Returns this unit's fine coordinate, representing its model location.
    • map

      Coord.Map map()
      Returns this unit's map coordinate relative to the loaded world area.
    • area

      default Rect area()
      Returns the area this unit occupies.
    • distanceTo

      default int distanceTo(Coord coord)
      Returns Chebyshev tile distance from this unit's occupied area to a coordinate.
    • distanceTo

      default int distanceTo(Unit unit)
      Returns Chebyshev tile distance between this unit and another unit.
    • distanceTo

      default int distanceTo(Rect rect)
      Returns Chebyshev tile distance from this unit's occupied area to an area.
    • manhattanDistanceTo

      default int manhattanDistanceTo(Coord coord)
      Returns Manhattan/taxicab tile distance from this unit's occupied area to a coordinate.
    • manhattanDistanceTo

      default int manhattanDistanceTo(Unit unit)
      Returns Manhattan/taxicab tile distance between this unit and another unit.
    • manhattanDistanceTo

      default int manhattanDistanceTo(Rect rect)
      Returns Manhattan/taxicab tile distance from this unit's occupied area to an area.
    • lineOfSightTo

      default boolean lineOfSightTo(Coord coord)
      Returns whether line of sight is clear from this unit to a coordinate in the currently loaded world.
    • lineOfSightTo

      default boolean lineOfSightTo(Rect rect)
      Returns whether line of sight is clear from this unit to an area in the currently loaded world.
    • lineOfSightTo

      default boolean lineOfSightTo(Unit unit)
      Returns whether line of sight is clear from this unit to another unit in the currently loaded world.
    • lineOfWalkTo

      default boolean lineOfWalkTo(Coord coord)
      Returns whether a direct line of walk is clear from this unit to a coordinate in the currently loaded world.
    • lineOfWalkTo

      default boolean lineOfWalkTo(Rect rect)
      Returns whether a direct line of walk is clear from this unit to an area in the currently loaded world.
    • lineOfWalkTo

      default boolean lineOfWalkTo(Unit unit)
      Returns whether a direct line of walk is clear from this unit to another unit in the currently loaded world.
    • directPathTo

      default List<Coord> directPathTo(Coord coord)
      Returns the direct greedy/dumb walk path from this unit to a coordinate in the currently loaded world.

      This is not full pathfinding. It only steps directly toward the target and returns any partial path before blocking.

    • directPathTo

      default List<Coord> directPathTo(Rect rect)
      Returns the direct greedy/dumb walk path from this unit to an area in the currently loaded world.

      This is not full pathfinding. It only steps directly toward the target and returns any partial path before blocking.

    • directPathTo

      default List<Coord> directPathTo(Unit unit)
      Returns the direct greedy/dumb walk path from this unit to another unit in the currently loaded world.

      This is not full pathfinding. It only steps directly toward the target and returns any partial path before blocking.

    • pathInDirection

      default boolean pathInDirection(int x, int y)
      Returns whether this unit has an open one-tile path in the supplied direction in the currently loaded world.