Struct base::world::chunk::Chunk [] [src]

pub struct Chunk {
    pub pillars: Vec<HexPillar>,
}

Represents one part of the game world.

A chunk saves CHUNK_SIZE² many hex pillars which are arranged rougly in the form of a parallelogram. See this blog post for more information (the shape is called "rhombus" there).

This type implements the Index trait and can be indexed with an AxialPoint.

Fields

pillars: Vec<HexPillar>

All pillars are layed out in this one dimensional vector which saves all rows (same r-value) consecutive.

Methods

impl Chunk
[src]

fn from_pillars(pillars: Vec<HexPillar>) -> Self

Creates a chunk from a Vec<HexPillar>

fn pillars(&self) -> ChunkPillars

fn get(&self, pos: AxialPoint) -> Option<&HexPillar>

Safer method to get through a chunk with an ìndex

fn get_mut(&mut self, pos: AxialPoint) -> Option<&mut HexPillar>

Safer method to get through a chunk with an ìndex

fn for_pillars_positions<F>(func: F) where F: FnMut(AxialPoint)

Calls the given closure with all pillar positions that are contained in a Chunk

fn with_pillars<F>(chunk_index: ChunkIndex, func: F) -> Chunk where F: FnMut(AxialPoint) -> HexPillar

Creates a Chunk using individual pillars returned by a closure

Trait Implementations

impl Debug for Chunk
[src]

fn fmt(&self, __arg_0: &mut Formatter) -> Result

Formats the value using the given formatter.

impl Index<AxialPoint> for Chunk
[src]

type Output = HexPillar

The returned type after indexing

fn index(&self, pos: AxialPoint) -> &Self::Output

The method for the indexing (Foo[Bar]) operation

impl IndexMut<AxialPoint> for Chunk
[src]

fn index_mut(&mut self, pos: AxialPoint) -> &mut Self::Output

The method for the indexing (Foo[Bar]) operation