Add assembly generation

This commit is contained in:
hal8174 2025-01-23 21:01:25 +01:00
parent fec7dd70db
commit 05f4edf83a
4 changed files with 286 additions and 0 deletions

View file

@ -17,6 +17,7 @@ pub enum UndergroundType {
pub enum InserterType {
Burner,
Normal,
Long,
Fast,
Bulk,
Stack,
@ -27,6 +28,7 @@ impl InserterType {
match self {
InserterType::Burner => "burner-inserter",
InserterType::Normal => "inserter",
InserterType::Long => "long-handed-inserter",
InserterType::Fast => "fast-inserter",
InserterType::Bulk => "bulk-inserter",
InserterType::Stack => "stack-inserter",
@ -87,6 +89,11 @@ pub enum EntityType {
inserter_type: InserterType,
override_stack_size: Option<u8>,
},
Production {
name: String,
recipe: String,
size: Position,
},
Unknown {
name: String,
size: Position,
@ -149,6 +156,24 @@ impl Entity {
)
}
pub fn new_production(
name: impl AsRef<str>,
recipe: impl AsRef<str>,
position: Position,
direction: Direction,
size: Position,
) -> Self {
Self::new(
EntityType::Production {
name: name.as_ref().to_owned(),
recipe: recipe.as_ref().to_owned(),
size,
},
position,
direction,
)
}
pub fn new_unknown(
name: impl AsRef<str>,
position: Position,
@ -188,6 +213,11 @@ impl Entity {
inserter_type,
override_stack_size: _,
} => inserter_type.string(),
EntityType::Production {
name,
recipe: _,
size: _,
} => name.clone(),
}
}
@ -211,6 +241,17 @@ impl Entity {
}
}
pub fn get_maybe_recipe(&self) -> Option<String> {
match &self.entity {
EntityType::Production {
name: _,
recipe,
size: _,
} => Some(recipe.clone()),
_ => None,
}
}
pub fn size(&self) -> Position {
match &self.entity {
EntityType::Splitter(_) => Position::new(4, 2),
@ -219,6 +260,11 @@ impl Entity {
size,
misc: _,
} => *size,
EntityType::Production {
name: _,
recipe: _,
size,
} => *size,
EntityType::ElectricPole(electric_pole_type) => electric_pole_type.size(),
_ => Position::new(2, 2),
}
@ -321,6 +367,7 @@ impl Blueprint {
})
.maybe_underground_type(e.get_maybe_underground_type_string())
.maybe_override_stack_size(e.get_maybe_override_stack_size())
.maybe_recipe(e.get_maybe_recipe())
.build()
})
.collect();