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

    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete 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.
      protected void beginGameObjectChange()
      Records that this game object is about to change.
      T clone()
      Creates a clone of this base object.
      int countInvObjects()
      Counts the number of all inventory items (recursively).
      protected void endGameObjectChange()
      Records that this game object has changed.
      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.
      double getAttributeDouble​(@NotNull java.lang.String attributeName)
      Returns an attribute value of this Archetype as double.
      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)
      Returns an attribute value of this Archetype as int.
      int getAttributeInt​(@NotNull java.lang.String attributeName, boolean queryArchetype)
      Returns the requested attribute value of this GameObject as int.
      @NotNull java.util.Collection<java.lang.String> getAttributeKeys()
      Returns all attribute keys of this object.
      long getAttributeLong​(@NotNull java.lang.String attributeName)
      Returns an attribute value of this Archetype as long.
      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)
      Returns the requested attribute value of this GameObject as String.
      protected @Nullable java.lang.String getAttributeValue​(@NotNull java.lang.String attributeName)
      Returns an attribute value by attribute name.
      @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.
      protected abstract @Nullable java.lang.String getEffectiveFaceName​(@NotNull java.lang.String faceName)
      Returns the effective face name for faceName for a given real face name.
      @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.
      protected @Nullable MultiArchData<G,​A,​R,​T> getMulti()
      Returns the MultiArchData for this base 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.
      protected abstract T getThis()
      Returns this as its real type.
      int getTypeNo()
      Returns the type number of this Archetype.
      boolean hasAttribute​(@NotNull java.lang.String attributeName)
      Returns whether an attribute name exists.
      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.
      abstract void notifyBeginChange()
      Notifies the map model that this container is about to change.
      abstract void notifyEndChange()
      Notifies the map model that this container has changed.
      void removeAttribute​(@NotNull java.lang.String attributeName)
      Removes the String of an archetype attribute from the objectText.
      void removeTailParts()
      Removes all tail parts of this game object.
      void setAttributeInt​(@NotNull java.lang.String attributeName, int value)
      Sets an int value attribute.
      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.
      protected void setThisContainer​(G gameObject)
      Sets a GameObject's container to this container.
      @NotNull java.lang.String toString​(@NotNull java.lang.String format)
      Returns a string representation of this game object.
      protected void updateArchetype()
      Called whenever BaseObject.getArchetype() has changed.
      • Methods inherited from class java.lang.Object

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

        forEach, iterator, spliterator
    • Constructor Detail

      • AbstractBaseObject

        protected AbstractBaseObject​(@NotNull
                                     @NotNull FaceObjectProviders faceObjectProviders,
                                     @NotNull
                                     @NotNull AnimationObjects animationObjects)
        Creates a new instance.
        Parameters:
        faceObjectProviders - the face object providers for looking up faces
        animationObjects - the animation objects for looking up animations
    • Method Detail

      • getEffectiveFaceName

        @Nullable
        protected abstract @Nullable java.lang.String getEffectiveFaceName​(@NotNull
                                                                           @NotNull java.lang.String faceName)
        Returns the effective face name for faceName for a given real face name.
        Parameters:
        faceName - the real face name
        Returns:
        the effective face name or null if the real face name is unset or equals the archetype's face name
      • getFaceName

        @Nullable
        public @Nullable java.lang.String getFaceName()
        Description copied from interface: BaseObject
        Returns the name of the face of this Archetype or GameObject.
        Specified by:
        getFaceName in 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>>
        Returns:
        the name of the face of this archetype or game object
      • countInvObjects

        public int countInvObjects()
        Description copied from interface: BaseObject
        Counts the number of all inventory items (recursively). The returned value does not include this GameObject.
        Specified by:
        countInvObjects in 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>>
        Returns:
        the number of objects in the inventory (recursively)
      • hasAttribute

        public boolean hasAttribute​(@NotNull
                                    @NotNull java.lang.String attributeName,
                                    boolean queryArchetype)
        Description copied from interface: BaseObject
        Returns whether an attribute name exists.
        Specified by:
        hasAttribute in 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>>
        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
      • hasAttribute

        public boolean hasAttribute​(@NotNull
                                    @NotNull java.lang.String attributeName)
        Description copied from interface: Attributes
        Returns whether an attribute name exists.
        Specified by:
        hasAttribute in interface Attributes
        Parameters:
        attributeName - the attribute name
        Returns:
        whether the attribute name exists
      • getAttributeValue

        @Nullable
        protected @Nullable java.lang.String getAttributeValue​(@NotNull
                                                               @NotNull java.lang.String attributeName)
        Returns an attribute value by attribute name.
        Parameters:
        attributeName - the attribute name
        Returns:
        the attribute value or null
      • getAttributeString

        @NotNull
        public @NotNull java.lang.String getAttributeString​(@NotNull
                                                            @NotNull java.lang.String attributeName)
        Description copied from interface: Attributes
        Returns the requested attribute value of this GameObject as String. The attribute value is first searched in this GameObject. 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.
        Specified by:
        getAttributeString in interface Attributes
        Parameters:
        attributeName - the name of the attribute to search
        Returns:
        the attribute value or an empty String ("") if no such attribute
      • getAttributeInt

        public int getAttributeInt​(@NotNull
                                   @NotNull java.lang.String attributeName)
        Description copied from interface: Attributes
        Returns an attribute value of this Archetype as int.
        Specified by:
        getAttributeInt in interface Attributes
        Parameters:
        attributeName - the name of the attribute value to return
        Returns:
        the attribute value or 0 (zero) if not found
        See Also:
        Attributes.getAttributeString(String)
      • getAttributeLong

        public long getAttributeLong​(@NotNull
                                     @NotNull java.lang.String attributeName)
        Description copied from interface: Attributes
        Returns an attribute value of this Archetype as long.
        Specified by:
        getAttributeLong in interface Attributes
        Parameters:
        attributeName - the name of the attribute value to return
        Returns:
        the attribute value or 0 (zero) if not found
        See Also:
        Attributes.getAttributeString(String)
      • getAttributeDouble

        public double getAttributeDouble​(@NotNull
                                         @NotNull java.lang.String attributeName)
        Description copied from interface: Attributes
        Returns an attribute value of this Archetype as double.
        Specified by:
        getAttributeDouble in interface Attributes
        Parameters:
        attributeName - the name of the attribute value to return
        Returns:
        the attribute value or 0.0 (zero) if not found
        See Also:
        Attributes.getAttributeString(String)
      • setAttributeString

        public void setAttributeString​(@NotNull
                                       @NotNull java.lang.String attributeName,
                                       @NotNull
                                       @NotNull java.lang.String value)
        Description copied from interface: BaseObject
        Sets the String of an archetype attribute in the objectText.
        Specified by:
        setAttributeString in 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>>
        Parameters:
        attributeName - search for "attributeName <string>"
        value - the value to set
      • setAttributeInt

        public void setAttributeInt​(@NotNull
                                    @NotNull java.lang.String attributeName,
                                    int value)
        Description copied from interface: Attributes
        Sets an int value attribute.
        Specified by:
        setAttributeInt in interface Attributes
        Parameters:
        attributeName - the name of the attribute to update
        value - the new value
      • removeAttribute

        public void removeAttribute​(@NotNull
                                    @NotNull java.lang.String attributeName)
        Description copied from interface: Attributes
        Removes the String of an archetype attribute from the objectText.
        Specified by:
        removeAttribute in interface Attributes
        Parameters:
        attributeName - search for "attributeName <string>"
      • addMsgTextLine

        public void addMsgTextLine​(@NotNull
                                   @NotNull java.lang.String text)
        Description copied from interface: BaseObject
        Adds a line of message text. This is used when creating the GameObject from the ArchetypeParser.
        Specified by:
        addMsgTextLine in 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>>
        Parameters:
        text - the text to append to message text
      • getMsgText

        @Nullable
        public @Nullable java.lang.String getMsgText​(boolean queryArchetype)
        Description copied from interface: BaseObject
        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.
        Specified by:
        getMsgText in 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>>
        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
      • getMapX

        public int getMapX()
        Description copied from interface: BaseObject
        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.
        Specified by:
        getMapX in 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>>
        Returns:
        the x coordinate on map
        See Also:
        BaseObject.getMapY()
      • getMapY

        public int getMapY()
        Description copied from interface: BaseObject
        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.
        Specified by:
        getMapY in 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>>
        Returns:
        the y coordinate on map
        See Also:
        BaseObject.getMapX()
      • getMapLocation

        @NotNull
        public @NotNull java.awt.Point getMapLocation()
        Description copied from interface: BaseObject
        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.
        Specified by:
        getMapLocation in 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>>
        Returns:
        the coordinate on map
      • isHead

        public boolean isHead()
        Description copied from interface: BaseObject
        Returns whether this object is a single-part object or the head of the multi-part object.
        Specified by:
        isHead in 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>>
        Returns:
        true if single-part or head of multi-part, otherwise false
      • getMultiNext

        @Nullable
        public T getMultiNext()
        Description copied from interface: BaseObject
        Returns the next of this multi-part object.
        Specified by:
        getMultiNext in 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>>
        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
      • getBestName

        @NotNull
        public @NotNull java.lang.String getBestName()
        Description copied from interface: BaseObject
        Returns the name which is best appropriate to describe this GameObject. (This can be Archetype name or GameObject name.)
        Specified by:
        getBestName in 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>>
        Returns:
        the best suitable descriptive name
      • addObjectText

        public void addObjectText​(@NotNull
                                  @NotNull java.lang.String line)
        Description copied from interface: BaseObject
        Appends text to the object text of this GameObject.
        Specified by:
        addObjectText in 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>>
        Parameters:
        line - a line of text to append, may contain '\n' for appending multiple lines
      • isEqual

        public boolean isEqual​(@NotNull
                               @NotNull BaseObject<?,​?,​?,​?> gameObject)
        Description copied from interface: BaseObject
        Compares this object to another game object.
        Specified by:
        isEqual in 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>>
        Parameters:
        gameObject - the other game object
        Returns:
        true if this object equals the other object
      • beginGameObjectChange

        protected void beginGameObjectChange()
        Records that this game object is about to change.
      • endGameObjectChange

        protected void endGameObjectChange()
        Records that this game object has changed.
      • getMulti

        @Nullable
        protected @Nullable MultiArchData<G,​A,​R,​T> getMulti()
        Returns the MultiArchData for this base object.
        Returns:
        the multi arch data or null if this object is not a multi-square object
      • setObjectFace

        public void setObjectFace()
        Description copied from interface: BaseObject
        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.
        Specified by:
        setObjectFace in 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>>
      • toString

        @NotNull
        public @NotNull java.lang.String toString​(@NotNull
                                                  @NotNull java.lang.String format)
        Description copied from interface: BaseObject
        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
        Specified by:
        toString in 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>>
        Parameters:
        format - the format to use
        Returns:
        the string representation
      • getThis

        @NotNull
        protected abstract T getThis()
        Returns this as its real type.
        Returns:
        this
      • getAttributeKeys

        @NotNull
        public @NotNull java.util.Collection<java.lang.String> getAttributeKeys()
        Returns all attribute keys of this object.
        Returns:
        the attribute keys