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(FaceObjectProviders faceObjectProviders,
AnimationObjects animationObjects)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
void |
addMsgTextLine(java.lang.String text)
Adds a line of message text.
|
void |
addObjectText(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() |
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.
|
java.lang.String |
getAnimName()
DaiEditor only: Returns the name of the animation.
|
double |
getAttributeDouble(java.lang.String attributeName)
Returns an attribute value of this Archetype as double.
|
double |
getAttributeDouble(java.lang.String attributeName,
boolean queryArchetype)
Returns the requested attribute value of this GameObject as
double . |
int |
getAttributeInt(java.lang.String attributeName)
Returns an attribute value of this Archetype as int.
|
int |
getAttributeInt(java.lang.String attributeName,
boolean queryArchetype)
Returns the requested attribute value of this GameObject as
int . |
java.util.Collection<java.lang.String> |
getAttributeKeys()
Returns all attribute keys of this object.
|
long |
getAttributeLong(java.lang.String attributeName)
Returns an attribute value of this Archetype as long.
|
long |
getAttributeLong(java.lang.String attributeName,
boolean queryArchetype)
Returns the requested attribute value of this GameObject as
long . |
java.lang.String |
getAttributeString(java.lang.String attributeName)
Returns the requested attribute value of this GameObject as
String . |
protected java.lang.String |
getAttributeValue(java.lang.String attributeName)
Returns an attribute value by attribute name.
|
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 java.lang.String |
getEffectiveFaceName(java.lang.String faceName)
Returns the effective face name for
faceName for a given real
face name. |
java.lang.String |
getFaceName()
Returns the name of the face of this Archetype or GameObject.
|
java.lang.String |
getFaceObjName()
Returns the face name, can be from animation or face.
|
FaceSource |
getFaceObjSource()
Returns the
FaceSource of this base object. |
T |
getHead()
Return the head part of a multi-part object.
|
java.lang.String |
getLoreText()
Returns the map lore.
|
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.
|
java.lang.String |
getMsgText()
Returns the message bound to this object.
|
protected 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.
|
javax.swing.ImageIcon |
getNormalImage()
Returns the normal face for this GameObject.
|
java.lang.String |
getObjectText()
Returns the object text of this GameObject as String.
|
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(java.lang.String attributeName)
Returns whether an attribute name exists.
|
boolean |
hasAttribute(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(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()
Notify the map model that this container is about to change.
|
abstract void |
notifyEndChange()
Notify the map model that this container has changed.
|
void |
removeAttribute(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(java.lang.String attributeName,
int value)
Sets an int value attribute.
|
void |
setAttributeString(java.lang.String attributeName,
java.lang.String value)
Sets the String of an archetype attribute in the objectText.
|
void |
setEditType(int editType)
Sets the edit type.
|
void |
setLoreText(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(java.lang.String msgText)
Sets the message text.
|
void |
setMulti(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(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. |
java.lang.String |
toString(java.lang.String format)
Returns a string representation of this game object.
|
protected void |
transientGameObjectChange()
Records that this game object has changed but need not be restored by
undo/redo actions.
|
protected void |
updateArchetype()
Called whenever
BaseObject.getArchetype() has changed. |
addFirst, addLast, asGameObject, getFirst, getLast, getMapSquare, 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 FaceObjectProviders faceObjectProviders, @NotNull AnimationObjects animationObjects)
faceObjectProviders
- the face object providers for looking up
facesanimationObjects
- the animation objects for looking up animationspublic int getTypeNo()
@Nullable protected abstract java.lang.String getEffectiveFaceName(@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 java.lang.String getFaceName()
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()
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 java.lang.String attributeName, boolean queryArchetype)
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 java.lang.String attributeName)
hasAttribute
in interface Attributes
attributeName
- the attribute name@Nullable protected java.lang.String getAttributeValue(@NotNull java.lang.String attributeName)
attributeName
- the attribute namenull
@NotNull public java.lang.String getAttributeString(@NotNull java.lang.String attributeName)
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 java.lang.String attributeName, boolean queryArchetype)
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 java.lang.String attributeName)
getAttributeInt
in interface Attributes
attributeName
- the name of the attribute value to return0
(zero) if not foundAttributes.getAttributeString(String)
public long getAttributeLong(@NotNull java.lang.String attributeName, boolean queryArchetype)
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 java.lang.String attributeName)
getAttributeLong
in interface Attributes
attributeName
- the name of the attribute value to return0
(zero) if not foundAttributes.getAttributeString(String)
public double getAttributeDouble(@NotNull java.lang.String attributeName, boolean queryArchetype)
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 java.lang.String attributeName)
getAttributeDouble
in interface Attributes
attributeName
- the name of the attribute value to return0.0
(zero) if not foundAttributes.getAttributeString(String)
public void setAttributeString(@NotNull java.lang.String attributeName, @NotNull java.lang.String value)
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 java.lang.String attributeName, int value)
setAttributeInt
in interface Attributes
attributeName
- the name of the attribute to updatevalue
- the new valuepublic void removeAttribute(@NotNull java.lang.String attributeName)
removeAttribute
in interface Attributes
attributeName
- search for "attributeName <string>"public abstract void notifyBeginChange()
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()
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()
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)
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 java.lang.String text)
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 java.lang.String getMsgText()
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>>
public void setMsgText(@Nullable java.lang.String msgText)
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()
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()
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()
public java.awt.Point getMapLocation()
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)
public void setMapY(int mapY)
public boolean isHead()
@Nullable public T getMultiNext()
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()
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)
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.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()
public boolean isTail()
public int getSizeX()
public int getSizeY()
public int getMaxX()
public int getMaxY()
public int getMinX()
public int getMinY()
@NotNull public T clone()
protected void setThisContainer(@NotNull G gameObject)
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 java.lang.String getObjName()
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 java.lang.String getBestName()
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 java.lang.String getObjectText()
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 java.lang.String line)
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 java.lang.String objectText)
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()
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 BaseObject<?,?,?,?> gameObject)
public int getDirection()
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()
protected void transientGameObjectChange()
@NotNull public FaceSource getFaceObjSource()
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 java.lang.String getAnimName()
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()
@Nullable protected MultiArchData<G,A,R,T> getMulti()
MultiArchData
for this base object.null
if this object is not a
multi-square objectpublic void setMulti(@NotNull MultiArchData<G,A,R,T> multi)
@Nullable public java.lang.String getFaceObjName()
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()
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 javax.swing.ImageIcon getNormalImage()
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 java.lang.String getLoreText()
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 java.lang.CharSequence loreText)
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()
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 java.lang.String toString(@NotNull java.lang.String format)
format
string which supports the
following replacements:
@NotNull protected abstract T getThis()
this
as its real type.this
@NotNull public java.util.Collection<java.lang.String> getAttributeKeys()