Class Blockmap
java.lang.Object
net.mtrop.doom.map.data.Blockmap
- All Implemented Interfaces:
BinaryObject
Representation of the Blockmap lump for a map.
This aids in collision detection for linedefs.
- Author:
- Matthew Tropiano
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.mtrop.doom.object.BinaryObject
BinaryObject.InlineScanner<BO extends BinaryObject>, BinaryObject.Reflect, BinaryObject.Scanner<BO extends BinaryObject>, BinaryObject.Shared, BinaryObject.Transformer<BO extends BinaryObject> -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddIndex(int x, int y, int linedefIndex) Adds a linedef index to this blockmap.intgetColumnByMapPosition(int posX) Returns the column index used by a particular map position, according to this grid's startX value.getIndexList(int x, int y) Returns an iterable structure for linedef indices for a certain block.getIndexListForPosition(int posX, int posY) Returns an iterable structure for linedef indices for a certain block using a map position.intgetRowByMapPosition(int posY) Returns the row index used by a particular map position, according to this grid's startY value.floatfloatvoidreadBytes(InputStream in) Reads from anInputStreamand sets this object's fields.booleanremoveIndex(int x, int y, int linedefIndex) Removes a linedef index to this blockmap.voidwriteBytes(OutputStream out) Writes this object to anOutputStream.
-
Constructor Details
-
Blockmap
public Blockmap()Creates a new Blockmap, startX and startY set to 0. -
Blockmap
public Blockmap(int startX, int startY) Creates a new Blockmap.- Parameters:
startX- the grid lower-left start position (x-axis).startY- the grid lower-left start position (y-axis).- Throws:
IllegalArgumentException- ifstartXorstartYis outside the range of -32768 to 32767.
-
-
Method Details
-
addIndex
public void addIndex(int x, int y, int linedefIndex) Adds a linedef index to this blockmap.- Parameters:
x- the grid row.y- the grid column.linedefIndex- the linedef index to add.- Throws:
IllegalArgumentException- ifxoryis outside the range 0 to 512 orlinedefIndexis outside the range 0 to 65535.
-
removeIndex
public boolean removeIndex(int x, int y, int linedefIndex) Removes a linedef index to this blockmap.- Parameters:
x- the grid column.y- the grid row.linedefIndex- the linedef index to remove.- Returns:
- true if removed, false if not.
- Throws:
IllegalArgumentException- ifxoryis outside the range 0 to 512 orlinedefIndexis outside the range 0 to 65535.
-
getStartX
public float getStartX()- Returns:
- the map position start, X coordinate.
-
getStartY
public float getStartY()- Returns:
- the map position start, Y coordinate.
-
getColumnByMapPosition
public int getColumnByMapPosition(int posX) Returns the column index used by a particular map position, according to this grid's startX value. If posX is less than startX, this returns -1.- Parameters:
posX- the map position x-coordinate.- Returns:
- the corresponding block column or if
posXis less thangetStartX(), this returns -1.
-
getRowByMapPosition
public int getRowByMapPosition(int posY) Returns the row index used by a particular map position, according to this grid's startY value.- Parameters:
posY- the map position y-coordinate.- Returns:
- the corresponding block row or if
posYis less thangetStartY(), this returns -1.
-
getIndexList
-
getIndexListForPosition
Returns an iterable structure for linedef indices for a certain block using a map position.- Parameters:
posX- the map position, X-coordinate.posY- the map position, Y-coordinate.- Returns:
- an iterable structure for a particular block that corresponds to the map position.
-
readBytes
Description copied from interface:BinaryObjectReads from anInputStreamand sets this object's fields. Only reads the amount of bytes that it takes to read a single instance of the object. Note that not every object may have a consistent length!- Specified by:
readBytesin interfaceBinaryObject- Parameters:
in- theInputStreamto read from.- Throws:
IOException- if a read error occurs.
-
writeBytes
Description copied from interface:BinaryObjectWrites this object to anOutputStream.- Specified by:
writeBytesin interfaceBinaryObject- Parameters:
out- theOutputStreamto write to.- Throws:
IOException- if a write error occurs.
-