pub struct Chunk {
pub walls: Vec<Option<TileIndex>>,
pub floors: Vec<Option<TileIndex>>,
pub spawns: Vec<Point>,
pub pcs: HashMap<PcHandle, PlayerCharacter>,
}
Expand description
Contains the map tiles, spawn points (if any), and player characters for a limited area in the game.
Chunks are the main level of granularity within the game: each Chunk can be updated independently, and when players move between chunks, they get removed from one and added to the other, so that players are always in one specific chunk.
Fields
walls: Vec<Option<TileIndex>>
The wall layer of this chunk. Walls block movement. The Vec contains
CHUNK_WIDTH × CHUNK_HEIGHT elements. The tile for coordinates X and
Y can be found at index X + Y * CHUNK_WIDTH
. The value is None if
there’s no wall at the given position.
floors: Vec<Option<TileIndex>>
The floor layer of this chunk. The Vec contains CHUNK_WIDTH ×
CHUNK_HEIGHT elements. The tile for coordinates X and Y can be found
at index X + Y * CHUNK_WIDTH
. The value is None if there’s just
empty floor at the given position.
spawns: Vec<Point>
The list of points in this Chunk where a player can be spawned when they’re initially added into the world.
pcs: HashMap<PcHandle, PlayerCharacter>
The player characters in this chunk.
Implementations
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Chunk
impl<'de> Deserialize<'de> for Chunk
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations
impl RefUnwindSafe for Chunk
impl Send for Chunk
impl Sync for Chunk
impl Unpin for Chunk
impl UnwindSafe for Chunk
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more