/datum/dungeon_room
This datum represents a "room" which is created by the Dungeon Generator process. Whether you use Binary Space Partition(BSP) or Random Room Placement(RRP), the Rust algorith will populate the given area with rooms, which are just squares and rectangles of various dimensions with X and Y coordinates. I created this datum to give better control over the data the generator is using. So you can look through the list of rooms for feedback or to understand what's happening.
The datum has procs to construct itself at the given coordinates, and procs to furnish itself according to the randomly assigned "theme" it chooses for itself on init.
Vars | |
center | The center tile of a room, or at least as close to center as it can get if the room is of different dimensions, or equal dimensions with no center |
---|---|
completed_room | If this room needed to get trimmed because it overlapped an area that shouldn't be touched |
doors | A list of the doors belonging to a room |
exterior | A list of the outermost turfs. This is used to generate walls and doors |
height | Tile height of the room, including walls. A 5 height room is a 3 tile tall interior with a wall on each side |
id | Some kind of identifier. Will default to the number of the rooms in the list, like "Random room 5" |
interior | A list of the turfs inside the outer walls. This is the room for activities and decorations |
protected_atoms | List of protected atom types. Rooms use turf.empty() to replace turfs and delete their contents at the same time. This is so that if a room overlaps another, lingering elements like walls, doors, windows, and even mobs will be removed. This is also helpful if you want to generate over elements that are already placed by map editors, like in the case of pipes and cables for atmos and station power. |
room_type | for differentiating room types yourself. like maybe 1 is a ruin, and 2 is empty |
width | Tile width of the room, including walls. A 5 width room is a 3 tile wide interior with a wall on each side |
x1 | X coordinate of the bottom left corner |
x2 | X coordinate of the top right corner |
y1 | Y coordinate of the bottom left corner |
y2 | Y coordinate of the top right corner |
z | z-level of the room |
Procs | |
Initialize | Override this for each new room type so you know whether to trim or discard rooms that overlap areas that should remain untouched |
add_doors | Add a random number of doors to the room. If you're lucky, people will actually be able to access the room. If not, it's a |
add_features | Sprinkle in the flavor from the room's theme like blood splatters, trash, or items. The number of flavor items is based on the room size and feature weight |
add_mobs | Add mobs if the room's theme has any, be it rats or space dragons lmao. The number of mobs is based on the room size and mob weight |
add_special_features | Sprinkle in the flavor from the room's theme like blood splatters, trash, or items. The number of flavor items is based on the room size and feature weight |
build_flooring | Build the flooring for the room. Potentially not necessary based on the build area, but making sure the room doesn't construct over space or gen turf is a good idea |
build_walls | This loop is for setting the inside of a room to match the area of its center. The reason we also fuck around with the lighting overlays is because at the time of generation, the lighting subsystem isn't initialized yet, so we'll handle calling the building and clearing of area lighting diffs ourselves. For each tile in the exterior, build a wall to keep the assistants out. Or a window if the room theme calls for it |
delete_self | We toggle the mob AI off as they're created because if the generator is being ran slowly and taking a while to generate, mobs can break out of their rooms and start fighting before the generator is even done |
generate | Construct yourself in the game world NOW. Assuming you have a theme to pull from, otherwise stay theoretical. |
is_ruin_compatible | If you're making an area that has ruin map files, you can use this to determine if it should be a ruin room |
validation_check | checks if the room overlaps areas it shouldn't and if it does remove that tile from the room |
Var Details
center
The center tile of a room, or at least as close to center as it can get if the room is of different dimensions, or equal dimensions with no center
completed_room
If this room needed to get trimmed because it overlapped an area that shouldn't be touched
doors
A list of the doors belonging to a room
exterior
A list of the outermost turfs. This is used to generate walls and doors
- exterior = Full room - interior
- [X][X][X][X] = [X][X][X][X] - [0][0][0][0]
- [X][0][0][X] = [X][X][X][X] - [0][X][X][0]
- [X][0][0][X] = [X][X][X][X] - [0][X][X][0]
- [X][X][X][X] = [X][X][X][X] - [0][0][0][0]
height
Tile height of the room, including walls. A 5 height room is a 3 tile tall interior with a wall on each side
id
Some kind of identifier. Will default to the number of the rooms in the list, like "Random room 5"
interior
A list of the turfs inside the outer walls. This is the room for activities and decorations
- Interior area of full room
- [0][0][0][0]
- [0][X][X][0]
- [0][X][X][0]
- [0][0][0][0]
protected_atoms
List of protected atom types. Rooms use turf.empty() to replace turfs and delete their contents at the same time. This is so that if a room overlaps another, lingering elements like walls, doors, windows, and even mobs will be removed. This is also helpful if you want to generate over elements that are already placed by map editors, like in the case of pipes and cables for atmos and station power.
room_type
for differentiating room types yourself. like maybe 1 is a ruin, and 2 is empty
width
Tile width of the room, including walls. A 5 width room is a 3 tile wide interior with a wall on each side
x1
X coordinate of the bottom left corner
x2
X coordinate of the top right corner
y1
Y coordinate of the bottom left corner
y2
Y coordinate of the top right corner
z
z-level of the room
Proc Details
Initialize
Override this for each new room type so you know whether to trim or discard rooms that overlap areas that should remain untouched
add_doors
Add a random number of doors to the room. If you're lucky, people will actually be able to access the room. If not, it's a super secret room
add_features
Sprinkle in the flavor from the room's theme like blood splatters, trash, or items. The number of flavor items is based on the room size and feature weight
add_mobs
Add mobs if the room's theme has any, be it rats or space dragons lmao. The number of mobs is based on the room size and mob weight
add_special_features
Sprinkle in the flavor from the room's theme like blood splatters, trash, or items. The number of flavor items is based on the room size and feature weight
build_flooring
Build the flooring for the room. Potentially not necessary based on the build area, but making sure the room doesn't construct over space or gen turf is a good idea
build_walls
This loop is for setting the inside of a room to match the area of its center. The reason we also fuck around with the lighting overlays is because at the time of generation, the lighting subsystem isn't initialized yet, so we'll handle calling the building and clearing of area lighting diffs ourselves. For each tile in the exterior, build a wall to keep the assistants out. Or a window if the room theme calls for it
delete_self
We toggle the mob AI off as they're created because if the generator is being ran slowly and taking a while to generate, mobs can break out of their rooms and start fighting before the generator is even done
Experimental and buggy, but calling this SHOULD remove the room from the game world, along with all the room's tiles and items. leaving the area looking how it did before generation. just thanos snap the room off the map like it never existed. however with rooms overlapping and intersecting this may just remove a chunk of another room
generate
Construct yourself in the game world NOW. Assuming you have a theme to pull from, otherwise stay theoretical.
is_ruin_compatible
If you're making an area that has ruin map files, you can use this to determine if it should be a ruin room
validation_check
checks if the room overlaps areas it shouldn't and if it does remove that tile from the room