Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coords can't be changed after creation #66

Merged
merged 1 commit into from
Sep 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading