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

    • Field Summary

      Fields 
      Modifier and Type Field Description
      static @NotNull java.lang.String ANIM_SPEED
      The name of the "anim_speed" attribute.
      static @NotNull java.lang.String ANIMATION
      The attribute name of the object's animation.
      static @NotNull java.lang.String BLOCKSVIEW
      The name of the "blocksview" attribute.
      static @NotNull java.lang.String DIRECTION
      The attribute name of the object's direction.
      static int EDIT_TYPE_NONE  
      static @NotNull java.lang.String FACE
      The attribute name of the object's face.
      static @NotNull java.lang.String HP
      The attribute name of the "hp" attribute.
      static @NotNull java.lang.String IS_ANIMATED
      The attribute name of the "is_animated" flag.
      static @NotNull java.lang.String IS_TURNABLE
      The name of the "is_turnable" attribute.
      static @NotNull java.lang.String LAST_HEAL
      The name of the "last_heal" attribute.
      static @NotNull java.lang.String LEVEL
      The name of the "level" attribute.
      static @NotNull java.lang.String NAME
      The attribute name of the object's name.
      static @NotNull java.lang.String NO_PASS
      The name of the "no_pass" attribute.
      static @NotNull java.lang.String NO_PICK
      The name of the "no_pick" attribute.
      static @NotNull java.lang.String SLAYING
      The name of the "slaying" attribute.
      static @NotNull java.lang.String SP
      The attribute name of the "sp" attribute.
      static @NotNull java.lang.String TITLE
      The attribute name of the object's title.
      static @NotNull java.lang.String TYPE
      The attribute name of the object's type.
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void addMsgTextLine​(@NotNull java.lang.String text)
      Adds a line of message text.
      void addObjectText​(@NotNull java.lang.String line)
      Appends text to the object text of this GameObject.
      void addTailPart​(T tail)
      Appends a tail to this GameObject.
      T clone()
      Creates a clone of this base object.
      int countInvObjects()
      Counts the number of all inventory items (recursively).
      void facesReloaded()
      Will be called whenever the archetype faces have been reloaded.
      @Nullable java.lang.String getAnimName()
      DaiEditor only: Returns the name of the animation.
      R getArchetype()
      Returns the Archetype this GameObject is based on.
      double getAttributeDouble​(@NotNull java.lang.String attributeName, boolean queryArchetype)
      Returns the requested attribute value of this GameObject as double.
      int getAttributeInt​(@NotNull java.lang.String attributeName, boolean queryArchetype)
      Returns the requested attribute value of this GameObject as int.
      long getAttributeLong​(@NotNull java.lang.String attributeName, boolean queryArchetype)
      Returns the requested attribute value of this GameObject as long.
      @NotNull java.lang.String getAttributeString​(@NotNull java.lang.String attributeName, boolean queryArchetype)
      Returns the requested attribute value of this GameObject as String.
      @NotNull java.lang.String getBestName()
      Returns the name which is best appropriate to describe this GameObject.
      int getDirection()
      Returns the direction of this Archetype or GameObject.
      int getEditType()
      Returns the edit type.
      @Nullable java.lang.String getFaceName()
      Returns the name of the face of this Archetype or GameObject.
      @Nullable java.lang.String getFaceObjName()
      Returns the face name, can be from animation or face.
      @NotNull FaceSource getFaceObjSource()
      Returns the FaceSource of this base object.
      T getHead()
      Return the head part of a multi-part object.
      @NotNull java.lang.String getLoreText()
      Returns the map lore.
      @NotNull java.awt.Point getMapLocation()
      Returns the coordinate of this GameObject on its map.
      int getMapX()
      Returns the X coordinate of this GameObject on its map.
      int getMapY()
      Returns the Y coordinate of this GameObject on its map.
      int getMaxX()
      Determines the maximum x-coordinate of any part relative to the head part.
      int getMaxY()
      Determines the maximum y-coordinate of any part relative to the head part.
      int getMinX()
      Determines the minimum x-coordinate of any part relative to the head part.
      int getMinY()
      Determines the minimum y-coordinate of any part relative to the head part.
      @Nullable java.lang.String getMsgText​(boolean queryArchetype)
      Returns the message bound to this object.
      T getMultiNext()
      Returns the next of this multi-part object.
      int getMultiRefCount()
      Returns the number of parts for multi-part heads.
      @NotNull javax.swing.ImageIcon getNormalImage()
      Returns the normal face for this GameObject.
      @NotNull java.lang.String getObjectText()
      Returns the object text of this GameObject as String.
      @NotNull java.lang.String getObjName()
      Returns the name of the object as shown to the player.
      int getSizeX()
      Determines the horizontal extent in squares.
      int getSizeY()
      Determines the vertical extent in squares.
      int getTypeNo()
      Returns the type number of this Archetype.
      boolean hasAttribute​(@NotNull java.lang.String attributeName, boolean queryArchetype)
      Returns whether an attribute name exists.
      boolean isDefaultGameObject()
      Returns whether this game object is unmodified from its underlying archetype.
      boolean isEqual​(@NotNull BaseObject<?,​?,​?,​?> gameObject)
      Compares this object to another game object.
      boolean isHead()
      Returns whether this object is a single-part object or the head of the multi-part object.
      boolean isMulti()
      Returns whether this Archetype is a multi-part object.
      boolean isTail()
      Determines if this part is a tail part.
      G newInstance​(@NotNull GameObjectFactory<G,​A,​R> gameObjectFactory)
      Creates a new GameObject instance: an Archetype is instantiated, a GameObject is cloned.
      void notifyBeginChange()
      Notifies the map model that this container is about to change.
      void notifyEndChange()
      Notifies the map model that this container has changed.
      void notifyTransientChange()
      Notifies the map model that this container has changed but need not be restored by undo/redo.
      void removeTailParts()
      Removes all tail parts of this game object.
      void setAttributeString​(@NotNull java.lang.String attributeName, @NotNull java.lang.String value)
      Sets the String of an archetype attribute in the objectText.
      void setEditType​(int editType)
      Sets the edit type.
      void setLoreText​(@NotNull java.lang.CharSequence loreText)
      Sets the map lore.
      void setMapX​(int mapX)
      Sets the X coordinate of this GameObject on its map.
      void setMapY​(int mapY)
      Sets the Y coordinate of this GameObject on its map.
      void setMsgText​(@Nullable java.lang.String msgText)
      Sets the message text.
      void setMulti​(@NotNull MultiArchData<G,​A,​R,​T> multi)  
      void setObjectFace()
      We set here the real face of the objects, depending on the set face and the set animation.
      void setObjectText​(@NotNull java.lang.String objectText)
      Sets objectText as object text of this GameObject.
      @NotNull java.lang.String toString​(@NotNull java.lang.String format)
      Returns a string representation of this game object.
      boolean usesDirection()
      Return whether this base object uses the "direction" attribute.
      void visit​(@NotNull BaseObjectVisitor<G,​A,​R> baseObjectVisitor)
      Calls the appropriate visit() function of a BaseObjectVisitor.
      • Methods inherited from interface java.lang.Iterable

        forEach, iterator, spliterator
    • Field Detail

      • ANIMATION

        @NotNull
        static final @NotNull java.lang.String ANIMATION
        The attribute name of the object's animation.
        See Also:
        Constant Field Values
      • DIRECTION

        @NotNull
        static final @NotNull java.lang.String DIRECTION
        The attribute name of the object's direction.
        See Also:
        Constant Field Values
      • FACE

        @NotNull
        static final @NotNull java.lang.String FACE
        The attribute name of the object's face.
        See Also:
        Constant Field Values
      • NAME

        @NotNull
        static final @NotNull java.lang.String NAME
        The attribute name of the object's name.
        See Also:
        Constant Field Values
      • TYPE

        @NotNull
        static final @NotNull java.lang.String TYPE
        The attribute name of the object's type.
        See Also:
        Constant Field Values
      • TITLE

        @NotNull
        static final @NotNull java.lang.String TITLE
        The attribute name of the object's title.
        See Also:
        Constant Field Values
      • IS_ANIMATED

        @NotNull
        static final @NotNull java.lang.String IS_ANIMATED
        The attribute name of the "is_animated" flag.
        See Also:
        Constant Field Values
      • IS_TURNABLE

        @NotNull
        static final @NotNull java.lang.String IS_TURNABLE
        The name of the "is_turnable" attribute.
        See Also:
        Constant Field Values
      • HP

        @NotNull
        static final @NotNull java.lang.String HP
        The attribute name of the "hp" attribute.
        See Also:
        Constant Field Values
      • SP

        @NotNull
        static final @NotNull java.lang.String SP
        The attribute name of the "sp" attribute.
        See Also:
        Constant Field Values
      • NO_PASS

        @NotNull
        static final @NotNull java.lang.String NO_PASS
        The name of the "no_pass" attribute.
        See Also:
        Constant Field Values
      • NO_PICK

        @NotNull
        static final @NotNull java.lang.String NO_PICK
        The name of the "no_pick" attribute.
        See Also:
        Constant Field Values
      • LEVEL

        @NotNull
        static final @NotNull java.lang.String LEVEL
        The name of the "level" attribute.
        See Also:
        Constant Field Values
      • SLAYING

        @NotNull
        static final @NotNull java.lang.String SLAYING
        The name of the "slaying" attribute.
        See Also:
        Constant Field Values
      • LAST_HEAL

        @NotNull
        static final @NotNull java.lang.String LAST_HEAL
        The name of the "last_heal" attribute.
        See Also:
        Constant Field Values
      • BLOCKSVIEW

        @NotNull
        static final @NotNull java.lang.String BLOCKSVIEW
        The name of the "blocksview" attribute.
        See Also:
        Constant Field Values
      • ANIM_SPEED

        @NotNull
        static final @NotNull java.lang.String ANIM_SPEED
        The name of the "anim_speed" attribute.
        See Also:
        Constant Field Values
    • Method Detail

      • getTypeNo

        int getTypeNo()
        Returns the type number of this Archetype.
        Returns:
        the type number of this archetype
      • getFaceName

        @Nullable
        @Nullable java.lang.String getFaceName()
        Returns the name of the face of this Archetype or GameObject.
        Returns:
        the name of the face of this archetype or game object
      • countInvObjects

        int countInvObjects()
        Counts the number of all inventory items (recursively). The returned value does not include this GameObject.
        Returns:
        the number of objects in the inventory (recursively)
      • hasAttribute

        boolean hasAttribute​(@NotNull
                             @NotNull java.lang.String attributeName,
                             boolean queryArchetype)
        Returns whether an attribute name exists.
        Parameters:
        attributeName - the attribute name
        queryArchetype - whether to query the Archetype of this GameObject: true if the Archetype should be queried as well, false to ignore it.
        Returns:
        whether the attribute name exists
      • getAttributeString

        @NotNull
        @NotNull java.lang.String getAttributeString​(@NotNull
                                                     @NotNull java.lang.String attributeName,
                                                     boolean queryArchetype)
        Returns the requested attribute value of this GameObject as String. The attribute value is first searched in this GameObject. If queryArchetype == true, additional search is done: if the attribute value is not found and this GameObject is not an Archetype itself, the attribute value is searched in this GameObject's Archetype as well.
        Parameters:
        attributeName - the name of the attribute to search; this will be "attributeName value" in the object text
        queryArchetype - whether to query the Archetype of this GameObject: true if the Archetype should be queried as well, false to ignore it
        Returns:
        the attribute value or an empty String ("") if no such attribute
        See Also:
        Attributes.getAttributeString(String)
      • getAttributeInt

        int getAttributeInt​(@NotNull
                            @NotNull java.lang.String attributeName,
                            boolean queryArchetype)
        Returns the requested attribute value of this GameObject as int.
        Parameters:
        attributeName - the name of the attribute to search
        queryArchetype - whether to query the archetype of this game object
        Returns:
        attribute the value or zero if not found
        See Also:
        Attributes.getAttributeInt(String), getAttributeString(String, boolean)
      • getAttributeLong

        long getAttributeLong​(@NotNull
                              @NotNull java.lang.String attributeName,
                              boolean queryArchetype)
        Returns the requested attribute value of this GameObject as long.
        Parameters:
        attributeName - the name of the attribute to search
        queryArchetype - whether to query the archetype of this game object
        Returns:
        the attribute value or zero if not found
        See Also:
        Attributes.getAttributeLong(String), getAttributeString(String, boolean)
      • getAttributeDouble

        double getAttributeDouble​(@NotNull
                                  @NotNull java.lang.String attributeName,
                                  boolean queryArchetype)
        Returns the requested attribute value of this GameObject as double.
        Parameters:
        attributeName - the name of the attribute to search
        queryArchetype - whether to query the archetype of this game object
        Returns:
        the attribute value or zero if not found
        See Also:
        Attributes.getAttributeDouble(String), getAttributeString(String, boolean)
      • setAttributeString

        void setAttributeString​(@NotNull
                                @NotNull java.lang.String attributeName,
                                @NotNull
                                @NotNull java.lang.String value)
        Sets the String of an archetype attribute in the objectText.
        Parameters:
        attributeName - search for "attributeName <string>"
        value - the value to set
      • notifyBeginChange

        void notifyBeginChange()
        Notifies the map model that this container is about to change.
      • notifyEndChange

        void notifyEndChange()
        Notifies the map model that this container has changed.
      • notifyTransientChange

        void notifyTransientChange()
        Notifies the map model that this container has changed but need not be restored by undo/redo.
      • getArchetype

        @NotNull
        R getArchetype()
        Returns the Archetype this GameObject is based on.
        Returns:
        the archetype this game object is based on
        Note:
        For Archetypes, this method returns this.
      • getEditType

        int getEditType()
        Returns the edit type.
        Returns:
        the edit type
      • setEditType

        void setEditType​(int editType)
        Sets the edit type.
        Parameters:
        editType - the edit type
      • addMsgTextLine

        void addMsgTextLine​(@NotNull
                            @NotNull java.lang.String text)
        Adds a line of message text. This is used when creating the GameObject from the ArchetypeParser.
        Parameters:
        text - the text to append to message text
      • getMsgText

        @Nullable
        @Nullable java.lang.String getMsgText​(boolean queryArchetype)
        Returns the message bound to this object. If the message is empty, the empty String is returned. If the object has no message, this method returns null.
        Parameters:
        queryArchetype - whether to query the Archetype of this GameObject: true if the Archetype should be queried as well, false to ignore it.
        Returns:
        the message bound to this object
      • setMsgText

        void setMsgText​(@Nullable
                        @Nullable java.lang.String msgText)
        Sets the message text.
        Parameters:
        msgText - the message text
      • getMapX

        int getMapX()
        Returns the X coordinate of this GameObject on its map. This method only guarantees a reasonable value for GameObjects that are directly bound to a map. Implementations may also return reasonable values for GameObjects inside containers, but they are not required to do so.
        Returns:
        the x coordinate on map
        See Also:
        getMapY()
      • getMapY

        int getMapY()
        Returns the Y coordinate of this GameObject on its map. This method only guarantees a reasonable value for GameObjects that are directly bound to a map. Implementations may also return reasonable values for GameObjects inside containers, but they are not required to do so.
        Returns:
        the y coordinate on map
        See Also:
        getMapX()
      • getMapLocation

        @NotNull
        @NotNull java.awt.Point getMapLocation()
        Returns the coordinate of this GameObject on its map. This method only guarantees a reasonable value for GameObjects that are directly bound to a map. Implementations may also return reasonable values for GameObjects inside containers, but they are not required to do so.
        Returns:
        the coordinate on map
      • setMapX

        void setMapX​(int mapX)
        Sets the X coordinate of this GameObject on its map.
        Parameters:
        mapX - the x coordinate
        Warning:
        Only use this method during the load process.
      • setMapY

        void setMapY​(int mapY)
        Sets the Y coordinate of this GameObject on its map.
        Parameters:
        mapY - the y coordinate
        Warning:
        Only use this method during the load process.
      • isHead

        boolean isHead()
        Returns whether this object is a single-part object or the head of the multi-part object.
        Returns:
        true if single-part or head of multi-part, otherwise false
      • getMultiNext

        @Nullable
        T getMultiNext()
        Returns the next of this multi-part object.
        Returns:
        the next of this multi-part object or null if this isn't a multi-part object or this is the last part of a multi-part object
      • getMultiRefCount

        int getMultiRefCount()
        Returns the number of parts for multi-part heads. (*.getMultiRefCount() > 0) is often used as way to find multi-parts.
        Returns:
        the number of parts
        Todo:
        rename me, "Ref" is a term in Java short for "Reference" and this is not about "References" but about multi-square arches.
      • addTailPart

        void addTailPart​(@NotNull
                         T tail)
        Appends a tail to this GameObject.
        Parameters:
        tail - the tail to append
      • removeTailParts

        void removeTailParts()
        Removes all tail parts of this game object. Afterwards isMulti() will return false.
      • getHead

        T getHead()
        Return the head part of a multi-part object. For single-part objects it is the object itself.
        Returns:
        the head of the object
      • isTail

        boolean isTail()
        Determines if this part is a tail part. For single-part objects this is never true.
        Returns:
        true iff this part if a tail part
      • getSizeX

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

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

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

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

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

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

        @NotNull
        @NotNull java.lang.String getObjName()
        Returns the name of the object as shown to the player.
        Returns:
        the name of the object as shown to the player
      • getBestName

        @NotNull
        @NotNull java.lang.String getBestName()
        Returns the name which is best appropriate to describe this GameObject. (This can be Archetype name or GameObject name.)
        Returns:
        the best suitable descriptive name
      • getObjectText

        @NotNull
        @NotNull java.lang.String getObjectText()
        Returns the object text of this GameObject as String.
        Returns:
        the object text
      • addObjectText

        void addObjectText​(@NotNull
                           @NotNull java.lang.String line)
        Appends text to the object text of this GameObject.
        Parameters:
        line - a line of text to append, may contain '\n' for appending multiple lines
      • setObjectText

        void setObjectText​(@NotNull
                           @NotNull java.lang.String objectText)
        Sets objectText as object text of this GameObject.
        Parameters:
        objectText - the text to set as object text
      • isDefaultGameObject

        boolean isDefaultGameObject()
        Returns whether this game object is unmodified from its underlying archetype.
        Returns:
        whether this game object is unmodified
      • isEqual

        boolean isEqual​(@NotNull
                        @NotNull BaseObject<?,​?,​?,​?> gameObject)
        Compares this object to another game object.
        Parameters:
        gameObject - the other game object
        Returns:
        true if this object equals the other object
      • getDirection

        int getDirection()
        Returns the direction of this Archetype or GameObject.
        Returns:
        the direction of this archetype or game object
      • getFaceObjSource

        @NotNull
        @NotNull FaceSource getFaceObjSource()
        Returns the FaceSource of this base object.
        Returns:
        the face source
      • getAnimName

        @Nullable
        @Nullable java.lang.String getAnimName()
        DaiEditor only: Returns the name of the animation.
        Returns:
        the name of the animation
      • isMulti

        boolean isMulti()
        Returns whether this Archetype is a multi-part object.
        Returns:
        true if this Archetype is a multi-part object, otherwise false
      • setMulti

        void setMulti​(@NotNull
                      @NotNull MultiArchData<G,​A,​R,​T> multi)
      • getFaceObjName

        @Nullable
        @Nullable java.lang.String getFaceObjName()
        Returns the face name, can be from animation or face.
        Returns:
        the face name
      • setObjectFace

        void setObjectFace()
        We set here the real face of the objects, depending on the set face and the set animation. The rule is, that a active animation will overrule the default face. We will catch it here. This method should always be invoked after the face or animation has changed and no other change is expected right now, so the changes to animation / face should be applied.
      • getNormalImage

        @NotNull
        @NotNull javax.swing.ImageIcon getNormalImage()
        Returns the normal face for this GameObject.
        Returns:
        the normal face for this GameObject
      • clone

        @NotNull
        T clone()
        Creates a clone of this base object.
      • getLoreText

        @NotNull
        @NotNull java.lang.String getLoreText()
        Returns the map lore.
        Returns:
        the map lore
      • setLoreText

        void setLoreText​(@NotNull
                         @NotNull java.lang.CharSequence loreText)
        Sets the map lore.
        Parameters:
        loreText - the map lore
      • newInstance

        @NotNull
        G newInstance​(@NotNull
                      @NotNull GameObjectFactory<G,​A,​R> gameObjectFactory)
        Creates a new GameObject instance: an Archetype is instantiated, a GameObject is cloned.
        Parameters:
        gameObjectFactory - the game object factory for creating new game objects
        Returns:
        the new game object instance
      • visit

        void visit​(@NotNull
                   @NotNull BaseObjectVisitor<G,​A,​R> baseObjectVisitor)
        Calls the appropriate visit() function of a BaseObjectVisitor.
        Parameters:
        baseObjectVisitor - the base object visitor
      • usesDirection

        boolean usesDirection()
        Return whether this base object uses the "direction" attribute.
        Returns:
        whether this base object uses the "direction" attribute
      • facesReloaded

        void facesReloaded()
        Will be called whenever the archetype faces have been reloaded.
      • toString

        @NotNull
        @NotNull java.lang.String toString​(@NotNull
                                           @NotNull java.lang.String format)
        Returns a string representation of this game object. The string representation is the given format string which supports the following replacements:
        • $$ - a string $ character
        • ${NAME} - the in-game object name
        • ${name} - the value of attribute "name"
        • ${name:text} - text if the attribute name exists; empty otherwise. replacements within "text" are processed
        Parameters:
        format - the format to use
        Returns:
        the string representation