Gridarta Editor
BaseObject.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2023 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.model.baseobject;
21 
22 import java.awt.Point;
23 import java.io.Serializable;
24 import javax.swing.ImageIcon;
31 import org.jetbrains.annotations.NotNull;
32 import org.jetbrains.annotations.Nullable;
33 
34 public interface BaseObject<G extends GameObject<G, A, R>, A extends MapArchObject<A>, R extends Archetype<G, A, R>, T extends BaseObject<G, A, R, T>> extends Attributes, Cloneable, Iterable<G>, Serializable {
35 
36  int EDIT_TYPE_NONE = 0x10000; // special case
37 
41  @NotNull
42  String ANIMATION = "animation";
43 
47  @NotNull
48  String DIRECTION = "direction";
49 
53  @NotNull
54  String FACE = "face";
55 
59  @NotNull
60  String NAME = "name";
61 
65  @NotNull
66  String TYPE = "type";
67 
71  @NotNull
72  String TITLE = "title";
73 
77  @NotNull
78  String IS_ANIMATED = "is_animated";
79 
83  @NotNull
84  String IS_TURNABLE = "is_turnable";
85 
89  @NotNull
90  String HP = "hp";
91 
95  @NotNull
96  String SP = "sp";
97 
101  @NotNull
102  String NO_PASS = "no_pass";
103 
107  @NotNull
108  String NO_PICK = "no_pick";
109 
113  @NotNull
114  String LEVEL = "level";
115 
119  @NotNull
120  String SLAYING = "slaying";
121 
125  @NotNull
126  String LAST_HEAL = "last_heal";
127 
131  @NotNull
132  String BLOCKSVIEW = "blocksview";
133 
137  @NotNull
138  String ANIM_SPEED = "anim_speed";
139 
144  int getTypeNo();
145 
150  @Nullable
151  String getFaceName();
152 
158  int countInvObjects();
159 
168  boolean hasAttribute(@NotNull String attributeName, boolean queryArchetype);
169 
186  @NotNull
187  String getAttributeString(@NotNull String attributeName, boolean queryArchetype);
188 
197  int getAttributeInt(@NotNull String attributeName, boolean queryArchetype);
198 
208  long getAttributeLong(@NotNull String attributeName, boolean queryArchetype);
209 
219  double getAttributeDouble(@NotNull String attributeName, boolean queryArchetype);
220 
226  void setAttributeString(@NotNull String attributeName, @NotNull String value);
227 
231  void notifyBeginChange();
232 
236  void notifyEndChange();
237 
242  void notifyTransientChange();
243 
249  @NotNull
250  R getArchetype();
251 
256  int getEditType();
257 
262  void setEditType(int editType);
263 
269  void addMsgTextLine(@NotNull String text);
270 
280  @Nullable
281  String getMsgText(boolean queryArchetype);
282 
287  void setMsgText(@Nullable String msgText);
288 
297  int getMapX();
298 
307  int getMapY();
308 
316  @NotNull
317  Point getMapLocation();
318 
324  void setMapX(int mapX);
325 
331  void setMapY(int mapY);
332 
339  boolean isHead();
340 
346  @Nullable
347  T getMultiNext();
348 
356  int getMultiRefCount();
357 
362  void addTailPart(@NotNull T tail);
363 
368  void removeTailParts();
369 
375  T getHead();
376 
382  boolean isTail();
383 
389  int getSizeX();
390 
396  int getSizeY();
397 
403  int getMaxX();
404 
410  int getMaxY();
411 
417  int getMinX();
418 
424  int getMinY();
425 
430  @NotNull
431  String getObjName();
432 
438  @NotNull
439  String getBestName();
440 
445  @NotNull
446  String getObjectText();
447 
453  void addObjectText(@NotNull String line);
454 
459  void setObjectText(@NotNull String objectText);
460 
466  boolean isDefaultGameObject();
467 
473  boolean isEqual(@NotNull BaseObject<?, ?, ?, ?> gameObject);
474 
479  int getDirection();
480 
485  @NotNull
487 
492  @Nullable
493  String getAnimName();
494 
500  boolean isMulti();
501 
502  void setMulti(@NotNull MultiArchData<G, A, R, T> multi);
503 
508  @Nullable
509  String getFaceObjName();
510 
518  void setObjectFace();
519 
524  @NotNull
525  ImageIcon getNormalImage();
526 
530  @NotNull
531  T clone();
532 
537  @NotNull
538  String getLoreText();
539 
544  void setLoreText(@NotNull CharSequence loreText);
545 
553  @NotNull
554  G newInstance(@NotNull GameObjectFactory<G, A, R> gameObjectFactory);
555 
561  void visit(@NotNull BaseObjectVisitor<G, A, R> baseObjectVisitor);
562 
567  boolean usesDirection();
568 
572  void facesReloaded();
573 
588  @NotNull
589  String toString(@NotNull String format);
590 
591 }
net.sf.gridarta.model.baseobject.BaseObject.getLoreText
String getLoreText()
Returns the map lore.
net.sf.gridarta.model.baseobject.BaseObject.getDirection
int getDirection()
Returns the direction of this Archetype or GameObject.
net.sf.gridarta.model.gameobject.GameObjectFactory
Abstract factory for creating GameObject instances.
Definition: GameObjectFactory.java:31
net.sf.gridarta.model.baseobject.BaseObject.isMulti
boolean isMulti()
Returns whether this Archetype is a multi-part object.
net.sf.gridarta.model.gameobject.FaceSource
Enumeration describing the state of the face.
Definition: FaceSource.java:28
net.sf.gridarta
Base package of all Gridarta classes.
net.sf.gridarta.model.baseobject.BaseObject.addObjectText
void addObjectText(@NotNull String line)
Appends.
net.sf.gridarta.model.baseobject.BaseObject.getMapX
int getMapX()
Returns the X coordinate of this GameObject on its map.
net.sf.gridarta.model.baseobject.BaseObject.SP
String SP
The attribute name of the "sp" attribute.
Definition: BaseObject.java:96
net.sf.gridarta.model.baseobject.BaseObject.getMsgText
String getMsgText(boolean queryArchetype)
Returns the message bound to this object.
net.sf.gridarta.model.baseobject.BaseObjectVisitor
Definition: BaseObjectVisitor.java:27
net.sf.gridarta.model.baseobject.BaseObject.getEditType
int getEditType()
Returns the edit type.
net.sf.gridarta.model.gameobject.MultiArchData
Class related to GameObject to store multi-part information.
Definition: MultiArchData.java:41
net.sf.gridarta.model.baseobject.BaseObject.setEditType
void setEditType(int editType)
Sets the edit type.
net.sf.gridarta.model.baseobject.BaseObject.getAttributeInt
int getAttributeInt(@NotNull String attributeName, boolean queryArchetype)
Returns the requested attribute value of this GameObject as.
net.sf.gridarta.model.baseobject.BaseObject.getMinY
int getMinY()
Determines the minimum y-coordinate of any part relative to the head part.
net.sf.gridarta.model.baseobject.BaseObject.getObjectText
String getObjectText()
Returns the object text of this GameObject as String.
net.sf
net.sf.gridarta.model.baseobject.BaseObject.getSizeX
int getSizeX()
Determines the horizontal extent in squares.
net.sf.gridarta.model.baseobject.BaseObject.getMinX
int getMinX()
Determines the minimum x-coordinate of any part relative to the head part.
net.sf.gridarta.model.baseobject.BaseObject.BLOCKSVIEW
String BLOCKSVIEW
The name of the "blocksview" attribute.
Definition: BaseObject.java:132
net.sf.gridarta.model.baseobject.BaseObject.TITLE
String TITLE
The attribute name of the object's title.
Definition: BaseObject.java:72
net.sf.gridarta.model.baseobject.BaseObject.newInstance
G newInstance(@NotNull GameObjectFactory< G, A, R > gameObjectFactory)
Creates a new GameObject instance: an Archetype is instantiated, a GameObject is cloned.
net.sf.gridarta.model.baseobject.BaseObject.getMapLocation
Point getMapLocation()
Returns the coordinate of this GameObject on its map.
net.sf.gridarta.model.baseobject.BaseObject.isEqual
boolean isEqual(@NotNull BaseObject<?, ?, ?, ?> gameObject)
Compares this object to another game object.
net.sf.gridarta.model.baseobject.BaseObject.notifyBeginChange
void notifyBeginChange()
Notifies the map model that this container is about to change.
net.sf.gridarta.model.archetype
Definition: AbstractArchetype.java:20
net.sf.gridarta.model.gameobject.GameObject
Reflects a game object (object on a map).
Definition: GameObject.java:36
net.sf.gridarta.model.baseobject.BaseObject.getBestName
String getBestName()
Returns the name which is best appropriate to describe this GameObject.
net.sf.gridarta.model.baseobject.BaseObject.setObjectFace
void setObjectFace()
We set here the real face of the objects, depending on the set face and the set animation.
net.sf.gridarta.model.baseobject.BaseObject.NAME
String NAME
The attribute name of the object's name.
Definition: BaseObject.java:60
net.sf.gridarta.model.baseobject.BaseObject.isTail
boolean isTail()
Determines if this part is a tail part.
net.sf.gridarta.model.baseobject.BaseObject.IS_TURNABLE
String IS_TURNABLE
The name of the "is_turnable" attribute.
Definition: BaseObject.java:84
net.sf.gridarta.model.baseobject.BaseObject.IS_ANIMATED
String IS_ANIMATED
The attribute name of the "is_animated" flag.
Definition: BaseObject.java:78
net.sf.gridarta.model.baseobject.BaseObject.isHead
boolean isHead()
Returns whether this object is a single-part object or the head of the multi-part object.
net.sf.gridarta.model.baseobject.BaseObject.setMulti
void setMulti(@NotNull MultiArchData< G, A, R, T > multi)
net.sf.gridarta.model.baseobject.BaseObject.getArchetype
R getArchetype()
Returns the Archetype this GameObject is based on.
net.sf.gridarta.model.baseobject.BaseObject.usesDirection
boolean usesDirection()
Return whether this base object uses the "direction" attribute.
net.sf.gridarta.model.baseobject.Attributes
A set of key/value pairs.
Definition: Attributes.java:28
net.sf.gridarta.model.baseobject.BaseObject.EDIT_TYPE_NONE
int EDIT_TYPE_NONE
Definition: BaseObject.java:36
net.sf.gridarta.model.gameobject
GameObjects are the objects based on Archetypes found on maps.
Definition: AbstractGameObject.java:20
net
net.sf.gridarta.model.baseobject.BaseObject.getMaxX
int getMaxX()
Determines the maximum x-coordinate of any part relative to the head part.
net.sf.gridarta.model.baseobject.BaseObject.getFaceObjSource
FaceSource getFaceObjSource()
Returns the FaceSource of this base object.
net.sf.gridarta.model.baseobject.BaseObject.FACE
String FACE
The attribute name of the object's face.
Definition: BaseObject.java:54
net.sf.gridarta.model.baseobject.BaseObject.getNormalImage
ImageIcon getNormalImage()
Returns the normal face for this GameObject.
net.sf.gridarta.model.maparchobject.MapArchObject
Interface for MapArchObjects.
Definition: MapArchObject.java:40
net.sf.gridarta.model.baseobject.BaseObject.getAttributeDouble
double getAttributeDouble(@NotNull String attributeName, boolean queryArchetype)
Returns the requested attribute value of this GameObject as.
net.sf.gridarta.model.baseobject.BaseObject.setMsgText
void setMsgText(@Nullable String msgText)
Sets the message text.
net.sf.gridarta.model.baseobject.BaseObject.NO_PASS
String NO_PASS
The name of the "no_pass" attribute.
Definition: BaseObject.java:102
net.sf.gridarta.model.baseobject.BaseObject.toString
String toString(@NotNull String format)
Returns a string representation of this game object.
net.sf.gridarta.model.baseobject.BaseObject.SLAYING
String SLAYING
The name of the "slaying" attribute.
Definition: BaseObject.java:120
net.sf.gridarta.model.baseobject.BaseObject
Definition: BaseObject.java:34
net.sf.gridarta.model.baseobject.BaseObject.NO_PICK
String NO_PICK
The name of the "no_pick" attribute.
Definition: BaseObject.java:108
net.sf.gridarta.model.baseobject.BaseObject.LAST_HEAL
String LAST_HEAL
The name of the "last_heal" attribute.
Definition: BaseObject.java:126
net.sf.gridarta.model.baseobject.BaseObject.setMapX
void setMapX(int mapX)
Sets the X coordinate of this GameObject on its map.
net.sf.gridarta.model.baseobject.BaseObject.getSizeY
int getSizeY()
Determines the vertical extent in squares.
net.sf.gridarta.model.baseobject.BaseObject.setAttributeString
void setAttributeString(@NotNull String attributeName, @NotNull String value)
Sets the String of an archetype attribute in the objectText.
net.sf.gridarta.model.baseobject.BaseObject.visit
void visit(@NotNull BaseObjectVisitor< G, A, R > baseObjectVisitor)
Calls the appropriate.
net.sf.gridarta.model.baseobject.BaseObject.getHead
T getHead()
Return the head part of a multi-part object.
net.sf.gridarta.model.baseobject.BaseObject.getMapY
int getMapY()
Returns the Y coordinate of this GameObject on its map.
net.sf.gridarta.model.baseobject.BaseObject.removeTailParts
void removeTailParts()
Removes all tail parts of this game object.
net.sf.gridarta.model.baseobject.BaseObject.LEVEL
String LEVEL
The name of the "level" attribute.
Definition: BaseObject.java:114
net.sf.gridarta.model.baseobject.BaseObject.getObjName
String getObjName()
Returns the name of the object as shown to the player.
net.sf.gridarta.model.baseobject.BaseObject.getFaceName
String getFaceName()
Returns the name of the face of this Archetype or GameObject.
net.sf.gridarta.model
net.sf.gridarta.model.archetype.Archetype
Reflects an Archetype.
Definition: Archetype.java:41
net.sf.gridarta.model.baseobject.BaseObject.getAnimName
String getAnimName()
DaiEditor only: Returns the name of the animation.
net.sf.gridarta.model.baseobject.BaseObject.hasAttribute
boolean hasAttribute(@NotNull String attributeName, boolean queryArchetype)
Returns whether an attribute name exists.
net.sf.gridarta.model.baseobject.BaseObject.facesReloaded
void facesReloaded()
Will be called whenever the archetype faces have been reloaded.
net.sf.gridarta.model.baseobject.BaseObject.getFaceObjName
String getFaceObjName()
Returns the face name, can be from animation or face.
net.sf.gridarta.model.baseobject.BaseObject.getAttributeLong
long getAttributeLong(@NotNull String attributeName, boolean queryArchetype)
Returns the requested attribute value of this GameObject as.
net.sf.gridarta.model.baseobject.BaseObject.getMaxY
int getMaxY()
Determines the maximum y-coordinate of any part relative to the head part.
net.sf.gridarta.model.baseobject.BaseObject.setLoreText
void setLoreText(@NotNull CharSequence loreText)
Sets the map lore.
net.sf.gridarta.model.maparchobject
Definition: AbstractMapArchObject.java:20
net.sf.gridarta.model.baseobject.BaseObject.getTypeNo
int getTypeNo()
Returns the type number of this Archetype.
net.sf.gridarta.model.baseobject.BaseObject.getMultiNext
T getMultiNext()
Returns the next of this multi-part object.
net.sf.gridarta.model.baseobject.BaseObject.HP
String HP
The attribute name of the "hp" attribute.
Definition: BaseObject.java:90
net.sf.gridarta.model.baseobject.BaseObject.getAttributeString
String getAttributeString(@NotNull String attributeName, boolean queryArchetype)
Returns the requested attribute value of this GameObject as {}.
net.sf.gridarta.model.baseobject.BaseObject.setMapY
void setMapY(int mapY)
Sets the Y coordinate of this GameObject on its map.
net.sf.gridarta.model.baseobject.BaseObject.TYPE
String TYPE
The attribute name of the object's type.
Definition: BaseObject.java:66
net.sf.gridarta.model.baseobject.BaseObject.ANIM_SPEED
String ANIM_SPEED
The name of the "anim_speed" attribute.
Definition: BaseObject.java:138
net.sf.gridarta.model.baseobject.BaseObject.getMultiRefCount
int getMultiRefCount()
Returns the number of parts for multi-part heads.
net.sf.gridarta.model.baseobject.BaseObject.notifyTransientChange
void notifyTransientChange()
Notifies the map model that this container has changed but need not be restored by undo/redo.
net.sf.gridarta.model.baseobject.BaseObject.addTailPart
void addTailPart(@NotNull T tail)
Appends a tail to this GameObject.
net.sf.gridarta.model.baseobject.BaseObject.countInvObjects
int countInvObjects()
Counts the number of all inventory items (recursively).
net.sf.gridarta.model.baseobject.BaseObject.setObjectText
void setObjectText(@NotNull String objectText)
Sets.
net.sf.gridarta.model.baseobject.BaseObject.clone
T clone()
Creates a clone of this base object.
net.sf.gridarta.model.baseobject.BaseObject.isDefaultGameObject
boolean isDefaultGameObject()
Returns whether this game object is unmodified from its underlying archetype.
net.sf.gridarta.model.baseobject.BaseObject.ANIMATION
String ANIMATION
The attribute name of the object's animation.
Definition: BaseObject.java:42
net.sf.gridarta.model.baseobject.BaseObject.addMsgTextLine
void addMsgTextLine(@NotNull String text)
Adds a line of message text.
net.sf.gridarta.model.baseobject.BaseObject.notifyEndChange
void notifyEndChange()
Notifies the map model that this container has changed.
net.sf.gridarta.model.baseobject.BaseObject.DIRECTION
String DIRECTION
The attribute name of the object's direction.
Definition: BaseObject.java:48