Package net.sf.gridarta.model.gameobject
Class AbstractGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
- java.lang.Object
-
- net.sf.gridarta.model.baseobject.GameObjectContainer<G,A,R>
-
- net.sf.gridarta.model.baseobject.AbstractBaseObject<G,A,R,G>
-
- net.sf.gridarta.model.gameobject.AbstractGameObject<G,A,R>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<G>,Attributes,BaseObject<G,A,R,G>,GameObject<G,A,R>
- Direct Known Subclasses:
DefaultIsoGameObject,GameObject
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>
Abstract base class ofGameObjectimplementations.- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface net.sf.gridarta.model.baseobject.BaseObject
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
-
Fields inherited from interface net.sf.gridarta.model.gameobject.GameObject
EDITOR_FOLDER_INTERN
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractGameObject(R archetype, @NotNull FaceObjectProviders faceObjectProviders, @NotNull AnimationObjects animationObjects)Creates a new instance.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description GasGameObject()Returns this instance as aGameObjectornullif this instance is not a game object.Gclone()Creates a clone of this base object.RgetArchetype()Returns the Archetype this GameObject is based on.@NotNull java.lang.StringgetAttributeString(@NotNull java.lang.String attributeName, boolean queryArchetype)Returns the requested attribute value of this GameObject asString.@Nullable GameObjectContainer<G,A,R>getContainer()Returns container of this GameObject.GgetContainerGameObject()Returns the environment game object if this game object is in the inventory ornull.protected @Nullable java.lang.StringgetEffectiveFaceName(@NotNull java.lang.String faceName)Returns the effective face name forAbstractBaseObject.faceNamefor a given real face name.@NotNull MapSquare<G,A,R>getMapSquare()Returns theMapSquarethis game object is part of.@Nullable MapSquare<G,A,R>getMapSquareOptional()Returns theMapSquarethis game object is part of.GgetNext()Returns the game object succeeding this game object.GgetPrev()Returns the game object preceding this game object.GgetTopContainer()Get the topmost container of this GameObject (in Game sense, which means being in a MapSquare isn't, but being in a GameObject is).booleanhasUndefinedArchetype()Return whether this instance references an undefined archetype.voidinsertAfter(G node)Insert a GameObject after this GameObject.voidinsertBefore(G node)Insert a GameObject before this GameObject.booleanisBottom()Returns whether this game object is the bottom-most one.booleanisInContainer()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).booleanisTop()Returns whether this game object is the top-most one.voidmarkModified()Marks this game object as "modified".voidmoveBottom()Move this GameObject bottom.voidmoveDown()Move this GameObject down.voidmoveTop()Move this GameObject top.voidmoveUp()Move this GameObject up.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.voidremove()Remove this GameObject from its container.voidsetArchetype(R archetype)Set the Archetype of this GameObject.voidsetContainer(@Nullable GameObjectContainer<G,A,R> container, int mapX, int mapY)Sets container of this GameObject.voidvisit(@NotNull BaseObjectVisitor<G,A,R> baseObjectVisitor)Calls the appropriatevisit()function of aBaseObjectVisitor.-
Methods inherited from class net.sf.gridarta.model.baseobject.AbstractBaseObject
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
-
Methods inherited from class net.sf.gridarta.model.baseobject.GameObjectContainer
addFirst, addLast, getFirst, getLast, getNext, getPrev, hasSameContents, insertAfter, insertBefore, isBottom, isEmpty, isTop, iterator, moveBottom, moveDown, moveTop, moveUp, recursive, remove, removeAll, replace, reverse, toString
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface net.sf.gridarta.model.baseobject.Attributes
getAttributeDouble, getAttributeInt, getAttributeLong, getAttributeString, hasAttribute, removeAttribute, setAttributeInt
-
Methods inherited from interface net.sf.gridarta.model.baseobject.BaseObject
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
-
Methods inherited from interface net.sf.gridarta.model.gameobject.GameObject
addFirst, addLast, applyMassChange, getFirst, getLast, getLightRadius, isEmpty, isScripted, iterator, propagateElevation, recursive, removeAll, reverse, updateTileStretch
-
-
-
-
Constructor Detail
-
AbstractGameObject
protected AbstractGameObject(@NotNull R archetype, @NotNull @NotNull FaceObjectProviders faceObjectProviders, @NotNull @NotNull AnimationObjects animationObjects)Creates a new instance.- Parameters:
archetype- the archetype associated with with game objectfaceObjectProviders- the face object providers for looking up facesanimationObjects- the animation objects for looking up animations
-
-
Method Detail
-
getAttributeString
@NotNull public @NotNull java.lang.String getAttributeString(@NotNull @NotNull java.lang.String attributeName, boolean queryArchetype)Description copied from interface:BaseObjectReturns 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.- Specified by:
getAttributeStringin interfaceBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>- 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)
-
getEffectiveFaceName
@Nullable protected @Nullable java.lang.String getEffectiveFaceName(@NotNull @NotNull java.lang.String faceName)Description copied from class:AbstractBaseObjectReturns the effective face name forAbstractBaseObject.faceNamefor a given real face name.- Specified by:
getEffectiveFaceNamein classAbstractBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>- Parameters:
faceName- the real face name- Returns:
- the effective face name or
nullif the real face name is unset or equals the archetype's face name
-
notifyBeginChange
public void notifyBeginChange()
Description copied from class:GameObjectContainerNotifies the map model that this container is about to change.- Specified by:
notifyBeginChangein interfaceBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>- Specified by:
notifyBeginChangein classAbstractBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
-
notifyEndChange
public void notifyEndChange()
Description copied from class:GameObjectContainerNotifies the map model that this container has changed.- Specified by:
notifyEndChangein interfaceBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>- Specified by:
notifyEndChangein classAbstractBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
-
notifyTransientChange
public void notifyTransientChange()
Description copied from interface:BaseObjectNotifies the map model that this container has changed but need not be restored by undo/redo.- Specified by:
notifyTransientChangein interfaceBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
-
clone
@NotNull public G clone()
Description copied from interface:BaseObjectCreates a clone of this base object.- Specified by:
clonein interfaceBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>- Overrides:
clonein classAbstractBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>
-
asGameObject
@NotNull public G asGameObject()
Description copied from class:GameObjectContainerReturns this instance as aGameObjectornullif this instance is not a game object.- Specified by:
asGameObjectin classGameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- this instance or
null
-
newInstance
@NotNull public G newInstance(@NotNull @NotNull GameObjectFactory<G,A,R> gameObjectFactory)
Description copied from interface:BaseObject- Specified by:
newInstancein interfaceBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>- Parameters:
gameObjectFactory- the game object factory for creating new game objects- Returns:
- the new game object instance
-
visit
public void visit(@NotNull @NotNull BaseObjectVisitor<G,A,R> baseObjectVisitor)Description copied from interface:BaseObjectCalls the appropriatevisit()function of aBaseObjectVisitor.- Specified by:
visitin interfaceBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>- Parameters:
baseObjectVisitor- the base object visitor
-
remove
public void remove()
Description copied from interface:GameObjectRemove this GameObject from its container. Does nothing if the object has no container. This method also takes perfectly well care of multi-part GameObjects.- Specified by:
removein interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
getContainer
@Nullable public @Nullable GameObjectContainer<G,A,R> getContainer()
Description copied from interface:GameObjectReturns container of this GameObject. There are two possibilities for the container:- Another GameObject, which means this object is in the inventory of that GameObject.
- A MapSquare, which means that this GameObject is top level on that
MapSquare (Crossfire returns
nullfor this).
- Specified by:
getContainerin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the container of this game object
- See Also:
GameObject.getTopContainer()
-
isTop
public boolean isTop()
Description copied from interface:GameObjectReturns whether this game object is the top-most one. Returns true if it has no container.- Specified by:
isTopin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- whether this game object is the top-most one
-
isBottom
public boolean isBottom()
Description copied from interface:GameObjectReturns whether this game object is the bottom-most one. Returns true if it has no container.- Specified by:
isBottomin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- whether this game object is the bottom-most one
-
moveTop
public void moveTop()
Description copied from interface:GameObjectMove this GameObject top. Does nothing if the object has no container.- Specified by:
moveTopin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
moveUp
public void moveUp()
Description copied from interface:GameObjectMove this GameObject up. Does nothing if the object has no container.- Specified by:
moveUpin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
moveDown
public void moveDown()
Description copied from interface:GameObjectMove this GameObject down. Does nothing if the object has no container.- Specified by:
moveDownin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
moveBottom
public void moveBottom()
Description copied from interface:GameObjectMove this GameObject bottom. Does nothing if the object has no container.- Specified by:
moveBottomin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
insertBefore
public void insertBefore(@NotNull G node)Description copied from interface:GameObjectInsert a GameObject before this GameObject.- Specified by:
insertBeforein interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
node- GameObject to append
-
insertAfter
public void insertAfter(@NotNull G node)Description copied from interface:GameObjectInsert a GameObject after this GameObject.- Specified by:
insertAfterin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
node- GameObject to append
-
getContainerGameObject
@Nullable public G getContainerGameObject()
Description copied from interface:GameObjectReturns the environment game object if this game object is in the inventory ornull.- Specified by:
getContainerGameObjectin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the game object this game object is part of or
null
-
getTopContainer
@NotNull public G getTopContainer()
Description copied from interface:GameObjectGet the topmost container of this GameObject (in Game sense, which means being in a MapSquare isn't, but being in a GameObject is).- Specified by:
getTopContainerin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the topmost container but always GameObject, never a map square; if this object is topmost itself, it returns itself
- See Also:
GameObject.getContainer()
-
setContainer
public void setContainer(@Nullable @Nullable GameObjectContainer<G,A,R> container, int mapX, int mapY)Description copied from interface:GameObjectSets container of this GameObject. There are two possibilities for the container:- Another GameObject, which means this object is in the inventory of that GameObject.
- A MapSquare, which means that this GameObject is top level on that MapSquare.
- Specified by:
setContainerin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
container- the container of this game objectmapX- the x coordinate on the map or0mapY- the y coordinate on the map or0
-
isInContainer
public boolean isInContainer()
Description copied from interface:GameObjectCheck whether this GameObject is in a Container (in Gridarta sense, which means being in a MapSquare isn't, but being is a GameObject is).- Specified by:
isInContainerin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
trueif this GameObject has a Container and the Container is a GameObject, otherwise (no Container or Container is not an GameObject) false
-
getMapSquare
@NotNull public @NotNull MapSquare<G,A,R> getMapSquare()
Description copied from class:GameObjectContainerReturns theMapSquarethis game object is part of.- Specified by:
getMapSquarein interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Specified by:
getMapSquarein classGameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the map square
-
getMapSquareOptional
@Nullable public @Nullable MapSquare<G,A,R> getMapSquareOptional()
Description copied from class:GameObjectContainerReturns theMapSquarethis game object is part of.- Specified by:
getMapSquareOptionalin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Specified by:
getMapSquareOptionalin classGameObjectContainer<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the map square or
nullif the game object is not part of a map
-
getPrev
@Nullable public G getPrev()
Description copied from interface:GameObjectReturns the game object preceding this game object.- Specified by:
getPrevin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the successor game object or
nullif no preceding game object exists.
-
getNext
@Nullable public G getNext()
Description copied from interface:GameObjectReturns the game object succeeding this game object.- Specified by:
getNextin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the preceding game object or
nullif no successor game object exists.
-
getArchetype
@NotNull public R getArchetype()
Description copied from interface:BaseObjectReturns the Archetype this GameObject is based on.- Specified by:
getArchetypein interfaceBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,G extends GameObject<G,A,R>>- Returns:
- the archetype this game object is based on
-
setArchetype
public void setArchetype(@NotNull R archetype)Description copied from interface:GameObjectSet the Archetype of this GameObject.- Specified by:
setArchetypein interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
archetype- the new archetype of this game object- See Also:
BaseObject.getArchetype()
-
hasUndefinedArchetype
public boolean hasUndefinedArchetype()
Description copied from interface:GameObjectReturn whether this instance references an undefined archetype.- Specified by:
hasUndefinedArchetypein interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
trueif this instance references an undefined archetype
-
markModified
public void markModified()
Description copied from interface:GameObjectMarks this game object as "modified".- Specified by:
markModifiedin interfaceGameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
-