resource: update block type code generator for Rust

This commit is contained in:
Matthias Schiffer 2023-02-07 22:09:14 +01:00
parent 6379472282
commit 718ecf5909
Signed by: neocturne
GPG key ID: 16EF3F64CB201D9C
6 changed files with 6399 additions and 12 deletions

View file

@ -1,3 +1,4 @@
pub mod io;
pub mod resource;
pub mod types;
pub mod world;

6327
src/resource/block_types.rs Normal file

File diff suppressed because it is too large Load diff

33
src/resource/mod.rs Normal file
View file

@ -0,0 +1,33 @@
mod block_types;
use std::collections::HashMap;
use enumflags2::{bitflags, BitFlags};
#[bitflags]
#[repr(u8)]
#[derive(Debug, Clone, Copy, PartialEq)]
pub enum BlockFlags {
Opaque,
Grass,
Foliage,
Birch,
Spruce,
Water,
}
#[derive(Debug, Clone, Copy)]
pub struct BlockColor(pub u8, pub u8, pub u8);
#[derive(Debug, Clone, Copy)]
pub struct BlockType {
pub flags: BitFlags<BlockFlags>,
pub color: BlockColor,
}
pub fn get_block_types() -> HashMap<String, BlockType> {
block_types::BLOCK_TYPES
.iter()
.map(|(k, v)| (String::from(*k), *v))
.collect()
}