Add stacked belts to station
This commit is contained in:
parent
65e2c03824
commit
59d7cf50cb
5 changed files with 85 additions and 45 deletions
|
|
@ -2,7 +2,7 @@ use clap::Parser;
|
|||
use factorio_blueprint::abstraction::serde::AbstractBlueprintString;
|
||||
use factorio_blueprint::{BlueprintString, encode};
|
||||
use factorio_blueprint_generator::multistation::{StationSpec, multistation};
|
||||
use factorio_core::beltoptions::Beltspeed;
|
||||
use factorio_core::beltoptions::{Beltspeed, Belttype};
|
||||
use factorio_core::visualize::Visualize;
|
||||
|
||||
#[derive(Parser)]
|
||||
|
|
@ -29,11 +29,7 @@ fn main() {
|
|||
|
||||
let (beltspeed, s) = s.split_at_checked(1).expect("extracting lanes");
|
||||
|
||||
let (lanes, belttype) = if s.ends_with(['l', 'r']) {
|
||||
s.split_at(s.len() - 1)
|
||||
} else {
|
||||
(s, "")
|
||||
};
|
||||
let lanes = s.trim_end_matches(['r', 'l', 's']);
|
||||
|
||||
StationSpec {
|
||||
locomotives: locomotives.parse().expect("parsing locomotive count"),
|
||||
|
|
@ -51,12 +47,14 @@ fn main() {
|
|||
_ => panic!("unknown belt speed {beltspeed}"),
|
||||
},
|
||||
lanes: lanes.parse().expect("parsing lane count"),
|
||||
belttype: match belttype {
|
||||
"" => factorio_core::beltoptions::Belttype::Full,
|
||||
"r" => factorio_core::beltoptions::Belttype::Right,
|
||||
"l" => factorio_core::beltoptions::Belttype::Left,
|
||||
_ => panic!("unknown belttype {belttype}"),
|
||||
belttype: if s.contains('l') {
|
||||
Belttype::Left
|
||||
} else if s.contains('r') {
|
||||
Belttype::Right
|
||||
} else {
|
||||
Belttype::Full
|
||||
},
|
||||
stacked: s.contains('s'),
|
||||
}
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ fn main() {
|
|||
o,
|
||||
beltspeed,
|
||||
Belttype::Full,
|
||||
false,
|
||||
);
|
||||
|
||||
inner_inner_b.push(BlueprintBookEntry::new(
|
||||
|
|
@ -94,10 +95,13 @@ fn main() {
|
|||
BlueprintBook::builder()
|
||||
.blueprints(inner_b)
|
||||
.active_index(0)
|
||||
.label(format!("{locomotives}-{cargo}-{}", match load {
|
||||
true => "load",
|
||||
false => "unload",
|
||||
}))
|
||||
.label(format!(
|
||||
"{locomotives}-{cargo}-{}",
|
||||
match load {
|
||||
true => "load",
|
||||
false => "unload",
|
||||
}
|
||||
))
|
||||
.build(),
|
||||
),
|
||||
2 * i as u32 + load as u32,
|
||||
|
|
@ -126,8 +130,16 @@ fn main() {
|
|||
belttype,
|
||||
} => {
|
||||
let b = BlueprintString::Blueprint(
|
||||
basic_station(load, locomotives, length, outputs, beltspeed, belttype)
|
||||
.to_blueprint(),
|
||||
basic_station(
|
||||
load,
|
||||
locomotives,
|
||||
length,
|
||||
outputs,
|
||||
beltspeed,
|
||||
belttype,
|
||||
false,
|
||||
)
|
||||
.to_blueprint(),
|
||||
);
|
||||
|
||||
if args.json {
|
||||
|
|
|
|||
|
|
@ -413,6 +413,7 @@ pub fn generate_factory<L: Layouter, P: Pathfinder + Sync, R: Rng + SeedableRng
|
|||
beltspeed: Beltspeed::from_items_per_second(c.amount),
|
||||
lanes: 1,
|
||||
belttype: factorio_core::beltoptions::Belttype::Full,
|
||||
stacked: false,
|
||||
}));
|
||||
station_spec.extend(output_connections.iter().map(|&(_, c)| StationSpec {
|
||||
locomotives: 2,
|
||||
|
|
@ -421,6 +422,7 @@ pub fn generate_factory<L: Layouter, P: Pathfinder + Sync, R: Rng + SeedableRng
|
|||
beltspeed: Beltspeed::from_items_per_second(c.amount),
|
||||
lanes: 1,
|
||||
belttype: factorio_core::beltoptions::Belttype::Full,
|
||||
stacked: false,
|
||||
}));
|
||||
|
||||
intermediate_connections.push(IntermediateConnection {
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ pub struct StationSpec {
|
|||
pub beltspeed: Beltspeed,
|
||||
pub lanes: usize,
|
||||
pub belttype: Belttype,
|
||||
pub stacked: bool,
|
||||
}
|
||||
|
||||
fn calculate_station_height(
|
||||
|
|
@ -268,6 +269,7 @@ pub fn multistation(
|
|||
station.lanes,
|
||||
station.beltspeed,
|
||||
station.belttype,
|
||||
station.stacked,
|
||||
);
|
||||
let output_height = -b.bounding_box().min().y;
|
||||
|
||||
|
|
|
|||
|
|
@ -6,9 +6,23 @@ use factorio_core::{
|
|||
|
||||
use crate::binary_merger::merger;
|
||||
|
||||
pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Blueprint, PositionType) {
|
||||
pub fn unloader(
|
||||
beltspeed: Beltspeed,
|
||||
belttype: Belttype,
|
||||
stacked: bool,
|
||||
) -> (Blueprint, PositionType) {
|
||||
let mut b = Blueprint::new();
|
||||
|
||||
let (belt_inserter, stack_size, quality) = match (beltspeed, stacked) {
|
||||
(Beltspeed::Normal, false) => (InserterType::Fast, None, Quality::Normal),
|
||||
(Beltspeed::Fast, false) => (InserterType::Fast, None, Quality::Normal),
|
||||
(Beltspeed::Express, false) => (InserterType::Bulk, Some(7), Quality::Normal),
|
||||
(Beltspeed::Turbo, false) => (InserterType::Bulk, Some(10), Quality::Normal),
|
||||
(Beltspeed::Normal, true) => (InserterType::Stack, None, Quality::Normal),
|
||||
(Beltspeed::Fast, true) => (InserterType::Stack, None, Quality::Normal),
|
||||
(Beltspeed::Express, true) => (InserterType::Stack, None, Quality::Rare),
|
||||
(Beltspeed::Turbo, true) => (InserterType::Stack, None, Quality::Epic),
|
||||
};
|
||||
if beltspeed == Beltspeed::Normal {
|
||||
b.add_entity(Entity::new_belt(
|
||||
Beltspeed::Fast,
|
||||
|
|
@ -30,12 +44,15 @@ pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Blueprint, Positio
|
|||
Direction::Down,
|
||||
));
|
||||
|
||||
b.add_entity(Entity::new_inserter(
|
||||
InserterType::Fast,
|
||||
None,
|
||||
Position::new(1, 1) + 2 * Position::new(4, -2),
|
||||
Direction::Right,
|
||||
));
|
||||
b.add_entity(
|
||||
Entity::new_inserter(
|
||||
belt_inserter,
|
||||
stack_size,
|
||||
Position::new(1, 1) + 2 * Position::new(4, -2),
|
||||
Direction::Right,
|
||||
)
|
||||
.quality(quality),
|
||||
);
|
||||
}
|
||||
|
||||
if belttype.contains_right() {
|
||||
|
|
@ -52,23 +69,19 @@ pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Blueprint, Positio
|
|||
Direction::Down,
|
||||
));
|
||||
|
||||
b.add_entity(Entity::new_inserter(
|
||||
InserterType::Fast,
|
||||
None,
|
||||
Position::new(1, 1) + 2 * Position::new(2, -2),
|
||||
Direction::Left,
|
||||
));
|
||||
b.add_entity(
|
||||
Entity::new_inserter(
|
||||
belt_inserter,
|
||||
stack_size,
|
||||
Position::new(1, 1) + 2 * Position::new(2, -2),
|
||||
Direction::Left,
|
||||
)
|
||||
.quality(quality),
|
||||
);
|
||||
}
|
||||
|
||||
(b, -3)
|
||||
} else {
|
||||
let (belt_inserter, stack_size, quality) = match beltspeed {
|
||||
Beltspeed::Normal => unreachable!(),
|
||||
Beltspeed::Fast => (InserterType::Fast, None, Quality::Normal),
|
||||
Beltspeed::Express => (InserterType::Bulk, Some(7), Quality::Normal),
|
||||
Beltspeed::Turbo => (InserterType::Bulk, Some(10), Quality::Normal),
|
||||
};
|
||||
|
||||
b.add_entity(Entity::new_belt(
|
||||
beltspeed,
|
||||
Position::new(1, 1) + 2 * Position::new(3, -4),
|
||||
|
|
@ -118,12 +131,16 @@ pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Blueprint, Positio
|
|||
}
|
||||
}
|
||||
|
||||
pub fn one_loader(beltspeed: Beltspeed) -> (Blueprint, PositionType) {
|
||||
let (belt_inserter, quality) = match beltspeed {
|
||||
Beltspeed::Normal => (InserterType::Fast, Quality::Normal),
|
||||
Beltspeed::Fast => (InserterType::Bulk, Quality::Uncommon),
|
||||
Beltspeed::Express => (InserterType::Bulk, Quality::Rare),
|
||||
Beltspeed::Turbo => (InserterType::Bulk, Quality::Legendary),
|
||||
pub fn one_loader(beltspeed: Beltspeed, stacked: bool) -> (Blueprint, PositionType) {
|
||||
let (belt_inserter, quality) = match (beltspeed, stacked) {
|
||||
(Beltspeed::Normal, false) => (InserterType::Fast, Quality::Normal),
|
||||
(Beltspeed::Fast, false) => (InserterType::Bulk, Quality::Uncommon),
|
||||
(Beltspeed::Express, false) => (InserterType::Bulk, Quality::Rare),
|
||||
(Beltspeed::Turbo, false) => (InserterType::Bulk, Quality::Legendary),
|
||||
(Beltspeed::Normal, true) => todo!(),
|
||||
(Beltspeed::Fast, true) => todo!(),
|
||||
(Beltspeed::Express, true) => todo!(),
|
||||
(Beltspeed::Turbo, true) => todo!(),
|
||||
};
|
||||
|
||||
let mut b = Blueprint::new();
|
||||
|
|
@ -186,6 +203,7 @@ pub fn basic_station(
|
|||
outputs: usize,
|
||||
beltspeed: Beltspeed,
|
||||
belttype: Belttype,
|
||||
stacked: bool,
|
||||
) -> Blueprint {
|
||||
let section_size = length / outputs;
|
||||
assert!(length % outputs == 0);
|
||||
|
|
@ -215,16 +233,24 @@ pub fn basic_station(
|
|||
false => unloader(
|
||||
beltspeed.halvings((length / outputs).ilog2() as usize),
|
||||
belttype,
|
||||
stacked,
|
||||
),
|
||||
true => one_loader(
|
||||
beltspeed.halvings((length / outputs).ilog2() as usize),
|
||||
stacked,
|
||||
),
|
||||
true => one_loader(beltspeed.halvings((length / outputs).ilog2() as usize)),
|
||||
};
|
||||
for l in 0..length {
|
||||
let (mut unloader, _) = match load {
|
||||
false => unloader(
|
||||
beltspeed.halvings((length / outputs).ilog2() as usize),
|
||||
belttype,
|
||||
stacked,
|
||||
),
|
||||
true => one_loader(
|
||||
beltspeed.halvings((length / outputs).ilog2() as usize),
|
||||
stacked,
|
||||
),
|
||||
true => one_loader(beltspeed.halvings((length / outputs).ilog2() as usize)),
|
||||
};
|
||||
|
||||
unloader.transform(Transformation::new(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue