public abstract class AbstractGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends AbstractBaseObject<G,A,R,G> implements GameObject<G,A,R>
GameObject
implementations.EDITOR_FOLDER_INTERN
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 |
AbstractGameObject(R archetype,
@NotNull FaceObjectProviders faceObjectProviders,
@NotNull AnimationObjects animationObjects)
Creates a new instance.
|
Modifier and Type | Method and Description |
---|---|
G |
asGameObject()
Returns this instance as a
GameObject or null if this
instance is not a game object. |
G |
clone()
Creates a clone of this base object.
|
R |
getArchetype()
Returns the Archetype this GameObject is based on.
|
@NotNull java.lang.String |
getAttributeString(@NotNull java.lang.String attributeName,
boolean queryArchetype)
Returns the requested attribute value of this GameObject as
String . |
@Nullable GameObjectContainer<G,A,R> |
getContainer()
Returns container of this GameObject.
|
G |
getContainerGameObject()
Returns the environment game object if this game object is in the
inventory or
null . |
protected @Nullable java.lang.String |
getEffectiveFaceName(@NotNull java.lang.String faceName)
Returns the effective face name for
AbstractBaseObject.faceName for a given real
face name. |
@NotNull MapSquare<G,A,R> |
getMapSquare()
Returns the
MapSquare this game object is part of. |
@Nullable MapSquare<G,A,R> |
getMapSquareOptional()
Returns the
MapSquare this game object is part of. |
G |
getNext()
Returns the game object succeeding this game object.
|
G |
getPrev()
Returns the game object preceding this game object.
|
G |
getTopContainer()
Get the topmost container of this GameObject (in Game sense, which means
being in a MapSquare isn't, but being in a GameObject is).
|
boolean |
hasUndefinedArchetype()
Return whether this instance references an undefined archetype.
|
void |
insertAfter(G node)
Insert a GameObject after this GameObject.
|
void |
insertBefore(G node)
Insert a GameObject before this GameObject.
|
boolean |
isBottom()
Returns whether this game object is the bottom-most one.
|
boolean |
isInContainer()
Check whether this GameObject is in a Container (in Gridarta sense, which
means being in a MapSquare isn't, but being is a GameObject is).
|
boolean |
isTop()
Returns whether this game object is the top-most one.
|
void |
markModified()
Marks this game object as "modified".
|
void |
moveBottom()
Move this GameObject bottom.
|
void |
moveDown()
Move this GameObject down.
|
void |
moveTop()
Move this GameObject top.
|
void |
moveUp()
Move this GameObject up.
|
G |
newInstance(@NotNull GameObjectFactory<G,A,R> gameObjectFactory)
|
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 |
remove()
Remove this GameObject from its container.
|
void |
setArchetype(R archetype)
Set the Archetype of this GameObject.
|
void |
setContainer(@Nullable GameObjectContainer<G,A,R> container,
int mapX,
int mapY)
Sets container of this GameObject.
|
void |
visit(@NotNull BaseObjectVisitor<G,A,R> baseObjectVisitor)
Calls the appropriate
visit() function of a BaseObjectVisitor . |
addMsgTextLine, addObjectText, addTailPart, beginGameObjectChange, countInvObjects, endGameObjectChange, facesReloaded, getAnimName, getAttributeDouble, getAttributeDouble, getAttributeInt, getAttributeInt, getAttributeKeys, getAttributeLong, getAttributeLong, getAttributeString, getAttributeValue, getBestName, getDirection, getEditType, getFaceName, getFaceObjName, getFaceObjSource, getHead, getLoreText, getMapLocation, getMapX, getMapY, getMaxX, getMaxY, getMinX, getMinY, getMsgText, getMulti, getMultiNext, getMultiRefCount, getNormalImage, getObjectText, getObjName, getSizeX, getSizeY, getThis, getTypeNo, hasAttribute, hasAttribute, isDefaultGameObject, isEqual, isHead, isMulti, isTail, removeAttribute, removeTailParts, setAttributeInt, setAttributeString, setEditType, setLoreText, setMapX, setMapY, setMsgText, setMulti, setObjectFace, setObjectText, setThisContainer, toString, updateArchetype
addFirst, addLast, getFirst, getLast, 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
addFirst, addLast, applyMassChange, getFirst, getLast, getLightRadius, isEmpty, isScripted, iterator, propagateElevation, recursive, removeAll, reverse, updateTileStretch
addMsgTextLine, addObjectText, addTailPart, countInvObjects, facesReloaded, getAnimName, getAttributeDouble, getAttributeInt, getAttributeLong, getBestName, getDirection, getEditType, getFaceName, getFaceObjName, getFaceObjSource, getHead, getLoreText, getMapLocation, getMapX, getMapY, getMaxX, getMaxY, getMinX, getMinY, getMsgText, getMultiNext, getMultiRefCount, getNormalImage, getObjectText, getObjName, getSizeX, getSizeY, getTypeNo, hasAttribute, isDefaultGameObject, isEqual, isHead, isMulti, isTail, removeTailParts, setAttributeString, setEditType, setLoreText, setMapX, setMapY, setMsgText, setMulti, setObjectFace, setObjectText, toString, usesDirection
getAttributeDouble, getAttributeInt, getAttributeLong, getAttributeString, hasAttribute, removeAttribute, setAttributeInt
protected AbstractGameObject(@NotNull R archetype, @NotNull @NotNull FaceObjectProviders faceObjectProviders, @NotNull @NotNull AnimationObjects animationObjects)
archetype
- the archetype associated with with game objectfaceObjectProviders
- the face object providers for looking up
facesanimationObjects
- the animation objects for looking up animations@NotNull public @NotNull java.lang.String getAttributeString(@NotNull @NotNull java.lang.String attributeName, boolean queryArchetype)
BaseObject
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.getAttributeString
in interface BaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
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 itAttributes.getAttributeString(String)
@Nullable protected @Nullable java.lang.String getEffectiveFaceName(@NotNull @NotNull java.lang.String faceName)
AbstractBaseObject
AbstractBaseObject.faceName
for a given real
face name.getEffectiveFaceName
in class AbstractBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
faceName
- the real face namenull
if the real face name is
unset or equals the archetype's face namepublic void notifyBeginChange()
GameObjectContainer
notifyBeginChange
in interface BaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
notifyBeginChange
in class AbstractBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
public void notifyEndChange()
GameObjectContainer
notifyEndChange
in interface BaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
notifyEndChange
in class AbstractBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
public void notifyTransientChange()
BaseObject
notifyTransientChange
in interface BaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
@NotNull public G clone()
BaseObject
clone
in interface BaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
clone
in class AbstractBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
@NotNull public G asGameObject()
GameObjectContainer
GameObject
or null
if this
instance is not a game object.asGameObject
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
null
@NotNull public G newInstance(@NotNull @NotNull GameObjectFactory<G,A,R> gameObjectFactory)
BaseObject
newInstance
in interface BaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
gameObjectFactory
- the game object factory for creating new game
objectspublic void visit(@NotNull @NotNull BaseObjectVisitor<G,A,R> baseObjectVisitor)
BaseObject
visit()
function of a BaseObjectVisitor
.visit
in interface BaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
baseObjectVisitor
- the base object visitorpublic void remove()
GameObject
remove
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
@Nullable public @Nullable GameObjectContainer<G,A,R> getContainer()
GameObject
null
for this).
getContainer
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
GameObject.getTopContainer()
public boolean isTop()
GameObject
isTop
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public boolean isBottom()
GameObject
isBottom
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public void moveTop()
GameObject
moveTop
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public void moveUp()
GameObject
moveUp
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public void moveDown()
GameObject
moveDown
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public void moveBottom()
GameObject
moveBottom
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public void insertBefore(@NotNull G node)
GameObject
insertBefore
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
node
- GameObject to appendpublic void insertAfter(@NotNull G node)
GameObject
insertAfter
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
node
- GameObject to append@Nullable public G getContainerGameObject()
GameObject
null
.getContainerGameObject
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
null
@NotNull public G getTopContainer()
GameObject
getTopContainer
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
GameObject.getContainer()
public void setContainer(@Nullable @Nullable GameObjectContainer<G,A,R> container, int mapX, int mapY)
GameObject
setContainer
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
container
- the container of this game objectmapX
- the x coordinate on the map or 0
mapY
- the y coordinate on the map or 0
public boolean isInContainer()
GameObject
isInContainer
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
true
if this GameObject has a Container and the Container
is a GameObject, otherwise (no Container or Container is not an
GameObject) false@NotNull public @NotNull MapSquare<G,A,R> getMapSquare()
GameObjectContainer
MapSquare
this game object is part of.getMapSquare
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
getMapSquare
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
@Nullable public @Nullable MapSquare<G,A,R> getMapSquareOptional()
GameObjectContainer
MapSquare
this game object is part of.getMapSquareOptional
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
getMapSquareOptional
in class GameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
null
if the game object is not part of
a map@Nullable public G getPrev()
GameObject
getPrev
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
null
if no preceding game
object exists.@Nullable public G getNext()
GameObject
getNext
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
null
if no successor game
object exists.@NotNull public R getArchetype()
BaseObject
getArchetype
in interface BaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
public void setArchetype(@NotNull R archetype)
GameObject
setArchetype
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
archetype
- the new archetype of this game objectBaseObject.getArchetype()
public boolean hasUndefinedArchetype()
GameObject
hasUndefinedArchetype
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
true
if this instance references an undefined archetypepublic void markModified()
GameObject
markModified
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>