mirror of
https://git.kittycat.homes/zoe/codename-routes.git
synced 2024-08-15 03:18:26 +00:00
clean up generation
This commit is contained in:
parent
8a98462f69
commit
cf27ccca4b
3 changed files with 11 additions and 9 deletions
Binary file not shown.
|
@ -1,5 +1,7 @@
|
|||
use gdnative::prelude::*;
|
||||
|
||||
use self::gen::GameRng;
|
||||
|
||||
mod saves;
|
||||
mod world;
|
||||
mod gen;
|
||||
|
@ -8,6 +10,7 @@ mod gen;
|
|||
#[inherit(Node)]
|
||||
#[register_with(Self::register)]
|
||||
pub struct StateServer {
|
||||
rng: GameRng,
|
||||
world: world::World,
|
||||
}
|
||||
|
||||
|
@ -15,7 +18,8 @@ pub struct StateServer {
|
|||
impl StateServer {
|
||||
fn new(_owner: &Node) -> Self {
|
||||
StateServer {
|
||||
world: world::World::new(0, 0, 0, gen::get_rng("seed".to_string())),
|
||||
world: world::World::new(0, 0, 0),
|
||||
rng: gen::get_rng("seed".to_string())
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -34,8 +38,9 @@ impl StateServer {
|
|||
|
||||
#[export]
|
||||
fn generate_world(&mut self, _owner: &Node, xsize: usize, ysize: usize, zsize: usize, seed: String) {
|
||||
self.world = world::World::new(xsize, ysize, zsize, gen::get_rng(seed));
|
||||
let w = self.world.generate();
|
||||
self.rng = gen::get_rng(seed);
|
||||
self.world = world::World::new(xsize, ysize, zsize);
|
||||
let w = self.world.generate(&mut self.rng);
|
||||
_owner.emit_signal("request_init", &[]);
|
||||
_owner.emit_signal("changed_tiletypes", &[Variant::new(&w)]);
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ use gdnative::prelude::*;
|
|||
|
||||
use self::gen::GameRng;
|
||||
|
||||
|
||||
mod gen;
|
||||
mod tiles;
|
||||
|
||||
|
@ -11,7 +10,6 @@ pub struct World {
|
|||
pub ysize: usize,
|
||||
pub zsize: usize,
|
||||
tiles: Vec<Vec<Vec<tiles::Tiletypes>>>,
|
||||
rng: GameRng,
|
||||
attributes: tiles::Attributelists,
|
||||
}
|
||||
|
||||
|
@ -32,9 +30,9 @@ impl World {
|
|||
true
|
||||
}
|
||||
|
||||
pub fn generate(&mut self) -> Vector3Array {
|
||||
pub fn generate(&mut self, rng: &mut GameRng) -> Vector3Array {
|
||||
self.tiles = get_vec3(self.xsize, self.ysize, self.zsize);
|
||||
let noisemap = gen::get_noise(&mut self.rng, (self.xsize, self.ysize));
|
||||
let noisemap = gen::get_noise(rng, (self.xsize, self.ysize));
|
||||
|
||||
let mut ret: Vector3Array = Vector3Array::new();
|
||||
for x in 0..self.xsize {
|
||||
|
@ -92,13 +90,12 @@ impl World {
|
|||
positions
|
||||
}
|
||||
|
||||
pub fn new(xsize: usize, ysize: usize, zsize: usize, rng: GameRng) -> World {
|
||||
pub fn new(xsize: usize, ysize: usize, zsize: usize) -> World {
|
||||
World {
|
||||
xsize,
|
||||
ysize,
|
||||
zsize,
|
||||
tiles: get_vec3(xsize, ysize, zsize),
|
||||
rng,
|
||||
attributes: tiles::Attributelists::new(),
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue