Skip to content

Commit

Permalink
Coords can't be changed after creation
Browse files Browse the repository at this point in the history
  • Loading branch information
mockersf committed Sep 21, 2024
1 parent f4366a4 commit 8b89dad
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ pub struct Mesh {
#[derive(Debug, PartialEq, Clone, Copy)]
pub struct Coords {
/// The position
pub pos: Vec2,
pos: Vec2,
/// The layer
///
/// If specified, the point will be searched in that layer only.
pub layer: Option<u8>,
layer: Option<u8>,
/// internal: this coords have been built by a search on the mesh that found the polygon index
/// if used for a path, this will be used directly instead of searching for it again in the mesh
/// default value is u32::MAX which means it hasn't been searched
Expand All @@ -105,6 +105,11 @@ impl From<Vec2> for Coords {
}

impl Coords {
/// A point on the navigation mesh
pub fn on_mesh(pos: Vec2) -> Self {
pos.into()
}

/// A point on the navigation mesh on the specified layer
pub fn on_layer(pos: Vec2, layer: u8) -> Self {
Coords {
Expand All @@ -113,6 +118,16 @@ impl Coords {
polygon_index: u32::MAX,
}
}

/// Position of this point
pub fn position(&self) -> Vec2 {
self.pos
}

/// Layer of this point, if known
pub fn layer(&self) -> Option<u8> {
self.layer
}
}

impl Display for Coords {
Expand Down

0 comments on commit 8b89dad

Please sign in to comment.