Class CoveredByCameraIterator

  • All Implemented Interfaces:
    java.util.Iterator<RenderCell>


    public class CoveredByCameraIterator
    extends java.lang.Object
    implements java.util.Iterator<RenderCell>
    A map iterator which loops only over the chunks covered by the camera (0-8). Loops over the map areas covered by the camera.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      int[] getCurrentIndex​()
      get the indices position relative to a 3x3 chunk matrix.
      boolean hasNext​()  
      RenderCell next​()
      Returns the next element in the iteration.
      void reset​(int centerCoordX, int centerCoordY)  
      void setTopLimitZ​(int zLimit)
      set the top/last limit of the iteration.
      • Methods inherited from interface java.util.Iterator

        forEachRemaining, remove
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • CoveredByCameraIterator

        public CoveredByCameraIterator​(RenderStorage renderStorage,
                                       Camera camera,
                                       int startingZ,
                                       int topLevel)
        Starts at z = -1.
        Parameters:
        renderStorage -
        camera - camera which center is used
        startingZ - to loop over ground level pass -1
        topLevel - the top limit of the z axis
    • Method Detail

      • reset

        public void reset​(int centerCoordX,
                          int centerCoordY)
      • setTopLimitZ

        public void setTopLimitZ​(int zLimit)
        set the top/last limit of the iteration.
        Parameters:
        zLimit -
      • next

        public RenderCell next​()
                        throws java.util.NoSuchElementException
        Returns the next element in the iteration.
        Specified by:
        next in interface java.util.Iterator<RenderCell>
        Returns:
        Can return null.
        Throws:
        java.util.NoSuchElementException
      • getCurrentIndex

        public int[] getCurrentIndex​()
        get the indices position relative to a 3x3 chunk matrix.
        Returns:
        copy safe
      • hasNext

        public boolean hasNext​()
        Specified by:
        hasNext in interface java.util.Iterator<RenderCell>
        Returns: