diff --git a/assets/world/style/colors.ron b/assets/world/style/colors.ron index cbcfa31e5d..e974827c67 100644 --- a/assets/world/style/colors.ron +++ b/assets/world/style/colors.ron @@ -34,6 +34,7 @@ Chestnut: [(start: (30, 80, 0), end: (50, 120, 0))], Baobab: [(start: (50, 100, 40), end: (50, 90, 0))], MapleLeaves: [(start: (103, 32, 21), end: (131, 24, 26)), (start: (96, 30, 44), end: (92, 9, 46))], + CherryLeaves: [(start: (210, 109, 116), end: (217, 102, 102)), (start: (191, 128, 151), end: (206, 113, 123))] ) // Water blocks ignore color now so this isn't used, but just in case this color was worth diff --git a/common/src/terrain/structure.rs b/common/src/terrain/structure.rs index e8c41bb1b9..619fe4c33f 100644 --- a/common/src/terrain/structure.rs +++ b/common/src/terrain/structure.rs @@ -49,6 +49,7 @@ make_case_elim!( KeyholeBars(consumes: String) = 29, HaniwaKeyhole(consumes: String) = 30, MapleLeaves = 31, + CherryLeaves = 32, } ); diff --git a/world/src/all.rs b/world/src/all.rs index 14cedea1e4..9a59503deb 100644 --- a/world/src/all.rs +++ b/world/src/all.rs @@ -20,6 +20,7 @@ pub enum ForestKind { Frostpine, Dead, Mapletree, + Cherry, } pub struct Environment { @@ -44,7 +45,8 @@ impl ForestKind { ForestKind::Mangrove => 0.5..1.3, ForestKind::Swamp => 0.5..1.1, ForestKind::Dead => 0.0..1.5, - ForestKind::Mapletree => 0.55..1.25, + ForestKind::Mapletree => 0.65..1.25, + ForestKind::Cherry => 0.45..0.75, _ => 0.0..0.0, } } @@ -65,6 +67,7 @@ impl ForestKind { ForestKind::Swamp => -0.6..0.8, ForestKind::Dead => -1.5..1.0, ForestKind::Mapletree => -0.15..0.25, + ForestKind::Cherry => -0.10..0.15, _ => 0.0..0.0, } } @@ -94,6 +97,7 @@ impl ForestKind { ForestKind::Swamp => 1.0, ForestKind::Dead => 0.01, ForestKind::Mapletree => 0.65, + ForestKind::Cherry => 12.0, _ => 0.0, } } @@ -112,6 +116,7 @@ impl ForestKind { ForestKind::Mangrove => 1.0, ForestKind::Swamp => 0.4, ForestKind::Mapletree => 0.4, + ForestKind::Cherry => 0.3, _ => 1.0, } } diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index 8c9d954590..5aae6790cd 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -281,7 +281,8 @@ pub fn block_from_structure( | StructureBlock::Mangrove | StructureBlock::Chestnut | StructureBlock::Baobab - | StructureBlock::MapleLeaves => { + | StructureBlock::MapleLeaves + | StructureBlock::CherryLeaves => { let ranges = sblock .elim_case_pure(&index.colors.block.structure_blocks) .as_ref() diff --git a/world/src/layer/tree.rs b/world/src/layer/tree.rs index af1986a2a1..ba012f6094 100644 --- a/world/src/layer/tree.rs +++ b/world/src/layer/tree.rs @@ -233,6 +233,15 @@ pub fn apply_trees_to( StructureBlock::MapleLeaves, ); }, + ForestKind::Cherry => { + break 'model TreeModel::Procedural( + ProceduralTree::generate( + TreeConfig::cherry(&mut RandomPerm::new(seed), scale), + &mut RandomPerm::new(seed), + ), + StructureBlock::CherryLeaves, + ); + }, }; let models = models.read(); @@ -732,6 +741,31 @@ impl TreeConfig { trunk_block: StructureBlock::Filled(BlockKind::Wood, Rgb::new(110, 68, 22)), } } + + pub fn cherry(rng: &mut impl Rng, scale: f32) -> Self { + let scale = scale * (0.8 + rng.gen::().powi(2) * 0.5); + let log_scale = 1.0 + scale.log2().max(0.0); + + Self { + trunk_len: 7.0 * scale, + trunk_radius: 1.27 * scale, + branch_child_len: 0.9, + branch_child_radius: 0.70, + branch_child_radius_lerp: true, + leaf_radius: 2.5 * log_scale..3.0 * log_scale, + leaf_radius_scaled: 0.0, + straightness: 0.55, + max_depth: 4, + splits: 2.0..3.0, + split_range: 0.75..1.3, + branch_len_bias: 0.0, + leaf_vertical_scale: 1.0, + proportionality: 0.0, + inhabited: false, + hanging_sprites: &[], + trunk_block: StructureBlock::Filled(BlockKind::Wood, Rgb::new(69, 37, 17)), + } + } } // TODO: Rename this to `Tree` when the name conflict is gone