Add loader station
This commit is contained in:
parent
b715c4ad06
commit
505ca6ff5c
12 changed files with 479 additions and 494 deletions
|
|
@ -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,
|
||||
|
|
|
|||
122
factorio-blueprint-generator/src/binary_merger.rs
Normal file
122
factorio-blueprint-generator/src/binary_merger.rs
Normal file
|
|
@ -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<BlueprintEntity> {
|
||||
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
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
pub mod balancer;
|
||||
pub mod binary_merger;
|
||||
pub mod station;
|
||||
pub mod train;
|
||||
|
|
|
|||
|
|
@ -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<BlueprintEntity>, 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<BlueprintEntity>, 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<BlueprintEntity>, 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,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue