pub struct VisionGrid { /* private fields */ }Expand description
The vision grid of a campaign map.
Implementations§
Source§impl VisionGrid
impl VisionGrid
Sourcepub fn new(world_size: (f32, f32)) -> Self
pub fn new(world_size: (f32, f32)) -> Self
Creates the vision grid of a map of the given size in world units.
Sourcepub fn dimensions(&self) -> (u32, u32, u32)
pub fn dimensions(&self) -> (u32, u32, u32)
Returns the columns, rows and quad tree side, as the QUAD_TREE_BIT_ARRAY records store them.
Sourcepub fn cell_at(&self, position: (f32, f32)) -> (u32, u32)
pub fn cell_at(&self, position: (f32, f32)) -> (u32, u32)
Returns the cell containing a world position.
Sourcepub fn cell_position(&self, cell: (u32, u32)) -> (f32, f32)
pub fn cell_position(&self, cell: (u32, u32)) -> (f32, f32)
Returns the world position of a cell’s corner closest to the origin: the cell times the map size, over the cells of the grid. This gives the game’s floats horizontally, and vertically in 3 of 4 cases.
Sourcepub fn disk(&self, position: (f32, f32), radius: f32) -> Vision
pub fn disk(&self, position: (f32, f32), radius: f32) -> Vision
Returns what a character sees: the cells within its sight radius around its cell, counting the radius in
horizontal cells. A cell (dx, dy) away is in if dx² + dy² <= r * (r + 1).
Sourcepub fn around(&self, positions: &[(f32, f32)], radius: f32) -> Vision
pub fn around(&self, positions: &[(f32, f32)], radius: f32) -> Vision
Returns the cells whose centre is within a radius of any of the given world positions.
Sourcepub fn cells_where(
&self,
min: (f32, f32),
max: (f32, f32),
keep: impl FnMut((f32, f32)) -> bool,
) -> (Vision, WorldBounds)
pub fn cells_where( &self, min: (f32, f32), max: (f32, f32), keep: impl FnMut((f32, f32)) -> bool, ) -> (Vision, WorldBounds)
Returns the cells of a world rectangle whose corner closest to the origin passes a test. The rectangle is snapped outwards to the grid, as the game does.
§Arguments
min- Corner of the rectangle closest to the origin.max- Opposite corner of the rectangle.keep- Test on the world position of each cell’s corner.
§Returns
The area, and the world bounds of the snapped rectangle.
Trait Implementations§
Source§impl Clone for VisionGrid
impl Clone for VisionGrid
Source§fn clone(&self) -> VisionGrid
fn clone(&self) -> VisionGrid
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for VisionGrid
Source§impl Debug for VisionGrid
impl Debug for VisionGrid
Source§impl PartialEq for VisionGrid
impl PartialEq for VisionGrid
impl StructuralPartialEq for VisionGrid
Auto Trait Implementations§
impl Freeze for VisionGrid
impl RefUnwindSafe for VisionGrid
impl Send for VisionGrid
impl Sync for VisionGrid
impl Unpin for VisionGrid
impl UnsafeUnpin for VisionGrid
impl UnwindSafe for VisionGrid
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreimpl<T> MaybeSend for T
impl<T> MaybeSync for T
§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
impl<T> Scalar for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.