Class Room
Implements Room Objects for room accretion.
Room objects are
containers of tile data, with special behavior for generation.
Usage:
Room()
Info:
- Copyright: Creative Commons Attribution 4.0 International License
- Author: LonelyOwl
room.Class |
List of data structures contained within. |
room:setPosition (x, y) |
Set world position of room, and update tile (wx, wy) positions. |
room:getRoomWidth (excludeEmpties) |
Return room width by largest x-value of contained tiles. |
room:getRoomHeight (excludeEmpties) |
Return room height by largest h-value of contained tiles. |
room:getRoomDimensions (excludeEmpties) |
A function for getting width & height. |
room:getPosition () |
A function for getting the (x, y) position of a room. |
room:generateSquareRoom (width, height) |
Generate a square room |
room:generateCircleRoom (radius) |
Generate a circular room given a radius. |
room:generateCARoom (width, height, ...) |
Generate a Cellular Automata blob |
room:setTile (x, y, type) |
Set the type of a tile at local x, y position |
room:getSerializedRoomTiles () |
Iterates over all tiles inside room, and serializes those tiles for output. |
room:getTile (x, y) |
Returns a tile Object based on local (x, y) position. |
room:getTileByWorld (wx, wy) |
Returns a tile Object based on world (x, y) position |
room:setNeighbors () |
Populate tile neighbors on tile Object for later reference. |
room:addWallsToRoom () |
Iterates over every tile in a room, and assigns empty cells
to wall cells if they're neighbored by floor cells. |
room:assignRoomIds (id) |
Used after a room is generated. |
room:createRoomFromTable (width, height, table) |
Creates a room object from a list of tiles. |
room:serialize () |
Serialization of room, and tiles consequentially. |
-
room.Class
-
List of data structures contained within.
- x
(int) x world position of room. (top left corner)
- y
(int) y world position of room. (top left corner)
- dungeon
(int) id of dungeon the room belongs to.
- connectedRooms
(table) a list of connected rooms indexed by id.
- tiles
(table) List of tile objects in room.
- tileCache
(table) 2D array of tile ids indexed by local x, y position.
Methods
-
room._createRoomBuffer ()
-
Creates a room buffer (hash map) for tile manipulation.
-
room.connectTo ()
-
A function for pushing ids to Room.connectedRooms
-
room:setPosition (x, y)
-
Set world position of room, and update tile (wx, wy) positions.
Parameters:
-
room:getRoomWidth (excludeEmpties)
-
Return room width by largest x-value of contained tiles.
Parameters:
- excludeEmpties
boolean
whether to include empty tiles in calculation.
-
room:getRoomHeight (excludeEmpties)
-
Return room height by largest h-value of contained tiles.
Parameters:
- excludeEmpties
boolean
whether to include empty tiles in calculation.
-
room:getRoomDimensions (excludeEmpties)
-
A function for getting width & height.
Parameters:
- excludeEmpties
boolean
whether empty tiles should be counted.
See also:
-
room:getPosition ()
-
A function for getting the (x, y) position of a room.
See also:
-
room:generateSquareRoom (width, height)
-
Generate a square room
Parameters:
-
room:generateCircleRoom (radius)
-
Generate a circular room given a radius.
Parameters:
-
room:generateCARoom (width, height, ...)
-
Generate a Cellular Automata blob
Parameters:
-
room:setTile (x, y, type)
-
Set the type of a tile at local x, y position
Parameters:
-
room:getSerializedRoomTiles ()
-
Iterates over all tiles inside room, and serializes those tiles for output.
-
room:getTile (x, y)
-
Returns a tile Object based on local (x, y) position.
Parameters:
-
room:getTileByWorld (wx, wy)
-
Returns a tile Object based on world (x, y) position
Parameters:
- wx
- wy
convert world to local
-
room:setNeighbors ()
-
Populate tile neighbors on tile Object for later reference.
-
room:addWallsToRoom ()
-
Iterates over every tile in a room, and assigns empty cells
to wall cells if they're neighbored by floor cells.
-
room:assignRoomIds (id)
-
Used after a room is generated. Set the roomid property of all
tiles in the room to the corresponding room.
Parameters:
-
room:createRoomFromTable (width, height, table)
-
Creates a room object from a list of tiles.
Needed because some generation algorithms
like CA will output its result into a single
dimension table instead of a 2D array of tiles.
Parameters:
-
room:serialize ()
-
Serialization of room, and tiles consequentially.
Serialization data: {key = id, value = {serializedTileData}}