20 package net.sf.gridarta.model.gameobject;
30 import org.jetbrains.annotations.NotNull;
31 import org.jetbrains.annotations.Nullable;
38 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> {
75 super(faceObjectProviders, animationObjects);
82 public String
getAttributeString(@NotNull
final String attributeName,
final boolean queryArchetype) {
87 return queryArchetype ? archetype.getAttributeString(attributeName) :
"";
93 final String normalizedFaceName = faceName.isEmpty() ? null : faceName.intern();
96 return normalizedFaceName != null && !normalizedFaceName.isEmpty() && normalizedFaceName != archetype.getFaceName() ? normalizedFaceName : null;
102 if (mapSquare != null) {
110 if (mapSquare != null) {
118 if (mapSquare != null) {
125 @SuppressWarnings(
"unchecked")
130 return clone.getThis();
142 return gameObjectFactory.cloneGameObject(
getThis());
147 baseObjectVisitor.visit(
this);
151 public void remove() {
153 for (G tail = head.getMultiNext(); tail != null; tail = tail.getMultiNext()) {
155 if (tailContainer == null) {
158 tailContainer.
remove(tail);
161 if (headContainer == null) {
164 headContainer.
remove(head);
246 if (gameObject != null) {
247 return gameObject.getTopContainer();
294 if (this.archetype == archetype) {
R archetype
The Archetype of this game object.
String faceName
The name of the face.
boolean hasUndefinedArchetype()
Abstract base class of GameObject implementations.
void endGameObjectChange()
Records that this game object has changed.
abstract T getThis()
Returns.
GameObjectContainer< G, A, R > container
Container of this GameObject.
G getNext(@NotNull final G gameObject)
Return the GameObject succeeding a given game object.
void setContainer(@Nullable final GameObjectContainer< G, A, R > container, final int mapX, final int mapY)
abstract MapSquare< G, A, R > getMapSquare()
Returns the MapSquare of this container.
void insertBefore(@NotNull final G node)
MapModel< G, A, R > getMapModel()
Returns the MapModel this map square is part of.
void visit(@NotNull final BaseObjectVisitor< G, A, R > baseObjectVisitor)
Gridarta can handle frame information of animations and allow the selection of an animation using a t...
void insertBefore(@NotNull final G gameObject, @Nullable final G nextGameObject)
Add a GameObject before another.
void transientGameObjectChange(@NotNull G gameObject)
Method to notify the model that a game object was changed but need not be restored by undo/redo...
Base class for classes that contain GameObjects as children in the sense of containment.
void moveTop(@NotNull final G gameObject)
Move an item to top.
String getEffectiveFaceName(@NotNull final String faceName)
boolean isTop(@NotNull final G gameObject)
Returns whether this game object is the top-most one.
G newInstance(@NotNull final GameObjectFactory< G, A, R > gameObjectFactory)
Base package of all Gridarta classes.
boolean isBottom(@NotNull final G gameObject)
Returns whether this game object is the bottom-most one.
This exception is thrown in case a method of a GameObject without a container or the wrong container ...
Reflects a game object (object on a map).
void beginGameObjectChange()
Records that this game object is about to change.
int mapY
The map y position if on map.
G getContainerGameObject()
void insertAfter(@NotNull final G node)
final AnimationObjects animationObjects
The AnimationObjects for looking up animations.
AnimationObjects is a container for AnimationObjects.
void setMapY(final int mapY)
abstract G asGameObject()
Returns this instance as a GameObject or.
void insertAfter(@Nullable final G previousGameObject, @NotNull final G gameObject)
Add a GameObject after another.
static final long serialVersionUID
The serial version UID.
GameObjectContainer< G, A, R > getContainer()
AbstractGameObject(@NotNull final R archetype, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects)
Creates a new instance.
void notifyTransientChange()
void moveUp(@NotNull final G gameObject)
Move an item up.
String getAttributeString(@NotNull final String attributeName, final boolean queryArchetype)
void moveDown(@NotNull final G gameObject)
Move an item down.
Provider for faces of GameObjects and Archetypes.
G getPrev(@NotNull final G gameObject)
Return the GameObject preceding a given game object.
The face is the appearance of an object.
void beginGameObjectChange(@NotNull G gameObject)
Method to notify the model that a game object is about to change.
Default implementation for GameObject implementing classes.
void setArchetype(@NotNull final R archetype)
void endGameObjectChange(@NotNull G gameObject)
Method to notify the model that a game object was changed.
final transient FaceObjectProviders faceObjectProviders
The FaceObjectProviders for looking up faces.
void remove(@NotNull final G gameObject)
Remove a GameObject from this container.
String getAttributeValue(@NotNull final String attributeName)
Returns an attribute value by attribute name.
void updateArchetype()
Called whenever getArchetype() has changed.
void setMapX(final int mapX)
MapSquare< G, A, R > getMapSquare()
Interface for MapArchObjects.
void moveBottom(@NotNull final G gameObject)
Move an item to bottom.
int mapX
The map x position if on map.