Gridarta Editor
AbstractBaseObject.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 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.util.Collection;
24 import javax.swing.ImageIcon;
35 import org.jetbrains.annotations.NotNull;
36 import org.jetbrains.annotations.Nullable;
37 
45 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> {
46 
50  private static final long serialVersionUID = 1L;
51 
55  @NotNull
57 
62  @NotNull
64 
71  @Nullable
72  private String faceObjName;
73 
78  @NotNull
80 
85  @Nullable
86  private ImageIcon normalFace;
87 
91  @NotNull
92  private final transient FaceObjectProviders faceObjectProviders;
93 
98  @NotNull
99  private String objName = "";
100 
109  @Nullable
110  private StringBuilder msgText;
111 
116  private int mapX;
117 
122  private int mapY;
123 
128  @Nullable
130 
137  @Deprecated
138  // default arches don't get an editType (not worth the time)
139  // they get one assigned as soon as put on a map though.
140  // TODO: This should be changed.
141  private int editType = EDIT_TYPE_NONE;
142 
147  @Nullable
148  private String faceName;
149 
154  private int typeNo;
155 
160  @Nullable
161  private String animName;
162 
169  private int direction;
170 
174  @NotNull
175  private String loreText = "";
176 
183  protected AbstractBaseObject(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects) {
184  this.faceObjectProviders = faceObjectProviders;
185  this.animationObjects = animationObjects;
186  }
187 
188  @Override
189  public int getTypeNo() {
190  return typeNo;
191  }
192 
197  private void setTypeNo(final int typeNo) {
198  if (this.typeNo == typeNo) {
199  return;
200  }
201 
203  try {
204  this.typeNo = typeNo;
205  } finally {
207  }
208  }
209 
214  @SuppressWarnings("NullableProblems")
215  private void setFaceName(@NotNull final String faceName) {
216  final String effectiveFaceName = getEffectiveFaceName(faceName);
217  //Strings are interned
218  //noinspection StringEquality
219  if (this.faceName == effectiveFaceName) {
220  return;
221  }
222 
224  try {
225  this.faceName = effectiveFaceName;
226  } finally {
228  }
229  }
230 
238  @Nullable
239  protected abstract String getEffectiveFaceName(@NotNull String faceName);
240 
241  @Nullable
242  @Override
243  public String getFaceName() {
244  return faceName;
245  }
246 
247  @Override
248  public int countInvObjects() {
249  int count = 0;
250  for (final BaseObject<G, A, R, ?> gameObject : this) {
251  count++;
252  count += gameObject.countInvObjects();
253  }
254  return count;
255  }
256 
257  @Override
258  public boolean hasAttribute(@NotNull final String attributeName, final boolean queryArchetype) {
259  return !getAttributeString(attributeName, queryArchetype).isEmpty();
260  }
261 
262  @Override
263  public boolean hasAttribute(@NotNull final String attributeName) {
264  return hasAttribute(attributeName, true);
265  }
266 
272  @Nullable
273  protected String getAttributeValue(@NotNull final String attributeName) {
274  return gameObjectText.getAttributeValue(attributeName);
275  }
276 
277  @NotNull
278  @Override
279  public String getAttributeString(@NotNull final String attributeName) {
280  return getAttributeString(attributeName, true);
281  }
282 
283  @Override
284  public int getAttributeInt(@NotNull final String attributeName, final boolean queryArchetype) {
285  return NumberUtils.parseInt(getAttributeString(attributeName, queryArchetype));
286  }
287 
288  @Override
289  public int getAttributeInt(@NotNull final String attributeName) {
290  return getAttributeInt(attributeName, true);
291  }
292 
293  @Override
294  public long getAttributeLong(@NotNull final String attributeName, final boolean queryArchetype) {
295  return NumberUtils.parseLong(getAttributeString(attributeName, queryArchetype));
296  }
297 
298  @Override
299  public long getAttributeLong(@NotNull final String attributeName) {
300  return getAttributeLong(attributeName, true);
301  }
302 
303  @Override
304  public double getAttributeDouble(@NotNull final String attributeName, final boolean queryArchetype) {
305  return NumberUtils.parseDouble(getAttributeString(attributeName, queryArchetype));
306  }
307 
308  @Override
309  public double getAttributeDouble(@NotNull final String attributeName) {
310  return getAttributeDouble(attributeName, true);
311  }
312 
313  @Override
314  public void setAttributeString(@NotNull final String attributeName, @NotNull final String value) {
315  final boolean sameAsInArchetype = getArchetype().getAttributeString(attributeName).equals(value);
316  if (!gameObjectText.setAttributeValue(attributeName, sameAsInArchetype, value, this)) {
317  return;
318  }
319 
321  }
322 
323  @Override
324  public void setAttributeInt(@NotNull final String attributeName, final int value) {
325  final boolean sameAsInArchetype = getArchetype().getAttributeInt(attributeName) == value;
326  if (!gameObjectText.setAttributeValue(attributeName, sameAsInArchetype, Integer.toString(value), this)) {
327  return;
328  }
329 
331  }
332 
333  @Override
334  public void removeAttribute(@NotNull final String attributeName) {
335  if (!gameObjectText.removeAttribute(attributeName, this)) {
336  return;
337  }
338 
340  }
341 
346  @Override
347  public abstract void notifyBeginChange();
348 
353  @Override
354  public abstract void notifyEndChange();
355 
359  protected void updateArchetype() {
361  try {
363  if (multi != null) {
364  final int multiShapeID = getArchetype().getMultiShapeID();
365  assert multi != null;
366  multi.setMultiShapeID(multiShapeID);
367  }
368  } finally {
370  }
371  }
372 
373  @Override
374  public int getEditType() {
375  return isHead() ? editType : getHead().getEditType();
376  }
377 
378  @Override
379  public void setEditType(final int editType) {
380  assert isHead();
381  if (this.editType == editType) {
382  return;
383  }
384 
385  this.editType = editType;
387  }
388 
389  @Override
390  public void addMsgTextLine(@NotNull final String text) {
391  // It's intentional that if text == null, msgText still is created if it's empty.
392  // FIXME: Though it's intentional, it's not nice, search for users and fix this.
393  // (Also look at deleteMsgText() and getMsgText() then)
394  if (msgText == null) {
395  msgText = new StringBuilder();
396  }
397 
399  try {
400  final String trimmedText = StringUtils.removeTrailingWhitespace(text);
401  assert msgText != null;
402  msgText.append(trimmedText);
403  assert msgText != null;
404  msgText.append('\n');
405  } finally {
407  }
408  }
409 
410  @Nullable
411  @Override
412  public String getMsgText() {
413  return msgText != null ? msgText.toString() : null;
414  }
415 
416  @Override
417  public void setMsgText(@Nullable final String msgText) {
418  final String trimmedMsgText = msgText == null ? null : StringUtils.removeTrailingWhitespaceFromLines(StringUtils.ensureTrailingNewline(msgText));
419  if (this.msgText == null ? trimmedMsgText == null : this.msgText.toString().equals(trimmedMsgText)) {
420  return;
421  }
422 
424  try {
425  if (trimmedMsgText == null) {
426  this.msgText = null;
427  } else if (this.msgText == null) {
428  this.msgText = new StringBuilder(trimmedMsgText);
429  } else {
430  this.msgText.setLength(0);
431  assert this.msgText != null;
432  this.msgText.append(trimmedMsgText);
433  }
434  } finally {
436  }
437  }
438 
439  @Override
440  public int getMapX() {
441  return mapX;
442  }
443 
444  @Override
445  public int getMapY() {
446  return mapY;
447  }
448 
449  @Override
450  public Point getMapLocation() {
451  return new Point(mapX, mapY);
452  }
453 
454  @Override
455  public void setMapX(final int mapX) {
456  this.mapX = mapX;
457  }
458 
459  @Override
460  public void setMapY(final int mapY) {
461  this.mapY = mapY;
462  }
463 
464  @Override
465  public boolean isHead() {
466  // == is okay because that's the definition of being head.
467  //noinspection ObjectEquality
468  return getHead() == this;
469  }
470 
471  @Nullable
472  @Override
473  public T getMultiNext() {
474  //noinspection ConstantConditions
475  return multi != null ? multi.getNext(getThis()) : null;
476  }
477 
478  @Override
479  public int getMultiRefCount() {
480  return multi != null ? multi.getMultiRefCount() : 0;
481  }
482 
483  @Override
484  public void addTailPart(@NotNull final T tail) {
485  initMultiData();
486  assert multi != null;
487  tail.setMulti(multi);
488  assert multi != null;
489  multi.addPart(tail);
490  }
491 
492  @Override
493  public void removeTailParts() {
494  multi = null;
495  }
496 
497  @Override
498  public T getHead() {
499  return multi != null ? multi.getHead() : getThis();
500  }
501 
502  @Override
503  public boolean isTail() {
504  return getHead() != this;
505  }
506 
507  @Override
508  public int getSizeX() {
509  return multi != null ? multi.getSizeX() : 1;
510  }
511 
512  @Override
513  public int getSizeY() {
514  return multi != null ? multi.getSizeY() : 1;
515  }
516 
517  @Override
518  public int getMaxX() {
519  return multi != null ? multi.getMaxX() : 0;
520  }
521 
522  @Override
523  public int getMaxY() {
524  return multi != null ? multi.getMaxY() : 0;
525  }
526 
527  @Override
528  public int getMinX() {
529  return multi != null ? multi.getMinX() : 0;
530  }
531 
532  @Override
533  public int getMinY() {
534  return multi != null ? multi.getMinY() : 0;
535  }
536 
541  private void initMultiData() {
542  if (multi == null) {
543  multi = new MultiArchData<>(getThis(), getArchetype().getMultiShapeID());
544  }
545  }
546 
547  @Override
548  @NotNull
549  @SuppressWarnings("unchecked")
550  public T clone() {
551  //noinspection OverriddenMethodCallDuringObjectConstruction
553  // clone.archetype = archetype; // will NOT be cloned: archetypes are unique
555  if (msgText != null) {
556  clone.msgText = new StringBuilder(msgText);
557  }
558  clone.multi = null;
559  return clone.getThis();
560  }
561 
562  @Override
563  protected void setThisContainer(@NotNull final G gameObject) {
564  gameObject.setContainer(this, 0, 0);
565  }
566 
567  @NotNull
568  @Override
569  public String getObjName() {
570  return objName;
571  }
572 
577  private void setObjName(@NotNull final String objName) {
578  final String objName2 = objName.isEmpty() ? getArchetype().getArchetypeName() : objName;
579  final String newObjName = objName2.intern();
580  // Using == on these Strings is okay, they are both interned.
581  //noinspection StringEquality
582  if (this.objName == newObjName) {
583  return;
584  }
585 
587  try {
588  this.objName = newObjName;
589  } finally {
591  }
592  }
593 
594  @NotNull
595  @Override
596  public String getBestName() {
597  final String baseName;
598  if (objName.isEmpty()) {
599  final Archetype<G, A, R> archetype = getArchetype();
600  final String archObjName = archetype.getObjName();
601  if (archObjName.isEmpty()) {
602  baseName = archetype.getArchetypeName();
603  } else {
604  baseName = archObjName;
605  }
606  } else {
607  baseName = objName;
608  }
609 
610  final String title = getAttributeString(TITLE);
611  return title.isEmpty() ? baseName : baseName + " " + title;
612  }
613 
614  @NotNull
615  @Override
616  public String getObjectText() {
617  return gameObjectText.getObjectText();
618  }
619 
620  @Override
621  public void addObjectText(@NotNull final String line) {
622  if (!gameObjectText.addObjectText(line, this)) {
623  return;
624  }
625 
627  }
628 
629  @Override
630  public void setObjectText(@NotNull final String objectText) {
631  if (!gameObjectText.setObjectText(objectText, this)) {
632  return;
633  }
634 
636  }
637 
638  @Override
639  public boolean isDefaultGameObject() {
640  final R archetype = getArchetype();
641  if (!objName.equals(archetype.getObjName())) {
642  return false;
643  }
645  return false;
646  }
647  if (msgText != null && !msgText.toString().equals(archetype.getMsgText())) {
648  return false;
649  }
650  //noinspection ConstantConditions
651  if (faceName != null && !faceName.equals(archetype.getFaceName())) {
652  return false;
653  }
654  //noinspection ConstantConditions,SimplifiableIfStatement
655  if (animName != null && !animName.equals(archetype.getAnimName())) {
656  return false;
657  }
658  return typeNo == archetype.getTypeNo();
659  }
660 
661  @Override
662  public boolean isEqual(@NotNull final BaseObject<?, ?, ?, ?> gameObject) {
663  if (!(gameObject instanceof AbstractBaseObject)) {
664  return false;
665  }
666  final AbstractBaseObject<?, ?, ?, ?> abstractBaseObject = (AbstractBaseObject<?, ?, ?, ?>) gameObject;
667  if (!hasSameContents(abstractBaseObject)) {
668  return false;
669  }
670  if (abstractBaseObject.faceObjName == null ? faceObjName != null : !abstractBaseObject.faceObjName.equals(faceObjName)) {
671  return false;
672  }
673  // ignore "faceObjSource"
674  // ignore "normalFace"
675  // ignore "container"
676  if (abstractBaseObject.getArchetype() != getArchetype()) {
677  return false;
678  }
679  if (!abstractBaseObject.getArchetype().getArchetypeName().equals(getArchetype().getArchetypeName())) {
680  return false;
681  }
682  if (!abstractBaseObject.objName.equals(objName)) {
683  return false;
684  }
685  if (!abstractBaseObject.gameObjectText.equals(gameObjectText)) {
686  return false;
687  }
688  if (abstractBaseObject.msgText == null ? msgText != null : msgText == null || !msgText.toString().equals(abstractBaseObject.msgText.toString())) {
689  return false;
690  }
691  // ignore "mapX"
692  // ignore "mapY"
693  // ignore "attributeCache"
694  // ignore "multi"
695  // ignore "editType"
696  if (abstractBaseObject.faceName == null ? faceName != null : !abstractBaseObject.faceName.equals(faceName)) {
697  return false;
698  }
699  if (abstractBaseObject.animName == null ? animName != null : !abstractBaseObject.animName.equals(animName)) {
700  return false;
701  }
702  if (abstractBaseObject.typeNo != typeNo) {
703  return false;
704  }
705  //noinspection RedundantIfStatement
706  if (abstractBaseObject.direction != direction) {
707  return false;
708  }
709  return true;
710  }
711 
712  @Override
713  public int getDirection() {
714  return direction;
715  }
716 
720  protected void beginGameObjectChange() {
721  if (multi == null) {
723  } else {
724  for (final BaseObject<G, A, R, T> part : multi) {
725  part.notifyBeginChange();
726  }
727  }
728  }
729 
733  protected void endGameObjectChange() {
734  if (multi == null) {
735  notifyEndChange();
736  } else {
737  for (final BaseObject<G, A, R, T> part : multi) {
738  part.notifyEndChange();
739  }
740  }
741  }
742 
747  protected void transientGameObjectChange() {
748  if (multi == null) {
750  } else {
751  for (final BaseObject<G, A, R, T> part : multi) {
752  part.notifyTransientChange();
753  }
754  }
755  }
756 
757  @NotNull
758  @Override
760  return faceObjSource;
761  }
762 
767  @SuppressWarnings("NullableProblems")
768  private void setAnimName(@NotNull final String animName) {
769  final String newAnimName = animName.isEmpty() ? null : animName.intern();
770  // Using == on these Strings is okay, they are both interned.
771  //noinspection StringEquality
772  if (this.animName == newAnimName) {
773  return;
774  }
775 
777  try {
778  this.animName = newAnimName;
779  } finally {
781  }
782  }
783 
784  @Nullable
785  @Override
786  public String getAnimName() {
787  return animName;
788  }
789 
790  @Override
791  public boolean isMulti() {
792  return multi != null;
793  }
794 
800  @Nullable
802  return multi;
803  }
804 
805  @SuppressWarnings("NullableProblems")
806  @Override
807  public void setMulti(@NotNull final MultiArchData<G, A, R, T> multi) {
808  this.multi = multi;
809  }
810 
815  private void setFaceObjName(@Nullable final String faceObjName) {
816  final String newFaceObjName = faceObjName != null ? faceObjName.intern() : null;
817  // Using == on these Strings is okay, they are both interned.
818  //noinspection StringEquality
819  if (this.faceObjName == newFaceObjName) {
820  return;
821  }
822 
824  try {
825  this.faceObjName = newFaceObjName;
826  } finally {
828  }
829  }
830 
831  @Nullable
832  @Override
833  public String getFaceObjName() {
834  return faceObjName;
835  }
836 
837  @Override
838  public void setObjectFace() {
839  @Nullable String effectiveAnimName;
841  effectiveAnimName = null;
843  } else if (animName != null) {
844  effectiveAnimName = animName;
846  } else if (getArchetype() != null) {
847  effectiveAnimName = getArchetype().getAnimName();
849  } else {
850  effectiveAnimName = null;
852  }
853  if (effectiveAnimName != null && effectiveAnimName.equals("NONE")) {
854  effectiveAnimName = null;
855  }
856 
857  @Nullable String effectiveFaceObjName;
858  if (effectiveAnimName != null) { // we have a animation - get the frame picture
859  final AnimationObject animationObject = animationObjects.get(effectiveAnimName);
860  if (animationObject == null) {
861  effectiveFaceObjName = null;
862  } else {
863  try {
864  effectiveFaceObjName = animationObject.getFirstFrame(direction);
865  } catch (final IndexOutOfBoundsException ignored) {
866  effectiveFaceObjName = null;
867  }
868  }
869  } else { // ok, we fallback to the face picture
870  if (faceName != null) {
871  effectiveFaceObjName = faceName;
873  } else if (getArchetype() != null) {
874  effectiveFaceObjName = getArchetype().getFaceName();
876  } else {
877  effectiveFaceObjName = null;
879  }
880  }
881 
882  setFaceObjName(effectiveFaceObjName);
883 
884  if (effectiveFaceObjName == null || faceObjectProviders.getImageIconForFacename(effectiveFaceObjName) == null) {
886  }
887  normalFace = null;
888  }
889 
890  @NotNull
891  @Override
892  public ImageIcon getNormalImage() {
893  if (normalFace == null) {
895  }
896  return normalFace;
897  }
898 
899  @NotNull
900  @Override
901  public String getLoreText() {
902  return loreText;
903  }
904 
905  @Override
906  public void setLoreText(@NotNull final CharSequence loreText) {
907  final String trimmedLoreText = StringUtils.removeTrailingWhitespace(loreText);
908  if (this.loreText.equals(trimmedLoreText)) {
909  return;
910  }
911 
913  try {
914  this.loreText = trimmedLoreText.intern();
915  } finally {
917  }
918  }
919 
920  @Override
921  public void facesReloaded() {
922  normalFace = null;
924  }
925 
926  @NotNull
927  @Override
928  public String toString(@NotNull final String format) {
929  final StringBuilder sb = new StringBuilder();
930  final char[] chars = format.toCharArray();
931  int pos = 0;
932  while (pos < chars.length) {
933  if (chars[pos] == '$' && pos + 2 < chars.length && chars[pos + 1] == '{') {
934  pos += 2;
935  final int startPos = pos;
936  int nesting = 1;
937  while (pos < chars.length) {
938  if (chars[pos] == '}') {
939  nesting--;
940  pos++;
941  if (nesting <= 0) {
942  break;
943  }
944  } else if (chars[pos] == '$' && pos + 1 < chars.length && chars[pos + 1] == '{') {
945  nesting++;
946  pos += 2;
947  } else {
948  pos++;
949  }
950  }
951  if (nesting > 0) {
952  sb.append("${");
953  pos++;
954  } else {
955  final int endPos = pos - 1;
956  assert startPos <= endPos;
957  final CharSequence spec = new String(chars, startPos, endPos - startPos);
958  final String[] tmp = StringUtils.PATTERN_COLON.split(spec, 2);
959  if (tmp.length < 2) {
960  if (tmp[0].equals("NAME")) {
961  sb.append(getBestName());
962  } else {
963  sb.append(getAttributeString(tmp[0]));
964  }
965  } else {
966  if (hasAttribute(tmp[0])) {
967  sb.append(toString(tmp[1]));
968  }
969  }
970  }
971  } else {
972  sb.append(chars[pos]);
973  pos++;
974  }
975  }
976 
977  return sb.toString();
978  }
979 
984  @NotNull
985  protected abstract T getThis();
986 
991  private void updateCachedAttributes() {
993  try {
999  setObjectFace();
1000  } finally {
1002  }
1003  }
1004 
1009  @NotNull
1010  public Collection<String> getAttributeKeys() {
1012  }
1013 
1014 }
String getObjectText()
Returns the object text.
String IS_TURNABLE
The name of the "is_turnable" attribute.
Definition: BaseObject.java:84
void endGameObjectChange()
Records that this game object has changed.
int getSizeX()
Determine the horizontal extent in squares.
String getAttributeValue(@NotNull final String attributeName)
Returns an attribute value by attribute name.
Utility class for string manipulation.
void setObjectText(@NotNull final String objectText)
Collection< String > getAttributeKeys()
Returns all attribute keys of this object.
int getMaxX()
Determine the maximum x-coordinate of any part.
boolean removeAttribute(@NotNull final String attributeName, @NotNull final AbstractBaseObject<?, ?, ?, ?> baseObject)
Removes an attribute.
int getAttributeInt(@NotNull final String attributeName, final boolean queryArchetype)
String getObjName()
Returns the name of the object as shown to the player.
static String removeTrailingWhitespace(@NotNull final CharSequence str)
Removes trailing whitespace from a string.
void setTypeNo(final int typeNo)
Sets the type number of this Archetype.
int getSizeY()
Determine the vertical extent in squares.
void setAttributeString(@NotNull final String attributeName, @NotNull final String value)
boolean addObjectText(@NotNull final String line, @NotNull final AbstractBaseObject<?, ?, ?, ?> baseObject)
Appends a line to the object text.
void notifyTransientChange()
Notifies the map model that this container has changed but need not be restored by undo/redo...
Enumeration describing the state of the face.
Definition: FaceSource.java:28
Gridarta can handle frame information of animations and allow the selection of an animation using a t...
String ANIMATION
The attribute name of the object&#39;s animation.
Definition: BaseObject.java:42
boolean hasAttribute(@NotNull final String attributeName)
String FACE
The attribute name of the object&#39;s face.
Definition: BaseObject.java:54
double getAttributeDouble(@NotNull final String attributeName, final boolean queryArchetype)
Utility class for parsing strings into numbers.
boolean setObjectText(@NotNull final String objectText, @NotNull final AbstractBaseObject<?, ?, ?, ?> baseObject)
Sets the object text.
double getAttributeDouble(@NotNull final String attributeName)
int getMinX()
Determine the minimum x-coordinate of any part.
abstract void notifyBeginChange()
AbstractMethodOverridesAbstractMethod // needed because of public modifier
Base class for classes that contain GameObjects as children in the sense of containment.
static CharSequence ensureTrailingNewline(@NotNull final String str)
Returns a given string which ends with a trailing newline character; empty strings remain empty...
String getArchetypeName()
Returns the name of this archetype.
ANIM
This GameObject has an animation defined.
Definition: FaceSource.java:49
String getFirstFrame(int facing)
Get the first frame.
MultiArchData< G, A, R, T > getMulti()
Returns the MultiArchData for this base object.
long getAttributeLong(@NotNull final String attributeName, final boolean queryArchetype)
boolean setAttributeValue(@NotNull final String attributeName, final boolean sameAsInArchetype, @NotNull final String value, @NotNull final AbstractBaseObject<?, ?, ?, ?> baseObject)
Updates an attribute&#39;s value.
FACE
This GameObject has a normal face defined.
Definition: FaceSource.java:38
FaceSource faceObjSource
The state where the face comes from.
String TYPE
The attribute name of the object&#39;s type.
Definition: BaseObject.java:66
static String removeTrailingWhitespaceFromLines(@NotNull final CharSequence str)
Removes trailing whitespace from all lines of a string.
void setLoreText(@NotNull final CharSequence loreText)
Base package of all Gridarta classes.
ARCHETYPE_FACE
This GameObject has no face defined and thus inherited the face from its archetype.
Definition: FaceSource.java:44
Reflects a game object (object on a map).
Definition: GameObject.java:36
void beginGameObjectChange()
Records that this game object is about to change.
boolean isEqual(@NotNull final BaseObject<?, ?, ?, ?> gameObject)
boolean hasAttribute(@NotNull final String attributeName, final boolean queryArchetype)
static double parseDouble(@NotNull final String s)
Parses a double string.
static int parseInt(@NotNull final String s)
Parses an integer string.
String DIRECTION
The attribute name of the object&#39;s direction.
Definition: BaseObject.java:48
E get(@NotNull String objectName)
Gets a AbstractNamedObject.
final AnimationObjects animationObjects
The AnimationObjects for looking up animations.
int getAttributeInt(@NotNull final String attributeName)
void setFaceObjName(@Nullable final String faceObjName)
Sets the effective face name.
AnimationObjects is a container for AnimationObjects.
GameObjectText gameObjectText
The object text of this game object.
GameObjects are the objects based on Archetypes found on maps.
An AnimationObject reflects the animation ("@code anim\n @endcode " ...
abstract void notifyEndChange()
AbstractMethodOverridesAbstractMethod // needed because of public modifier
void setMulti(@NotNull final MultiArchData< G, A, R, T > multi)
void setAttributeInt(@NotNull final String attributeName, final int value)
String animName
The object&#39;s animation animation.
int countInvObjects()
Counts the number of all inventory items (recursively).
boolean hasObjectText()
Returns whether an object text is set.
R getArchetype()
Returns the Archetype this GameObject is based on.
void setObjName(@NotNull final String objName)
Sets the name of this object.
T getNext(@NotNull final T ob)
Return the part following a given part.
Provider for faces of GameObjects and Archetypes.
The face is the appearance of an object.
String IS_ANIMATED
The attribute name of the "is_animated" flag.
Definition: BaseObject.java:78
boolean hasSameContents( @NotNull final GameObjectContainer<?, ?, ?> gameObjectContainer)
Compare this object to another game object container.
void removeAttribute(@NotNull final String attributeName)
T getHead()
Return the head part of this multi-part object.
abstract String getEffectiveFaceName(@NotNull String faceName)
Returns the effective face name for faceName for a given real face name.
void addPart(@NotNull final T tail)
Add a part to this multi-part object.
String NAME
The attribute name of the object&#39;s name.
Definition: BaseObject.java:60
int getMaxY()
Determine the maximum y-coordinate of any part.
Default implementation for GameObject implementing classes.
ImageIcon getImageIconForFacename(@NotNull final String faceObjName)
Returns the ImageIcon for a given face object name.
final transient FaceObjectProviders faceObjectProviders
The FaceObjectProviders for looking up faces.
String faceObjName
Face name, can be from animation or face.
static long parseLong(@NotNull final String s)
Parses a long string.
String getAttributeString(@NotNull final String attributeName)
FACE_NOT_FOUND
The face of this GameObject was not found.
Definition: FaceSource.java:33
static final Pattern PATTERN_COLON
The pattern that matches a single colon (":").
String getAttributeValue(@NotNull final String attributeName)
Returns an attribute value by attribute name.
MultiArchData< G, A, R, T > multi
Data for multi-part objects.
String TITLE
The attribute name of the object&#39;s title.
Definition: BaseObject.java:72
void updateCachedAttributes()
Updates attribute values that are cached.
void updateArchetype()
Called whenever getArchetype() has changed.
Collection< String > getAttributeKeys()
Returns all attribute keys of this object.
void initMultiData()
Initialize the multi-part data object - must only be called for multi-part arches.
void setFaceName(@NotNull final String faceName)
Sets the face name.
int getMultiRefCount()
Returns the number of parts this multi-part object contains.
void setAnimName(@NotNull final String animName)
Sets object animation.
static final long serialVersionUID
The serial version UID.
long getAttributeLong(@NotNull final String attributeName)
AbstractBaseObject(@NotNull final FaceObjectProviders faceObjectProviders, @NotNull final AnimationObjects animationObjects)
Creates a new instance.
ARCHETYPE_ANIM
This GameObject is animated but doesn&#39;t define an animation and thus inherited the animation from its...
Definition: FaceSource.java:55
int getMinY()
Determine the minimum y-coordinate of any part.
void transientGameObjectChange()
Records that this game object has changed but need not be restored by undo/redo actions.
void setMultiShapeID(final int multiShapeID)
Set the shape ID of this object.
int direction
The direction determines to which direction the GameObject&#39;s face is facing.
Class related to GameObject to store multi-part information.