Package net.sf.gridarta.model.baseobject
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>>
-
- All Superinterfaces:
Attributes,java.lang.Cloneable,java.lang.Iterable<G>,java.io.Serializable
- All Known Subinterfaces:
Archetype<G,A,R>,Archetype,Archetype,Archetype,GameObject<G,A,R>
- All Known Implementing Classes:
AbstractArchetype,AbstractBaseObject,AbstractGameObject,DefaultArchetype,DefaultArchetype,DefaultArchetype,DefaultIsoGameObject,GameObject,GameObject,GameObject,UndefinedArchetype,UndefinedArchetype,UndefinedArchetype
public 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>> extends Attributes, java.lang.Cloneable, java.lang.Iterable<G>, java.io.Serializable
-
-
Field Summary
Fields Modifier and Type Field Description static @NotNull java.lang.StringANIM_SPEEDThe name of the "anim_speed" attribute.static @NotNull java.lang.StringANIMATIONThe attribute name of the object's animation.static @NotNull java.lang.StringBLOCKSVIEWThe name of the "blocksview" attribute.static @NotNull java.lang.StringDIRECTIONThe attribute name of the object's direction.static intEDIT_TYPE_NONEstatic @NotNull java.lang.StringFACEThe attribute name of the object's face.static @NotNull java.lang.StringHPThe attribute name of the "hp" attribute.static @NotNull java.lang.StringIS_ANIMATEDThe attribute name of the "is_animated" flag.static @NotNull java.lang.StringIS_TURNABLEThe name of the "is_turnable" attribute.static @NotNull java.lang.StringLAST_HEALThe name of the "last_heal" attribute.static @NotNull java.lang.StringLEVELThe name of the "level" attribute.static @NotNull java.lang.StringNAMEThe attribute name of the object's name.static @NotNull java.lang.StringNO_PASSThe name of the "no_pass" attribute.static @NotNull java.lang.StringNO_PICKThe name of the "no_pick" attribute.static @NotNull java.lang.StringSLAYINGThe name of the "slaying" attribute.static @NotNull java.lang.StringSPThe attribute name of the "sp" attribute.static @NotNull java.lang.StringTITLEThe attribute name of the object's title.static @NotNull java.lang.StringTYPEThe attribute name of the object's type.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddMsgTextLine(@NotNull java.lang.String text)Adds a line of message text.voidaddObjectText(@NotNull java.lang.String line)Appendstextto the object text of this GameObject.voidaddTailPart(T tail)Appends a tail to this GameObject.Tclone()Creates a clone of this base object.intcountInvObjects()Counts the number of all inventory items (recursively).voidfacesReloaded()Will be called whenever the archetype faces have been reloaded.@Nullable java.lang.StringgetAnimName()DaiEditor only: Returns the name of the animation.RgetArchetype()Returns the Archetype this GameObject is based on.doublegetAttributeDouble(@NotNull java.lang.String attributeName, boolean queryArchetype)Returns the requested attribute value of this GameObject asdouble.intgetAttributeInt(@NotNull java.lang.String attributeName, boolean queryArchetype)Returns the requested attribute value of this GameObject asint.longgetAttributeLong(@NotNull java.lang.String attributeName, boolean queryArchetype)Returns the requested attribute value of this GameObject aslong.@NotNull java.lang.StringgetAttributeString(@NotNull java.lang.String attributeName, boolean queryArchetype)Returns the requested attribute value of this GameObject asString.@NotNull java.lang.StringgetBestName()Returns the name which is best appropriate to describe this GameObject.intgetDirection()Returns the direction of this Archetype or GameObject.intgetEditType()Returns the edit type.@Nullable java.lang.StringgetFaceName()Returns the name of the face of this Archetype or GameObject.@Nullable java.lang.StringgetFaceObjName()Returns the face name, can be from animation or face.@NotNull FaceSourcegetFaceObjSource()Returns theFaceSourceof this base object.TgetHead()Return the head part of a multi-part object.@NotNull java.lang.StringgetLoreText()Returns the map lore.@NotNull java.awt.PointgetMapLocation()Returns the coordinate of this GameObject on its map.intgetMapX()Returns the X coordinate of this GameObject on its map.intgetMapY()Returns the Y coordinate of this GameObject on its map.intgetMaxX()Determines the maximum x-coordinate of any part relative to the head part.intgetMaxY()Determines the maximum y-coordinate of any part relative to the head part.intgetMinX()Determines the minimum x-coordinate of any part relative to the head part.intgetMinY()Determines the minimum y-coordinate of any part relative to the head part.@Nullable java.lang.StringgetMsgText(boolean queryArchetype)Returns the message bound to this object.TgetMultiNext()Returns the next of this multi-part object.intgetMultiRefCount()Returns the number of parts for multi-part heads.@NotNull javax.swing.ImageIcongetNormalImage()Returns the normal face for this GameObject.@NotNull java.lang.StringgetObjectText()Returns the object text of this GameObject as String.@NotNull java.lang.StringgetObjName()Returns the name of the object as shown to the player.intgetSizeX()Determines the horizontal extent in squares.intgetSizeY()Determines the vertical extent in squares.intgetTypeNo()Returns the type number of this Archetype.booleanhasAttribute(@NotNull java.lang.String attributeName, boolean queryArchetype)Returns whether an attribute name exists.booleanisDefaultGameObject()Returns whether this game object is unmodified from its underlying archetype.booleanisEqual(@NotNull BaseObject<?,?,?,?> gameObject)Compares this object to another game object.booleanisHead()Returns whether this object is a single-part object or the head of the multi-part object.booleanisMulti()Returns whether this Archetype is a multi-part object.booleanisTail()Determines if this part is a tail part.GnewInstance(@NotNull GameObjectFactory<G,A,R> gameObjectFactory)voidnotifyBeginChange()Notifies the map model that this container is about to change.voidnotifyEndChange()Notifies the map model that this container has changed.voidnotifyTransientChange()Notifies the map model that this container has changed but need not be restored by undo/redo.voidremoveTailParts()Removes all tail parts of this game object.voidsetAttributeString(@NotNull java.lang.String attributeName, @NotNull java.lang.String value)Sets the String of an archetype attribute in the objectText.voidsetEditType(int editType)Sets the edit type.voidsetLoreText(@NotNull java.lang.CharSequence loreText)Sets the map lore.voidsetMapX(int mapX)Sets the X coordinate of this GameObject on its map.voidsetMapY(int mapY)Sets the Y coordinate of this GameObject on its map.voidsetMsgText(@Nullable java.lang.String msgText)Sets the message text.voidsetMulti(@NotNull MultiArchData<G,A,R,T> multi)voidsetObjectFace()We set here the real face of the objects, depending on the set face and the set animation.voidsetObjectText(@NotNull java.lang.String objectText)SetsobjectTextas object text of this GameObject.@NotNull java.lang.StringtoString(@NotNull java.lang.String format)Returns a string representation of this game object.booleanusesDirection()Return whether this base object uses the "direction" attribute.voidvisit(@NotNull BaseObjectVisitor<G,A,R> baseObjectVisitor)Calls the appropriatevisit()function of aBaseObjectVisitor.-
Methods inherited from interface net.sf.gridarta.model.baseobject.Attributes
getAttributeDouble, getAttributeInt, getAttributeLong, getAttributeString, hasAttribute, removeAttribute, setAttributeInt
-
-
-
-
Field Detail
-
EDIT_TYPE_NONE
static final int EDIT_TYPE_NONE
- See Also:
- Constant Field Values
-
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 namequeryArchetype- whether to query the Archetype of this GameObject:trueif the Archetype should be queried as well,falseto 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 asString. The attribute value is first searched in this GameObject. IfqueryArchetype == 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 theobject textqueryArchetype- whether to query the Archetype of this GameObject:trueif the Archetype should be queried as well,falseto 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 asint.- Parameters:
attributeName- the name of the attribute to searchqueryArchetype- 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 aslong.- Parameters:
attributeName- the name of the attribute to searchqueryArchetype- 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 asdouble.- Parameters:
attributeName- the name of the attribute to searchqueryArchetype- 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 returnsnull.- Parameters:
queryArchetype- whether to query the Archetype of this GameObject:trueif the Archetype should be queried as well,falseto 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:
trueif single-part or head of multi-part, otherwisefalse
-
getMultiNext
@Nullable T getMultiNext()
Returns the next of this multi-part object.- Returns:
- the next of this multi-part object or
nullif 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. AfterwardsisMulti()will returnfalse.
-
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:
trueiff 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)Appendstextto 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)SetsobjectTextas 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:
trueif 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 theFaceSourceof 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:
trueif this Archetype is a multi-part object, otherwisefalse
-
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)
- 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 appropriatevisit()function of aBaseObjectVisitor.- 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 givenformatstring 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
-
-