diff --git a/factorio-blueprint-generator/src/bin/station.rs b/factorio-blueprint-generator/src/bin/station.rs index b159036..e4d4895 100644 --- a/factorio-blueprint-generator/src/bin/station.rs +++ b/factorio-blueprint-generator/src/bin/station.rs @@ -1,6 +1,6 @@ use clap::{Parser, Subcommand}; use factorio_blueprint::{BlueprintBook, BlueprintBookEntry, BlueprintString, encode}; -use factorio_blueprint_generator::station::basic_unload_station; +use factorio_blueprint_generator::station::basic_station; use factorio_core::beltoptions::{Beltspeed, Belttype}; #[derive(Parser)] @@ -13,6 +13,7 @@ struct Args { enum Command { Book, Single { + load: bool, locomotives: usize, length: usize, outputs: usize, @@ -41,27 +42,31 @@ fn main() { ]; for (i, (locomotives, cargo)) in layouts.into_iter().enumerate() { - let mut inner_b = Vec::new(); + for load in [false, true] { + let mut inner_b = Vec::new(); - let mut j = 0; - for beltspeed in [ - Beltspeed::Normal, - Beltspeed::Fast, - Beltspeed::Express, - Beltspeed::Turbo, - ] { - let belttypes: &[_] = match beltspeed { - Beltspeed::Normal => &[Belttype::Full, Belttype::Left, Belttype::Right], - _ => &[Belttype::Full], - }; - for &belttype in belttypes { + for (j, beltspeed) in [ + Beltspeed::Normal, + Beltspeed::Fast, + Beltspeed::Express, + Beltspeed::Turbo, + ] + .into_iter() + .enumerate() + { let mut inner_inner_b = Vec::new(); for (l, o) in (0..=(cargo as u32).ilog2()).enumerate() { let o = 1 << o; - let blueprint = - basic_unload_station(locomotives, cargo, o, beltspeed, belttype); + let blueprint = basic_station( + load, + locomotives, + cargo, + o, + beltspeed, + Belttype::Full, + ); inner_inner_b.push(BlueprintBookEntry::new( BlueprintString::Blueprint(blueprint), @@ -74,25 +79,27 @@ fn main() { BlueprintBook::builder() .blueprints(inner_inner_b) .active_index(0) - .label(format!("{:?}-{:?}", beltspeed, belttype)) + .label(format!("{:?}", beltspeed)) .build(), ), - j, + j as u32, )); - j += 1; } - } - b.push(BlueprintBookEntry::new( - BlueprintString::BlueprintBook( - BlueprintBook::builder() - .blueprints(inner_b) - .active_index(0) - .label(format!("{locomotives}-{cargo}")) - .build(), - ), - i as u32, - )); + b.push(BlueprintBookEntry::new( + BlueprintString::BlueprintBook( + BlueprintBook::builder() + .blueprints(inner_b) + .active_index(0) + .label(format!("{locomotives}-{cargo}-{}", match load { + true => "load", + false => "unload", + })) + .build(), + ), + 2 * i as u32 + load as u32, + )); + } } let b = BlueprintString::BlueprintBook( @@ -105,13 +112,15 @@ fn main() { println!("{}", encode(&serde_json::to_string(&b).unwrap())); } Command::Single { + load, locomotives, length, outputs, beltspeed, belttype, } => { - let b = BlueprintString::Blueprint(basic_unload_station( + let b = BlueprintString::Blueprint(basic_station( + load, locomotives, length, outputs, diff --git a/factorio-blueprint-generator/src/binary_merger.rs b/factorio-blueprint-generator/src/binary_merger.rs new file mode 100644 index 0000000..9dc1b22 --- /dev/null +++ b/factorio-blueprint-generator/src/binary_merger.rs @@ -0,0 +1,122 @@ +use factorio_blueprint::{BlueprintEntity, BlueprintPosition}; +use factorio_core::beltoptions::Beltspeed; + +pub fn merger( + reverse: bool, + beltspeed: Beltspeed, + offset_x: f64, + offset_y: f64, + outer_offset: u32, + intervall: usize, + outputs: usize, + lines: usize, +) -> Vec { + let section_size = lines / outputs; + assert!(lines % outputs == 0); + assert!(section_size.is_power_of_two()); + assert!(outputs <= lines); + + let flip = match reverse { + true => 8, + false => 0, + }; + + let mut e = Vec::new(); + + // output and merging + for o in 0..outputs { + // stubs + let stubspeed = beltspeed.halvings(section_size.ilog2() as usize); + for i in 0..section_size { + let depth = o + i.count_ones() as usize; + + for j in 0..depth { + let offset = outer_offset + e.len() as u32; + e.push( + BlueprintEntity::builder( + stubspeed.string(), + offset, + BlueprintPosition::new( + (intervall * (i + o * section_size)) as f64 + offset_x, + offset_y - j as f64, + ), + ) + .direction(flip) + .build(), + ); + } + + let offset = outer_offset + e.len() as u32; + e.push( + BlueprintEntity::builder( + stubspeed.string(), + offset, + BlueprintPosition::new( + (intervall * (i + o * section_size)) as f64 + offset_x, + offset_y - depth as f64, + ), + ) + .direction(match reverse { + true => 8, + false => 12, + }) + .build(), + ); + } + + // merger + for i in 1..(section_size.ilog2() as usize + 1) { + let p = 1 << i; + let mergespeed = beltspeed.halvings((section_size.ilog2() as usize) - i); + for j in 0..(section_size / p) { + let depth = o + j.count_ones() as usize; + let offset = outer_offset + e.len() as u32; + e.push( + BlueprintEntity::builder( + mergespeed.string_splitter(), + offset, + BlueprintPosition::new( + (intervall * (j * p + o * section_size)) as f64 - i as f64 + offset_x, + offset_y - i as f64 + 0.5 - depth as f64, + ), + ) + .direction(12 - flip) + .build(), + ); + e.extend((0..(7 * p / 2)).map(|l| { + BlueprintEntity::builder( + mergespeed.halve().string(), + offset + 1 + l as u32, + BlueprintPosition::new( + (intervall * (j * p + o * section_size)) as f64 - i as f64 + + offset_x + + l as f64 + + 1.0, + offset_y - i as f64 - depth as f64, + ), + ) + .direction(12 - flip) + .build() + })); + } + } + + // connect + let offset = outer_offset + e.len() as u32; + let step = o + section_size.ilog2() as usize; + e.extend((0..(7 * o * section_size)).map(|l| { + BlueprintEntity::builder( + beltspeed.string(), + offset + l as u32, + BlueprintPosition::new( + l as f64 + offset_x - section_size.ilog2() as f64, + offset_y - step as f64, + ), + ) + .direction(12 - flip) + .build() + })); + } + + e +} diff --git a/factorio-blueprint-generator/src/lib.rs b/factorio-blueprint-generator/src/lib.rs index 1b0ddb2..c3b8fbb 100644 --- a/factorio-blueprint-generator/src/lib.rs +++ b/factorio-blueprint-generator/src/lib.rs @@ -1,3 +1,4 @@ pub mod balancer; +pub mod binary_merger; pub mod station; pub mod train; diff --git a/factorio-blueprint-generator/src/station.rs b/factorio-blueprint-generator/src/station.rs index 7d33af0..91aa3a2 100644 --- a/factorio-blueprint-generator/src/station.rs +++ b/factorio-blueprint-generator/src/station.rs @@ -1,14 +1,295 @@ use factorio_blueprint::{Blueprint, BlueprintEntity, BlueprintPosition}; use factorio_core::beltoptions::{Beltspeed, Belttype}; -pub fn station_unload( - length: usize, +use crate::binary_merger::merger; + +pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Vec, f64) { + if beltspeed == Beltspeed::Normal { + let mut e = vec![ + BlueprintEntity::builder( + "fast-transport-belt".to_owned(), + 0, + BlueprintPosition::new(3.5, -1.5), + ) + .build(), + ]; + + if belttype.contains_left() { + let offset = e.len() as u32; + e.extend_from_slice(&[ + BlueprintEntity::builder( + "steel-chest".to_owned(), + offset, + BlueprintPosition::new(5.5, -1.5), + ) + .build(), + BlueprintEntity::builder( + "bulk-inserter".to_owned(), + offset + 1, + BlueprintPosition::new(5.5, -0.5), + ) + .direction(8) + .build(), + BlueprintEntity::builder( + "fast-inserter".to_owned(), + offset + 2, + BlueprintPosition::new(4.5, -1.5), + ) + .direction(4) + .build(), + ]); + } + + if belttype.contains_right() { + let offset = e.len() as u32; + e.extend_from_slice(&[ + BlueprintEntity::builder( + "steel-chest".to_owned(), + offset, + BlueprintPosition::new(1.5, -1.5), + ) + .build(), + BlueprintEntity::builder( + "bulk-inserter".to_owned(), + offset + 1, + BlueprintPosition::new(1.5, -0.5), + ) + .direction(8) + .build(), + BlueprintEntity::builder( + "fast-inserter".to_owned(), + offset + 2, + BlueprintPosition::new(2.5, -1.5), + ) + .direction(12) + .build(), + ]); + } + + (e, -2.5) + } else { + let (belt_inserter, stack_size, quality) = match beltspeed { + Beltspeed::Normal => unreachable!(), + Beltspeed::Fast => ("fast-inserter", None, None), + Beltspeed::Express => ("bulk-inserter", Some(8), None), + Beltspeed::Turbo => ("fast-inserter", None, Some(String::from("epic"))), + }; + let mut e = vec![ + BlueprintEntity::builder(beltspeed.string(), 0, BlueprintPosition::new(3.5, -3.5)) + .build(), + ]; + + if belttype.contains_left() { + let offset = e.len() as u32; + e.extend_from_slice(&[ + BlueprintEntity::builder( + "steel-chest".to_owned(), + offset, + BlueprintPosition::new(1.5, -1.5), + ) + .build(), + BlueprintEntity::builder( + "bulk-inserter".to_owned(), + offset + 1, + BlueprintPosition::new(1.5, -0.5), + ) + .direction(8) + .build(), + BlueprintEntity::builder( + belt_inserter.to_owned(), + offset + 2, + BlueprintPosition::new(1.5, -2.5), + ) + .direction(8) + .maybe_override_stack_size(stack_size) + .maybe_quality(quality.clone()) + .build(), + BlueprintEntity::builder( + beltspeed.string(), + offset + 3, + BlueprintPosition::new(1.5, -3.5), + ) + .direction(4) + .build(), + BlueprintEntity::builder( + "steel-chest".to_owned(), + offset + 4, + BlueprintPosition::new(2.5, -1.5), + ) + .build(), + BlueprintEntity::builder( + "bulk-inserter".to_owned(), + offset + 5, + BlueprintPosition::new(2.5, -0.5), + ) + .direction(8) + .build(), + BlueprintEntity::builder( + belt_inserter.to_owned(), + offset + 6, + BlueprintPosition::new(2.5, -2.5), + ) + .direction(8) + .maybe_override_stack_size(stack_size) + .maybe_quality(quality.clone()) + .build(), + BlueprintEntity::builder( + beltspeed.string(), + offset + 7, + BlueprintPosition::new(2.5, -3.5), + ) + .direction(4) + .build(), + ]); + } + + if belttype.contains_right() { + let offset = e.len() as u32; + e.extend_from_slice(&[ + BlueprintEntity::builder( + "steel-chest".to_owned(), + offset, + BlueprintPosition::new(4.5, -1.5), + ) + .build(), + BlueprintEntity::builder( + "bulk-inserter".to_owned(), + offset + 1, + BlueprintPosition::new(4.5, -0.5), + ) + .direction(8) + .build(), + BlueprintEntity::builder( + belt_inserter.to_owned(), + offset + 2, + BlueprintPosition::new(4.5, -2.5), + ) + .direction(8) + .maybe_override_stack_size(stack_size) + .maybe_quality(quality.clone()) + .build(), + BlueprintEntity::builder( + beltspeed.string(), + offset + 3, + BlueprintPosition::new(4.5, -3.5), + ) + .direction(12) + .build(), + BlueprintEntity::builder( + "steel-chest".to_owned(), + offset + 4, + BlueprintPosition::new(5.5, -1.5), + ) + .build(), + BlueprintEntity::builder( + "bulk-inserter".to_owned(), + offset + 5, + BlueprintPosition::new(5.5, -0.5), + ) + .direction(8) + .build(), + BlueprintEntity::builder( + belt_inserter.to_owned(), + offset + 6, + BlueprintPosition::new(5.5, -2.5), + ) + .direction(8) + .maybe_override_stack_size(stack_size) + .maybe_quality(quality.clone()) + .build(), + BlueprintEntity::builder( + beltspeed.string(), + offset + 7, + BlueprintPosition::new(5.5, -3.5), + ) + .direction(12) + .build(), + ]); + } + + (e, -4.5) + } +} + +pub fn one_loader(beltspeed: Beltspeed) -> (Vec, f64) { + let (belt_inserter, quality) = match beltspeed { + Beltspeed::Normal => ("fast-inserter", None), + Beltspeed::Fast => ("bulk-inserter", Some(String::from("uncommon"))), + Beltspeed::Express => ("bulk-inserter", Some(String::from("rare"))), + Beltspeed::Turbo => ("bulk-inserter", Some(String::from("legendary"))), + }; + + ( + vec![ + BlueprintEntity::builder( + beltspeed.string_splitter(), + 0, + BlueprintPosition::new(4.0, -4.5), + ) + .direction(8) + .build(), + BlueprintEntity::builder(beltspeed.string(), 1, BlueprintPosition::new(2.5, -3.5)) + .direction(12) + .build(), + BlueprintEntity::builder(beltspeed.string(), 2, BlueprintPosition::new(3.5, -3.5)) + .direction(12) + .build(), + BlueprintEntity::builder(beltspeed.string(), 3, BlueprintPosition::new(4.5, -3.5)) + .direction(4) + .build(), + BlueprintEntity::builder(beltspeed.string(), 4, BlueprintPosition::new(5.5, -3.5)) + .direction(4) + .build(), + BlueprintEntity::builder( + belt_inserter.to_owned(), + 5, + BlueprintPosition::new(2.5, -2.5), + ) + .maybe_quality(quality.clone()) + .build(), + BlueprintEntity::builder( + belt_inserter.to_owned(), + 6, + BlueprintPosition::new(5.5, -2.5), + ) + .maybe_quality(quality.clone()) + .build(), + BlueprintEntity::builder( + "steel-chest".to_owned(), + 7, + BlueprintPosition::new(2.5, -1.5), + ) + .build(), + BlueprintEntity::builder( + "steel-chest".to_owned(), + 8, + BlueprintPosition::new(5.5, -1.5), + ) + .build(), + BlueprintEntity::builder( + "bulk-inserter".to_owned(), + 9, + BlueprintPosition::new(2.5, -0.5), + ) + .build(), + BlueprintEntity::builder( + "bulk-inserter".to_owned(), + 10, + BlueprintPosition::new(5.5, -0.5), + ) + .build(), + ], + -5.5, + ) +} + +pub fn basic_station( + load: bool, locomotives: usize, - unloader: &[BlueprintEntity], - beltspeed: Beltspeed, + length: usize, outputs: usize, - output_x: f64, - output_y: f64, + beltspeed: Beltspeed, + belttype: Belttype, ) -> Blueprint { let section_size = length / outputs; assert!(length % outputs == 0); @@ -32,6 +313,14 @@ pub fn station_unload( } // unloader + let (unloader, output_y) = match load { + false => unloader( + beltspeed.halvings((length / outputs).ilog2() as usize), + belttype, + ), + true => one_loader(beltspeed.halvings((length / outputs).ilog2() as usize)), + }; + let offset = e.len(); for l in 0..length { e.extend(unloader.iter().cloned().map(|mut e| { @@ -68,96 +357,16 @@ pub fn station_unload( } // output and merging - for o in 0..outputs { - // stubs - let stubspeed = beltspeed.halvings(section_size.ilog2() as usize); - for i in 0..section_size { - let depth = o + i.count_ones() as usize; - - for j in 0..depth { - let offset = e.len() as u32; - e.push( - BlueprintEntity::builder( - stubspeed.string(), - offset, - BlueprintPosition::new( - (7 * (i + o * section_size) + global_x_offset) as f64 + output_x, - output_y - j as f64, - ), - ) - .build(), - ); - } - - let offset = e.len() as u32; - e.push( - BlueprintEntity::builder( - stubspeed.string(), - offset, - BlueprintPosition::new( - (7 * (i + o * section_size) + global_x_offset) as f64 + output_x, - output_y - depth as f64, - ), - ) - .direction(12) - .build(), - ); - } - - // merger - for i in 1..(section_size.ilog2() as usize + 1) { - let p = 1 << i; - let mergespeed = beltspeed.halvings((section_size.ilog2() as usize) - i); - for j in 0..(section_size / p) { - let depth = o + j.count_ones() as usize; - let offset = e.len() as u32; - e.push( - BlueprintEntity::builder( - mergespeed.string_splitter(), - offset, - BlueprintPosition::new( - (7 * (j * p + o * section_size) + global_x_offset) as f64 - i as f64 - + output_x, - output_y - i as f64 + 0.5 - depth as f64, - ), - ) - .direction(12) - .build(), - ); - e.extend((0..(7 * p / 2)).map(|l| { - BlueprintEntity::builder( - mergespeed.halve().string(), - offset + 1 + l as u32, - BlueprintPosition::new( - (7 * (j * p + o * section_size) + global_x_offset) as f64 - i as f64 - + output_x - + l as f64 - + 1.0, - output_y - i as f64 - depth as f64, - ), - ) - .direction(12) - .build() - })); - } - } - - // connect - let offset = e.len() as u32; - let step = o + section_size.ilog2() as usize; - e.extend((0..(7 * o * section_size)).map(|l| { - BlueprintEntity::builder( - beltspeed.string(), - offset + l as u32, - BlueprintPosition::new( - (l + global_x_offset) as f64 + output_x - section_size.ilog2() as f64, - output_y - step as f64, - ), - ) - .direction(12) - .build() - })); - } + e.extend(merger( + load, + beltspeed, + global_x_offset as f64 + 3.5, + output_y, + e.len() as u32, + 7, + outputs, + length, + )); Blueprint::builder() .label("station".to_owned()) @@ -169,363 +378,3 @@ pub fn station_unload( ) .build() } - -pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Vec, f64) { - match beltspeed { - Beltspeed::Normal => { - let mut e = vec![ - BlueprintEntity::builder( - "fast-transport-belt".to_owned(), - 0, - BlueprintPosition::new(3.5, -1.5), - ) - .build(), - ]; - - if belttype.contains_left() { - let offset = e.len() as u32; - e.extend_from_slice(&[ - BlueprintEntity::builder( - "steel-chest".to_owned(), - offset, - BlueprintPosition::new(5.5, -1.5), - ) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 1, - BlueprintPosition::new(5.5, -0.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "fast-inserter".to_owned(), - offset + 2, - BlueprintPosition::new(4.5, -1.5), - ) - .direction(4) - .build(), - ]); - } - - if belttype.contains_right() { - let offset = e.len() as u32; - e.extend_from_slice(&[ - BlueprintEntity::builder( - "steel-chest".to_owned(), - offset, - BlueprintPosition::new(1.5, -1.5), - ) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 1, - BlueprintPosition::new(1.5, -0.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "fast-inserter".to_owned(), - offset + 2, - BlueprintPosition::new(2.5, -1.5), - ) - .direction(12) - .build(), - ]); - } - - (e, -2.5) - } - Beltspeed::Fast => { - let mut e = vec![ - BlueprintEntity::builder( - "fast-transport-belt".to_owned(), - 0, - BlueprintPosition::new(3.5, -3.5), - ) - .build(), - ]; - - if belttype.contains_left() { - let offset = e.len() as u32; - e.extend_from_slice(&[ - BlueprintEntity::builder( - "steel-chest".to_owned(), - offset, - BlueprintPosition::new(1.5, -1.5), - ) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 1, - BlueprintPosition::new(1.5, -0.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "fast-inserter".to_owned(), - offset + 2, - BlueprintPosition::new(1.5, -2.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "fast-transport-belt".to_owned(), - offset + 3, - BlueprintPosition::new(1.5, -3.5), - ) - .direction(4) - .build(), - BlueprintEntity::builder( - "steel-chest".to_owned(), - offset + 4, - BlueprintPosition::new(2.5, -1.5), - ) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 5, - BlueprintPosition::new(2.5, -0.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "fast-inserter".to_owned(), - offset + 6, - BlueprintPosition::new(2.5, -2.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "fast-transport-belt".to_owned(), - offset + 7, - BlueprintPosition::new(2.5, -3.5), - ) - .direction(4) - .build(), - ]); - } - - if belttype.contains_right() { - let offset = e.len() as u32; - e.extend_from_slice(&[ - BlueprintEntity::builder( - "steel-chest".to_owned(), - offset, - BlueprintPosition::new(4.5, -1.5), - ) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 1, - BlueprintPosition::new(4.5, -0.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "fast-inserter".to_owned(), - offset + 2, - BlueprintPosition::new(4.5, -2.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "fast-transport-belt".to_owned(), - offset + 3, - BlueprintPosition::new(4.5, -3.5), - ) - .direction(12) - .build(), - BlueprintEntity::builder( - "steel-chest".to_owned(), - offset + 4, - BlueprintPosition::new(5.5, -1.5), - ) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 5, - BlueprintPosition::new(5.5, -0.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "fast-inserter".to_owned(), - offset + 6, - BlueprintPosition::new(5.5, -2.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "fast-transport-belt".to_owned(), - offset + 7, - BlueprintPosition::new(5.5, -3.5), - ) - .direction(12) - .build(), - ]); - } - - (e, -4.5) - } - Beltspeed::Express => { - let mut e = vec![ - BlueprintEntity::builder( - "express-transport-belt".to_owned(), - 0, - BlueprintPosition::new(3.5, -3.5), - ) - .build(), - ]; - - if belttype.contains_left() { - let offset = e.len() as u32; - e.extend_from_slice(&[ - BlueprintEntity::builder( - "steel-chest".to_owned(), - offset, - BlueprintPosition::new(1.5, -1.5), - ) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 1, - BlueprintPosition::new(1.5, -0.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 2, - BlueprintPosition::new(1.5, -2.5), - ) - .direction(8) - .override_stack_size(8) - .build(), - BlueprintEntity::builder( - "express-transport-belt".to_owned(), - offset + 3, - BlueprintPosition::new(1.5, -3.5), - ) - .direction(4) - .build(), - BlueprintEntity::builder( - "steel-chest".to_owned(), - offset + 4, - BlueprintPosition::new(2.5, -1.5), - ) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 5, - BlueprintPosition::new(2.5, -0.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 6, - BlueprintPosition::new(2.5, -2.5), - ) - .direction(8) - .override_stack_size(8) - .build(), - BlueprintEntity::builder( - "express-transport-belt".to_owned(), - offset + 7, - BlueprintPosition::new(2.5, -3.5), - ) - .direction(4) - .build(), - ]); - } - - if belttype.contains_right() { - let offset = e.len() as u32; - e.extend_from_slice(&[ - BlueprintEntity::builder( - "steel-chest".to_owned(), - offset, - BlueprintPosition::new(4.5, -1.5), - ) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 1, - BlueprintPosition::new(4.5, -0.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 2, - BlueprintPosition::new(4.5, -2.5), - ) - .direction(8) - .override_stack_size(8) - .build(), - BlueprintEntity::builder( - "express-transport-belt".to_owned(), - offset + 3, - BlueprintPosition::new(4.5, -3.5), - ) - .direction(12) - .build(), - BlueprintEntity::builder( - "steel-chest".to_owned(), - offset + 4, - BlueprintPosition::new(5.5, -1.5), - ) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 5, - BlueprintPosition::new(5.5, -0.5), - ) - .direction(8) - .build(), - BlueprintEntity::builder( - "bulk-inserter".to_owned(), - offset + 6, - BlueprintPosition::new(5.5, -2.5), - ) - .direction(8) - .override_stack_size(8) - .build(), - BlueprintEntity::builder( - "express-transport-belt".to_owned(), - offset + 7, - BlueprintPosition::new(5.5, -3.5), - ) - .direction(12) - .build(), - ]); - } - - (e, -4.5) - } - Beltspeed::Turbo => (Vec::new(), -4.5), - } -} - -pub fn basic_unload_station( - locomotives: usize, - length: usize, - outputs: usize, - beltspeed: Beltspeed, - belttype: Belttype, -) -> Blueprint { - let (unloader, output_y) = unloader( - beltspeed.halvings((length / outputs).ilog2() as usize), - belttype, - ); - station_unload( - length, - locomotives, - &unloader, - beltspeed, - outputs, - 3.5, - output_y, - ) -} diff --git a/factorio-blueprint/blueprints/electric_pole_connection2.bp b/factorio-blueprint/blueprints/electric_pole_connection2.bp new file mode 100644 index 0000000..9cb4aca --- /dev/null +++ b/factorio-blueprint/blueprints/electric_pole_connection2.bp @@ -0,0 +1 @@ +0eNqdkMsKgzAQRf9l1qPUaFrMr4gUH0MZMIkksa1I/r3RLroodFFmc+d15jIb9NNCs2MTQG3AgzUeVLOB55vppr1mOk2gQNPIi85ooiE4HrLZTgQRgc1IT1BFbBHIBA5Mb8KRrFez6J5cGsCfJITZ+rRszX4zAS8ilwgrqKyoTrmMEb+Q4n9kWe7IZPnB7vDbFCj2aDEpmZRsU5cD6YT//AjhTs4fSHkWdVXXUlZS1GUR4wvMGmsM diff --git a/factorio-blueprint/blueprints/electric_pole_connection3.bp b/factorio-blueprint/blueprints/electric_pole_connection3.bp new file mode 100644 index 0000000..fd8133b --- /dev/null +++ b/factorio-blueprint/blueprints/electric_pole_connection3.bp @@ -0,0 +1 @@ +0eNqd0M0KgzAMAOB3yTnKWu2GfRWR4U8YgbZKrdtE+u6r7rDDYIfdkib5ErpBZxaaPLsAegPuRzeDrjeY+eZas7+51hJosDTwYjMy1AfPfTaNhiAisBvoCVrEBoFc4MD0Fo5kvbrFduRTA/6UEKZxTsOj23cm8CJzhbCCzkR5ylWM+EXK/8mi2Ml08oP9cW8tUKBE0WCKVIpUk6ocyCb+80cId/LzQaqzrMqqUqpUsipEjC/LnmsK diff --git a/factorio-blueprint/blueprints/inserter-quality.bp b/factorio-blueprint/blueprints/inserter-quality.bp new file mode 100644 index 0000000..c46a0d1 --- /dev/null +++ b/factorio-blueprint/blueprints/inserter-quality.bp @@ -0,0 +1 @@ +0eNqtkLEOwjAMRP/Fc4pIIUDyKwhVoTXIonUhSRFQ5d8xMDAgJAZG2+e7pxth2w54DMQJ3AhU9xzBrUeItGffPnbsOwQHOx9TQRwxJAyg4DT4ltJVLsEHhKyAuMELOJ03CpATJcKX13O4Vjx0W3l1Wn3zPPZRvnp+xIpToacTo0AyiqWdGIloKGD9Uqw+EBT0ZwyBGqxi8vWhinSTlFlWHwjl7wj6LwhSCSXsRPfuW4Fo49PJLEo7t9aYuSntTOd8Bwiih1s= diff --git a/factorio-blueprint/blueprints/rail-curve.bp b/factorio-blueprint/blueprints/rail-curve.bp new file mode 100644 index 0000000..f46987f --- /dev/null +++ b/factorio-blueprint/blueprints/rail-curve.bp @@ -0,0 +1 @@ +0eNqN0UsKgzAQBuC7zDqCUaMmVyml+BjKgMYSo1Qkd2/USmnrwuU8/m8xM0PZDPgwpC2oGajqdA/qMkNPd100S08XLYICU1ADjgHpGp+guLsyQG3JEm6JtZhuemhLNH6B7clqMCPWwQIEBTB4dL1PdXrBvSRyyWACFfAw9X5NBqttzEPH/tzo0C2P3Gx3+Qk3Pu/GmyuzbzY5UJPTV8jytyp+VX9osth64/MrBiOafl0QaSQTKYVIRCRj7twLWaaXjg== diff --git a/factorio-blueprint/blueprints/rail-diagonal.bp b/factorio-blueprint/blueprints/rail-diagonal.bp new file mode 100644 index 0000000..83ff6d4 --- /dev/null +++ b/factorio-blueprint/blueprints/rail-diagonal.bp @@ -0,0 +1 @@ +0eNpFjtEKgzAMRf/lPleYzg7aXxljVA0uoFHaOibSf19Vxh6T3HNyNzTDQrNnibAbuJ0kwN43BO7FDftO3Eiw8I4HJAWWjj6wZXookESOTCdxDOtTlrEhnwPqR4aY2f4Vi0OhME8hU5Ps8mzSplZYYQtzyfqOPbXntdpfcKQxO/4tFd7kwxHQt8rUxmhd68pcy5S+PTBDgg== diff --git a/factorio-blueprint/src/lib.rs b/factorio-blueprint/src/lib.rs index 25916e4..7928fcc 100644 --- a/factorio-blueprint/src/lib.rs +++ b/factorio-blueprint/src/lib.rs @@ -1,8 +1,5 @@ -use base64::Engine; -use base64::engine::general_purpose::STANDARD; -use base64::prelude::BASE64_STANDARD; -use std::io::Cursor; -use std::io::Read; +use base64::{Engine, engine::general_purpose::STANDARD, prelude::BASE64_STANDARD}; +use std::io::{Cursor, Read}; pub mod belt; pub mod structs; diff --git a/factorio-blueprint/src/structs.rs b/factorio-blueprint/src/structs.rs index eef6318..1537525 100644 --- a/factorio-blueprint/src/structs.rs +++ b/factorio-blueprint/src/structs.rs @@ -158,6 +158,8 @@ pub struct BlueprintEntity { switch_state: Option, #[serde(skip_serializing_if = "Option::is_none")] tags: Option, + #[serde(skip_serializing_if = "Option::is_none")] + quality: Option, } #[derive(Serialize, Deserialize, Debug, Clone)] diff --git a/factorio-pathfinding/src/bin/beltfinding.rs b/factorio-pathfinding/src/bin/beltfinding.rs index d7549ae..c8a1903 100644 --- a/factorio-pathfinding/src/bin/beltfinding.rs +++ b/factorio-pathfinding/src/bin/beltfinding.rs @@ -1,6 +1,6 @@ use clap::{Parser, Subcommand, ValueEnum}; -use factorio_blueprint::{encode, misc::Beltspeed, Blueprint, BlueprintString}; -use factorio_core::visualize::Visualize; +use factorio_blueprint::{encode, Blueprint, BlueprintString}; +use factorio_core::{beltoptions::Beltspeed, visualize::Visualize}; use factorio_pathfinding::belt_finding::{ conflict_avoidance::ConflictAvoidance, problems, Problem, };