mirror of
https://git.kittycat.homes/zoe/codename-routes.git
synced 2024-08-15 03:18:26 +00:00
placing tiles kinda works now
This commit is contained in:
parent
25acc57024
commit
c65f7a994c
8 changed files with 89 additions and 29 deletions
|
@ -59,9 +59,9 @@ impl StateServer {
|
|||
}
|
||||
|
||||
#[export]
|
||||
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
|
||||
fn put_tile_at(&mut self, _owner: &Node, x: usize, y: usize, z: usize, id: usize) {
|
||||
let changed = self.world.put_tile_at(x, y, z, id);
|
||||
_owner.emit_signal("changed_tiletypes", &[Variant::new(&changed)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -90,22 +90,26 @@ impl World {
|
|||
positions
|
||||
}
|
||||
|
||||
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;
|
||||
pub fn put_tile_at(&mut self, x: usize, y: usize, z: usize, id: usize) -> Vector3Array {
|
||||
let mut changed = Vector3Array::new();
|
||||
|
||||
if !self.can_put_tile_at(x, y, z, id) {
|
||||
return changed;
|
||||
}
|
||||
|
||||
self.tiles[x][y][z] = tiles::Tiletypes::from_repr(id as u8).unwrap();
|
||||
true
|
||||
changed.push(Vector3::new(x as f32, y as f32, z as f32));
|
||||
|
||||
changed
|
||||
}
|
||||
|
||||
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{
|
||||
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
|
||||
}
|
||||
|
||||
|
||||
pub fn new(xsize: usize, ysize: usize, zsize: usize) -> World {
|
||||
World {
|
||||
xsize,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue