Improve automatic splitter

This commit is contained in:
hal8174 2025-04-01 18:56:28 +02:00
parent aee56af22f
commit 618d9ca9de
2 changed files with 60 additions and 19 deletions

View file

@ -144,6 +144,7 @@ pub enum EntityType {
beltspeed: Beltspeed,
input_priority_left: Option<bool>,
output_priority_left: Option<bool>,
filter: Option<String>,
},
ElectricPole(ElectricPoleType),
Inserter {
@ -212,6 +213,7 @@ impl Entity {
beltspeed,
input_priority_left: None,
output_priority_left: None,
filter: None,
},
position,
direction,
@ -224,12 +226,14 @@ impl Entity {
direction: Direction,
input_priority_left: Option<bool>,
output_priority_left: Option<bool>,
filter: Option<String>,
) -> Self {
Self::new(
EntityType::Splitter {
beltspeed,
input_priority_left,
output_priority_left,
filter,
},
position,
direction,
@ -321,6 +325,7 @@ impl Entity {
beltspeed,
input_priority_left: _,
output_priority_left: _,
filter: _,
} => beltspeed.string_splitter(),
EntityType::Unknown {
name,
@ -379,6 +384,7 @@ impl Entity {
beltspeed: _,
input_priority_left,
output_priority_left: _,
filter: _,
} => match input_priority_left {
Some(true) => Some("left".to_string()),
Some(false) => Some("right".to_string()),
@ -394,6 +400,7 @@ impl Entity {
beltspeed: _,
input_priority_left: _,
output_priority_left,
filter: _,
} => match output_priority_left {
Some(true) => Some("left".to_string()),
Some(false) => Some("right".to_string()),
@ -402,6 +409,19 @@ impl Entity {
_ => None,
}
}
pub fn get_maybe_filter(&self) -> Option<String> {
match &self.entity {
EntityType::Splitter {
beltspeed: _,
input_priority_left: _,
output_priority_left: _,
filter,
} => filter.clone(),
_ => None,
}
}
pub fn size(&self) -> Position {
match &self.entity {
EntityType::Splitter { .. } => Position::new(4, 2),
@ -631,6 +651,7 @@ impl Blueprint {
.maybe_recipe(e.get_maybe_recipe())
.maybe_input_priority(e.get_maybe_input_priority())
.maybe_output_priority(e.get_maybe_output_priority())
.maybe_filter(e.get_maybe_filter())
.build()
})
.collect();