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,
FaceObjectProviders faceObjectProviders,
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() |
R |
getArchetype()
Returns the Archetype this GameObject is based on.
|
java.lang.String |
getAttributeString(java.lang.String attributeName,
boolean queryArchetype)
Returns the requested attribute value of this GameObject as
String . |
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 java.lang.String |
getEffectiveFaceName(java.lang.String faceName)
Returns the effective face name for
AbstractBaseObject.faceName for a given real
face name. |
MapSquare<G,A,R> |
getMapSquare()
Returns the
MapSquare of this container. |
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 an 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 in an 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(GameObjectFactory<G,A,R> gameObjectFactory)
|
void |
notifyBeginChange()
Notify the map model that this container is about to change.
|
void |
notifyEndChange()
Notify 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(GameObjectContainer<G,A,R> container,
int mapX,
int mapY)
Sets container of this GameObject.
|
void |
visit(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, transientGameObjectChange, 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 FaceObjectProviders faceObjectProviders, @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 java.lang.String getAttributeString(@NotNull java.lang.String attributeName, boolean queryArchetype)
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 java.lang.String getEffectiveFaceName(@NotNull java.lang.String faceName)
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()
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()
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()
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()
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()
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 GameObjectFactory<G,A,R> gameObjectFactory)
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 BaseObjectVisitor<G,A,R> baseObjectVisitor)
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()
remove
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
@Nullable public GameObjectContainer<G,A,R> getContainer()
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()
isTop
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public boolean isBottom()
isBottom
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public void moveTop()
moveTop
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public void moveUp()
moveUp
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public void moveDown()
moveDown
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
public void moveBottom()
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)
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)
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()
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()
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 GameObjectContainer<G,A,R> container, int mapX, int mapY)
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()
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 an GameObject, otherwise (no Container or Container is not an
GameObject) false@Nullable public MapSquare<G,A,R> getMapSquare()
MapSquare
of this container.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>>
null
if this
GameObjectContainer is not (yet?) connected to a map (a MapSquare
would return itself)@Nullable public G getPrev()
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()
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()
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)
setArchetype
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
archetype
- new Archetype of this GameObject.BaseObject.getArchetype()
public boolean hasUndefinedArchetype()
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()
markModified
in interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>