Package net.sf.gridarta.model.gameobject
Interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>
-
- All Superinterfaces:
Attributes,BaseObject<G,A,R,G>,java.lang.Cloneable,java.lang.Iterable<G>,java.io.Serializable
- All Known Implementing Classes:
AbstractGameObject,DefaultIsoGameObject,GameObject,GameObject,GameObject
public interface GameObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends BaseObject<G,A,R,G>
Reflects a game object (object on a map).
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringEDITOR_FOLDER_INTERNThe editor folder name for server-internal archetypes.-
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
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidaddFirst(G gameObject)Add the given GameObject at the beginning of this Container.voidaddLast(G gameObject)Add the given GameObject at the end of this Container.voidapplyMassChange(@NotNull java.lang.Integer @NotNull [] layers, @NotNull java.lang.Integer @NotNull [] subLayers, @NotNull java.lang.String changes)Applies mass changes to the specified object if all the match conditions are met.@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.GgetFirst()Return the first GameObject contained in this container.GgetLast()Return the last GameObject contained in this container.intgetLightRadius()Returns the effective light radius of this game object.@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.booleanisEmpty()Check whether this square is empty.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).booleanisScripted()Returns whether this GameObject has one or more scripted events defined.booleanisTop()Returns whether this game object is the top-most one.@NotNull java.util.Iterator<G>iterator()The Iterator returned does not recurse, it only contains objects on the first level.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.voidpropagateElevation(@NotNull BaseObject<?,?,?,?> gameObject)If there is elevation data in the other game object, move it to here.@NotNull java.lang.Iterable<G>recursive()Return an object that is a recursive representation.voidremove()Remove this GameObject from its container.voidremoveAll()Removes all GameObjects from this container.@NotNull java.lang.Iterable<G>reverse()Return an object that is the reverse representation.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.voidupdateTileStretch(int heightValue, boolean isAbsolute, @NotNull java.lang.Integer @Nullable [] subLayers)Updates the tile stretching value of the selected object.-
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, clone, countInvObjects, facesReloaded, getAnimName, getArchetype, getAttributeDouble, getAttributeInt, getAttributeLong, getAttributeString, 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, newInstance, notifyBeginChange, notifyEndChange, notifyTransientChange, removeTailParts, setAttributeString, setEditType, setLoreText, setMapX, setMapY, setMsgText, setMulti, setObjectFace, setObjectText, toString, usesDirection, visit
-
-
-
-
Field Detail
-
EDITOR_FOLDER_INTERN
static final java.lang.String EDITOR_FOLDER_INTERN
The editor folder name for server-internal archetypes. These archetypes are not available to users.- See Also:
- Constant Field Values
-
-
Method Detail
-
removeAll
void removeAll()
Removes all GameObjects from this container.- Fixme:
- this implementation does not take care of multi square objects.
-
addLast
void addLast(@NotNull G gameObject)Add the given GameObject at the end of this Container.- Parameters:
gameObject- the free yet unlinkedGameObjectto be placed in the inventory- Throws:
java.lang.IllegalArgumentException- ifgameObjectalready is inside another container
-
getLast
@Nullable G getLast()
Return the last GameObject contained in this container.- Returns:
- first GameObject contained or
nullifisEmpty()returnstrue
-
addFirst
void addFirst(@NotNull G gameObject)Add the given GameObject at the beginning of this Container.- Parameters:
gameObject- the free yet unlinkedGameObjectto be placed in the inventory- Throws:
java.lang.IllegalArgumentException- ifgameObjectalready is inside another container
-
getFirst
@Nullable G getFirst()
Return the first GameObject contained in this container.- Returns:
- first GameObject contained or
nullifisEmpty()returnstrue
-
propagateElevation
void propagateElevation(@NotNull @NotNull BaseObject<?,?,?,?> gameObject)If there is elevation data in the other game object, move it to here.- Parameters:
gameObject- the other game object
-
updateTileStretch
void updateTileStretch(int heightValue, boolean isAbsolute, @NotNull @NotNull java.lang.Integer @Nullable [] subLayers)Updates the tile stretching value of the selected object.- Parameters:
heightValue- height valueisAbsolute- whether the height change value is absolute or relativesubLayers- sub-layers to affect ornullto affect all layers
-
applyMassChange
void applyMassChange(@NotNull @NotNull java.lang.Integer @NotNull [] layers, @NotNull @NotNull java.lang.Integer @NotNull [] subLayers, @NotNull @NotNull java.lang.String changes)Applies mass changes to the specified object if all the match conditions are met.- Parameters:
layers- layers to match, can be emptysubLayers- sub-layers to match, can be emptychanges- changes to apply
-
iterator
@NotNull @NotNull java.util.Iterator<G> iterator()
The Iterator returned does not recurse, it only contains objects on the first level. The Iterator returned is transparent, that means modifying the iterator's collection actually modifies the underlying GameObjectContainer.- Specified by:
iteratorin interfacejava.lang.Iterable<G extends GameObject<G,A,R>>
-
reverse
@NotNull @NotNull java.lang.Iterable<G> reverse()
Return an object that is the reverse representation. Invoke this method if you want to iterate over the contained GameObjects in reverse order.- Returns:
- reverse representation
-
recursive
@NotNull @NotNull java.lang.Iterable<G> recursive()
Return an object that is a recursive representation. Invoke this method if you want to iterate over the contained GameObjects recursively.- Returns:
- recursive representation
-
isScripted
boolean isScripted()
Returns whether this GameObject has one or more scripted events defined.- Returns:
trueif this GameObject has one or more scripted events, otherwisefalse
-
isEmpty
boolean isEmpty()
Check whether this square is empty.- Returns:
trueif this square is empty, otherwisefalse
-
remove
void remove()
Remove this GameObject from its container. Does nothing if the object has no container. This method also takes perfectly well care of multi-part GameObjects.
-
getContainer
@Nullable @Nullable GameObjectContainer<G,A,R> getContainer()
Returns 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).
- Returns:
- the container of this game object
- See Also:
getTopContainer()
-
isTop
boolean isTop()
Returns whether this game object is the top-most one. Returns true if it has no container.- Returns:
- whether this game object is the top-most one
-
isBottom
boolean isBottom()
Returns whether this game object is the bottom-most one. Returns true if it has no container.- Returns:
- whether this game object is the bottom-most one
-
moveTop
void moveTop()
Move this GameObject top. Does nothing if the object has no container.
-
moveUp
void moveUp()
Move this GameObject up. Does nothing if the object has no container.
-
moveDown
void moveDown()
Move this GameObject down. Does nothing if the object has no container.
-
moveBottom
void moveBottom()
Move this GameObject bottom. Does nothing if the object has no container.
-
insertBefore
void insertBefore(@NotNull G node)Insert a GameObject before this GameObject.- Parameters:
node- GameObject to append
-
insertAfter
void insertAfter(@NotNull G node)Insert a GameObject after this GameObject.- Parameters:
node- GameObject to append
-
getContainerGameObject
@Nullable G getContainerGameObject()
Returns the environment game object if this game object is in the inventory ornull.- Returns:
- the game object this game object is part of or
null
-
getTopContainer
@NotNull 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).- Returns:
- the topmost container but always GameObject, never a map square; if this object is topmost itself, it returns itself
- See Also:
getContainer()
-
setContainer
void setContainer(@Nullable @Nullable GameObjectContainer<G,A,R> container, int mapX, int mapY)Sets 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.
- Parameters:
container- the container of this game objectmapX- the x coordinate on the map or0mapY- the y coordinate on the map or0- Throws:
java.lang.IllegalStateException- in case this GameObject is an Archetype (Archetypes must not be added to a map).
-
isInContainer
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).- 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 @NotNull MapSquare<G,A,R> getMapSquare()
Returns theMapSquarethis game object is part of.- Returns:
- the map square
- Throws:
java.lang.IllegalStateException- if the game object is not part of a map
-
getMapSquareOptional
@Nullable @Nullable MapSquare<G,A,R> getMapSquareOptional()
Returns theMapSquarethis game object is part of.- Returns:
- the map square or
nullif the game object is not part of a map
-
getPrev
@Nullable G getPrev()
Returns the game object preceding this game object.- Returns:
- the successor game object or
nullif no preceding game object exists.
-
getNext
@Nullable G getNext()
Returns the game object succeeding this game object.- Returns:
- the preceding game object or
nullif no successor game object exists.
-
setArchetype
void setArchetype(@NotNull R archetype)Set the Archetype of this GameObject.- Parameters:
archetype- the new archetype of this game object- See Also:
BaseObject.getArchetype()
-
hasUndefinedArchetype
boolean hasUndefinedArchetype()
Return whether this instance references an undefined archetype.- Returns:
trueif this instance references an undefined archetype
-
markModified
void markModified()
Marks this game object as "modified".
-
getLightRadius
int getLightRadius()
Returns the effective light radius of this game object.- Returns:
- the effective light radius or
0if this object does not emit light
-
-