Package net.sf.gridarta.model.archetype
Class AbstractArchetype<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,R>
-
- net.sf.gridarta.model.archetype.AbstractArchetype<G,A,R>
-
- All Implemented Interfaces:
java.io.Serializable,java.lang.Cloneable,java.lang.Iterable<G>,Archetype<G,A,R>,Attributes,BaseObject<G,A,R,R>
- Direct Known Subclasses:
DefaultArchetype,DefaultArchetype,DefaultArchetype,UndefinedArchetype,UndefinedArchetype,UndefinedArchetype
public abstract class AbstractArchetype<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>> extends AbstractBaseObject<G,A,R,R> implements Archetype<G,A,R>
Abstract base class forArchetypeimplementations.- 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
-
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractArchetype(@NotNull java.lang.String archetypeName, @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.Rclone()Creates a clone of this base object.RgetArchetype()Returns the Archetype this GameObject is based on.@NotNull java.lang.StringgetArchetypeName()Returns the name of this archetype.@NotNull java.lang.StringgetAttributeString(@NotNull java.lang.String attributeName, boolean queryArchetype)Returns the requested attribute value of this GameObject asString.@Nullable java.lang.StringgetEditorFolder()Returns the editor folder.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.intgetMultiPartNr()Returns the multi part id.intgetMultiShapeID()Returns the multi shape id.intgetMultiX()Returns the x-distance of this part to the head part.intgetMultiY()Returns the y-distance of this part to the head part.booleanisArtifact()Returns whether this GameObject is an Artifact.booleanisLowestPart()Returns whether this part has the smallest y coordinate when painting the image.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.voidsetArchetypeName(@NotNull java.lang.String archetypeName)Sets the name of this archetype.voidsetArtifact()Converts this game object into an artifact.voidsetEditorFolder(@Nullable java.lang.String editorFolder)Set the editor folder.voidsetLowestPart(boolean isLowestPart)Sets whether this part has the smallest y coordinate when painting the image.voidsetMultiPartNr(int multiPartNr)Sets the multi part id.voidsetMultiShapeID(int multiShapeID)Sets the multi shape id.voidsetMultiX(int multiX)Sets the x-position of this part of a multi-part object.voidsetMultiY(int multiY)Sets the y-position of this part of a multi-part object.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.archetype.Archetype
addFirst, addLast, getAttributeKeys, isUndefinedArchetype, iterator
-
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
-
-
-
-
Constructor Detail
-
AbstractArchetype
protected AbstractArchetype(@NotNull @NotNull java.lang.String archetypeName, @NotNull @NotNull FaceObjectProviders faceObjectProviders, @NotNull @NotNull AnimationObjects animationObjects)Creates a new instance.- Parameters:
archetypeName- the name of the archetypefaceObjectProviders- the face object providers for looking up facesanimationObjects- the animation objects for looking up animations
-
-
Method Detail
-
getMapSquare
@NotNull public @NotNull MapSquare<G,A,R> getMapSquare()
Description copied from class:GameObjectContainerReturns theMapSquarethis game object is part of.- 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 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
-
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>,R extends Archetype<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>,R extends Archetype<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>,R extends Archetype<G,A,R>>- Specified by:
notifyBeginChangein classAbstractBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,R extends Archetype<G,A,R>>- No Inspection:
- NoopMethodInAbstractClass
-
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>,R extends Archetype<G,A,R>>- Specified by:
notifyEndChangein classAbstractBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,R extends Archetype<G,A,R>>- No Inspection:
- NoopMethodInAbstractClass
-
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>,R extends Archetype<G,A,R>>- No Inspection:
- NoopMethodInAbstractClass
-
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>,R extends Archetype<G,A,R>>- Returns:
- the archetype this game object is based on
-
clone
@NotNull public R 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>,R extends Archetype<G,A,R>>- Overrides:
clonein classAbstractBaseObject<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>,R extends Archetype<G,A,R>>
-
asGameObject
@Nullable 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>,R extends Archetype<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.
-
getArchetypeName
@NotNull public @NotNull java.lang.String getArchetypeName()
Description copied from interface:ArchetypeReturns the name of this archetype.- Specified by:
getArchetypeNamein interfaceArchetype<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the name
-
setArchetypeName
public void setArchetypeName(@NotNull @NotNull java.lang.String archetypeName)Description copied from interface:ArchetypeSets the name of this archetype.- Specified by:
setArchetypeNamein interfaceArchetype<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
archetypeName- the name
-
setMultiX
public void setMultiX(int multiX)
Description copied from interface:ArchetypeSets the x-position of this part of a multi-part object. The x-position is relative to the head part.
-
setMultiY
public void setMultiY(int multiY)
Description copied from interface:ArchetypeSets the y-position of this part of a multi-part object. The y-position is relative to the head part.
-
getMultiX
public int getMultiX()
Description copied from interface:ArchetypeReturns the x-distance of this part to the head part. For single-part objects this is always zero.
-
getMultiY
public int getMultiY()
Description copied from interface:ArchetypeReturns the y-distance of this part to the head part. For single-part objects this is always zero.
-
isLowestPart
public boolean isLowestPart()
Description copied from interface:ArchetypeReturns whether this part has the smallest y coordinate when painting the image.- Specified by:
isLowestPartin interfaceArchetype<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- whether this part has the smallest y coordinate
-
setLowestPart
public void setLowestPart(boolean isLowestPart)
Description copied from interface:ArchetypeSets whether this part has the smallest y coordinate when painting the image.- Specified by:
setLowestPartin interfaceArchetype<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
isLowestPart- whether this part has the smallest y coordinate
-
getMultiShapeID
public int getMultiShapeID()
Description copied from interface:ArchetypeReturns the multi shape id.- Specified by:
getMultiShapeIDin interfaceArchetype<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the multi shape id
-
setMultiShapeID
public void setMultiShapeID(int multiShapeID)
Description copied from interface:ArchetypeSets the multi shape id.- Specified by:
setMultiShapeIDin interfaceArchetype<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
multiShapeID- the multi shape id
-
getMultiPartNr
public int getMultiPartNr()
Description copied from interface:ArchetypeReturns the multi part id.- Specified by:
getMultiPartNrin interfaceArchetype<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the multi part id
-
setMultiPartNr
public void setMultiPartNr(int multiPartNr)
Description copied from interface:ArchetypeSets the multi part id.- Specified by:
setMultiPartNrin interfaceArchetype<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
multiPartNr- the multi part id
-
getEditorFolder
@Nullable public @Nullable java.lang.String getEditorFolder()
Description copied from interface:ArchetypeReturns the editor folder.- Specified by:
getEditorFolderin interfaceArchetype<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
- the editor folder
-
setEditorFolder
public void setEditorFolder(@Nullable @Nullable java.lang.String editorFolder)Description copied from interface:ArchetypeSet the editor folder.- Specified by:
setEditorFolderin interfaceArchetype<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Parameters:
editorFolder- the editor folder
-
isArtifact
public boolean isArtifact()
Description copied from interface:ArchetypeReturns whether this GameObject is an Artifact. Artifacts are special forms of Archetypes, and they are excluded from Archetypes collection.- Specified by:
isArtifactin interfaceArchetype<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- Returns:
trueif this GameObject is an Artifact, otherwisefalse.
-
setArtifact
public void setArtifact()
Description copied from interface:ArchetypeConverts this game object into an artifact.- Specified by:
setArtifactin interfaceArchetype<G extends GameObject<G,A,R>,A extends MapArchObject<A>,R extends Archetype<G,A,R>>- See Also:
Archetype.isArtifact()
-
-