 |
Gridarta Editor
|
Go to the documentation of this file.
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> {
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")
128 clone.container =
null;
129 return clone.getThis();
141 return gameObjectFactory.cloneGameObject(
getThis());
146 baseObjectVisitor.visit(
this);
150 public void remove() {
152 for (G tail = head.getMultiNext(); tail !=
null; tail = tail.getMultiNext()) {
154 if (tailContainer ==
null) {
157 tailContainer.
remove(tail);
160 if (headContainer ==
null) {
163 headContainer.
remove(head);
237 if (gameObject !=
null) {
238 return gameObject.getTopContainer();
261 throw new IllegalStateException(
"not inside a container");
boolean isBottom(@NotNull final G gameObject)
Returns whether this game object is the bottom-most one.
MapSquare< G, A, R > getMapSquareOptional()
G getNext(@NotNull final G gameObject)
Returns the GameObject succeeding a given game object.
AbstractGameObject(@NotNull final R archetype, @NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects)
Creates a new instance.
void visit(@NotNull final BaseObjectVisitor< G, A, R > baseObjectVisitor)
void setMapX(final int mapX)
Base package of all Gridarta classes.
void transientGameObjectChange(@NotNull G gameObject)
Method to notify the model that a game object was changed but need not be restored by undo/redo.
abstract MapSquare< G, A, R > getMapSquareOptional()
Returns the MapSquare this game object is part of.
AnimationObjects is a container for AnimationObjects.
void beginGameObjectChange()
Records that this game object is about to change.
void notifyTransientChange()
Default implementation for GameObject implementing classes.
String faceName
The name of the face.
void updateArchetype()
Called whenever getArchetype() has changed.
int mapX
The map x position if on map.
Provider for faces of GameObjects and Archetypes.
Reflects a game object (object on a map).
void moveBottom(@NotNull final G gameObject)
Moves a game object to bottom.
G getPrev(@NotNull final G gameObject)
Returns the GameObject preceding a given game object.
void beginGameObjectChange(@NotNull G gameObject)
Method to notify the model that a game object is about to change.
R archetype
The Archetype of this game object.
void setMapY(final int mapY)
void setArchetype(@NotNull final R archetype)
int mapY
The map y position if on map.
void notifyEndChange()
@noinspection AbstractMethodOverridesAbstractMethod // needed because of public modifier
void insertBefore(@NotNull final G gameObject, @Nullable final G nextGameObject)
Adds a game object before another.
void remove(@NotNull final G gameObject)
Removes a game object from this container.
String getAttributeString(@NotNull final String attributeName, final boolean queryArchetype)
abstract G asGameObject()
Returns this instance as a GameObject or.
G newInstance(@NotNull final GameObjectFactory< G, A, R > gameObjectFactory)
Interface for MapArchObjects.
String getAttributeValue(@NotNull final String attributeName)
Returns an attribute value by attribute name.
boolean hasUndefinedArchetype()
void insertBefore(@NotNull final G node)
MapModel< G, A, R > getMapModel()
Returns the MapModel this map square is part of.
abstract T getThis()
Returns.
void moveTop(@NotNull final G gameObject)
Moves a game object to top.
MapSquare< G, A, R > getMapSquare()
void insertAfter(@Nullable final G previousGameObject, @NotNull final G gameObject)
Adds a game object after another.
void setContainer(@Nullable final GameObjectContainer< G, A, R > container, final int mapX, final int mapY)
static final long serialVersionUID
The serial version UID.
This exception is thrown in case a method of a GameObject without a container or the wrong container ...
void endGameObjectChange(@NotNull G gameObject)
Method to notify the model that a game object was changed.
String getEffectiveFaceName(@NotNull final String faceName)
Returns the effective face name for faceName for a given real face name.
The face is the appearance of an object.
Gridarta can handle frame information of animations and allow the selection of an animation using a t...
GameObjectContainer< G, A, R > getContainer()
GameObjectContainer< G, A, R > container
Container of this GameObject.
void insertAfter(@NotNull final G node)
final AnimationObjects animationObjects
The AnimationObjects for looking up animations.
void endGameObjectChange()
Records that this game object has changed.
void moveUp(@NotNull final G gameObject)
Moves a game object up.
Base class for classes that contain GameObjects as children in the sense of containment.
void notifyBeginChange()
@noinspection AbstractMethodOverridesAbstractMethod // needed because of public modifier
void moveDown(@NotNull final G gameObject)
Moves a game object down.
Abstract base class of GameObject implementations.
boolean isTop(@NotNull final G gameObject)
Returns whether this game object is the top-most one.
abstract MapSquare< G, A, R > getMapSquare()
Returns the MapSquare this game object is part of.
G getContainerGameObject()
final transient FaceObjectProviders faceObjectProviders
The FaceObjectProviders for looking up faces.