Class UnitView<T extends Unit,V extends UnitView<T,V>>

java.lang.Object
dev.twilite.game.stream.View<T>
dev.twilite.game.stream.UnitView<T,V>
All Implemented Interfaces:
Iterable<T>
Direct Known Subclasses:
ActorView, EffectView, HintArrowView, ProjectileView, SceneObjectView, TileItemView

public abstract class UnitView<T extends Unit,V extends UnitView<T,V>> extends View<T>
View specialization for positioned game units.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Creates a unit view backed by a stream supplier.
  • Method Summary

    Modifier and Type
    Method
    Description
    filter(Predicate<T> filter)
    Returns a new view with an additional unit filter.
    Returns the nearest unit to the coordinate.
    Returns the nearest unit to another unit.
    not()
    Returns a new view with the most recent filter negated.
    on(Coord... coords)
    Filters to units whose occupied area contains any of the coordinates.
    or(Predicate<T> filter)
    Returns a new unit view with the supplied filter OR'ed with the most recent filter.
    Filters to units reachable from the local player using loaded local-world collision.
    reachableWithin(int maxDistance)
    Filters to units reachable from the local player within the supplied local movement steps.
    within(int distance)
    Filters to units within Chebyshev distance of the local player.
    within(Coord coord, int distance)
    Filters to units within Chebyshev distance of a coordinate.
    within(Rect... areas)
    Filters to units whose occupied area intersects any of the areas.
    within(Rect rect, int distance)
    Filters to units within Chebyshev distance of an area.
    within(Unit unit, int distance)
    Filters to units within Chebyshev distance of another unit's occupied area.

    Methods inherited from class dev.twilite.game.stream.View

    count, exists, first, iterator, map, mapToInt, stream, toList

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.lang.Iterable

    forEach, spliterator
  • Constructor Details

    • UnitView

      public UnitView(Supplier<Stream<T>> source)
      Creates a unit view backed by a stream supplier.
  • Method Details

    • filter

      public V filter(Predicate<T> filter)
      Returns a new view with an additional unit filter.
      Overrides:
      filter in class View<T extends Unit>
    • not

      public V not()
      Returns a new view with the most recent filter negated.
      Overrides:
      not in class View<T extends Unit>
    • or

      public V or(Predicate<T> filter)
      Returns a new unit view with the supplied filter OR'ed with the most recent filter.
      Overrides:
      or in class View<T extends Unit>
    • on

      public V on(Coord... coords)
      Filters to units whose occupied area contains any of the coordinates.
    • within

      public V within(Rect... areas)
      Filters to units whose occupied area intersects any of the areas.
    • within

      public V within(Coord coord, int distance)
      Filters to units within Chebyshev distance of a coordinate.
      Parameters:
      coord - coordinate to measure from
      distance - maximum accepted distance
    • within

      public V within(Rect rect, int distance)
      Filters to units within Chebyshev distance of an area.
      Parameters:
      rect - area to measure from
      distance - maximum accepted distance
    • within

      public V within(Unit unit, int distance)
      Filters to units within Chebyshev distance of another unit's occupied area.
      Parameters:
      unit - unit to measure from
      distance - maximum accepted distance
    • within

      public V within(int distance)
      Filters to units within Chebyshev distance of the local player.
    • reachable

      public V reachable()
      Filters to units reachable from the local player using loaded local-world collision.
    • reachableWithin

      public V reachableWithin(int maxDistance)
      Filters to units reachable from the local player within the supplied local movement steps.
      Parameters:
      maxDistance - maximum local movement steps to search
    • nearestTo

      public Optional<T> nearestTo(Coord coord)
      Returns the nearest unit to the coordinate.
    • nearestTo

      public Optional<T> nearestTo(Unit unit)
      Returns the nearest unit to another unit.