Fix quality serialization
This commit is contained in:
parent
06b01c2fe4
commit
65e2c03824
3 changed files with 15 additions and 3 deletions
|
|
@ -1,4 +1,5 @@
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
|
use factorio_blueprint::abstraction::serde::AbstractBlueprintString;
|
||||||
use factorio_blueprint::{BlueprintString, encode};
|
use factorio_blueprint::{BlueprintString, encode};
|
||||||
use factorio_blueprint_generator::multistation::{StationSpec, multistation};
|
use factorio_blueprint_generator::multistation::{StationSpec, multistation};
|
||||||
use factorio_core::beltoptions::Beltspeed;
|
use factorio_core::beltoptions::Beltspeed;
|
||||||
|
|
@ -67,7 +68,7 @@ fn main() {
|
||||||
b.connect_power_networks();
|
b.connect_power_networks();
|
||||||
|
|
||||||
b.print_visualization();
|
b.print_visualization();
|
||||||
let b = BlueprintString::Blueprint(b.to_blueprint());
|
let b = AbstractBlueprintString { blueprint: &b };
|
||||||
|
|
||||||
if args.json {
|
if args.json {
|
||||||
println!("{}", serde_json::to_string_pretty(&b).unwrap());
|
println!("{}", serde_json::to_string_pretty(&b).unwrap());
|
||||||
|
|
|
||||||
|
|
@ -65,8 +65,8 @@ pub fn unloader(beltspeed: Beltspeed, belttype: Belttype) -> (Blueprint, Positio
|
||||||
let (belt_inserter, stack_size, quality) = match beltspeed {
|
let (belt_inserter, stack_size, quality) = match beltspeed {
|
||||||
Beltspeed::Normal => unreachable!(),
|
Beltspeed::Normal => unreachable!(),
|
||||||
Beltspeed::Fast => (InserterType::Fast, None, Quality::Normal),
|
Beltspeed::Fast => (InserterType::Fast, None, Quality::Normal),
|
||||||
Beltspeed::Express => (InserterType::Bulk, Some(8), Quality::Normal),
|
Beltspeed::Express => (InserterType::Bulk, Some(7), Quality::Normal),
|
||||||
Beltspeed::Turbo => (InserterType::Bulk, None, Quality::Epic),
|
Beltspeed::Turbo => (InserterType::Bulk, Some(10), Quality::Normal),
|
||||||
};
|
};
|
||||||
|
|
||||||
b.add_entity(Entity::new_belt(
|
b.add_entity(Entity::new_belt(
|
||||||
|
|
|
||||||
|
|
@ -83,6 +83,17 @@ impl Serialize for SerializeEntityWrapper<'_> {
|
||||||
|
|
||||||
entity_map.serialize_entry("position", &SerializePosition(self.1.position))?;
|
entity_map.serialize_entry("position", &SerializePosition(self.1.position))?;
|
||||||
|
|
||||||
|
let quality = match self.1.quality {
|
||||||
|
super::Quality::Normal => None,
|
||||||
|
super::Quality::Uncommon => Some("uncommon"),
|
||||||
|
super::Quality::Rare => Some("rare"),
|
||||||
|
super::Quality::Epic => Some("epic"),
|
||||||
|
super::Quality::Legendary => Some("legendary"),
|
||||||
|
};
|
||||||
|
if let Some(quality) = quality {
|
||||||
|
entity_map.serialize_entry("quality", quality)?;
|
||||||
|
}
|
||||||
|
|
||||||
if self.1.direction.get_index() != 0 {
|
if self.1.direction.get_index() != 0 {
|
||||||
entity_map.serialize_entry("direction", &self.1.direction.get_index())?;
|
entity_map.serialize_entry("direction", &self.1.direction.get_index())?;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue