pub struct MapScale { /* private fields */ }Expand description
World units per raw unit of a campaign map, horizontally and vertically.
Implementations§
Source§impl MapScale
impl MapScale
Sourcepub fn new(cells: (u32, u32), world_size: (f32, f32)) -> Self
pub fn new(cells: (u32, u32), world_size: (f32, f32)) -> Self
Returns the scale of a map.
§Arguments
cells- Columns and rows of the map’s hex grid.world_size- Size of the map in world units.
Sourcepub fn cell_at(&self, x: f32, y: f32) -> HexCell
pub fn cell_at(&self, x: f32, y: f32) -> HexCell
Returns the cell containing a world position, as the game finds it.
Odd columns are shifted half a cell down, so their rows start half a cell height later. Cells are hexagons wider than their column: the first third of a column holds the slanted edges shared with the previous column, where positions above or below the edge belong to the previous column’s cells.
Sourcepub fn world_position(&self, cell: HexCell) -> (f32, f32)
pub fn world_position(&self, cell: HexCell) -> (f32, f32)
Returns the world position of a cell’s top-left corner, where the game places characters given by cell.
The game multiplies in double precision by single precision scales, and adds the half-cell shift of odd columns as a separate single precision term, so the position is computed the same way.
Sourcepub fn world_to_raw(&self, x: f32, y: f32) -> (f32, f32)
pub fn world_to_raw(&self, x: f32, y: f32) -> (f32, f32)
Converts a world position to raw map units.
Trait Implementations§
impl Copy for MapScale
impl StructuralPartialEq for MapScale
Auto Trait Implementations§
impl Freeze for MapScale
impl RefUnwindSafe for MapScale
impl Send for MapScale
impl Sync for MapScale
impl Unpin for MapScale
impl UnsafeUnpin for MapScale
impl UnwindSafe for MapScale
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.