diff --git a/godot/native/StateServer.tscn b/godot/native/StateServer.tscn index 1d4dbcd..b57c586 100644 --- a/godot/native/StateServer.tscn +++ b/godot/native/StateServer.tscn @@ -4,6 +4,3 @@ [node name="StateServer" type="Node"] script = ExtResource( 1 ) -xsize = 14 -ysize = 14 -zsize = 14 diff --git a/godot/native/libroutes_native.so b/godot/native/libroutes_native.so index f36158d..d080e0e 100755 Binary files a/godot/native/libroutes_native.so and b/godot/native/libroutes_native.so differ diff --git a/godot/world/StateApi.gd b/godot/world/StateApi.gd index 13c6ac4..46e53f8 100644 --- a/godot/world/StateApi.gd +++ b/godot/world/StateApi.gd @@ -1,7 +1,5 @@ extends Node - -var server = preload("res://native/StateServer.tscn").instance() +onready var server = $StateServer func _ready(): - add_child(server) - server.generate_world() + server.generate_world(1024,1024,512) diff --git a/godot/world/world.tscn b/godot/world/world.tscn index 0daaa35..d09a08b 100644 --- a/godot/world/world.tscn +++ b/godot/world/world.tscn @@ -1,6 +1,7 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://world/terrain/terrain.tres" type="TileSet" id=1] +[ext_resource path="res://native/StateServer.tscn" type="PackedScene" id=2] [ext_resource path="res://world/worldcam.gd" type="Script" id=3] [ext_resource path="res://world/StateApi.gd" type="Script" id=5] @@ -9,6 +10,8 @@ [node name="StateApi" type="Node" parent="."] script = ExtResource( 5 ) +[node name="StateServer" parent="StateApi" instance=ExtResource( 2 )] + [node name="TileMap" type="TileMap" parent="."] position = Vector2( -2, 0 ) mode = 1 diff --git a/routes-native/src/stateserver.rs b/routes-native/src/stateserver.rs index 900d79c..d8e0d19 100644 --- a/routes-native/src/stateserver.rs +++ b/routes-native/src/stateserver.rs @@ -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) { - builder.signal("jumpled").done(); builder .signal("changed_tile") .with_param("position", VariantType::Vector3) diff --git a/routes-native/src/stateserver/world.rs b/routes-native/src/stateserver/world.rs index f65500f..31fe30c 100644 --- a/routes-native/src/stateserver/world.rs +++ b/routes-native/src/stateserver/world.rs @@ -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 {