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

Returns true if there’s a wall at the given coordinates.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Deserialize this value from the given Serde deserializer. Read more

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.