Constructor
new SectoredBlockMap(sectorWidth, sectorHeight, worldGenerator)
Parameters:
Name | Type | Description |
---|---|---|
sectorWidth |
Integer | The number of blocks wide each sector should be (must be odd!) |
sectorHeight |
Integer | The number of blocks high each sector should be (must be odd!) |
worldGenerator |
WorldGenerator | The WorldGenerator Object to be used for this map |
Properties:
Name | Type | Description |
---|---|---|
generator |
WorldGenerator | The WorldGenerator to be used for this map |
sectorRows |
Array | A 2D array of BlockSectors and undefined values that make up the map |
sWidth |
Integer | A number representing the width of the map in sectors. |
sHeight |
Integer | A number representing the height of the map in sectors. |
sectorWidth |
Integer | An odd number representing the width of a sector in blocks |
sectorHeight |
Integer | An odd number representing the height of a sector in blocks |
sectorCenterX |
Integer | The index in the center row where the center sector of the map is |
sectorCenterY |
Integer | The index of the center row where the center sector of the map is |
originSectorX |
Integer | The x coordinate of the origin sector of the map |
originSectorY |
Integer | The y coordinate of the origin sector of the map |
sectorRightBound |
Integer | The x coordinate of the furthest right sector of the map |
sectorLeftBound |
Integer | The x coordinate of the furthest left sector of the map |
sectorTopBound |
Integer | The y coordinate of the furthest up sector of the map |
sectorBottomBound |
Integer | The y coordinate of the furthest down sector of the map |
generationQue |
Array | An array of sector coordinates that need generating during the next update call. |
- Source:
Methods
(static) getOriginSector() → {BlockSector}
- Source:
Returns:
The origin BlockSector of the map.
- Type
- BlockSector
(static) getPositionRelativeTo(originPosition, relX, relY) → {BlockPosition}
Returns a new BlockPosition based upon relX blocks left and right and relY blocks up and down from the original BlockPosition originPosition
Parameters:
Name | Type | Description |
---|---|---|
originPosition |
BlockPosition | The position that will be used as a point of reference. |
relX |
Integer | Number of blocks to the right of the point of reference. (left if negative) |
relY |
Integer | Number of blocks below the point of reference (up if negative). |
- Source:
Returns:
- Type
- BlockPosition
(static) getSector(sectorX, sectorY) → {BlockSector}
Returns the BlockSector specified by the sector coords. Will return a BlockSector full of air/empty blocks if the sector doesn't exist!
Parameters:
Name | Type | Description |
---|---|---|
sectorX |
||
sectorY |
- Source:
Returns:
Returns the BlockSector specified by the sector coords. Will return a BlockSector full of air/empty blocks if the sector doesn't exist!
- Type
- BlockSector
(static) getWindow(centerPosition, width, height) → {Array}
This function takes a center position and dimensions to select an area of blocks from the SectoredBlockMap to return as a 2D array of blocks. It is a way to select all blocks in an area, even if that area contains multiple sectors.
Parameters:
Name | Type | Description |
---|---|---|
centerPosition |
BlockPosition | The position of the block that the window is centered around |
width |
Integer | The number of blocks from left bound to right bound of the window (must be odd!) |
height |
Integer | The number of blocks from the top bound to the bottom bound of the window (must be odd!) |
- Source:
Returns:
A 2D array of blocks that are within the window
- Type
- Array
(static) init()
Itializes the map, should be called before the map is used!
- Source:
(static) sectorCoordsToSectorIndex(sectorX, sectorY)
This methods converts x and y coordinates into the indexes in the map's 2D array to access the specified sector.
Parameters:
Name | Type | Description |
---|---|---|
sectorX |
Number | |
sectorY |
Number |
- Source:
Returns:
(Object) An object with two properties "sectorXIndex" and "sectorYIndex" that contain the x and y indexes of the sector specified with the x and y coords.
(static) sectorExists(sectorX, sectorY) → {Boolean}
Parameters:
Name | Type | Description |
---|---|---|
sectorX |
Number | |
sectorY |
Number |
- Source:
Returns:
True if the sector is within the map bounds and has been generated, false if otherwise.
- Type
- Boolean
(static) sectorInBounds(sectorX, sectorY) → {Boolean}
Tests to see if the specified sector is within the current bounds of the SectoredBlockMap.
Parameters:
Name | Type | Description |
---|---|---|
sectorX |
||
sectorY |
- Source:
Returns:
true if the sector is within the current bounds, false if not. This does not check to see if the sector exists!
- Type
- Boolean