1use common_assets::{Asset, AssetCombined, AssetHandle, Concatenate, RonLoader};
2use lazy_static::lazy_static;
3
4use crate::terrain::BiomeKind;
5use strum::EnumIter;
6
7#[derive(Copy, Clone, Debug, EnumIter, PartialEq)]
26pub enum Spot {
27 DwarvenGrave,
28 SaurokAltar,
29 MyrmidonTemple,
30 GnarlingTotem,
31 WitchHouse,
32 GnomeSpring,
33 WolfBurrow,
34 Igloo,
35 LionRock,
43 TreeStumpForest,
44 DesertBones,
45 Arch,
46 AirshipCrash,
47 FruitTree,
48 Shipwreck,
49 Shipwreck2,
50 FallenTree,
51 GraveSmall,
52 JungleTemple,
53 SaurokTotem,
54 JungleOutpost,
55 #[strum(disabled)]
56 RonFile(&'static SpotProperties),
57}
58
59#[derive(serde::Deserialize, Clone, Debug, PartialEq)]
60pub enum SpotCondition {
61 MaxGradient(f32),
62 Biome(Vec<BiomeKind>),
63 NearCliffs,
64 NearRiver,
65 IsWay,
66 IsUnderwater,
67
68 Typical,
70 MinWaterDepth(f32),
72
73 Not(Box<SpotCondition>),
74 All(Vec<SpotCondition>),
75 Any(Vec<SpotCondition>),
76}
77
78#[derive(serde::Deserialize, Clone, Debug, PartialEq)]
79pub struct SpotProperties {
80 pub base_structures: String,
81 pub freq: f32,
82 pub condition: SpotCondition,
83 pub spawn: bool,
84}
85
86#[derive(serde::Deserialize, Clone, Debug)]
87#[serde(transparent)]
88pub struct RonSpots(pub Vec<SpotProperties>);
89
90impl Asset for RonSpots {
91 type Loader = RonLoader;
92
93 const EXTENSION: &'static str = "ron";
94}
95
96impl Concatenate for RonSpots {
97 fn concatenate(self, b: Self) -> Self { Self(self.0.concatenate(b.0)) }
98}
99
100lazy_static! {
101 pub static ref RON_SPOT_PROPERTIES: RonSpots = {
102 let spots: AssetHandle<RonSpots> =
103 RonSpots::load_expect_combined_static("world.manifests.spots");
104 RonSpots(spots.read().0.to_vec())
105 };
106}