pub fn pillar_at_mut(&mut self, pos: PillarIndex) -> Option<&mut HexPillar> {
        let chunk_size = super::CHUNK_SIZE as i32;
        let mut new_pos = pos;
        // TODO: use `/` operator once it's implemented
        // let chunk_pos = pos / (super::CHUNK_SIZE as i32);
        if new_pos.0.q < 0 {
            new_pos.0.q -= 15;
        }
        if new_pos.0.r < 0 {
            new_pos.0.r -= 15;
        }
        let chunk_pos = new_pos.0 / chunk_size;
        let out = self.chunks.get_mut(&ChunkIndex(chunk_pos)).map(|chunk| {
            let mut inner_pos = pos.0 % chunk_size;
            if inner_pos.q < 0 {
                inner_pos.q += chunk_size;
            }
            if inner_pos.r < 0 {
                inner_pos.r += chunk_size;
            }
            if chunk_pos.q != chunk_pos.r {
                ::std::mem::swap(&mut inner_pos.r, &mut inner_pos.q);
            }
            &mut chunk[inner_pos]
        });

        if out.is_none() {
            debug!(
                "chunk {:?} is not loaded (position request {:?})",
                chunk_pos, pos
            );
        }
        out
    }
/// Returns the hex pillar at the given world position, iff the
/// corresponding chunk is loaded.
Returns the hex pillar at the given world position, iff the
corresponding chunk is loaded.
Returns the hex pillar at the given world position iff the corresponding chunk is loaded .
pub fn pillar_at_mut(&mut self, pos: PillarIndex) -> Option<&mut HexPillar> {
        let chunk_size = super::CHUNK_SIZE as i32;
        let mut new_pos = pos;
        // TODO: use `/` operator once it's implemented
        // let chunk_pos = pos / (super::CHUNK_SIZE as i32);
        if new_pos.0.q < 0 {
            new_pos.0.q -= 15;
        }
        if new_pos.0.r < 0 {
            new_pos.0.r -= 15;
        }
        let chunk_pos = new_pos.0 / chunk_size;
        let out = self.chunks.get_mut(&ChunkIndex(chunk_pos)).map(|chunk| {
            let mut inner_pos = pos.0 % chunk_size;
            if inner_pos.q < 0 {
                inner_pos.q += chunk_size;
            }
            if inner_pos.r < 0 {
                inner_pos.r += chunk_size;
            }
            if chunk_pos.q != chunk_pos.r {
                ::std::mem::swap(&mut inner_pos.r, &mut inner_pos.q);
            }
            &mut chunk[inner_pos]
        });
        if out.is_none() {
            debug!(
                "chunk {:?} is not loaded (position request {:?})",
                chunk_pos, pos
            );
        }
        out
    }
pub fn pillar_at_mut ( & mut self , pos : PillarIndex ) -> Option < & mut HexPillar > { let chunk_size = super :: CHUNK_SIZE as i32 ; let mut new_pos = pos ; // TODO: use `/` operator once it's implemented // let chunk_pos = pos / (super::CHUNK_SIZE as i32); if new_pos . 0 . q < 0 { new_pos . 0 . q -= 15 ; } if new_pos . 0 . r < 0 { new_pos . 0 . r -= 15 ; } let chunk_pos = new_pos . 0 / chunk_size ; let out = self . chunks . get_mut ( & ChunkIndex ( chunk_pos ) ) . map ( | chunk | { let mut inner_pos = pos . 0 % chunk_size ; if inner_pos . q < 0 { inner_pos . q += chunk_size ; } if inner_pos . r < 0 { inner_pos . r += chunk_size ; } if chunk_pos . q != chunk_pos . r { :: std :: mem :: swap ( & mut inner_pos . r , & mut inner_pos . q ) ; } & mut chunk [ inner_pos ] } ) ; if out . is_none ( ) { debug ! ( " " chunk_pos pos ) ; } out }
Returns the hex pillar at the given world position, iff the
corresponding chunk is loaded.
Returns the hex pillar at the given world position iff the corresponding chunk is loaded .
&mut self
pos
PillarIndex