ck3-regions 0.0.5

Generates title-based region textures for use with the custom dynamic terrain shader system implemented in some CK3 mods.
Documentation
use std::collections::HashSet;

use grid::Grid;

use super::EXPECT_WAVE_GRID_BOUNDS;

//
// pub trait VisitedCoordsTracker
//

pub trait VisitedCoordsTracker {
    fn mark_visited_coords(&mut self, coords: (u32, u32));

    fn has_visited_coords(&self, coords: &(u32, u32)) -> bool;
}

// Foreign impls

impl VisitedCoordsTracker for HashSet<(u32, u32)> {
    fn mark_visited_coords(&mut self, coords: (u32, u32)) {
        self.insert(coords);
    }

    fn has_visited_coords(&self, coords: &(u32, u32)) -> bool {
        self.contains(coords)
    }
}

impl VisitedCoordsTracker for Grid<bool> {
    fn mark_visited_coords(&mut self, coords: (u32, u32)) {
        let cell = self.get_mut(coords.1 as usize, coords.0 as usize)
            .expect(EXPECT_WAVE_GRID_BOUNDS);

        *cell = true
    }

    fn has_visited_coords(&self, coords: &(u32, u32)) -> bool {
        *self.get(coords.1 as usize, coords.0 as usize)
            .expect(EXPECT_WAVE_GRID_BOUNDS)
    }
}