Skip to main content

steel_core/worldgen/structure/piece_placer/ocean_monument/
mod.rs

1use glam::DVec3;
2use steel_registry::blocks::block_state_ext::BlockStateExt as _;
3use steel_registry::{Registry, vanilla_blocks, vanilla_entities};
4use steel_utils::random::Random;
5use steel_utils::random::worldgen_random::WorldgenRandom;
6use steel_utils::{BlockStateId, BoundingBox, Direction};
7
8use crate::worldgen::region::WorldGenRegion;
9use steel_worldgen::structure::ocean_monument::{
10    OceanMonumentChildPiece, OceanMonumentChildPieceKind, OceanMonumentPieceData,
11    OceanMonumentRoomData,
12};
13
14use super::StructurePiecePlacer;
15use super::scattered_feature::ScatteredFeaturePlacer;
16
17impl StructurePiecePlacer {
18    pub(super) fn place_ocean_monument_piece(
19        region: &mut WorldGenRegion<'_>,
20        registry: &Registry,
21        bounding_box: BoundingBox,
22        orientation: Option<Direction>,
23        data: &mut OceanMonumentPieceData,
24        clip: BoundingBox,
25        random: &mut WorldgenRandom,
26    ) -> bool {
27        {
28            let mut building_box = bounding_box;
29            let mut placer =
30                ScatteredFeaturePlacer::new(region, registry, &mut building_box, orientation, clip);
31            place_monument_building_shell(&mut placer);
32        }
33
34        for child in &data.child_pieces {
35            if !child.bounding_box.intersects(clip) {
36                continue;
37            }
38
39            let mut child_box = child.bounding_box;
40            let mut placer =
41                ScatteredFeaturePlacer::new(region, registry, &mut child_box, orientation, clip);
42            place_child_piece(&mut placer, child, random);
43        }
44
45        true
46    }
47}
48
49fn place_child_piece(
50    placer: &mut ScatteredFeaturePlacer<'_, '_>,
51    child: &OceanMonumentChildPiece,
52    random: &mut WorldgenRandom,
53) {
54    match &child.kind {
55        OceanMonumentChildPieceKind::EntryRoom { room } => place_entry_room(placer, *room),
56        OceanMonumentChildPieceKind::CoreRoom => place_core_room(placer),
57        OceanMonumentChildPieceKind::DoubleXRoom { west, east } => {
58            place_double_x_room(placer, *west, *east);
59        }
60        OceanMonumentChildPieceKind::DoubleXYRoom {
61            west,
62            east,
63            west_up,
64            east_up,
65        } => place_double_xy_room(placer, *west, *east, *west_up, *east_up),
66        OceanMonumentChildPieceKind::DoubleYRoom { room, above } => {
67            place_double_y_room(placer, *room, *above);
68        }
69        OceanMonumentChildPieceKind::DoubleYZRoom {
70            south,
71            north,
72            south_up,
73            north_up,
74        } => place_double_yz_room(placer, *south, *north, *south_up, *north_up),
75        OceanMonumentChildPieceKind::DoubleZRoom { south, north } => {
76            place_double_z_room(placer, *south, *north);
77        }
78        OceanMonumentChildPieceKind::SimpleRoom { room, main_design } => {
79            place_simple_room(placer, random, *room, *main_design);
80        }
81        OceanMonumentChildPieceKind::SimpleTopRoom { room } => {
82            place_simple_top_room(placer, random, *room);
83        }
84        OceanMonumentChildPieceKind::WingRoom { main_design } => {
85            place_wing_room(placer, *main_design);
86        }
87        OceanMonumentChildPieceKind::Penthouse => place_penthouse(placer),
88    }
89}
90
91mod shell;
92
93use shell::place_monument_building_shell;
94
95mod room_core;
96
97use room_core::{place_core_room, place_entry_room};
98
99mod room_double;
100
101use room_double::{
102    place_double_x_room, place_double_xy_room, place_double_y_room, place_double_yz_room,
103    place_double_z_room,
104};
105
106mod room_simple;
107
108use room_simple::{place_simple_room, place_simple_top_room};
109
110mod room_special;
111
112use room_special::{place_penthouse, place_wing_room};
113
114mod helpers;
115
116use helpers::{
117    base_black, base_gray, base_light, dot_deco, generate_box_on_fill_only, generate_default_floor,
118    generate_water_box, lamp, open, spawn_elder,
119};