Break RoomGenerators into Rect and Room methods
A RoomGenerator is now made up of two "method" classes that do separate things: 1. A RectMethod takes the size of the area to generate and creates an iterable stream of Rects to fill that area. 2. A RoomMethod takes a Rect and creates a room inside of it. These two components are composable in interesting ways, and allow a more data-driven approach to map generation, though I don't yet have the ability to make this mechansim entirely data-driven.
This commit is contained in:
parent
c17258bd73
commit
dd8b0364e0
2 changed files with 138 additions and 34 deletions
|
@ -18,7 +18,7 @@ from .geometry import Point, Size
|
|||
from .interface import Interface
|
||||
from .map import Map
|
||||
from .map.generator import RoomsAndCorridorsGenerator
|
||||
from .map.generator.room import RandomRectRoomGenerator
|
||||
from .map.generator.room import RoomGenerator, RandomRectMethod, RectangularRoomMethod
|
||||
from .map.generator.corridor import ElbowCorridorGenerator
|
||||
from .messages import MessageLog
|
||||
from .object import Actor, Entity, Hero, Monster
|
||||
|
@ -58,7 +58,14 @@ class Engine:
|
|||
|
||||
map_size = config.map_size
|
||||
map_generator = RoomsAndCorridorsGenerator(
|
||||
RandomRectRoomGenerator(size=map_size),
|
||||
RoomGenerator(
|
||||
size=map_size,
|
||||
config=RoomGenerator.Configuration(
|
||||
rect_method=RandomRectMethod(
|
||||
size=map_size,
|
||||
config=RandomRectMethod.Configuration(number_of_rooms=4)),
|
||||
room_method=RectangularRoomMethod())
|
||||
),
|
||||
ElbowCorridorGenerator())
|
||||
self.map = Map(config, map_generator)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue