mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Cleaner solution.
This commit is contained in:
parent
f8d14bdfd5
commit
09525bf964
@ -55,44 +55,37 @@ pub struct WorldSim {
|
||||
|
||||
impl WorldSim {
|
||||
pub fn generate(mut seed: u32) -> Self {
|
||||
seed = seed_expan::diffuse(seed);
|
||||
let mut gen_seed = |seed: &mut u32| std::mem::replace(seed, seed_expan::diffuse(*seed + 1));
|
||||
let mut seed = &mut seed;
|
||||
let mut gen_seed = || {
|
||||
*seed = seed_expan::diffuse(*seed);
|
||||
*seed
|
||||
};
|
||||
|
||||
let mut gen_ctx = GenCtx {
|
||||
turb_x_nz: SuperSimplex::new().set_seed(gen_seed(&mut seed)),
|
||||
turb_y_nz: SuperSimplex::new().set_seed(gen_seed(&mut seed)),
|
||||
chaos_nz: RidgedMulti::new()
|
||||
.set_octaves(7)
|
||||
.set_seed(gen_seed(&mut seed)),
|
||||
hill_nz: SuperSimplex::new().set_seed(gen_seed(&mut seed)),
|
||||
turb_x_nz: SuperSimplex::new().set_seed(gen_seed()),
|
||||
turb_y_nz: SuperSimplex::new().set_seed(gen_seed()),
|
||||
chaos_nz: RidgedMulti::new().set_octaves(7).set_seed(gen_seed()),
|
||||
hill_nz: SuperSimplex::new().set_seed(gen_seed()),
|
||||
alt_nz: HybridMulti::new()
|
||||
.set_octaves(8)
|
||||
.set_persistence(0.1)
|
||||
.set_seed(gen_seed(&mut seed)),
|
||||
temp_nz: SuperSimplex::new().set_seed(gen_seed(&mut seed)),
|
||||
dry_nz: BasicMulti::new().set_seed(gen_seed(&mut seed)),
|
||||
small_nz: BasicMulti::new()
|
||||
.set_octaves(2)
|
||||
.set_seed(gen_seed(&mut seed)),
|
||||
rock_nz: HybridMulti::new()
|
||||
.set_persistence(0.3)
|
||||
.set_seed(gen_seed(&mut seed)),
|
||||
cliff_nz: HybridMulti::new()
|
||||
.set_persistence(0.3)
|
||||
.set_seed(gen_seed(&mut seed)),
|
||||
warp_nz: BasicMulti::new()
|
||||
.set_octaves(3)
|
||||
.set_seed(gen_seed(&mut seed)),
|
||||
.set_seed(gen_seed()),
|
||||
temp_nz: SuperSimplex::new().set_seed(gen_seed()),
|
||||
dry_nz: BasicMulti::new().set_seed(gen_seed()),
|
||||
small_nz: BasicMulti::new().set_octaves(2).set_seed(gen_seed()),
|
||||
rock_nz: HybridMulti::new().set_persistence(0.3).set_seed(gen_seed()),
|
||||
cliff_nz: HybridMulti::new().set_persistence(0.3).set_seed(gen_seed()),
|
||||
warp_nz: BasicMulti::new().set_octaves(3).set_seed(gen_seed()),
|
||||
tree_nz: BasicMulti::new()
|
||||
.set_octaves(12)
|
||||
.set_persistence(0.75)
|
||||
.set_seed(gen_seed(&mut seed)),
|
||||
cave_0_nz: SuperSimplex::new().set_seed(gen_seed(&mut seed)),
|
||||
cave_1_nz: SuperSimplex::new().set_seed(gen_seed(&mut seed)),
|
||||
.set_seed(gen_seed()),
|
||||
cave_0_nz: SuperSimplex::new().set_seed(gen_seed()),
|
||||
cave_1_nz: SuperSimplex::new().set_seed(gen_seed()),
|
||||
|
||||
structure_gen: StructureGen2d::new(gen_seed(&mut seed), 32, 24),
|
||||
region_gen: StructureGen2d::new(gen_seed(&mut seed), 400, 96),
|
||||
cliff_gen: StructureGen2d::new(gen_seed(&mut seed), 80, 56),
|
||||
structure_gen: StructureGen2d::new(gen_seed(), 32, 24),
|
||||
region_gen: StructureGen2d::new(gen_seed(), 400, 96),
|
||||
cliff_gen: StructureGen2d::new(gen_seed(), 80, 56),
|
||||
};
|
||||
|
||||
let mut chunks = Vec::new();
|
||||
@ -103,11 +96,11 @@ impl WorldSim {
|
||||
}
|
||||
|
||||
let mut this = Self {
|
||||
seed,
|
||||
seed: *seed,
|
||||
chunks,
|
||||
locations: Vec::new(),
|
||||
gen_ctx,
|
||||
rng: ChaChaRng::from_seed(seed_expan::rng_state(seed)),
|
||||
rng: ChaChaRng::from_seed(seed_expan::rng_state(*seed)),
|
||||
};
|
||||
|
||||
this.seed_elements();
|
||||
|
Loading…
Reference in New Issue
Block a user