This commit is contained in:
StephenAdamson
2025-01-21 21:02:40 +00:00
parent 53b95f452f
commit bb3905e6b9
3 changed files with 8 additions and 4 deletions
+2 -2
View File
@@ -200,7 +200,7 @@ pub fn citizen_movement(
fn is_valid_move(tilemap: &TileMap, pos: IVec3) -> bool {
// Check if the tile at current position is not blocking
if let Some(current_tile) = tilemap.floor_tiles.get(&pos) {
if current_tile.1 {
if current_tile.0 != 0 {
return false;
}
}
@@ -208,7 +208,7 @@ fn is_valid_move(tilemap: &TileMap, pos: IVec3) -> bool {
// Check if there's solid ground below
let pos_below = pos - IVec3::new(0, 0, 1);
if let Some(below_tile) = tilemap.floor_tiles.get(&pos_below) {
return below_tile.1;
return below_tile.0 != 0;
}
false
}
+1 -1
View File
@@ -54,7 +54,7 @@ fn main() {
tile::camera_z_movement,
tile::update_tile_visibility
.run_if(|camera_moved: Res<tile::CameraMoved>| camera_moved.0),
// log_fps_system,
log_fps_system,
),
)
.run();
+5 -1
View File
@@ -86,7 +86,7 @@ pub fn calculate_visibility(pos: IVec3, tilemap: &TileMap) -> [u32; 8] {
let mut is_occluded = false;
'vertical_check: for z_offset in 1..=35 {
'vertical_check: for z_offset in 1..5 {
let above_pos = IVec3::new(pos.x, pos.y, pos.z + (z_offset * tile_size));
if above_pos.z <= camera_z {
if let Some(&(_, opaque, _, _, _)) = tilemap.floor_tiles.get(&above_pos) {
@@ -95,6 +95,10 @@ pub fn calculate_visibility(pos: IVec3, tilemap: &TileMap) -> [u32; 8] {
break 'vertical_check;
}
}
if z_offset >= 4 {
is_occluded = true;
break 'vertical_check;
}
// if let Some(&(_, solid, _)) = tilemap.fixtures.get(&above_pos) {
// if solid {
// is_occluded = true;