Add station book output
This commit is contained in:
parent
2c7373f7d9
commit
94473c64e0
3 changed files with 496 additions and 126 deletions
|
|
@ -1,6 +1,9 @@
|
|||
use std::sync::Arc;
|
||||
|
||||
use super::{belt::Beltspeed, Blueprint, BlueprintEntity, BlueprintPosition};
|
||||
use super::{
|
||||
belt::{Beltspeed, Belttype},
|
||||
Blueprint, BlueprintEntity, BlueprintPosition,
|
||||
};
|
||||
|
||||
pub fn station_unload(
|
||||
length: usize,
|
||||
|
|
@ -171,118 +174,356 @@ 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 top = vec![
|
||||
BlueprintEntity::builder(
|
||||
"steel-chest".to_owned(),
|
||||
0,
|
||||
BlueprintPosition::new(1.5, -1.5),
|
||||
)
|
||||
.build(),
|
||||
BlueprintEntity::builder(
|
||||
"bulk-inserter".to_owned(),
|
||||
1,
|
||||
BlueprintPosition::new(1.5, -0.5),
|
||||
)
|
||||
.direction(8)
|
||||
.build(),
|
||||
BlueprintEntity::builder(
|
||||
"fast-inserter".to_owned(),
|
||||
2,
|
||||
BlueprintPosition::new(2.5, -1.5),
|
||||
)
|
||||
.direction(12)
|
||||
.build(),
|
||||
BlueprintEntity::builder(
|
||||
"fast-transport-belt".to_owned(),
|
||||
3,
|
||||
BlueprintPosition::new(3.5, -1.5),
|
||||
)
|
||||
.build(),
|
||||
];
|
||||
|
||||
let bottom = vec![
|
||||
BlueprintEntity::builder(
|
||||
"steel-chest".to_owned(),
|
||||
0,
|
||||
BlueprintPosition::new(1.5, -1.5),
|
||||
)
|
||||
.build(),
|
||||
BlueprintEntity::builder(
|
||||
"bulk-inserter".to_owned(),
|
||||
1,
|
||||
BlueprintPosition::new(1.5, -0.5),
|
||||
)
|
||||
.direction(8)
|
||||
.build(),
|
||||
BlueprintEntity::builder(
|
||||
"fast-inserter".to_owned(),
|
||||
2,
|
||||
BlueprintPosition::new(2.5, -1.5),
|
||||
)
|
||||
.direction(12)
|
||||
.build(),
|
||||
BlueprintEntity::builder(
|
||||
"fast-transport-belt".to_owned(),
|
||||
3,
|
||||
BlueprintPosition::new(3.5, -1.5),
|
||||
)
|
||||
.build(),
|
||||
];
|
||||
|
||||
let full = vec![
|
||||
BlueprintEntity::builder(
|
||||
"steel-chest".to_owned(),
|
||||
0,
|
||||
BlueprintPosition::new(1.5, -1.5),
|
||||
)
|
||||
.build(),
|
||||
BlueprintEntity::builder(
|
||||
"bulk-inserter".to_owned(),
|
||||
1,
|
||||
BlueprintPosition::new(1.5, -0.5),
|
||||
)
|
||||
.direction(8)
|
||||
.build(),
|
||||
BlueprintEntity::builder(
|
||||
"fast-inserter".to_owned(),
|
||||
2,
|
||||
BlueprintPosition::new(2.5, -1.5),
|
||||
)
|
||||
.direction(12)
|
||||
.build(),
|
||||
BlueprintEntity::builder(
|
||||
"steel-chest".to_owned(),
|
||||
0,
|
||||
BlueprintPosition::new(5.5, -1.5),
|
||||
)
|
||||
.build(),
|
||||
BlueprintEntity::builder(
|
||||
"bulk-inserter".to_owned(),
|
||||
1,
|
||||
BlueprintPosition::new(5.5, -0.5),
|
||||
)
|
||||
.direction(8)
|
||||
.build(),
|
||||
BlueprintEntity::builder(
|
||||
"fast-inserter".to_owned(),
|
||||
2,
|
||||
BlueprintPosition::new(4.5, -1.5),
|
||||
)
|
||||
.direction(4)
|
||||
.build(),
|
||||
BlueprintEntity::builder(
|
||||
"fast-transport-belt".to_owned(),
|
||||
3,
|
||||
BlueprintPosition::new(3.5, -1.5),
|
||||
)
|
||||
.build(),
|
||||
];
|
||||
|
||||
station_unload(length, locomotives, &full, beltspeed, outputs, 3.5, -2.5)
|
||||
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