Allow for halve belts in multistation
This commit is contained in:
parent
cd86679d65
commit
06b01c2fe4
4 changed files with 24 additions and 6 deletions
|
|
@ -9,7 +9,7 @@ struct Args {
|
||||||
#[arg(short, long)]
|
#[arg(short, long)]
|
||||||
json: bool,
|
json: bool,
|
||||||
stacker_size: usize,
|
stacker_size: usize,
|
||||||
/// format: <locomotives>-<wagons>[lu][nfet]<lanes>
|
/// format: <locomotives>-<wagons>[lu][nfet]<lanes>[lr]?
|
||||||
stations: Vec<String>,
|
stations: Vec<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -26,7 +26,13 @@ fn main() {
|
||||||
|
|
||||||
let (load, s) = s.split_at_checked(1).expect("extracting direction");
|
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 {
|
StationSpec {
|
||||||
locomotives: locomotives.parse().expect("parsing locomotive count"),
|
locomotives: locomotives.parse().expect("parsing locomotive count"),
|
||||||
|
|
@ -44,6 +50,12 @@ fn main() {
|
||||||
_ => panic!("unknown belt speed {beltspeed}"),
|
_ => panic!("unknown belt speed {beltspeed}"),
|
||||||
},
|
},
|
||||||
lanes: lanes.parse().expect("parsing lane count"),
|
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<_>>();
|
.collect::<Vec<_>>();
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::{
|
use crate::{
|
||||||
multistation::{StationSpec, multistation},
|
multistation::{StationSpec, multistation},
|
||||||
subfactory::{BeltConnection, SubFactory, assembling_line::assembly_line_2_input},
|
subfactory::{BeltConnection, SubFactory},
|
||||||
};
|
};
|
||||||
use factorio_blueprint::abstraction::{Blueprint, Entity};
|
use factorio_blueprint::abstraction::{Blueprint, Entity};
|
||||||
use factorio_core::{beltoptions::Beltspeed, prelude::*, visualize::Visualize};
|
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,
|
load: true,
|
||||||
beltspeed: Beltspeed::from_items_per_second(c.amount),
|
beltspeed: Beltspeed::from_items_per_second(c.amount),
|
||||||
lanes: 1,
|
lanes: 1,
|
||||||
|
belttype: factorio_core::beltoptions::Belttype::Full,
|
||||||
}));
|
}));
|
||||||
station_spec.extend(output_connections.iter().map(|&(_, c)| StationSpec {
|
station_spec.extend(output_connections.iter().map(|&(_, c)| StationSpec {
|
||||||
locomotives: 2,
|
locomotives: 2,
|
||||||
|
|
@ -419,6 +420,7 @@ pub fn generate_factory<L: Layouter, P: Pathfinder + Sync, R: Rng + SeedableRng
|
||||||
load: false,
|
load: false,
|
||||||
beltspeed: Beltspeed::from_items_per_second(c.amount),
|
beltspeed: Beltspeed::from_items_per_second(c.amount),
|
||||||
lanes: 1,
|
lanes: 1,
|
||||||
|
belttype: factorio_core::beltoptions::Belttype::Full,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
intermediate_connections.push(IntermediateConnection {
|
intermediate_connections.push(IntermediateConnection {
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,10 @@ use crate::{balancer::binary_balancer, station::basic_station};
|
||||||
use factorio_blueprint::abstraction::{
|
use factorio_blueprint::abstraction::{
|
||||||
Blueprint, ElectricPoleType, Entity, RailType, UndergroundType,
|
Blueprint, ElectricPoleType, Entity, RailType, UndergroundType,
|
||||||
};
|
};
|
||||||
use factorio_core::{beltoptions::Beltspeed, prelude::*};
|
use factorio_core::{
|
||||||
|
beltoptions::{Beltspeed, Belttype},
|
||||||
|
prelude::*,
|
||||||
|
};
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct StationSpec {
|
pub struct StationSpec {
|
||||||
|
|
@ -11,6 +14,7 @@ pub struct StationSpec {
|
||||||
pub load: bool,
|
pub load: bool,
|
||||||
pub beltspeed: Beltspeed,
|
pub beltspeed: Beltspeed,
|
||||||
pub lanes: usize,
|
pub lanes: usize,
|
||||||
|
pub belttype: Belttype,
|
||||||
}
|
}
|
||||||
|
|
||||||
fn calculate_station_height(
|
fn calculate_station_height(
|
||||||
|
|
@ -263,7 +267,7 @@ pub fn multistation(
|
||||||
station.wagons,
|
station.wagons,
|
||||||
station.lanes,
|
station.lanes,
|
||||||
station.beltspeed,
|
station.beltspeed,
|
||||||
factorio_core::beltoptions::Belttype::Full,
|
station.belttype,
|
||||||
);
|
);
|
||||||
let output_height = -b.bounding_box().min().y;
|
let output_height = -b.bounding_box().min().y;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ use assembling_line::{assembly_line, assembly_line_2_input};
|
||||||
use clap::Subcommand;
|
use clap::Subcommand;
|
||||||
use factorio_blueprint::abstraction::Blueprint;
|
use factorio_blueprint::abstraction::Blueprint;
|
||||||
use factorio_core::{
|
use factorio_core::{
|
||||||
beltoptions::{Beltspeed, Belttype},
|
beltoptions::Beltspeed,
|
||||||
prelude::{Direction, Position},
|
prelude::{Direction, Position},
|
||||||
};
|
};
|
||||||
use factorio_layout::{Interface, MacroBlock};
|
use factorio_layout::{Interface, MacroBlock};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue