1use super::{Direction, IVec3, LegacyRandom, Rotation};
2use super::{
3 placement::get_room_name,
4 template::{
5 MansionTemplatePiece, Mirror, add_piece, compose_rotation, relative, zero_pos_transform,
6 },
7};
8
9pub(super) fn add_room_1x1(
10 pieces: &mut Vec<MansionTemplatePiece>,
11 room_pos: IVec3,
12 rotation: Rotation,
13 door_dir: Option<Direction>,
14 floor: usize,
15 rng: &mut LegacyRandom,
16) {
17 let mut piece_rot = Rotation::None;
18 let kind;
19 match door_dir {
20 Some(Direction::East) => kind = "1x1",
21 Some(Direction::North) => {
22 piece_rot = Rotation::CounterClockwise90;
23 kind = "1x1";
24 }
25 Some(Direction::West) => {
26 piece_rot = Rotation::Clockwise180;
27 kind = "1x1";
28 }
29 Some(Direction::South) => {
30 piece_rot = Rotation::Clockwise90;
31 kind = "1x1";
32 }
33 _ => kind = "1x1s",
34 }
35 let name = get_room_name(rng, floor, kind, false);
36 let orient = zero_pos_transform(IVec3::new(1, 0, 0), piece_rot, 7, 7);
37 piece_rot = compose_rotation(piece_rot, rotation);
38 let orient = rotation.transform_pos(orient, IVec3::ZERO);
39 let pos = room_pos + IVec3::new(orient.x, 0, orient.z);
40 add_piece(pieces, name, pos, piece_rot, Mirror::None);
41}
42
43#[expect(
44 clippy::too_many_arguments,
45 reason = "mirrors vanilla's MansionRoom1x2 constructor surface"
46)]
47#[expect(
48 clippy::too_many_lines,
49 reason = "exhaustive (door_dir × room_dir) dispatch mirroring vanilla's MansionRoom1x2"
50)]
51pub(super) fn add_room_1x2(
52 pieces: &mut Vec<MansionTemplatePiece>,
53 room_pos: IVec3,
54 rotation: Rotation,
55 room_dir: Direction,
56 door_dir: Direction,
57 floor: usize,
58 is_stairs: bool,
59 rng: &mut LegacyRandom,
60) {
61 let (pos, rot, mirror, kind) = match (door_dir, room_dir) {
62 (Direction::East, Direction::South) => (
63 relative(room_pos, rotation, Direction::East, 1),
64 rotation,
65 Mirror::None,
66 "1x2side",
67 ),
68 (Direction::East, Direction::North) => {
69 let p = relative(
70 relative(room_pos, rotation, Direction::East, 1),
71 rotation,
72 Direction::South,
73 6,
74 );
75 (p, rotation, Mirror::LeftRight, "1x2side")
76 }
77 (Direction::West, Direction::North) => {
78 let p = relative(
79 relative(room_pos, rotation, Direction::East, 7),
80 rotation,
81 Direction::South,
82 6,
83 );
84 (
85 p,
86 compose_rotation(rotation, Rotation::Clockwise180),
87 Mirror::None,
88 "1x2side",
89 )
90 }
91 (Direction::West, Direction::South) => (
92 relative(room_pos, rotation, Direction::East, 7),
93 rotation,
94 Mirror::FrontBack,
95 "1x2side",
96 ),
97 (Direction::South, Direction::East) => (
98 relative(room_pos, rotation, Direction::East, 1),
99 compose_rotation(rotation, Rotation::Clockwise90),
100 Mirror::LeftRight,
101 "1x2side",
102 ),
103 (Direction::South, Direction::West) => (
104 relative(room_pos, rotation, Direction::East, 7),
105 compose_rotation(rotation, Rotation::Clockwise90),
106 Mirror::None,
107 "1x2side",
108 ),
109 (Direction::North, Direction::West) => {
110 let p = relative(
111 relative(room_pos, rotation, Direction::East, 7),
112 rotation,
113 Direction::South,
114 6,
115 );
116 (
117 p,
118 compose_rotation(rotation, Rotation::Clockwise90),
119 Mirror::FrontBack,
120 "1x2side",
121 )
122 }
123 (Direction::North, Direction::East) => {
124 let p = relative(
125 relative(room_pos, rotation, Direction::East, 1),
126 rotation,
127 Direction::South,
128 6,
129 );
130 (
131 p,
132 compose_rotation(rotation, Rotation::CounterClockwise90),
133 Mirror::None,
134 "1x2side",
135 )
136 }
137 (Direction::South, Direction::North) => {
138 let p = relative(
139 relative(room_pos, rotation, Direction::East, 1),
140 rotation,
141 Direction::North,
142 8,
143 );
144 (p, rotation, Mirror::None, "1x2front")
145 }
146 (Direction::North, Direction::South) => {
147 let p = relative(
148 relative(room_pos, rotation, Direction::East, 7),
149 rotation,
150 Direction::South,
151 14,
152 );
153 (
154 p,
155 compose_rotation(rotation, Rotation::Clockwise180),
156 Mirror::None,
157 "1x2front",
158 )
159 }
160 (Direction::West, Direction::East) => (
161 relative(room_pos, rotation, Direction::East, 15),
162 compose_rotation(rotation, Rotation::Clockwise90),
163 Mirror::None,
164 "1x2front",
165 ),
166 (Direction::East, Direction::West) => {
167 let p = relative(
168 relative(room_pos, rotation, Direction::West, 7),
169 rotation,
170 Direction::South,
171 6,
172 );
173 (
174 p,
175 compose_rotation(rotation, Rotation::CounterClockwise90),
176 Mirror::None,
177 "1x2front",
178 )
179 }
180 (Direction::Up, Direction::East) => (
181 relative(room_pos, rotation, Direction::East, 15),
182 compose_rotation(rotation, Rotation::Clockwise90),
183 Mirror::None,
184 "1x2secret",
185 ),
186 (Direction::Up, Direction::South) => {
187 let p = relative(
188 relative(room_pos, rotation, Direction::East, 1),
189 rotation,
190 Direction::North,
191 0,
192 );
193 (p, rotation, Mirror::None, "1x2secret")
194 }
195 _ => return,
196 };
197
198 let name = get_room_name(rng, floor, kind, is_stairs);
199 add_piece(pieces, name, pos, rot, mirror);
200}
201
202pub(super) fn add_room_2x2(
203 pieces: &mut Vec<MansionTemplatePiece>,
204 room_pos: IVec3,
205 rotation: Rotation,
206 room_dir: Direction,
207 door_dir: Direction,
208 floor: usize,
209 rng: &mut LegacyRandom,
210) {
211 let (east, south, rot, mirror) = match (door_dir, room_dir) {
212 (Direction::East, Direction::South) => (-7, 0, rotation, Mirror::None),
213 (Direction::East, Direction::North) => (-7, 6, rotation, Mirror::LeftRight),
214 (Direction::North, Direction::East) => (
215 1,
216 14,
217 compose_rotation(rotation, Rotation::CounterClockwise90),
218 Mirror::None,
219 ),
220 (Direction::North, Direction::West) => (
221 7,
222 14,
223 compose_rotation(rotation, Rotation::CounterClockwise90),
224 Mirror::LeftRight,
225 ),
226 (Direction::South, Direction::West) => (
227 7,
228 -8,
229 compose_rotation(rotation, Rotation::Clockwise90),
230 Mirror::None,
231 ),
232 (Direction::South, Direction::East) => (
233 1,
234 -8,
235 compose_rotation(rotation, Rotation::Clockwise90),
236 Mirror::LeftRight,
237 ),
238 (Direction::West, Direction::North) => (
239 15,
240 6,
241 compose_rotation(rotation, Rotation::Clockwise180),
242 Mirror::None,
243 ),
244 (Direction::West, Direction::South) => (15, 0, rotation, Mirror::FrontBack),
245 _ => return,
246 };
247
248 let pos = relative(
249 relative(room_pos, rotation, Direction::East, east),
250 rotation,
251 Direction::South,
252 south,
253 );
254 let name = get_room_name(rng, floor, "2x2", false);
255 add_piece(pieces, name, pos, rot, mirror);
256}
257
258pub(super) fn add_room_2x2_secret(
259 pieces: &mut Vec<MansionTemplatePiece>,
260 room_pos: IVec3,
261 rotation: Rotation,
262 floor: usize,
263 rng: &mut LegacyRandom,
264) {
265 let pos = relative(room_pos, rotation, Direction::East, 1);
266 let name = get_room_name(rng, floor, "2x2secret", false);
267 add_piece(pieces, name, pos, rotation, Mirror::None);
268}