|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.maps.MapWriter
Writes out a map to a mapfile.
Field Summary | |
protected java.util.HashSet |
cache_
|
protected java.util.HashMap |
externCache_
|
protected java.lang.String |
filename_
|
protected java.io.PrintWriter |
out_
|
protected java.util.HashSet |
terrainCache_
|
Constructor Summary | |
MapWriter()
|
Method Summary | |
protected boolean |
compareObjects(GameObject o1,
GameObject o2)
Compares 2 objects to see if they'd write to the mapfile identically. |
protected int |
extendLeftRight(GameMap map,
Point start,
int dir,
Rectangle bounds,
GameObject obj)
Checks to the left or right of the passed location to see how far this type of object extends. |
protected int |
extendUpDown(GameMap map,
GameObject obj,
Rectangle bounds,
int dir,
int y,
int x1,
int x2)
Checks above or below the passed horizontal strip of objects to see how far the strip can be extended up or down. |
protected GameObject |
findClone(GameMap map,
GameObject obj,
Point loc)
Looks for an object at the specified location that exactly matches the passed object. |
java.lang.String |
getMapClassName(GameMap map)
Returns an appropriate map-class name for writing to the file. |
protected void |
iterateObjects(GameMap map,
java.util.Iterator it,
Point p)
Iterates over the objects at a particular map location, writing them out in the largest rectangles possible. |
protected void |
openFile(java.lang.String filename)
Opens the file for writing, and sets global variables for the filename and output stream. |
boolean |
overlapping(GameObject o1,
GameObject o2)
Returns true if two otherwise identical objects are overlapping. |
protected void |
printMapProps(GameMap map,
java.io.PrintWriter out)
Prints map properties to output stream. |
protected void |
writeDenseMap(GameMap map)
Writes a dense map. |
protected void |
writeLocalArchetypes(GameMap map)
Writes any map-local archetypes to the mapfile. |
void |
writeMap(GameMap map,
java.lang.String filename)
Writes the entire contents of the specified map. |
protected void |
writeObject(GameMap map,
GameObject obj,
Point p)
Writes an object - called by iterateObjects, after checking if the object is in the cache, discarding players and transient properties, etc. |
protected void |
writeObject(GameObject obj,
int x,
int y)
Writes XML version of a single object. |
void |
writeObjectAndNeighbors(GameMap map,
GameObject obj,
Point p)
Writes an object and all its identical neighbors to a rectangle. |
protected void |
writeRectangle(GameObject obj,
int x,
int y,
int w,
int h)
Writes out a rectangle in the map containing the passed object at every location in the rectangle. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected java.util.HashSet cache_
protected java.util.HashSet terrainCache_
protected java.io.PrintWriter out_
protected java.lang.String filename_
protected java.util.HashMap externCache_
Constructor Detail |
public MapWriter()
Method Detail |
public void writeMap(GameMap map, java.lang.String filename) throws java.io.IOException
map
- the Map to writefilename
- the full path to the map file to write
java.io.IOException
- if the write failsprotected void writeDenseMap(GameMap map) throws java.io.IOException
map
- the map to write
java.io.IOException
- if the write failspublic java.lang.String getMapClassName(GameMap map)
map
- the map to write
protected void printMapProps(GameMap map, java.io.PrintWriter out)
protected void writeLocalArchetypes(GameMap map)
map
- the map to writeprotected void iterateObjects(GameMap map, java.util.Iterator it, Point p)
map
- the map we're writingit
- an Iterator whose elements are GameObjectsp
- the Point (map location) we're iteratingprotected void writeObject(GameMap map, GameObject obj, Point p)
public void writeObjectAndNeighbors(GameMap map, GameObject obj, Point p)
map
- the GameMap we're writingobj
- the object to write into the mapp
- the map location we're writingprotected void writeObject(GameObject obj, int x, int y)
obj
- the object to write into the mapx
- the x location for the objecty
- the y location for the objectprotected void writeRectangle(GameObject obj, int x, int y, int w, int h)
obj
- the object to write into the mapx
- rectangle lefty
- rectangle topw
- rectangle widthh
- rectangle heightprotected boolean compareObjects(GameObject o1, GameObject o2)
o1
- the first objecto2
- the second object
protected GameObject findClone(GameMap map, GameObject obj, Point loc)
map
- the map to look inobj
- the object to find a clone ofloc
- the point at which to look
protected int extendLeftRight(GameMap map, Point start, int dir, Rectangle bounds, GameObject obj)
map
- the map we're writingstart
- the start location to go left or right fromdir
- -1 to go left, +1 to go rightbounds
- the GameMap bounds, so we don't go OOBobj
- the object we're writing
protected int extendUpDown(GameMap map, GameObject obj, Rectangle bounds, int dir, int y, int x1, int x2)
map
- the GameMap we're writingobj
- the type of object being writtenbounds
- the GameMap bounds, so we don't go OOBdir
- -1 for up, 1 for downy
- map y coordinate of stripx1
- left side of stripx2
- right side of strip
public boolean overlapping(GameObject o1, GameObject o2)
protected void openFile(java.lang.String filename) throws java.io.IOException
filename
- the file to open.
java.io.IOException
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |