dont render tiles that are hidden
This commit is contained in:
parent
5b58f246a0
commit
1de09f7014
Binary file not shown.
|
@ -21,8 +21,9 @@ func get_tile_at(pos: Vector3) -> String:
|
||||||
|
|
||||||
func update_tiles(tile_positions: PoolVector3Array):
|
func update_tiles(tile_positions: PoolVector3Array):
|
||||||
for tile in tile_positions:
|
for tile in tile_positions:
|
||||||
tilemaps[tile.z].set_tile_graphics(Vector2(tile.x, tile.y),
|
if !StateServer.is_tile_hidden(int(tile.x), int(tile.y), int(tile.z)):
|
||||||
get_tile_at(tile))
|
tilemaps[tile.z].set_tile_graphics(Vector2(tile.x, tile.y),
|
||||||
|
get_tile_at(tile))
|
||||||
|
|
||||||
func _on_StateServer_request_init():
|
func _on_StateServer_request_init():
|
||||||
call_deferred("respawn_tilemaps")
|
call_deferred("respawn_tilemaps")
|
||||||
|
|
|
@ -48,6 +48,11 @@ impl StateServer {
|
||||||
fn get_tile_at(&self, _owner: &Node, x: usize, y: usize, z: usize) -> u16 {
|
fn get_tile_at(&self, _owner: &Node, x: usize, y: usize, z: usize) -> u16 {
|
||||||
self.world.get_tile_at(x, y, z)
|
self.world.get_tile_at(x, y, z)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[export]
|
||||||
|
fn is_tile_hidden(&self, _owner: &Node, x: usize, y: usize, z: usize) -> bool{
|
||||||
|
self.world.is_tile_hidden(x, y, z)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// signals
|
// signals
|
||||||
|
|
|
@ -14,6 +14,13 @@ impl World {
|
||||||
//TODO: error handling, or maybe just do that in godot
|
//TODO: error handling, or maybe just do that in godot
|
||||||
self.tiles[x][y][z] as u16
|
self.tiles[x][y][z] as u16
|
||||||
}
|
}
|
||||||
|
pub fn is_tile_hidden(&self, x: usize, y: usize, z: usize) -> bool{
|
||||||
|
if x == self.xsize - 1 || y == self.ysize -1 || z == self.zsize - 1{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
pub fn generate(&mut self) -> Vector3Array{
|
pub fn generate(&mut self) -> Vector3Array{
|
||||||
self.tiles = get_vec3(self.xsize, self.ysize, self.zsize);
|
self.tiles = get_vec3(self.xsize, self.ysize, self.zsize);
|
||||||
let mut ret: Vector3Array = Vector3Array::new();
|
let mut ret: Vector3Array = Vector3Array::new();
|
||||||
|
|
|
@ -23,6 +23,12 @@ pub struct Tile {
|
||||||
can_be_above: Vec<Tiletypes>,
|
can_be_above: Vec<Tiletypes>,
|
||||||
#[builder(default = "vec![]")]
|
#[builder(default = "vec![]")]
|
||||||
can_be_next_to: Vec<Tiletypes>,
|
can_be_next_to: Vec<Tiletypes>,
|
||||||
|
#[builder(default = "true")]
|
||||||
|
hide_top_left: bool,
|
||||||
|
#[builder(default = "true")]
|
||||||
|
hide_top_right: bool,
|
||||||
|
#[builder(default = "true")]
|
||||||
|
hide_below: bool,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Tile {
|
impl Tile {
|
||||||
|
|
Loading…
Reference in New Issue