Implement survival mode by caelunshun · Pull Request #214 · feather-rs/feather · GitHub
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 56 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Cargo.toml
3 changes: 2 additions & 1 deletion core/blocks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ authors = ["caelunshun <caelunshun@gmail.com>"]
edition = "2018"

[dependencies]
feather-definitions = { path = "../../definitions" }

bit-set = "0.5"
once_cell = { version = "1.3", features = ["parking_lot"] }
anyhow = "1.0"
thiserror = "1.0"
num-traits = "0.2"
num-derive = "0.3"
serde = { version = "1.0", features = ["derive"] }
bincode = "1.2"

Expand Down
4 changes: 1 addition & 3 deletions core/blocks/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,13 @@ fn main() {

let _ = std::fs::create_dir_all(base);

let kind = format!("{}/kind.rs", base);
let block_fns = format!("{}/block_fns.rs", base);
let table = format!("{}/table.rs", base);

write_to_file(&kind, &code.kind);
write_to_file(&block_fns, &code.block_fns);
write_to_file(&table, &code.block_table);

[kind, block_fns, table].iter().for_each(|path| {
[block_fns, table].iter().for_each(|path| {
Command::new("rustfmt").arg(path).output().unwrap();
});

Expand Down
20 changes: 0 additions & 20 deletions core/blocks/generator/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,6 @@ enum PropertyKind {

#[derive(Debug, Default)]
pub struct Output {
pub kind: String,
pub block_fns: String,
pub block_table: String,
pub block_table_serialized: Vec<u8>,
Expand All @@ -247,7 +246,6 @@ pub fn generate() -> anyhow::Result<Output> {

let mut output = Output::default();

output.kind.push_str(&generate_kind(&blocks).to_string());
let table_src = generate_table(&blocks);
output.block_table.push_str(&table_src.to_string());
let block_fns_src = generate_block_fns(&blocks);
Expand All @@ -259,24 +257,6 @@ pub fn generate() -> anyhow::Result<Output> {
Ok(output)
}

/// Generates the `BlockKind` enum.
fn generate_kind(blocks: &Blocks) -> TokenStream {
let mut variants = vec![];

for block in &blocks.blocks {
let name = &block.name_camel_case;
variants.push(quote! { #name });
}

quote! {
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ToPrimitive, FromPrimitive)]
#[repr(u16)]
pub enum BlockKind {
#(#variants,)*
}
}
}

/// Generates the `BlockTable` struct and its implementation.
fn generate_table(blocks: &Blocks) -> TokenStream {
let mut fields = vec![];
Expand Down
10 changes: 1 addition & 9 deletions core/blocks/src/categories.rs
Loading