Class MultiArchData<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<G,​A,​R>,​T extends BaseObject<G,​A,​R,​T>>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Iterable<T>

    public class MultiArchData<G extends GameObject<G,​A,​R>,​A extends MapArchObject<A>,​R extends Archetype<G,​A,​R>,​T extends BaseObject<G,​A,​R,​T>>
    extends java.lang.Object
    implements java.lang.Iterable<T>, java.io.Serializable
    Class related to GameObject to store multi-part information. This data is only used for multi-part objects. When the editor is running, usually a big number of GameObjects exist - most of them single-part objects. The encapsulation of this "multi-part-only" data can save a little bit of memory.
    See Also:
    Serialized Form
    • Constructor Summary

      Constructors 
      Constructor Description
      MultiArchData​(T head, int multiShapeID)
      Creates a new instance.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addPart​(T tail)
      Adds a part to this multi-part object.
      T getHead()
      Returns the head part of this multi-part object.
      int getMaxX()
      Returns the maximum x-coordinate of any part.
      int getMaxY()
      Returns the maximum y-coordinate of any part.
      int getMinX()
      Returns the minimum x-coordinate of any part.
      int getMinY()
      Returns the minimum y-coordinate of any part.
      int getMultiRefCount()
      Returns the number of parts this multi-part object contains.
      int getMultiShapeID()
      Returns the shape ID of this object.
      T getNext​(T ob)
      Returns the part following a given part.
      int getSizeX()
      Returns the horizontal extent in squares.
      int getSizeY()
      Returns the vertical extent in squares.
      java.util.Iterator<T> iterator()  
      void setMultiShapeID​(int multiShapeID)
      Sets the shape ID of this object.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Constructor Detail

      • MultiArchData

        public MultiArchData​(@NotNull
                             T head,
                             int multiShapeID)
        Creates a new instance.
        Parameters:
        head - the head part of the multi-part object
        multiShapeID - the shape ID of this object
    • Method Detail

      • getMultiRefCount

        public int getMultiRefCount()
        Returns the number of parts this multi-part object contains.
        Returns:
        the number of parts this multi-part object contains
      • getSizeX

        public int getSizeX()
        Returns the horizontal extent in squares. For single-part objects 1 is returned.
        Returns:
        the horizontal extent
      • getSizeY

        public int getSizeY()
        Returns the vertical extent in squares. For single-part objects 1 is returned.
        Returns:
        the vertical extent
      • getMaxX

        public int getMaxX()
        Returns the maximum x-coordinate of any part. The value is relative to the head part. For single-part objects 0 is returned.
        Returns:
        the maximum x-coordinate
      • getMaxY

        public int getMaxY()
        Returns the maximum y-coordinate of any part. The value is relative to the head part. For single-part objects 0 is returned.
        Returns:
        the maximum y-coordinate
      • getMinX

        public int getMinX()
        Returns the minimum x-coordinate of any part. The value is relative to the head part. For single-part objects 0 is returned.
        Returns:
        the minimum x-coordinate
      • getMinY

        public int getMinY()
        Returns the minimum y-coordinate of any part. The value is relative to the head part. For single-part objects 0 is returned.
        Returns:
        the minimum y-coordinate
      • getMultiShapeID

        public int getMultiShapeID()
        Returns the shape ID of this object.
        Returns:
        the shape ID of this object
      • setMultiShapeID

        public void setMultiShapeID​(int multiShapeID)
        Sets the shape ID of this object.
        Parameters:
        multiShapeID - the new shape ID of this object
      • getHead

        @NotNull
        public T getHead()
        Returns the head part of this multi-part object.
        Returns:
        the head part
      • getNext

        @Nullable
        public T getNext​(@NotNull
                         T ob)
        Returns the part following a given part.
        Parameters:
        ob - the current part
        Returns:
        the part following the current part or null if this part was the last.
      • addPart

        public void addPart​(@NotNull
                            T tail)
        Adds a part to this multi-part object.
        Parameters:
        tail - the tail part to add
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<G extends GameObject<G,​A,​R>>