Allow for halve belts in multistation

This commit is contained in:
hal8174 2025-04-20 22:08:15 +02:00
parent cd86679d65
commit 06b01c2fe4
4 changed files with 24 additions and 6 deletions

View file

@ -9,7 +9,7 @@ struct Args {
#[arg(short, long)]
json: bool,
stacker_size: usize,
/// format: <locomotives>-<wagons>[lu][nfet]<lanes>
/// format: <locomotives>-<wagons>[lu][nfet]<lanes>[lr]?
stations: Vec<String>,
}
@ -26,7 +26,13 @@ fn main() {
let (load, s) = s.split_at_checked(1).expect("extracting direction");
let (beltspeed, lanes) = s.split_at_checked(1).expect("extracting lanes");
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, "")
};
StationSpec {
locomotives: locomotives.parse().expect("parsing locomotive count"),
@ -44,6 +50,12 @@ 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}"),
},
}
})
.collect::<Vec<_>>();

View file

@ -1,6 +1,6 @@
use crate::{
multistation::{StationSpec, multistation},
subfactory::{BeltConnection, SubFactory, assembling_line::assembly_line_2_input},
subfactory::{BeltConnection, SubFactory},
};
use factorio_blueprint::abstraction::{Blueprint, Entity};
use factorio_core::{beltoptions::Beltspeed, prelude::*, visualize::Visualize};
@ -412,6 +412,7 @@ pub fn generate_factory<L: Layouter, P: Pathfinder + Sync, R: Rng + SeedableRng
load: true,
beltspeed: Beltspeed::from_items_per_second(c.amount),
lanes: 1,
belttype: factorio_core::beltoptions::Belttype::Full,
}));
station_spec.extend(output_connections.iter().map(|&(_, c)| StationSpec {
locomotives: 2,
@ -419,6 +420,7 @@ pub fn generate_factory<L: Layouter, P: Pathfinder + Sync, R: Rng + SeedableRng
load: false,
beltspeed: Beltspeed::from_items_per_second(c.amount),
lanes: 1,
belttype: factorio_core::beltoptions::Belttype::Full,
}));
intermediate_connections.push(IntermediateConnection {

View file

@ -2,7 +2,10 @@ use crate::{balancer::binary_balancer, station::basic_station};
use factorio_blueprint::abstraction::{
Blueprint, ElectricPoleType, Entity, RailType, UndergroundType,
};
use factorio_core::{beltoptions::Beltspeed, prelude::*};
use factorio_core::{
beltoptions::{Beltspeed, Belttype},
prelude::*,
};
#[derive(Debug, Clone)]
pub struct StationSpec {
@ -11,6 +14,7 @@ pub struct StationSpec {
pub load: bool,
pub beltspeed: Beltspeed,
pub lanes: usize,
pub belttype: Belttype,
}
fn calculate_station_height(
@ -263,7 +267,7 @@ pub fn multistation(
station.wagons,
station.lanes,
station.beltspeed,
factorio_core::beltoptions::Belttype::Full,
station.belttype,
);
let output_height = -b.bounding_box().min().y;

View file

@ -2,7 +2,7 @@ use assembling_line::{assembly_line, assembly_line_2_input};
use clap::Subcommand;
use factorio_blueprint::abstraction::Blueprint;
use factorio_core::{
beltoptions::{Beltspeed, Belttype},
beltoptions::Beltspeed,
prelude::{Direction, Position},
};
use factorio_layout::{Interface, MacroBlock};