mirror of
https://codeberg.org/icewind/sourcenav.git
synced 2026-06-03 18:24:10 +02:00
expose all nav areas
This commit is contained in:
parent
37f764e48e
commit
95fd2d4da3
3 changed files with 29 additions and 1 deletions
20
src/lib.rs
20
src/lib.rs
|
|
@ -113,6 +113,26 @@ impl NavTree {
|
|||
}
|
||||
})
|
||||
}
|
||||
|
||||
/// Get all navigation areas from the nav file
|
||||
///
|
||||
/// ## Examples
|
||||
///
|
||||
/// ```no_run
|
||||
/// use sourcenav::get_area_tree;
|
||||
///
|
||||
/// # fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
/// let file = std::fs::read("path/to/navfile.nav")?;
|
||||
/// let tree = get_area_tree(file)?;
|
||||
/// for area in tree.areas() {
|
||||
/// println!("area: {}", area.id)
|
||||
/// }
|
||||
/// # Ok(())
|
||||
/// # }
|
||||
/// ```
|
||||
pub fn areas(&self) -> impl Iterator<Item = &NavArea> {
|
||||
self.0.iter().map(|(_, (area, _))| area)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
use aabb_quadtree::Spatial;
|
||||
use bitbuffer::{BitRead, BitReadStream, Endianness, ReadError};
|
||||
use euclid::{TypedPoint2D, TypedRect, TypedSize2D};
|
||||
use std::fmt;
|
||||
use std::fmt::Debug;
|
||||
use std::ops::Index;
|
||||
|
||||
/// A 3 dimensional coordinate
|
||||
|
|
@ -11,6 +13,12 @@ pub struct Vector3(pub f32, pub f32, pub f32);
|
|||
#[derive(Debug, BitRead, Clone, Copy, Eq, PartialEq)]
|
||||
pub struct NavAreaId(u32);
|
||||
|
||||
impl fmt::Display for NavAreaId {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
fmt::Display::fmt(&self.0, f)
|
||||
}
|
||||
}
|
||||
|
||||
/// A navigation area from the nav file
|
||||
#[derive(Debug)]
|
||||
pub struct NavArea {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue