mirror of
https://codeberg.org/icewind/sourcenav.git
synced 2026-06-03 10:14:11 +02:00
expose all nav areas
This commit is contained in:
parent
37f764e48e
commit
95fd2d4da3
3 changed files with 29 additions and 1 deletions
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "sourcenav"
|
name = "sourcenav"
|
||||||
version = "0.1.0"
|
version = "0.1.1"
|
||||||
authors = ["Robin Appelman <robin@icewind.nl>"]
|
authors = ["Robin Appelman <robin@icewind.nl>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
description = "parsing of SourceEngine .nav files"
|
description = "parsing of SourceEngine .nav files"
|
||||||
|
|
|
||||||
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]
|
#[test]
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
use aabb_quadtree::Spatial;
|
use aabb_quadtree::Spatial;
|
||||||
use bitbuffer::{BitRead, BitReadStream, Endianness, ReadError};
|
use bitbuffer::{BitRead, BitReadStream, Endianness, ReadError};
|
||||||
use euclid::{TypedPoint2D, TypedRect, TypedSize2D};
|
use euclid::{TypedPoint2D, TypedRect, TypedSize2D};
|
||||||
|
use std::fmt;
|
||||||
|
use std::fmt::Debug;
|
||||||
use std::ops::Index;
|
use std::ops::Index;
|
||||||
|
|
||||||
/// A 3 dimensional coordinate
|
/// A 3 dimensional coordinate
|
||||||
|
|
@ -11,6 +13,12 @@ pub struct Vector3(pub f32, pub f32, pub f32);
|
||||||
#[derive(Debug, BitRead, Clone, Copy, Eq, PartialEq)]
|
#[derive(Debug, BitRead, Clone, Copy, Eq, PartialEq)]
|
||||||
pub struct NavAreaId(u32);
|
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
|
/// A navigation area from the nav file
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct NavArea {
|
pub struct NavArea {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue