public abstract class AbstractMapArchObject<A extends MapArchObject<A>> extends java.lang.Object implements MapArchObject<A>
MapArchObject
that covers similarities between
Crossfire maps and Daimonin maps.hashCode()
and equals(Object)
work on non-final fields and thus will break any operation
inside Collections!Modifier and Type | Field and Description |
---|---|
static @NotNull java.lang.String |
MAP_NAME_UNNAMED
The name of an unnamed map.
|
Modifier | Constructor and Description |
---|---|
protected |
AbstractMapArchObject()
Creates a new instance.
|
protected |
AbstractMapArchObject(@NotNull AbstractMapArchObject<A> mapArchObject)
Creates a new instance as a copy of another map arch object.
|
Modifier and Type | Method and Description |
---|---|
void |
addMapArchObjectListener(@NotNull MapArchObjectListener listener)
Registers an event listener.
|
void |
addText(@NotNull java.lang.String text)
Appends 'text' to the map text.
|
void |
beginTransaction()
Starts a new transaction.
|
@NotNull java.lang.String |
calculateTilePath(@NotNull Direction direction,
@Nullable MapFile mapFile)
Calculate a single tile path in a particular direction.
|
void |
calculateTilePaths(@Nullable MapFile mapFile,
@NotNull java.io.File mapsDirectory)
Calculates tiled paths for the map automatically.
|
void |
endTransaction()
Ends a transaction.
|
void |
endTransaction(boolean fireEvent)
Ends a transaction.
|
boolean |
equals(@Nullable java.lang.Object obj) |
int |
getDarkness()
Returns the light / darkness of this map.
|
int |
getDifficulty()
Returns the map's difficulty.
|
@NotNull java.awt.Point |
getEnter()
Returns the enter coordinates.
|
int |
getEnterX()
Returns the enter x coordinate.
|
int |
getEnterY()
Returns the enter y coordinate.
|
@NotNull java.lang.String |
getMapName()
Returns the map name.
|
@NotNull Size2D |
getMapSize()
Returns the map size.
|
int |
getResetTimeout()
Returns the reset timeout (in seconds).
|
int |
getSwapTime()
Returns the swap time (in ticks).
|
@NotNull java.lang.String |
getText()
Returns the message text.
|
@NotNull java.lang.String |
getTilePath(@NotNull Direction direction)
Returns a tile path.
|
int |
getTilePaths()
Returns the number of tile paths.
|
int |
hashCode() |
boolean |
isFixedReset()
Returns whether this map uses a fixed reset.
|
boolean |
isOutdoor()
Returns whether the map is an "outdoor" map.
|
boolean |
isPointValid(@Nullable java.awt.Point pos)
Checks whether the given coordinate is within map bounds.
|
boolean |
isTilePathAuto(@NotNull Direction direction,
@Nullable MapFile mapFile)
Determines whether a tiled map in the specified direction is automatic
tiled path or not.
|
void |
removeMapArchObjectListener(@NotNull MapArchObjectListener listener)
Unregisters an event listener.
|
void |
setDarkness(int darkness)
Sets the light / darkness of this map.
|
void |
setDifficulty(int difficulty)
Sets the map's difficulty.
|
void |
setEnterX(int enterX)
Sets the enter x coordinate.
|
void |
setEnterY(int enterY)
Sets the enter y coordinate.
|
void |
setFixedReset(boolean fixedReset)
Sets whether this map uses a fixed reset.
|
void |
setMapName(@NotNull java.lang.String name)
Sets the map name.
|
void |
setMapSize(@NotNull Size2D mapSize)
Sets the map size.
|
protected void |
setModified()
Marks this map arch object as changed.
|
void |
setOutdoor(boolean outdoor)
Sets whether the map is an "outdoor" map.
|
void |
setResetTimeout(int resetTimeout)
Sets the reset timeout (in seconds).
|
void |
setState(A mapArchObject)
Resets the state of this object to the state of the given map arch
object.
|
void |
setSwapTime(int swapTime)
Sets the swap time (in ticks).
|
void |
setText(java.lang.String text)
Sets the map text.
|
void |
setTilePath(@NotNull Direction direction,
@NotNull java.lang.String tilePath)
Sets a tile path.
|
void |
updateModifiedAttribute(@NotNull java.lang.String userName)
Updates the "Modified:" attribute in the message text.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
createClone
@NotNull public static final @NotNull java.lang.String MAP_NAME_UNNAMED
protected AbstractMapArchObject()
protected AbstractMapArchObject(@NotNull @NotNull AbstractMapArchObject<A> mapArchObject)
mapArchObject
- the other map arch object@NotNull public @NotNull Size2D getMapSize()
MapArchObject
getMapSize
in interface MapArchObject<A extends MapArchObject<A>>
public void setMapSize(@NotNull @NotNull Size2D mapSize)
MapArchObject
setMapSize
in interface MapArchObject<A extends MapArchObject<A>>
mapSize
- the new map size@NotNull public @NotNull java.lang.String getMapName()
MapArchObject
getMapName
in interface MapArchObject<A extends MapArchObject<A>>
public void setMapName(@NotNull @NotNull java.lang.String name)
MapArchObject
setMapName
in interface MapArchObject<A extends MapArchObject<A>>
name
- the new map namepublic int getEnterX()
MapArchObject
getEnterX
in interface MapArchObject<A extends MapArchObject<A>>
public void setEnterX(int enterX)
MapArchObject
setEnterX
in interface MapArchObject<A extends MapArchObject<A>>
enterX
- the new enter x coordinatepublic int getEnterY()
MapArchObject
getEnterY
in interface MapArchObject<A extends MapArchObject<A>>
public void setEnterY(int enterY)
MapArchObject
setEnterY
in interface MapArchObject<A extends MapArchObject<A>>
enterY
- the new enter y coordinate@NotNull public @NotNull java.awt.Point getEnter()
MapArchObject
getEnter
in interface MapArchObject<A extends MapArchObject<A>>
public boolean isOutdoor()
MapArchObject
isOutdoor
in interface MapArchObject<A extends MapArchObject<A>>
public void setOutdoor(boolean outdoor)
MapArchObject
setOutdoor
in interface MapArchObject<A extends MapArchObject<A>>
outdoor
- whether the map is an "outdoor" mappublic int getResetTimeout()
MapArchObject
getResetTimeout
in interface MapArchObject<A extends MapArchObject<A>>
public void setResetTimeout(int resetTimeout)
MapArchObject
setResetTimeout
in interface MapArchObject<A extends MapArchObject<A>>
resetTimeout
- the new reset timeout (in seconds)public int getSwapTime()
MapArchObject
getSwapTime
in interface MapArchObject<A extends MapArchObject<A>>
public void setSwapTime(int swapTime)
MapArchObject
setSwapTime
in interface MapArchObject<A extends MapArchObject<A>>
swapTime
- the swap time (in ticks)public int getDifficulty()
MapArchObject
getDifficulty
in interface MapArchObject<A extends MapArchObject<A>>
public void setDifficulty(int difficulty)
MapArchObject
setDifficulty
in interface MapArchObject<A extends MapArchObject<A>>
difficulty
- the new difficulty for this mappublic boolean isFixedReset()
MapArchObject
isFixedReset
in interface MapArchObject<A extends MapArchObject<A>>
public void setFixedReset(boolean fixedReset)
MapArchObject
setFixedReset
in interface MapArchObject<A extends MapArchObject<A>>
fixedReset
- whether this map should use a fixed resetpublic int getDarkness()
MapArchObject
getDarkness
in interface MapArchObject<A extends MapArchObject<A>>
public void setDarkness(int darkness)
MapArchObject
setDarkness
in interface MapArchObject<A extends MapArchObject<A>>
darkness
- the new light / darkness of this mappublic int getTilePaths()
MapArchObject
getTilePaths
in interface MapArchObject<A extends MapArchObject<A>>
@NotNull public @NotNull java.lang.String getTilePath(@NotNull @NotNull Direction direction)
MapArchObject
getTilePath
in interface MapArchObject<A extends MapArchObject<A>>
direction
- the tile path directionpublic void setTilePath(@NotNull @NotNull Direction direction, @NotNull @NotNull java.lang.String tilePath)
MapArchObject
setTilePath
in interface MapArchObject<A extends MapArchObject<A>>
direction
- the tile path directiontilePath
- the new tile path@NotNull public @NotNull java.lang.String calculateTilePath(@NotNull @NotNull Direction direction, @Nullable @Nullable MapFile mapFile)
MapArchObject
calculateTilePath
in interface MapArchObject<A extends MapArchObject<A>>
direction
- the directionmapFile
- map filepublic void calculateTilePaths(@Nullable @Nullable MapFile mapFile, @NotNull @NotNull java.io.File mapsDirectory)
MapArchObject
calculateTilePaths
in interface MapArchObject<A extends MapArchObject<A>>
mapFile
- map filemapsDirectory
- maps directorypublic boolean isTilePathAuto(@NotNull @NotNull Direction direction, @Nullable @Nullable MapFile mapFile)
MapArchObject
isTilePathAuto
in interface MapArchObject<A extends MapArchObject<A>>
direction
- direction of the tiled mapmapFile
- map filepublic void setState(@NotNull A mapArchObject)
MapArchObject
setState
in interface MapArchObject<A extends MapArchObject<A>>
mapArchObject
- the map arch object to copy the state frompublic boolean equals(@Nullable @Nullable java.lang.Object obj)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object
public void addMapArchObjectListener(@NotNull @NotNull MapArchObjectListener listener)
MapArchObject
addMapArchObjectListener
in interface MapArchObject<A extends MapArchObject<A>>
listener
- the listener to registerpublic void removeMapArchObjectListener(@NotNull @NotNull MapArchObjectListener listener)
MapArchObject
removeMapArchObjectListener
in interface MapArchObject<A extends MapArchObject<A>>
listener
- the listener to unregisterprotected void setModified()
public void beginTransaction()
MapArchObject
MapArchObject.endTransaction()
.
Beginning a nested transaction is a cheap operation.
beginTransaction
in interface MapArchObject<A extends MapArchObject<A>>
MapArchObject.endTransaction()
,
MapArchObject.endTransaction(boolean)
public void endTransaction()
MapArchObject
Ending a nested operation is a cheap operation. Ending a transaction without changes also is a cheap operation.
If the last transaction is ended, the changes are committed.
Same as endTransaction(false)
.
endTransaction
in interface MapArchObject<A extends MapArchObject<A>>
MapArchObject.beginTransaction()
,
MapArchObject.endTransaction(boolean)
public void endTransaction(boolean fireEvent)
MapArchObject
Ending a nested operation is a cheap operation. Ending a transaction without changes also is a cheap operation.
If the last transaction is ended, the changes are committed.
An example where setting fireEvent
to true
is useful even
though the outermost transaction is not ended is when during painting the
UI should be updated though painting is not finished.
endTransaction
in interface MapArchObject<A extends MapArchObject<A>>
fireEvent
- true
if an event should be fired even in case
this doesn't end the outermost transaction.MapArchObject.beginTransaction()
,
MapArchObject.endTransaction()
public void addText(@NotNull @NotNull java.lang.String text)
MapArchObject
addText
in interface MapArchObject<A extends MapArchObject<A>>
text
- the string to addpublic void setText(java.lang.String text)
MapArchObject
setText
in interface MapArchObject<A extends MapArchObject<A>>
text
- the new map text@NotNull public @NotNull java.lang.String getText()
MapArchObject
getText
in interface MapArchObject<A extends MapArchObject<A>>
public void updateModifiedAttribute(@NotNull @NotNull java.lang.String userName)
MapArchObject
updateModifiedAttribute
in interface MapArchObject<A extends MapArchObject<A>>
userName
- the user name to includepublic boolean isPointValid(@Nullable @Nullable java.awt.Point pos)
MapArchObject
isPointValid
in interface MapArchObject<A extends MapArchObject<A>>
pos
- the coordinates to checktrue
if the given coordinates are on the map, otherwise
false
(also returns false
if pos == null
)