diff --git a/godot/native/libroutes_native.so b/godot/native/libroutes_native.so index 28240ad..66aec21 100755 Binary files a/godot/native/libroutes_native.so and b/godot/native/libroutes_native.so differ diff --git a/godot/world/Tools.gd b/godot/world/Tools.gd new file mode 100644 index 0000000..7929d38 --- /dev/null +++ b/godot/world/Tools.gd @@ -0,0 +1,3 @@ +extends Node2D + +enum ACTIVE {PLACE} diff --git a/godot/world/World.tscn b/godot/world/World.tscn index 93f171c..22be848 100644 --- a/godot/world/World.tscn +++ b/godot/world/World.tscn @@ -1,7 +1,8 @@ -[gd_scene load_steps=4 format=2] +[gd_scene load_steps=5 format=2] [ext_resource path="res://world/StateApi.gd" type="Script" id=1] [ext_resource path="res://world/Cam.tscn" type="PackedScene" id=2] +[ext_resource path="res://world/Tools.gd" type="Script" id=3] [ext_resource path="res://world/Tilemaps.gd" type="Script" id=4] [node name="World" type="Node"] @@ -11,3 +12,6 @@ script = ExtResource( 1 ) [node name="Tilemaps" type="Node" parent="."] script = ExtResource( 4 ) + +[node name="Tools" type="Node2D" parent="."] +script = ExtResource( 3 ) diff --git a/routes-native/src/stateserver.rs b/routes-native/src/stateserver.rs index 28b3110..077a7ee 100644 --- a/routes-native/src/stateserver.rs +++ b/routes-native/src/stateserver.rs @@ -59,8 +59,9 @@ impl StateServer { } #[export] - fn put_tile_at(&mut self, _owner: &Node, x: usize, y: usize, z: usize, id: usize){ - self.world.put_tile_at(x, y, z, id); + fn put_tile_at(&mut self, _owner: &Node, x: usize, y: usize, z: usize, id: usize) -> bool{ + let success = self.world.put_tile_at(x, y, z, id); + success } } diff --git a/routes-native/src/stateserver/world.rs b/routes-native/src/stateserver/world.rs index c36e6ed..6da4eb2 100644 --- a/routes-native/src/stateserver/world.rs +++ b/routes-native/src/stateserver/world.rs @@ -90,11 +90,18 @@ impl World { positions } - pub fn put_tile_at(&mut self, x: usize, y: usize, z: usize, id: usize){ - + pub fn put_tile_at(&mut self, x: usize, y: usize, z: usize, id: usize) -> bool{ + if !self.can_put_tile_at(x, y, z, id){ + return false; + } + self.tiles[x][y][z] = tiles::Tiletypes::from_repr(id as u8).unwrap(); + true } pub fn can_put_tile_at(&self, x: usize, y: usize, z: usize, id: usize) -> bool{ + if self.tiles[x][y][z] == tiles::Tiletypes::Air{ + return true; + } false }