public abstract 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>> extends GameObjectContainer<G,A,R> implements BaseObject<G,A,R,T>
GameObject
implementing classes. This
abstract class serves as a common base for GameObjects for Daimonin and
Crossfire to allow classes that use GameObjects being reused and moved to
Gridarta.ANIM_SPEED, ANIMATION, BLOCKSVIEW, DIRECTION, EDIT_TYPE_NONE, FACE, HP, IS_ANIMATED, IS_TURNABLE, LAST_HEAL, LEVEL, NAME, NO_PASS, NO_PICK, SLAYING, SP, TITLE, TYPE
Modifier | Constructor and Description |
---|---|
protected |
AbstractBaseObject(@NotNull FaceObjectProviders faceObjectProviders,
@NotNull AnimationObjects animationObjects)
Creates a new instance.
|
Modifier and Type | Method and 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. |
addFirst, addLast, asGameObject, getFirst, getLast, getMapSquare, getMapSquareOptional, getNext, getPrev, hasSameContents, insertAfter, insertBefore, isBottom, isEmpty, isTop, iterator, moveBottom, moveDown, moveTop, moveUp, recursive, remove, removeAll, replace, reverse, toString
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getArchetype, getAttributeString, newInstance, notifyTransientChange, usesDirection, visit
protected AbstractBaseObject(@NotNull @NotNull FaceObjectProviders faceObjectProviders, @NotNull @NotNull AnimationObjects animationObjects)
faceObjectProviders
- the face object providers for looking up
facesanimationObjects
- the animation objects for looking up animationspublic int getTypeNo()
BaseObject
@Nullable protected abstract @Nullable java.lang.String getEffectiveFaceName(@NotNull @NotNull java.lang.String faceName)
faceName
for a given real
face name.faceName
- the real face namenull
if the real face name is
unset or equals the archetype's face name@Nullable public @Nullable java.lang.String getFaceName()
BaseObject
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>>
public int countInvObjects()
BaseObject
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>>
public boolean hasAttribute(@NotNull @NotNull java.lang.String attributeName, boolean queryArchetype)
BaseObject
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>>
attributeName
- the attribute namequeryArchetype
- whether to query the Archetype of this GameObject:
true
if the Archetype should be queried as well, false
to
ignore it.public boolean hasAttribute(@NotNull @NotNull java.lang.String attributeName)
Attributes
hasAttribute
in interface Attributes
attributeName
- the attribute name@Nullable protected @Nullable java.lang.String getAttributeValue(@NotNull @NotNull java.lang.String attributeName)
attributeName
- the attribute namenull
@NotNull public @NotNull java.lang.String getAttributeString(@NotNull @NotNull java.lang.String attributeName)
Attributes
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.getAttributeString
in interface Attributes
attributeName
- the name of the attribute to searchpublic int getAttributeInt(@NotNull @NotNull java.lang.String attributeName, boolean queryArchetype)
BaseObject
int
.getAttributeInt
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>>
attributeName
- the name of the attribute to searchqueryArchetype
- whether to query the archetype of this game objectAttributes.getAttributeInt(String)
,
BaseObject.getAttributeString(String, boolean)
public int getAttributeInt(@NotNull @NotNull java.lang.String attributeName)
Attributes
getAttributeInt
in interface Attributes
attributeName
- the name of the attribute value to return0
(zero) if not foundAttributes.getAttributeString(String)
public long getAttributeLong(@NotNull @NotNull java.lang.String attributeName, boolean queryArchetype)
BaseObject
long
.getAttributeLong
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>>
attributeName
- the name of the attribute to searchqueryArchetype
- whether to query the archetype of this game objectAttributes.getAttributeLong(String)
,
BaseObject.getAttributeString(String, boolean)
public long getAttributeLong(@NotNull @NotNull java.lang.String attributeName)
Attributes
getAttributeLong
in interface Attributes
attributeName
- the name of the attribute value to return0
(zero) if not foundAttributes.getAttributeString(String)
public double getAttributeDouble(@NotNull @NotNull java.lang.String attributeName, boolean queryArchetype)
BaseObject
double
.getAttributeDouble
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>>
attributeName
- the name of the attribute to searchqueryArchetype
- whether to query the archetype of this game objectAttributes.getAttributeDouble(String)
,
BaseObject.getAttributeString(String, boolean)
public double getAttributeDouble(@NotNull @NotNull java.lang.String attributeName)
Attributes
getAttributeDouble
in interface Attributes
attributeName
- the name of the attribute value to return0.0
(zero) if not foundAttributes.getAttributeString(String)
public void setAttributeString(@NotNull @NotNull java.lang.String attributeName, @NotNull @NotNull java.lang.String value)
BaseObject
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>>
attributeName
- search for "attributeName <string>"value
- the value to setpublic void setAttributeInt(@NotNull @NotNull java.lang.String attributeName, int value)
Attributes
setAttributeInt
in interface Attributes
attributeName
- the name of the attribute to updatevalue
- the new valuepublic void removeAttribute(@NotNull @NotNull java.lang.String attributeName)
Attributes
removeAttribute
in interface Attributes
attributeName
- search for "attributeName <string>"public abstract void notifyBeginChange()
GameObjectContainer
notifyBeginChange
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>>
notifyBeginChange
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public abstract void notifyEndChange()
GameObjectContainer
notifyEndChange
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>>
notifyEndChange
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
protected void updateArchetype()
BaseObject.getArchetype()
has changed.public int getEditType()
BaseObject
getEditType
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>>
public void setEditType(int editType)
BaseObject
setEditType
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>>
editType
- the edit typepublic void addMsgTextLine(@NotNull @NotNull java.lang.String text)
BaseObject
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>>
text
- the text to append to message text@Nullable public @Nullable java.lang.String getMsgText(boolean queryArchetype)
BaseObject
null
.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>>
queryArchetype
- whether to query the Archetype of this GameObject:
true
if the Archetype should be queried as well, false
to
ignore it.public void setMsgText(@Nullable @Nullable java.lang.String msgText)
BaseObject
setMsgText
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>>
msgText
- the message textpublic int getMapX()
BaseObject
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>>
BaseObject.getMapY()
public int getMapY()
BaseObject
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>>
BaseObject.getMapX()
@NotNull public @NotNull java.awt.Point getMapLocation()
BaseObject
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>>
public void setMapX(int mapX)
BaseObject
public void setMapY(int mapY)
BaseObject
public boolean isHead()
BaseObject
@Nullable public T getMultiNext()
BaseObject
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>>
null
if this isn't
a multi-part object or this is the last part of a multi-part objectpublic int getMultiRefCount()
BaseObject
getMultiRefCount
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>>
public void addTailPart(@NotNull T tail)
BaseObject
addTailPart
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>>
tail
- the tail to appendpublic void removeTailParts()
BaseObject
BaseObject.isMulti()
will return false
.removeTailParts
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>>
public T getHead()
BaseObject
public boolean isTail()
BaseObject
public int getSizeX()
BaseObject
public int getSizeY()
BaseObject
public int getMaxX()
BaseObject
public int getMaxY()
BaseObject
public int getMinX()
BaseObject
public int getMinY()
BaseObject
@NotNull public T clone()
BaseObject
protected void setThisContainer(@NotNull G gameObject)
GameObjectContainer
GameObject
's container to this container.setThisContainer
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
gameObject
- the game object@NotNull public @NotNull java.lang.String getObjName()
BaseObject
getObjName
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>>
@NotNull public @NotNull java.lang.String getBestName()
BaseObject
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>>
@NotNull public @NotNull java.lang.String getObjectText()
BaseObject
getObjectText
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>>
public void addObjectText(@NotNull @NotNull java.lang.String line)
BaseObject
text
to the object text of this GameObject.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>>
line
- a line of text to append, may contain '\n' for appending
multiple linespublic void setObjectText(@NotNull @NotNull java.lang.String objectText)
BaseObject
objectText
as object text of this GameObject.setObjectText
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>>
objectText
- the text to set as object textpublic boolean isDefaultGameObject()
BaseObject
isDefaultGameObject
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>>
public boolean isEqual(@NotNull @NotNull BaseObject<?,?,?,?> gameObject)
BaseObject
public int getDirection()
BaseObject
getDirection
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>>
protected void beginGameObjectChange()
protected void endGameObjectChange()
@NotNull public @NotNull FaceSource getFaceObjSource()
BaseObject
FaceSource
of this base object.getFaceObjSource
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>>
@Nullable public @Nullable java.lang.String getAnimName()
BaseObject
getAnimName
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>>
public boolean isMulti()
BaseObject
@Nullable protected @Nullable MultiArchData<G,A,R,T> getMulti()
MultiArchData
for this base object.null
if this object is not a
multi-square objectpublic void setMulti(@NotNull @NotNull MultiArchData<G,A,R,T> multi)
@Nullable public @Nullable java.lang.String getFaceObjName()
BaseObject
getFaceObjName
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>>
public void setObjectFace()
BaseObject
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>>
@NotNull public @NotNull javax.swing.ImageIcon getNormalImage()
BaseObject
getNormalImage
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>>
@NotNull public @NotNull java.lang.String getLoreText()
BaseObject
getLoreText
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>>
public void setLoreText(@NotNull @NotNull java.lang.CharSequence loreText)
BaseObject
setLoreText
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>>
loreText
- the map lorepublic void facesReloaded()
BaseObject
facesReloaded
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>>
@NotNull public @NotNull java.lang.String toString(@NotNull @NotNull java.lang.String format)
BaseObject
format
string which supports the
following replacements:
@NotNull protected abstract T getThis()
this
as its real type.this
@NotNull public @NotNull java.util.Collection<java.lang.String> getAttributeKeys()