From 2e72d97b5e0a1139ffd8c7570f18a75339e3a7e2 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Sun, 29 Aug 2021 13:57:36 +0100 Subject: [PATCH] Multiple color gradient options --- assets/world/style/colors.ron | 19 ++++++++++++------- server-cli/Cargo.toml | 1 + server/Cargo.toml | 1 + world/src/block/mod.rs | 24 +++++++++++++++++------- world/src/layer/scatter.rs | 11 +++++++++++ 5 files changed, 42 insertions(+), 14 deletions(-) diff --git a/assets/world/style/colors.ron b/assets/world/style/colors.ron index 805098f127..e075b69ef7 100644 --- a/assets/world/style/colors.ron +++ b/assets/world/style/colors.ron @@ -17,13 +17,18 @@ Water: None, GreenSludge: None, // Leaves all actually get interpolated. - TemperateLeaves: (start: (0, 70, 45), end: (90, 140, 0)), - PineLeaves: (start: (0, 60, 50), end: (30, 80, 10)), - PalmLeavesInner: (start: (70, 140, 43), end: (55, 140, 32)), - PalmLeavesOuter: (start: (60, 130, 38), end: (30, 130, 65)), - Acacia: (start: (30, 100, 0), end: (90, 110, 20)), - Liana: (start: (0, 125, 107), end: (0, 155, 129)), - Mangrove: (start: (15, 80, 10), end: (20, 120, 47)), + TemperateLeaves: [ + (start: (0, 91, 68), end: (124, 173, 0)), + //(start: (178, 216, 0), end: (255, 185, 63)), + //(start: (142, 164, 0), end: (142, 164, 0)), + //(start: (168, 81, 0), end: (54, 150, 31)), + ], + PineLeaves: [(start: (0, 60, 50), end: (30, 80, 10))], + PalmLeavesInner: [(start: (70, 140, 43), end: (55, 140, 32))], + PalmLeavesOuter: [(start: (60, 130, 38), end: (30, 130, 65))], + Acacia: [(start: (30, 100, 0), end: (90, 110, 20))], + Liana: [(start: (0, 125, 107), end: (0, 155, 129))], + Mangrove: [(start: (15, 80, 10), end: (20, 120, 47))], ) // Water blocks ignore color now so this isn't used, but just in case this color was worth diff --git a/server-cli/Cargo.toml b/server-cli/Cargo.toml index 3df973d6d9..6bf0cecf13 100644 --- a/server-cli/Cargo.toml +++ b/server-cli/Cargo.toml @@ -22,6 +22,7 @@ default-publish = ["default"] default = ["worldgen", "persistent_world"] tracy = ["common-frontend/tracy"] plugins = ["server/plugins"] +hot-reloading = ["server/hot-reloading"] [dependencies] server = { package = "veloren-server", path = "../server", default-features = false, features = ["simd"] } diff --git a/server/Cargo.toml b/server/Cargo.toml index 4608b1551b..e53e96b132 100644 --- a/server/Cargo.toml +++ b/server/Cargo.toml @@ -9,6 +9,7 @@ worldgen = [] simd = ["vek/platform_intrinsics"] plugins = ["common-state/plugins"] persistent_world = [] +hot-reloading = ["common/hot-reloading"] default = ["worldgen", "plugins", "persistent_world", "simd"] diff --git a/world/src/block/mod.rs b/world/src/block/mod.rs index e0daa4194a..1c702e9e42 100644 --- a/world/src/block/mod.rs +++ b/world/src/block/mod.rs @@ -1,6 +1,6 @@ use crate::{ column::{ColumnGen, ColumnSample}, - util::{FastNoise, RandomField, Sampler, SmallCache}, + util::{FastNoise, RandomField, RandomPerm, Sampler, SmallCache}, IndexRef, }; use common::terrain::{ @@ -16,7 +16,7 @@ pub struct Colors { // TODO(@Sharp): After the merge, construct enough infrastructure to make it convenient to // define mapping functions over the input; i.e. we should be able to interpret some fields as // defining App, Arg>, where Fun : (Context, Arg) → (S, Type). - pub structure_blocks: structure::structure_block::PureCases>>, + pub structure_blocks: structure::structure_block::PureCases>>>, } pub struct BlockGen<'a> { @@ -289,10 +289,19 @@ pub fn block_from_structure( | StructureBlock::PalmLeavesInner | StructureBlock::PalmLeavesOuter | StructureBlock::Acacia - | StructureBlock::Mangrove => sblock - .elim_case_pure(&index.colors.block.structure_blocks) - .as_ref() - .map(|range| { + | StructureBlock::Mangrove => { + let ranges = sblock + .elim_case_pure(&index.colors.block.structure_blocks) + .as_ref() + .map(Vec::as_slice) + .unwrap_or(&[]); + let range = if ranges.len() == 0 { + None + } else { + ranges.get(RandomPerm::new(structure_seed).get(13) as usize % ranges.len()) + }; + + range.map(|range| { Block::new( BlockKind::Leaves, Rgb::::lerp( @@ -302,6 +311,7 @@ pub fn block_from_structure( ) .map(|e| e as u8), ) - }), + }) + }, } } diff --git a/world/src/layer/scatter.rs b/world/src/layer/scatter.rs index 1afc55bbfa..382722c643 100644 --- a/world/src/layer/scatter.rs +++ b/world/src/layer/scatter.rs @@ -151,6 +151,17 @@ pub fn apply_scatter_to(canvas: &mut Canvas, rng: &mut impl Rng) { None, ) }), + (Pumpkin, false, |c, _| { + ( + close(c.temp, CONFIG.temperate_temp, 0.5).min(close( + c.humidity, + CONFIG.forest_hum, + 0.5, + )) * MUSH_FACT + * 500.0, + Some((512.0, 0.05)), + ) + }), // Collectable Objects // Only spawn twigs in temperate forests (Twigs, false, |c, _| {