Go to the documentation of this file.
20 package net.sf.gridarta.model.baseobject;
22 import java.awt.Point;
23 import java.util.Collection;
24 import java.util.Objects;
25 import javax.swing.ImageIcon;
36 import org.jetbrains.annotations.NotNull;
37 import org.jetbrains.annotations.Nullable;
46 public abstract class AbstractBaseObject<G
extends GameObject<G, A, R>, A extends
MapArchObject<A>, R extends
Archetype<G, A, R>, T extends
BaseObject<G, A, R, T>> extends
GameObjectContainer<G, A, R> implements
BaseObject<G, A, R, T> {
199 if (this.typeNo ==
typeNo) {
219 if (this.faceName == effectiveFaceName) {
225 this.faceName = effectiveFaceName;
258 public boolean hasAttribute(@NotNull
final String attributeName,
final boolean queryArchetype) {
284 public int getAttributeInt(@NotNull
final String attributeName,
final boolean queryArchetype) {
294 public long getAttributeLong(@NotNull
final String attributeName,
final boolean queryArchetype) {
304 public double getAttributeDouble(@NotNull
final String attributeName,
final boolean queryArchetype) {
315 final boolean sameAsInArchetype =
getArchetype().getAttributeString(attributeName).equals(value);
325 final boolean sameAsInArchetype =
getArchetype().getAttributeInt(attributeName) == value;
364 final int multiShapeID =
getArchetype().getMultiShapeID();
365 assert
multi !=
null;
416 if (!queryArchetype) {
420 return archetype ==
this ? null : archetype.getMsgText(queryArchetype);
426 if (this.msgText ==
null ? trimmedMsgText ==
null : this.msgText.toString().equals(trimmedMsgText)) {
432 if (trimmedMsgText ==
null) {
434 }
else if (this.msgText ==
null) {
435 this.msgText =
new StringBuilder(trimmedMsgText);
437 this.msgText.setLength(0);
438 assert this.msgText !=
null;
439 this.msgText.append(trimmedMsgText);
493 assert
multi !=
null;
494 tail.setMulti(
multi);
495 assert
multi !=
null;
556 @SuppressWarnings(
"unchecked")
565 return clone.getThis();
570 gameObject.setContainer(
this, 0, 0);
585 final String newObjName = objName2.intern();
588 if (this.objName == newObjName) {
594 this.objName = newObjName;
603 final String baseName;
606 final String archObjName = archetype.
getObjName();
607 baseName = archObjName.isEmpty() ? archetype.
getArchetypeName() : archObjName;
613 return title.isEmpty() ? baseName : baseName +
" " + title;
643 if (!
objName.equals(archetype.getObjName())) {
649 if (
msgText !=
null && !
msgText.toString().equals(archetype.getMsgText(
false))) {
658 return typeNo == archetype.getTypeNo();
725 part.notifyBeginChange();
738 part.notifyEndChange();
752 part.notifyTransientChange();
771 if (this.animName == newAnimName) {
777 this.animName = newAnimName;
791 return multi !=
null;
817 if (this.faceObjName == newFaceObjName) {
823 this.faceObjName = newFaceObjName;
837 @Nullable String effectiveAnimName;
839 effectiveAnimName =
null;
848 effectiveAnimName =
null;
851 if (effectiveAnimName !=
null && effectiveAnimName.equals(
"NONE")) {
852 effectiveAnimName =
null;
855 @Nullable String effectiveFaceObjName;
856 if (effectiveAnimName ==
null) {
864 effectiveFaceObjName =
null;
869 if (animationObject ==
null) {
870 effectiveFaceObjName =
null;
874 }
catch (
final IndexOutOfBoundsException ignored) {
875 effectiveFaceObjName =
null;
906 if (this.loreText.equals(trimmedLoreText)) {
912 this.loreText = trimmedLoreText.intern();
926 public String
toString(@NotNull
final String format) {
927 final StringBuilder sb =
new StringBuilder();
928 final char[] chars = format.toCharArray();
930 while (pos < chars.length) {
931 if (chars[pos] ==
'$' && pos + 2 < chars.length && chars[pos + 1] ==
'{') {
933 final int startPos = pos;
935 while (pos < chars.length) {
936 if (chars[pos] ==
'}') {
942 }
else if (chars[pos] ==
'$' && pos + 1 < chars.length && chars[pos + 1] ==
'{') {
953 final int endPos = pos - 1;
954 assert startPos <= endPos;
955 final CharSequence spec =
new String(chars, startPos, endPos - startPos);
957 if (tmp.length < 2) {
958 if (tmp[0].equals(
"NAME")) {
970 sb.append(chars[pos]);
975 return sb.toString();
983 protected abstract T
getThis();
public< G extends GameObject< G, A, R >, A extends MapArchObject< A >, R extends Archetype< G, A, R > > ImageIcon getFace(@NotNull final BaseObject< G, A, R, ?> baseObject)
String getAttributeValue(@NotNull final String attributeName)
void setFaceObjName(@Nullable final String faceObjName)
boolean setObjectText(@NotNull final String objectText, @NotNull final AbstractBaseObject<?, ?, ?, ?> baseObject)
long getAttributeLong(@NotNull final String attributeName, final boolean queryArchetype)
String getMsgText(final boolean queryArchetype)
T getNext(@NotNull final T ob)
ImageIcon getImageIconForFacename(@NotNull final String faceObjName)
long getAttributeLong(@NotNull final String attributeName)
void setFaceName(@NotNull final String faceName)
void setObjName(@NotNull final String objName)
final transient FaceObjectProviders faceObjectProviders
boolean hasSameContents( @NotNull final GameObjectContainer<?, ?, ?> gameObjectContainer)
void setAttributeInt(@NotNull final String attributeName, final int value)
boolean setAttributeValue(@NotNull final String attributeName, final boolean sameAsInArchetype, @NotNull final String value, @NotNull final AbstractBaseObject<?, ?, ?, ?> baseObject)
void addObjectText(@NotNull final String line)
void addTailPart(@NotNull final T tail)
static CharSequence ensureTrailingNewline(@NotNull final String str)
boolean hasAttribute(@NotNull final String attributeName, final boolean queryArchetype)
String getAttributeString(@NotNull final String attributeName)
AbstractBaseObject(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects)
static String removeTrailingWhitespaceFromLines(@NotNull final CharSequence str)
static long parseLong(@NotNull final String s)
String getAttributeValue(@NotNull final String attributeName)
void addMsgTextLine(@NotNull final String text)
E get(@NotNull String objectName)
boolean isEqual(@NotNull final BaseObject<?, ?, ?, ?> gameObject)
void updateCachedAttributes()
static double parseDouble(@NotNull final String s)
FaceSource getFaceObjSource()
boolean addObjectText(@NotNull final String line, @NotNull final AbstractBaseObject<?, ?, ?, ?> baseObject)
static String removeTrailingWhitespace(@NotNull final CharSequence str)
Collection< String > getAttributeKeys()
void transientGameObjectChange()
void setEditType(final int editType)
MultiArchData< G, A, R, T > getMulti()
void removeAttribute(@NotNull final String attributeName)
void setLoreText(@NotNull final CharSequence loreText)
void addPart(@NotNull final T tail)
void setTypeNo(final int typeNo)
int getAttributeInt(@NotNull final String attributeName)
void notifyTransientChange()
Collection< String > getAttributeKeys()
void setMultiShapeID(final int multiShapeID)
static int parseInt(@NotNull final String s)
boolean removeAttribute(@NotNull final String attributeName, @NotNull final AbstractBaseObject<?, ?, ?, ?> baseObject)
abstract void notifyEndChange()
void endGameObjectChange()
String getFirstFrame(int facing)
String toString(@NotNull final String format)
abstract String getEffectiveFaceName(@NotNull String faceName)
void setAttributeString(@NotNull final String attributeName, @NotNull final String value)
void setObjectText(@NotNull final String objectText)
void setMapX(final int mapX)
double getAttributeDouble(@NotNull final String attributeName)
int getAttributeInt(@NotNull final String attributeName, final boolean queryArchetype)
GameObjectText gameObjectText
boolean isDefaultGameObject()
void setAnimName(@NotNull final String animName)
void setMulti(@NotNull final MultiArchData< G, A, R, T > multi)
void setThisContainer(@NotNull final G gameObject)
ImageIcon getNormalImage()
final AnimationObjects animationObjects
static final long serialVersionUID
String getArchetypeName()
void beginGameObjectChange()
boolean hasAttribute(@NotNull final String attributeName)
void setMsgText(@Nullable final String msgText)
double getAttributeDouble(@NotNull final String attributeName, final boolean queryArchetype)
abstract void notifyBeginChange()
static final Pattern PATTERN_COLON
MultiArchData< G, A, R, T > multi
void setMapY(final int mapY)