fucking signals, how do they work

This commit is contained in:
Zoe 2022-05-04 14:10:28 +02:00
parent bcd4a1b031
commit 9d9348faca
6 changed files with 10 additions and 16 deletions

View file

@ -39,8 +39,8 @@ impl StateServer {
}
#[export]
fn generate_world(&self, _owner: &Node) {
let mut new_world = world::World::new(3, 3, 3);
fn generate_world(&self, _owner: &Node, xsize: usize, ysize: usize, zsize: usize) {
let mut new_world = world::World::new(xsize, ysize, zsize);
new_world.generate();
}
}
@ -48,7 +48,6 @@ impl StateServer {
// signals
impl StateServer {
fn register(builder: &ClassBuilder<StateServer>) {
builder.signal("jumpled").done();
builder
.signal("changed_tile")
.with_param("position", VariantType::Vector3)

View file

@ -11,18 +11,15 @@ pub struct World {
impl World {
pub fn generate(&mut self) {
let mut tiles = get_vec3(self.xsize, self.ysize, self.zsize);
godot_print!("{:#?}", tiles);
self.tiles = get_vec3(self.xsize, self.ysize, self.zsize);
for x in 0..self.xsize {
for y in 0..self.ysize {
for z in 0..self.zsize {
let tile = tiles::Tile::new(tiles::Tiletypes::Dirt);
tiles[x][y][z] = tile;
self.tiles[x][y][z] = tile;
}
}
}
self.tiles = tiles;
godot_print!("{:?}", self.tiles);
}
pub fn new(xsize: usize, ysize: usize, zsize: usize) -> World {
World {