Add wagon inserter options to multistation
This commit is contained in:
parent
7638081f26
commit
7ef42e5202
6 changed files with 89 additions and 33 deletions
|
|
@ -1,6 +1,7 @@
|
|||
use clap::Parser;
|
||||
use factorio_blueprint::abstraction::serde::AbstractBlueprintString;
|
||||
use factorio_blueprint::{BlueprintString, encode};
|
||||
use factorio_blueprint::abstraction::{InserterType, Quality};
|
||||
use factorio_blueprint::encode;
|
||||
use factorio_blueprint_generator::multistation::{StationSpec, multistation};
|
||||
use factorio_core::beltoptions::{Beltspeed, Belttype};
|
||||
use factorio_core::visualize::Visualize;
|
||||
|
|
@ -9,6 +10,13 @@ use factorio_core::visualize::Visualize;
|
|||
struct Args {
|
||||
#[arg(short, long)]
|
||||
json: bool,
|
||||
|
||||
#[arg(short, long, default_value = "bulk")]
|
||||
wagon_inserter_type: InserterType,
|
||||
|
||||
#[arg(short, long, default_value = "normal")]
|
||||
wagon_inserter_quality: Quality,
|
||||
|
||||
stacker_size: usize,
|
||||
/// format: <locomotives>-<wagons>[lu][nfet]<lanes>[lr]?
|
||||
stations: Vec<String>,
|
||||
|
|
@ -61,7 +69,13 @@ fn main() {
|
|||
|
||||
dbg!(&stations);
|
||||
|
||||
let mut b = multistation(&stations, args.stacker_size).0;
|
||||
let mut b = multistation(
|
||||
&stations,
|
||||
args.stacker_size,
|
||||
args.wagon_inserter_type,
|
||||
args.wagon_inserter_quality,
|
||||
)
|
||||
.0;
|
||||
|
||||
b.connect_power_networks();
|
||||
|
||||
|
|
|
|||
|
|
@ -70,6 +70,8 @@ fn main() {
|
|||
beltspeed,
|
||||
Belttype::Full,
|
||||
false,
|
||||
factorio_blueprint::abstraction::InserterType::Bulk,
|
||||
factorio_blueprint::abstraction::Quality::Normal,
|
||||
);
|
||||
|
||||
inner_inner_b.push(BlueprintBookEntry::new(
|
||||
|
|
@ -138,6 +140,8 @@ fn main() {
|
|||
beltspeed,
|
||||
belttype,
|
||||
false,
|
||||
factorio_blueprint::abstraction::InserterType::Bulk,
|
||||
factorio_blueprint::abstraction::Quality::Normal,
|
||||
)
|
||||
.to_blueprint(),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -780,8 +780,12 @@ pub fn generate_factory<L: Layouter, P: Pathfinder + Sync, R: Rng + SeedableRng
|
|||
// dbg!(&blocks);
|
||||
// dbg!(&connections);
|
||||
|
||||
let (multistation_blueprint, multistation_x_offset, mut multistation_y_offsets) =
|
||||
multistation(&station_spec, 8);
|
||||
let (multistation_blueprint, multistation_x_offset, mut multistation_y_offsets) = multistation(
|
||||
&station_spec,
|
||||
8,
|
||||
factorio_blueprint::abstraction::InserterType::Bulk,
|
||||
factorio_blueprint::abstraction::Quality::Normal,
|
||||
);
|
||||
|
||||
let multistation_y_offset = multistation_y_offsets[0];
|
||||
multistation_y_offsets.iter_mut().for_each(move |y| {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
use crate::{balancer::binary_balancer, station::basic_station};
|
||||
use factorio_blueprint::abstraction::{
|
||||
Blueprint, ElectricPoleType, Entity, RailType, UndergroundType,
|
||||
Blueprint, ElectricPoleType, Entity, Quality, RailType, UndergroundType,
|
||||
};
|
||||
use factorio_core::{
|
||||
beltoptions::{Beltspeed, Belttype},
|
||||
|
|
@ -50,6 +50,8 @@ fn calculate_station_height(
|
|||
pub fn multistation(
|
||||
stations: &[StationSpec],
|
||||
stacker_size: usize,
|
||||
wagon_inserter_type: factorio_blueprint::abstraction::InserterType,
|
||||
wagon_inserter_quality: Quality,
|
||||
) -> (Blueprint, PositionType, Vec<PositionType>) {
|
||||
let longest_train = stations
|
||||
.iter()
|
||||
|
|
@ -270,6 +272,8 @@ pub fn multistation(
|
|||
station.beltspeed,
|
||||
station.belttype,
|
||||
station.stacked,
|
||||
wagon_inserter_type,
|
||||
wagon_inserter_quality,
|
||||
);
|
||||
let output_height = -b.bounding_box().min().y;
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ pub fn unloader(
|
|||
beltspeed: Beltspeed,
|
||||
belttype: Belttype,
|
||||
stacked: bool,
|
||||
wagon_inserter_type: InserterType,
|
||||
wagon_inserter_quality: Quality,
|
||||
) -> (Blueprint, PositionType) {
|
||||
let mut b = Blueprint::new();
|
||||
|
||||
|
|
@ -20,7 +22,7 @@ pub fn unloader(
|
|||
(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::Express, true) => (InserterType::Stack, Some(12), Quality::Rare),
|
||||
(Beltspeed::Turbo, true) => (InserterType::Stack, None, Quality::Epic),
|
||||
};
|
||||
if beltspeed == Beltspeed::Normal {
|
||||
|
|
@ -37,12 +39,15 @@ pub fn unloader(
|
|||
Direction::Up,
|
||||
Position::new(2, 2),
|
||||
));
|
||||
b.add_entity(Entity::new_inserter(
|
||||
InserterType::Bulk,
|
||||
b.add_entity(
|
||||
Entity::new_inserter(
|
||||
wagon_inserter_type,
|
||||
None,
|
||||
Position::new(1, 1) + 2 * Position::new(5, -1),
|
||||
Direction::Down,
|
||||
));
|
||||
)
|
||||
.quality(wagon_inserter_quality),
|
||||
);
|
||||
|
||||
b.add_entity(
|
||||
Entity::new_inserter(
|
||||
|
|
@ -62,12 +67,15 @@ pub fn unloader(
|
|||
Direction::Up,
|
||||
Position::new(2, 2),
|
||||
));
|
||||
b.add_entity(Entity::new_inserter(
|
||||
InserterType::Bulk,
|
||||
b.add_entity(
|
||||
Entity::new_inserter(
|
||||
wagon_inserter_type,
|
||||
None,
|
||||
Position::new(1, 1) + 2 * Position::new(1, -1),
|
||||
Direction::Down,
|
||||
));
|
||||
)
|
||||
.quality(wagon_inserter_quality),
|
||||
);
|
||||
|
||||
b.add_entity(
|
||||
Entity::new_inserter(
|
||||
|
|
@ -109,12 +117,15 @@ pub fn unloader(
|
|||
Direction::Up,
|
||||
Position::new(2, 2),
|
||||
));
|
||||
b.add_entity(Entity::new_inserter(
|
||||
InserterType::Bulk,
|
||||
b.add_entity(
|
||||
Entity::new_inserter(
|
||||
wagon_inserter_type,
|
||||
None,
|
||||
Position::new(1, 1) + 2 * Position::new(x, -1),
|
||||
Direction::Down,
|
||||
));
|
||||
)
|
||||
.quality(wagon_inserter_quality),
|
||||
);
|
||||
};
|
||||
|
||||
if belttype.contains_left() {
|
||||
|
|
@ -131,7 +142,12 @@ pub fn unloader(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn one_loader(beltspeed: Beltspeed, stacked: bool) -> (Blueprint, PositionType) {
|
||||
pub fn one_loader(
|
||||
beltspeed: Beltspeed,
|
||||
stacked: bool,
|
||||
wagon_inserter_type: InserterType,
|
||||
wagon_inserter_quality: Quality,
|
||||
) -> (Blueprint, PositionType) {
|
||||
let (belt_inserter, quality) = match (beltspeed, stacked) {
|
||||
(Beltspeed::Normal, false) => (InserterType::Fast, Quality::Normal),
|
||||
(Beltspeed::Fast, false) => (InserterType::Fast, Quality::Normal),
|
||||
|
|
@ -174,12 +190,15 @@ pub fn one_loader(beltspeed: Beltspeed, stacked: bool) -> (Blueprint, PositionTy
|
|||
Direction::Up,
|
||||
Position::new(2, 2),
|
||||
));
|
||||
b.add_entity(Entity::new_inserter(
|
||||
InserterType::Bulk,
|
||||
b.add_entity(
|
||||
Entity::new_inserter(
|
||||
wagon_inserter_type,
|
||||
None,
|
||||
Position::new(x, -1),
|
||||
Direction::Up,
|
||||
));
|
||||
)
|
||||
.quality(wagon_inserter_quality),
|
||||
);
|
||||
}
|
||||
|
||||
(b, -6)
|
||||
|
|
@ -193,6 +212,8 @@ pub fn basic_station(
|
|||
beltspeed: Beltspeed,
|
||||
belttype: Belttype,
|
||||
stacked: bool,
|
||||
wagon_inserter_type: InserterType,
|
||||
wagon_inserter_quality: Quality,
|
||||
) -> Blueprint {
|
||||
let section_size = length / outputs;
|
||||
assert!(length % outputs == 0);
|
||||
|
|
@ -223,10 +244,14 @@ pub fn basic_station(
|
|||
beltspeed.halvings((length / outputs).ilog2() as usize),
|
||||
belttype,
|
||||
stacked,
|
||||
wagon_inserter_type,
|
||||
wagon_inserter_quality,
|
||||
),
|
||||
true => one_loader(
|
||||
beltspeed.halvings((length / outputs).ilog2() as usize),
|
||||
stacked,
|
||||
wagon_inserter_type,
|
||||
wagon_inserter_quality,
|
||||
),
|
||||
};
|
||||
for l in 0..length {
|
||||
|
|
@ -235,10 +260,14 @@ pub fn basic_station(
|
|||
beltspeed.halvings((length / outputs).ilog2() as usize),
|
||||
belttype,
|
||||
stacked,
|
||||
wagon_inserter_type,
|
||||
wagon_inserter_quality,
|
||||
),
|
||||
true => one_loader(
|
||||
beltspeed.halvings((length / outputs).ilog2() as usize),
|
||||
stacked,
|
||||
wagon_inserter_type,
|
||||
wagon_inserter_quality,
|
||||
),
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
use crate::{BlueprintEntity, BlueprintPosition};
|
||||
use clap::ValueEnum;
|
||||
use factorio_core::{
|
||||
aabb::AABB,
|
||||
beltoptions::Beltspeed,
|
||||
|
|
@ -24,7 +25,7 @@ pub enum UndergroundType {
|
|||
Output,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, ValueEnum)]
|
||||
pub enum InserterType {
|
||||
Burner,
|
||||
Normal,
|
||||
|
|
@ -82,7 +83,7 @@ impl ElectricPoleType {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, ValueEnum)]
|
||||
pub enum Quality {
|
||||
Normal,
|
||||
Uncommon,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue