pub struct Map {
pub pos: Vec2,
pub tiles: Vec<TileData>,
pub lower_buffer: Vec<MapVertex>,
pub upper_buffer: Vec<MapVertex>,
pub stores: [Index; 2],
pub orders: [DrawOrder; 2],
pub filled_tiles: [u16; 9],
pub tilesize: u32,
pub can_render: bool,
pub camera_type: CameraType,
pub changed: bool,
}Expand description
Handler for rendering Map to GPU.
Fields§
§pos: Vec2X, Y, GroupID for loaded map. Add this to the higher up Map struct. pub world_pos: Vec3, its render position. within the screen.
tiles: Vec<TileData>§lower_buffer: Vec<MapVertex>§upper_buffer: Vec<MapVertex>§stores: [Index; 2]Store index per each layer.
orders: [DrawOrder; 2]the draw order of the maps. created when update is called.
filled_tiles: [u16; 9]count if any Filled Tiles Exist. this is to optimize out empty maps in rendering.
tilesize: u32The size of the Tile to render. for spacing tiles out upon vertex creation. Default will be 20.
can_render: boolUsed to deturmine if the map can be rendered or if its just a preload.
camera_type: CameraType§changed: boolIf the position or a tile gets changed.
Implementations§
Source§impl Map
impl Map
Sourcepub fn create_quad(&mut self, renderer: &mut GpuRenderer, atlas: &mut AtlasSet)
pub fn create_quad(&mut self, renderer: &mut GpuRenderer, atlas: &mut AtlasSet)
Updates the Map’s Buffers to prepare them for rendering.
Sourcepub fn new(renderer: &mut GpuRenderer, tilesize: u32) -> Self
pub fn new(renderer: &mut GpuRenderer, tilesize: u32) -> Self
Creates a new Map with tilesize.
Sourcepub fn unload(&self, renderer: &mut GpuRenderer)
pub fn unload(&self, renderer: &mut GpuRenderer)
Unloades the Map’s buffer from the buffer store.
Sourcepub fn get_tile(&self, pos: (u32, u32, u32)) -> TileData
pub fn get_tile(&self, pos: (u32, u32, u32)) -> TileData
gets the TileData based upon the tiles x, y, and MapLayers.
MapLayers::Ground is Layer 0.
Sourcepub fn set_camera_type(&mut self, camera_type: CameraType)
pub fn set_camera_type(&mut self, camera_type: CameraType)
Sets the CameraType this object will use to Render with.
Sourcepub fn set_tile(&mut self, pos: (u32, u32, u32), tile: TileData)
pub fn set_tile(&mut self, pos: (u32, u32, u32), tile: TileData)
This sets the tile’s Id within the texture, layer within the texture array and Alpha for its transparency. This allows us to loop through the tiles Shader side efficiently.
Sourcepub fn update(
&mut self,
renderer: &mut GpuRenderer,
atlas: &mut AtlasSet,
) -> Option<Vec<OrderedIndex>>
pub fn update( &mut self, renderer: &mut GpuRenderer, atlas: &mut AtlasSet, ) -> Option<Vec<OrderedIndex>>
Used to check and update the Map’s Buffer for Rendering.
Returns an Optional vec![Lower, Upper] OrderedIndex to use in Rendering.
Auto Trait Implementations§
impl Freeze for Map
impl RefUnwindSafe for Map
impl Send for Map
impl Sync for Map
impl Unpin for Map
impl UnwindSafe for Map
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
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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 more