This repository has been archived by the owner on Sep 19, 2022. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #41 from amethyst/fog-of-vision
Fog of vision implementation
- Loading branch information
Showing
7 changed files
with
44 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
use crate::*; | ||
|
||
/// Sets which tiles are visible. | ||
pub fn fog_of_vision_system( | ||
collision_res: &Option<CollisionResource>, | ||
sights: &Components<LineOfSight>, | ||
viewshed: &mut Viewshed, | ||
positions: &mut Components<Point>, | ||
) -> SystemResult { | ||
viewshed.visible_tiles.clear(); | ||
for (sight, pos) in join!(&sights && &positions).map(|(s, p)| (s.unwrap(), p.unwrap())) { | ||
if let Some(col_res) = collision_res { | ||
let map = &col_res.map; | ||
viewshed | ||
.visible_tiles | ||
.extend(field_of_view(*pos, sight.range, map)); | ||
viewshed.visible_tiles.retain(|p| { | ||
p.x >= 0 && p.x < (map.size().0 as i32) && p.y >= 0 && p.y < (map.size().1 as i32) | ||
}); | ||
} | ||
} | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters