start work on placing tiles
This commit is contained in:
parent
13ae90769b
commit
2a47a75b91
Binary file not shown.
|
@ -0,0 +1,3 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
enum ACTIVE {PLACE}
|
|
@ -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/StateApi.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://world/Cam.tscn" type="PackedScene" id=2]
|
[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]
|
[ext_resource path="res://world/Tilemaps.gd" type="Script" id=4]
|
||||||
|
|
||||||
[node name="World" type="Node"]
|
[node name="World" type="Node"]
|
||||||
|
@ -11,3 +12,6 @@ script = ExtResource( 1 )
|
||||||
|
|
||||||
[node name="Tilemaps" type="Node" parent="."]
|
[node name="Tilemaps" type="Node" parent="."]
|
||||||
script = ExtResource( 4 )
|
script = ExtResource( 4 )
|
||||||
|
|
||||||
|
[node name="Tools" type="Node2D" parent="."]
|
||||||
|
script = ExtResource( 3 )
|
||||||
|
|
|
@ -59,8 +59,9 @@ impl StateServer {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[export]
|
#[export]
|
||||||
fn put_tile_at(&mut self, _owner: &Node, x: usize, y: usize, z: usize, id: usize){
|
fn put_tile_at(&mut self, _owner: &Node, x: usize, y: usize, z: usize, id: usize) -> bool{
|
||||||
self.world.put_tile_at(x, y, z, id);
|
let success = self.world.put_tile_at(x, y, z, id);
|
||||||
|
success
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -90,11 +90,18 @@ impl World {
|
||||||
positions
|
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{
|
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
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue