refactor(vm): update prefab database with new data
This commit is contained in:
54314
data/database.json
54314
data/database.json
File diff suppressed because one or more lines are too long
@@ -1,5 +1,4 @@
|
||||
{
|
||||
"rust-analyzer.cargo.target": "wasm32-unknown-unknown",
|
||||
"rust-analyzer.cargo.features": [
|
||||
]
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -14,27 +14,45 @@ pub enum ObjectTemplate {
|
||||
StructureSlots(StructureSlotsTemplate),
|
||||
StructureLogic(StructureLogicTemplate),
|
||||
StructureLogicDevice(StructureLogicDeviceTemplate),
|
||||
StructureLogicDeviceConsumer(StructureLogicDeviceConsumerTemplate),
|
||||
StructureLogicDeviceMemory(StructureLogicDeviceMemoryTemplate),
|
||||
StructureLogicDeviceConsumerMemory(StructureLogicDeviceConsumerMemoryTemplate),
|
||||
StructureCircuitHolder(StructureCircuitHolderTemplate),
|
||||
Item(ItemTemplate),
|
||||
ItemSlots(ItemSlotsTemplate),
|
||||
ItemConsumer(ItemConsumerTemplate),
|
||||
ItemLogic(ItemLogicTemplate),
|
||||
ItemLogicMemory(ItemLogicMemoryTemplate),
|
||||
ItemCircuitHolder(ItemCircuitHolderTemplate),
|
||||
ItemSuit(ItemSuitTemplate),
|
||||
ItemSuitLogic(ItemSuitLogicTemplate),
|
||||
ItemSuitCircuitHolder(ItemSuitCircuitHolderTemplate),
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
impl ObjectTemplate {
|
||||
#[allow(clippy::must_use_candidate)]
|
||||
pub fn prefab(&self) -> &PrefabInfo {
|
||||
#[allow(clippy::enum_glob_use)]
|
||||
use ObjectTemplate::*;
|
||||
match self {
|
||||
Structure(s) => &s.prefab,
|
||||
StructureSlots(s) => &s.prefab,
|
||||
StructureLogic(s) => &s.prefab,
|
||||
StructureLogicDevice(s) => &s.prefab,
|
||||
StructureLogicDeviceConsumer(s) => &s.prefab,
|
||||
StructureLogicDeviceMemory(s) => &s.prefab,
|
||||
StructureLogicDeviceConsumerMemory(s) => &s.prefab,
|
||||
StructureCircuitHolder(s) => &s.prefab,
|
||||
Item(i) => &i.prefab,
|
||||
ItemSlots(i) => &i.prefab,
|
||||
ItemConsumer(i) => &i.prefab,
|
||||
ItemLogic(i) => &i.prefab,
|
||||
ItemLogicMemory(i) => &i.prefab,
|
||||
ItemCircuitHolder(i) => &i.prefab,
|
||||
ItemSuit(i) => &i.prefab,
|
||||
ItemSuitLogic(i) => &i.prefab,
|
||||
ItemSuitCircuitHolder(i) => &i.prefab,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -62,6 +80,11 @@ impl From<StructureLogicDeviceTemplate> for ObjectTemplate {
|
||||
Self::StructureLogicDevice(value)
|
||||
}
|
||||
}
|
||||
impl From<StructureLogicDeviceConsumerTemplate> for ObjectTemplate {
|
||||
fn from(value: StructureLogicDeviceConsumerTemplate) -> Self {
|
||||
Self::StructureLogicDeviceConsumer(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StructureLogicDeviceMemoryTemplate> for ObjectTemplate {
|
||||
fn from(value: StructureLogicDeviceMemoryTemplate) -> Self {
|
||||
@@ -69,6 +92,12 @@ impl From<StructureLogicDeviceMemoryTemplate> for ObjectTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StructureLogicDeviceConsumerMemoryTemplate> for ObjectTemplate {
|
||||
fn from(value: StructureLogicDeviceConsumerMemoryTemplate) -> Self {
|
||||
Self::StructureLogicDeviceConsumerMemory(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ItemTemplate> for ObjectTemplate {
|
||||
fn from(value: ItemTemplate) -> Self {
|
||||
Self::Item(value)
|
||||
@@ -81,6 +110,12 @@ impl From<ItemSlotsTemplate> for ObjectTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ItemConsumerTemplate> for ObjectTemplate {
|
||||
fn from(value: ItemConsumerTemplate) -> Self {
|
||||
Self::ItemConsumer(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ItemLogicTemplate> for ObjectTemplate {
|
||||
fn from(value: ItemLogicTemplate) -> Self {
|
||||
Self::ItemLogic(value)
|
||||
@@ -93,6 +128,36 @@ impl From<ItemLogicMemoryTemplate> for ObjectTemplate {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ItemSuitCircuitHolderTemplate> for ObjectTemplate {
|
||||
fn from(value: ItemSuitCircuitHolderTemplate) -> Self {
|
||||
Self::ItemSuitCircuitHolder(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ItemSuitTemplate> for ObjectTemplate {
|
||||
fn from(value: ItemSuitTemplate) -> Self {
|
||||
Self::ItemSuit(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ItemSuitLogicTemplate> for ObjectTemplate {
|
||||
fn from(value: ItemSuitLogicTemplate) -> Self {
|
||||
Self::ItemSuitLogic(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ItemCircuitHolderTemplate> for ObjectTemplate {
|
||||
fn from(value: ItemCircuitHolderTemplate) -> Self {
|
||||
Self::ItemCircuitHolder(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl From<StructureCircuitHolderTemplate> for ObjectTemplate {
|
||||
fn from(value: StructureCircuitHolderTemplate) -> Self {
|
||||
Self::StructureCircuitHolder(value)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||
pub struct PrefabInfo {
|
||||
pub prefab_name: String,
|
||||
@@ -133,6 +198,7 @@ pub struct ConnectionInfo {
|
||||
pub role: ConnectionRole,
|
||||
}
|
||||
|
||||
#[allow(clippy::struct_excessive_bools)]
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct DeviceInfo {
|
||||
pub connection_list: Vec<ConnectionInfo>,
|
||||
@@ -147,6 +213,12 @@ pub struct DeviceInfo {
|
||||
pub has_reagents: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct ConsumerInfo {
|
||||
pub consumed_resouces: Vec<String>,
|
||||
pub processed_reagents: Vec<i32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||
pub struct StructureInfo {
|
||||
pub small_grid: bool,
|
||||
@@ -166,16 +238,37 @@ pub struct MemoryInfo {
|
||||
pub memory_size: u32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct ThermalInfo {
|
||||
pub convection_factor: f32,
|
||||
pub radiation_factor: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct InternalAtmoInfo {
|
||||
pub volume: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct SuitInfo {
|
||||
pub hygine_reduction_multiplier: f32,
|
||||
pub waste_max_pressure: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct StructureTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub structure: StructureInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct StructureSlotsTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub structure: StructureInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
}
|
||||
|
||||
@@ -183,6 +276,8 @@ pub struct StructureSlotsTemplate {
|
||||
pub struct StructureLogicTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub structure: StructureInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub logic: LogicInfo,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
}
|
||||
@@ -191,38 +286,94 @@ pub struct StructureLogicTemplate {
|
||||
pub struct StructureLogicDeviceTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub structure: StructureInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub logic: LogicInfo,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
pub device: DeviceInfo,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct StructureLogicDeviceConsumerTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub structure: StructureInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub logic: LogicInfo,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
pub device: DeviceInfo,
|
||||
pub consumer_info: ConsumerInfo,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct StructureLogicDeviceMemoryTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub structure: StructureInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub logic: LogicInfo,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
pub device: DeviceInfo,
|
||||
pub memory: MemoryInfo,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct StructureCircuitHolderTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub structure: StructureInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub logic: LogicInfo,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
pub device: DeviceInfo,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct StructureLogicDeviceConsumerMemoryTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub structure: StructureInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub logic: LogicInfo,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
pub device: DeviceInfo,
|
||||
pub consumer_info: ConsumerInfo,
|
||||
pub memory: MemoryInfo,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct ItemTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub item: ItemInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct ItemSlotsTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub item: ItemInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct ItemConsumerTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub item: ItemInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
pub consumer_info: ConsumerInfo,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct ItemLogicTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub item: ItemInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub logic: LogicInfo,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
}
|
||||
@@ -231,7 +382,52 @@ pub struct ItemLogicTemplate {
|
||||
pub struct ItemLogicMemoryTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub item: ItemInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub logic: LogicInfo,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
pub memory: MemoryInfo,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct ItemCircuitHolderTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub item: ItemInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub logic: LogicInfo,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct ItemSuitTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub item: ItemInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
pub suit_info: SuitInfo,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct ItemSuitLogicTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub item: ItemInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub logic: LogicInfo,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
pub suit_info: SuitInfo,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct ItemSuitCircuitHolderTemplate {
|
||||
pub prefab: PrefabInfo,
|
||||
pub item: ItemInfo,
|
||||
pub thermal_info: Option<ThermalInfo>,
|
||||
pub internal_atmo_info: Option<InternalAtmoInfo>,
|
||||
pub logic: LogicInfo,
|
||||
pub slots: Vec<SlotInfo>,
|
||||
pub suit_info: SuitInfo,
|
||||
pub memory: MemoryInfo,
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![allow(clippy::module_name_repetitions, clippy::enum_glob_use)]
|
||||
|
||||
use std::{
|
||||
collections::BTreeMap,
|
||||
io::{BufWriter, Write},
|
||||
@@ -9,22 +11,30 @@ use serde_derive::{Deserialize, Serialize};
|
||||
|
||||
use crate::{
|
||||
enums,
|
||||
stationpedia::{self, Page, Stationpedia},
|
||||
stationpedia::{self, Memory, Page, Stationpedia},
|
||||
};
|
||||
|
||||
use stationeers_data::templates::{
|
||||
ConnectionInfo, DeviceInfo, Instruction, ItemInfo, ItemLogicMemoryTemplate, ItemLogicTemplate,
|
||||
ItemSlotsTemplate, ItemTemplate, LogicInfo, MemoryInfo, ObjectTemplate, PrefabInfo, SlotInfo,
|
||||
StructureInfo, StructureLogicDeviceMemoryTemplate, StructureLogicDeviceTemplate,
|
||||
StructureLogicTemplate, StructureSlotsTemplate, StructureTemplate,
|
||||
use stationeers_data::{
|
||||
enums::MemoryAccess,
|
||||
templates::{
|
||||
ConnectionInfo, ConsumerInfo, DeviceInfo, Instruction, InternalAtmoInfo,
|
||||
ItemCircuitHolderTemplate, ItemConsumerTemplate, ItemInfo, ItemLogicMemoryTemplate,
|
||||
ItemLogicTemplate, ItemSlotsTemplate, ItemSuitCircuitHolderTemplate, ItemSuitLogicTemplate,
|
||||
ItemSuitTemplate, ItemTemplate, LogicInfo, MemoryInfo, ObjectTemplate, PrefabInfo,
|
||||
SlotInfo, StructureCircuitHolderTemplate, StructureInfo,
|
||||
StructureLogicDeviceConsumerMemoryTemplate, StructureLogicDeviceConsumerTemplate,
|
||||
StructureLogicDeviceMemoryTemplate, StructureLogicDeviceTemplate, StructureLogicTemplate,
|
||||
StructureSlotsTemplate, StructureTemplate, SuitInfo, ThermalInfo,
|
||||
},
|
||||
};
|
||||
|
||||
#[allow(clippy::too_many_lines)]
|
||||
pub fn generate_database(
|
||||
stationpedia: &stationpedia::Stationpedia,
|
||||
enums: &enums::Enums,
|
||||
workspace: &std::path::Path,
|
||||
) -> color_eyre::Result<Vec<PathBuf>> {
|
||||
let templates = generate_templates(stationpedia)?;
|
||||
let templates = generate_templates(stationpedia);
|
||||
|
||||
eprintln!("Writing prefab database ...");
|
||||
|
||||
@@ -46,8 +56,19 @@ pub fn generate_database(
|
||||
| StructureSlots(_)
|
||||
| StructureLogic(_)
|
||||
| StructureLogicDevice(_)
|
||||
| StructureLogicDeviceMemory(_) => Some(val.prefab().prefab_name.clone()),
|
||||
Item(_) | ItemSlots(_) | ItemLogic(_) | ItemLogicMemory(_) => None,
|
||||
| StructureCircuitHolder(_)
|
||||
| StructureLogicDeviceConsumer(_)
|
||||
| StructureLogicDeviceMemory(_)
|
||||
| StructureLogicDeviceConsumerMemory(_) => Some(val.prefab().prefab_name.clone()),
|
||||
Item(_)
|
||||
| ItemSlots(_)
|
||||
| ItemConsumer(_)
|
||||
| ItemLogic(_)
|
||||
| ItemCircuitHolder(_)
|
||||
| ItemLogicMemory(_)
|
||||
| ItemSuit(_)
|
||||
| ItemSuitLogic(_)
|
||||
| ItemSuitCircuitHolder(_) => None,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
@@ -60,10 +81,19 @@ pub fn generate_database(
|
||||
| StructureSlots(_)
|
||||
| StructureLogic(_)
|
||||
| StructureLogicDevice(_)
|
||||
| StructureLogicDeviceMemory(_) => None,
|
||||
Item(_) | ItemSlots(_) | ItemLogic(_) | ItemLogicMemory(_) => {
|
||||
Some(val.prefab().prefab_name.clone())
|
||||
}
|
||||
| StructureCircuitHolder(_)
|
||||
| StructureLogicDeviceConsumer(_)
|
||||
| StructureLogicDeviceMemory(_)
|
||||
| StructureLogicDeviceConsumerMemory(_) => None,
|
||||
Item(_)
|
||||
| ItemSlots(_)
|
||||
| ItemConsumer(_)
|
||||
| ItemLogic(_)
|
||||
| ItemCircuitHolder(_)
|
||||
| ItemLogicMemory(_)
|
||||
| ItemSuit(_)
|
||||
| ItemSuitLogic(_)
|
||||
| ItemSuitCircuitHolder(_) => Some(val.prefab().prefab_name.clone()),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
@@ -76,10 +106,19 @@ pub fn generate_database(
|
||||
| StructureSlots(_)
|
||||
| StructureLogic(_)
|
||||
| StructureLogicDevice(_)
|
||||
| StructureCircuitHolder(_)
|
||||
| StructureLogicDeviceConsumer(_)
|
||||
| StructureLogicDeviceMemory(_)
|
||||
| StructureLogicDeviceConsumerMemory(_)
|
||||
| Item(_)
|
||||
| ItemSlots(_) => None,
|
||||
ItemLogic(_) | ItemLogicMemory(_) => Some(val.prefab().prefab_name.clone()),
|
||||
| ItemSlots(_)
|
||||
| ItemSuit(_)
|
||||
| ItemConsumer(_) => None,
|
||||
ItemLogic(_)
|
||||
| ItemCircuitHolder(_)
|
||||
| ItemLogicMemory(_)
|
||||
| ItemSuitLogic(_)
|
||||
| ItemSuitCircuitHolder(_) => Some(val.prefab().prefab_name.clone()),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
@@ -89,11 +128,47 @@ pub fn generate_database(
|
||||
.filter_map(|(_, val)| {
|
||||
use ObjectTemplate::*;
|
||||
match val {
|
||||
Structure(_) | StructureSlots(_) | StructureLogic(_) | Item(_) | ItemSlots(_)
|
||||
| ItemLogic(_) | ItemLogicMemory(_) => None,
|
||||
StructureLogicDevice(_) | StructureLogicDeviceMemory(_) => {
|
||||
Structure(_)
|
||||
| StructureSlots(_)
|
||||
| StructureLogic(_)
|
||||
| Item(_)
|
||||
| ItemSlots(_)
|
||||
| ItemConsumer(_)
|
||||
| ItemLogic(_)
|
||||
| ItemCircuitHolder(_)
|
||||
| ItemLogicMemory(_)
|
||||
| ItemSuit(_)
|
||||
| ItemSuitLogic(_)
|
||||
| ItemSuitCircuitHolder(_) => None,
|
||||
StructureLogicDevice(_)
|
||||
| StructureCircuitHolder(_)
|
||||
| StructureLogicDeviceMemory(_)
|
||||
| StructureLogicDeviceConsumer(_)
|
||||
| StructureLogicDeviceConsumerMemory(_) => Some(val.prefab().prefab_name.clone()),
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let suits = prefabs
|
||||
.iter()
|
||||
.filter_map(|(_, val)| {
|
||||
use ObjectTemplate::*;
|
||||
match val {
|
||||
ItemSuitCircuitHolder(_) | ItemSuitLogic(_) | ItemSuit(_) => {
|
||||
Some(val.prefab().prefab_name.clone())
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
let circuit_holders = prefabs
|
||||
.iter()
|
||||
.filter_map(|(_, val)| {
|
||||
use ObjectTemplate::*;
|
||||
match val {
|
||||
ItemSuitCircuitHolder(_) | ItemCircuitHolder(_) | StructureCircuitHolder(_) => {
|
||||
Some(val.prefab().prefab_name.clone())
|
||||
}
|
||||
_ => None,
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
@@ -106,6 +181,8 @@ pub fn generate_database(
|
||||
devices,
|
||||
items,
|
||||
logicable_items,
|
||||
suits,
|
||||
circuit_holders,
|
||||
};
|
||||
|
||||
let data_path = workspace.join("data");
|
||||
@@ -114,7 +191,7 @@ pub fn generate_database(
|
||||
}
|
||||
let database_path = data_path.join("database.json");
|
||||
let mut database_file = std::io::BufWriter::new(std::fs::File::create(database_path)?);
|
||||
serde_json::to_writer(&mut database_file, &db)?;
|
||||
serde_json::to_writer_pretty(&mut database_file, &db)?;
|
||||
database_file.flush()?;
|
||||
|
||||
let prefab_map_path = workspace
|
||||
@@ -171,10 +248,11 @@ fn write_prefab_map<T: std::io::Write>(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn generate_templates(pedia: &Stationpedia) -> color_eyre::Result<Vec<ObjectTemplate>> {
|
||||
#[allow(clippy::too_many_lines)]
|
||||
fn generate_templates(pedia: &Stationpedia) -> Vec<ObjectTemplate> {
|
||||
println!("Generating templates ...");
|
||||
let mut templates: Vec<ObjectTemplate> = Vec::new();
|
||||
for page in pedia.pages.iter() {
|
||||
for page in &pedia.pages {
|
||||
let prefab = PrefabInfo {
|
||||
prefab_name: page.prefab_name.clone(),
|
||||
prefab_hash: page.prefab_hash,
|
||||
@@ -192,14 +270,19 @@ fn generate_templates(pedia: &Stationpedia) -> color_eyre::Result<Vec<ObjectTemp
|
||||
slot_inserts,
|
||||
memory: None,
|
||||
device: None,
|
||||
transmission_receiver: None,
|
||||
wireless_logic: None,
|
||||
circuit_holder: None,
|
||||
transmission_receiver: false,
|
||||
wireless_logic: false,
|
||||
circuit_holder: false,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} if slot_inserts.is_empty() => {
|
||||
} if slot_inserts.is_empty() && item.suit.is_none() => {
|
||||
templates.push(ObjectTemplate::Item(ItemTemplate {
|
||||
prefab,
|
||||
item: item.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
}));
|
||||
}
|
||||
Page {
|
||||
@@ -209,14 +292,132 @@ fn generate_templates(pedia: &Stationpedia) -> color_eyre::Result<Vec<ObjectTemp
|
||||
slot_inserts,
|
||||
memory: None,
|
||||
device: None,
|
||||
transmission_receiver: None,
|
||||
wireless_logic: None,
|
||||
circuit_holder: None,
|
||||
transmission_receiver: false,
|
||||
wireless_logic: false,
|
||||
circuit_holder: false,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} => {
|
||||
} if item.suit.is_none() => {
|
||||
templates.push(ObjectTemplate::ItemSlots(ItemSlotsTemplate {
|
||||
prefab,
|
||||
item: item.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
}));
|
||||
}
|
||||
Page {
|
||||
item: Some(item),
|
||||
structure: None,
|
||||
logic_info: None,
|
||||
slot_inserts,
|
||||
memory: None,
|
||||
device: None,
|
||||
transmission_receiver: false,
|
||||
wireless_logic: false,
|
||||
circuit_holder: false,
|
||||
resource_consumer: Some(consumer),
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} if item.suit.is_none() => {
|
||||
templates.push(ObjectTemplate::ItemConsumer(ItemConsumerTemplate {
|
||||
prefab,
|
||||
item: item.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
consumer_info: consumer.into(),
|
||||
}));
|
||||
}
|
||||
Page {
|
||||
item: Some(item),
|
||||
structure: None,
|
||||
logic_info: None,
|
||||
slot_inserts,
|
||||
memory: None,
|
||||
device: None,
|
||||
transmission_receiver: false,
|
||||
wireless_logic: false,
|
||||
circuit_holder: false,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} if item.suit.is_some() => {
|
||||
templates.push(ObjectTemplate::ItemSuit(ItemSuitTemplate {
|
||||
prefab,
|
||||
item: item.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
suit_info: item.suit.as_ref().unwrap().into(),
|
||||
}));
|
||||
}
|
||||
Page {
|
||||
item: Some(item),
|
||||
structure: None,
|
||||
logic_info: Some(logic),
|
||||
slot_inserts,
|
||||
memory: None,
|
||||
device: None,
|
||||
transmission_receiver,
|
||||
wireless_logic,
|
||||
circuit_holder: false,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} if item.suit.is_some() => {
|
||||
let mut logic: LogicInfo = logic.into();
|
||||
if !page.mode_insert.is_empty() {
|
||||
logic.modes = Some(mode_inserts_to_info(&page.mode_insert));
|
||||
}
|
||||
logic.transmission_receiver = *transmission_receiver;
|
||||
logic.wireless_logic = *wireless_logic;
|
||||
logic.circuit_holder = false;
|
||||
|
||||
templates.push(ObjectTemplate::ItemSuitLogic(ItemSuitLogicTemplate {
|
||||
prefab,
|
||||
item: item.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
logic,
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
suit_info: item.suit.as_ref().unwrap().into(),
|
||||
}));
|
||||
}
|
||||
Page {
|
||||
item: Some(item),
|
||||
structure: None,
|
||||
logic_info: Some(logic),
|
||||
slot_inserts,
|
||||
memory: None,
|
||||
device: None,
|
||||
transmission_receiver,
|
||||
wireless_logic,
|
||||
circuit_holder: false,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} if item.suit.is_none() => {
|
||||
let mut logic: LogicInfo = logic.into();
|
||||
if !page.mode_insert.is_empty() {
|
||||
logic.modes = Some(mode_inserts_to_info(&page.mode_insert));
|
||||
}
|
||||
logic.transmission_receiver = *transmission_receiver;
|
||||
logic.wireless_logic = *wireless_logic;
|
||||
logic.circuit_holder = false;
|
||||
|
||||
templates.push(ObjectTemplate::ItemLogic(ItemLogicTemplate {
|
||||
prefab,
|
||||
item: item.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
logic,
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
}));
|
||||
}
|
||||
@@ -229,23 +430,30 @@ fn generate_templates(pedia: &Stationpedia) -> color_eyre::Result<Vec<ObjectTemp
|
||||
device: None,
|
||||
transmission_receiver,
|
||||
wireless_logic,
|
||||
circuit_holder,
|
||||
circuit_holder: true,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} => {
|
||||
} if item.suit.is_none() => {
|
||||
let mut logic: LogicInfo = logic.into();
|
||||
if !page.mode_insert.is_empty() {
|
||||
logic.modes = Some(mode_inserts_to_info(&page.mode_insert));
|
||||
}
|
||||
logic.transmission_receiver = transmission_receiver.unwrap_or(false);
|
||||
logic.wireless_logic = wireless_logic.unwrap_or(false);
|
||||
logic.circuit_holder = circuit_holder.unwrap_or(false);
|
||||
logic.transmission_receiver = *transmission_receiver;
|
||||
logic.wireless_logic = *wireless_logic;
|
||||
logic.circuit_holder = true;
|
||||
|
||||
templates.push(ObjectTemplate::ItemLogic(ItemLogicTemplate {
|
||||
prefab,
|
||||
item: item.into(),
|
||||
logic,
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
}));
|
||||
templates.push(ObjectTemplate::ItemCircuitHolder(
|
||||
ItemCircuitHolderTemplate {
|
||||
prefab,
|
||||
item: item.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
logic,
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
},
|
||||
));
|
||||
}
|
||||
Page {
|
||||
item: Some(item),
|
||||
@@ -256,20 +464,61 @@ fn generate_templates(pedia: &Stationpedia) -> color_eyre::Result<Vec<ObjectTemp
|
||||
device: None,
|
||||
transmission_receiver,
|
||||
wireless_logic,
|
||||
circuit_holder,
|
||||
circuit_holder: true,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} => {
|
||||
} if item.suit.is_some() => {
|
||||
let mut logic: LogicInfo = logic.into();
|
||||
if !page.mode_insert.is_empty() {
|
||||
logic.modes = Some(mode_inserts_to_info(&page.mode_insert));
|
||||
}
|
||||
logic.transmission_receiver = transmission_receiver.unwrap_or(false);
|
||||
logic.wireless_logic = wireless_logic.unwrap_or(false);
|
||||
logic.circuit_holder = circuit_holder.unwrap_or(false);
|
||||
logic.transmission_receiver = *transmission_receiver;
|
||||
logic.wireless_logic = *wireless_logic;
|
||||
logic.circuit_holder = true;
|
||||
|
||||
templates.push(ObjectTemplate::ItemSuitCircuitHolder(
|
||||
ItemSuitCircuitHolderTemplate {
|
||||
prefab,
|
||||
item: item.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
logic,
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
suit_info: item.suit.as_ref().unwrap().into(),
|
||||
memory: memory.into(),
|
||||
},
|
||||
));
|
||||
}
|
||||
Page {
|
||||
item: Some(item),
|
||||
structure: None,
|
||||
logic_info: Some(logic),
|
||||
slot_inserts,
|
||||
memory: Some(memory),
|
||||
device: None,
|
||||
transmission_receiver,
|
||||
wireless_logic,
|
||||
circuit_holder: false,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} if item.suit.is_none() => {
|
||||
let mut logic: LogicInfo = logic.into();
|
||||
if !page.mode_insert.is_empty() {
|
||||
logic.modes = Some(mode_inserts_to_info(&page.mode_insert));
|
||||
}
|
||||
logic.transmission_receiver = *transmission_receiver;
|
||||
logic.wireless_logic = *wireless_logic;
|
||||
logic.circuit_holder = false;
|
||||
|
||||
templates.push(ObjectTemplate::ItemLogicMemory(ItemLogicMemoryTemplate {
|
||||
prefab,
|
||||
item: item.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
logic,
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
memory: memory.into(),
|
||||
@@ -282,14 +531,19 @@ fn generate_templates(pedia: &Stationpedia) -> color_eyre::Result<Vec<ObjectTemp
|
||||
logic_info: None,
|
||||
memory: None,
|
||||
device: None,
|
||||
transmission_receiver: None,
|
||||
wireless_logic: None,
|
||||
circuit_holder: None,
|
||||
transmission_receiver: false,
|
||||
wireless_logic: false,
|
||||
circuit_holder: false,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} if slot_inserts.is_empty() => {
|
||||
templates.push(ObjectTemplate::Structure(StructureTemplate {
|
||||
prefab,
|
||||
structure: structure.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
}));
|
||||
// println!("Structure")
|
||||
}
|
||||
@@ -300,14 +554,19 @@ fn generate_templates(pedia: &Stationpedia) -> color_eyre::Result<Vec<ObjectTemp
|
||||
logic_info: None,
|
||||
memory: None,
|
||||
device: None,
|
||||
transmission_receiver: None,
|
||||
wireless_logic: None,
|
||||
circuit_holder: None,
|
||||
transmission_receiver: false,
|
||||
wireless_logic: false,
|
||||
circuit_holder: false,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} => {
|
||||
templates.push(ObjectTemplate::StructureSlots(StructureSlotsTemplate {
|
||||
prefab,
|
||||
structure: structure.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
}));
|
||||
// println!("Structure")
|
||||
@@ -321,20 +580,25 @@ fn generate_templates(pedia: &Stationpedia) -> color_eyre::Result<Vec<ObjectTemp
|
||||
device: None,
|
||||
transmission_receiver,
|
||||
wireless_logic,
|
||||
circuit_holder,
|
||||
circuit_holder: false,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} => {
|
||||
let mut logic: LogicInfo = logic.into();
|
||||
if !page.mode_insert.is_empty() {
|
||||
logic.modes = Some(mode_inserts_to_info(&page.mode_insert));
|
||||
}
|
||||
logic.transmission_receiver = transmission_receiver.unwrap_or(false);
|
||||
logic.wireless_logic = wireless_logic.unwrap_or(false);
|
||||
logic.circuit_holder = circuit_holder.unwrap_or(false);
|
||||
logic.transmission_receiver = *transmission_receiver;
|
||||
logic.wireless_logic = *wireless_logic;
|
||||
logic.circuit_holder = false;
|
||||
|
||||
templates.push(ObjectTemplate::StructureLogic(StructureLogicTemplate {
|
||||
prefab,
|
||||
structure: structure.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
logic,
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
}));
|
||||
@@ -349,21 +613,26 @@ fn generate_templates(pedia: &Stationpedia) -> color_eyre::Result<Vec<ObjectTemp
|
||||
device: Some(device),
|
||||
transmission_receiver,
|
||||
wireless_logic,
|
||||
circuit_holder,
|
||||
circuit_holder: false,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} => {
|
||||
let mut logic: LogicInfo = logic.into();
|
||||
if !page.mode_insert.is_empty() {
|
||||
logic.modes = Some(mode_inserts_to_info(&page.mode_insert));
|
||||
}
|
||||
logic.transmission_receiver = transmission_receiver.unwrap_or(false);
|
||||
logic.wireless_logic = wireless_logic.unwrap_or(false);
|
||||
logic.circuit_holder = circuit_holder.unwrap_or(false);
|
||||
logic.transmission_receiver = *transmission_receiver;
|
||||
logic.wireless_logic = *wireless_logic;
|
||||
logic.circuit_holder = false;
|
||||
|
||||
templates.push(ObjectTemplate::StructureLogicDevice(
|
||||
StructureLogicDeviceTemplate {
|
||||
prefab,
|
||||
structure: structure.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
logic,
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
device: device.into(),
|
||||
@@ -371,6 +640,87 @@ fn generate_templates(pedia: &Stationpedia) -> color_eyre::Result<Vec<ObjectTemp
|
||||
));
|
||||
// println!("Structure")
|
||||
}
|
||||
Page {
|
||||
item: None,
|
||||
structure: Some(structure),
|
||||
logic_info: Some(logic),
|
||||
slot_inserts,
|
||||
// NOTE: at the time of writing StructureCircuitHolder structure has a read write 0b memory, useless
|
||||
// other holders have no memory
|
||||
memory:
|
||||
Some(Memory {
|
||||
instructions: None,
|
||||
memory_size: 0,
|
||||
..
|
||||
})
|
||||
| None,
|
||||
device: Some(device),
|
||||
transmission_receiver,
|
||||
wireless_logic,
|
||||
circuit_holder: true,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} => {
|
||||
let mut logic: LogicInfo = logic.into();
|
||||
if !page.mode_insert.is_empty() {
|
||||
logic.modes = Some(mode_inserts_to_info(&page.mode_insert));
|
||||
}
|
||||
logic.transmission_receiver = *transmission_receiver;
|
||||
logic.wireless_logic = *wireless_logic;
|
||||
logic.circuit_holder = true;
|
||||
|
||||
templates.push(ObjectTemplate::StructureCircuitHolder(
|
||||
StructureCircuitHolderTemplate {
|
||||
prefab,
|
||||
structure: structure.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
logic,
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
device: device.into(),
|
||||
},
|
||||
));
|
||||
// println!("Structure")
|
||||
}
|
||||
Page {
|
||||
item: None,
|
||||
structure: Some(structure),
|
||||
logic_info: Some(logic),
|
||||
slot_inserts,
|
||||
memory: None,
|
||||
device: Some(device),
|
||||
transmission_receiver,
|
||||
wireless_logic,
|
||||
circuit_holder: false,
|
||||
resource_consumer: Some(consumer),
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} => {
|
||||
let mut logic: LogicInfo = logic.into();
|
||||
if !page.mode_insert.is_empty() {
|
||||
logic.modes = Some(mode_inserts_to_info(&page.mode_insert));
|
||||
}
|
||||
logic.transmission_receiver = *transmission_receiver;
|
||||
logic.wireless_logic = *wireless_logic;
|
||||
logic.circuit_holder = false;
|
||||
|
||||
templates.push(ObjectTemplate::StructureLogicDeviceConsumer(
|
||||
StructureLogicDeviceConsumerTemplate {
|
||||
prefab,
|
||||
structure: structure.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
logic,
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
device: device.into(),
|
||||
consumer_info: consumer.into(),
|
||||
},
|
||||
));
|
||||
// println!("Structure")
|
||||
}
|
||||
Page {
|
||||
item: None,
|
||||
structure: Some(structure),
|
||||
@@ -380,20 +730,25 @@ fn generate_templates(pedia: &Stationpedia) -> color_eyre::Result<Vec<ObjectTemp
|
||||
device: Some(device),
|
||||
transmission_receiver,
|
||||
wireless_logic,
|
||||
circuit_holder,
|
||||
circuit_holder: false,
|
||||
resource_consumer: None,
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} => {
|
||||
let mut logic: LogicInfo = logic.into();
|
||||
if !page.mode_insert.is_empty() {
|
||||
logic.modes = Some(mode_inserts_to_info(&page.mode_insert));
|
||||
}
|
||||
logic.transmission_receiver = transmission_receiver.unwrap_or(false);
|
||||
logic.wireless_logic = wireless_logic.unwrap_or(false);
|
||||
logic.circuit_holder = circuit_holder.unwrap_or(false);
|
||||
logic.transmission_receiver = *transmission_receiver;
|
||||
logic.wireless_logic = *wireless_logic;
|
||||
logic.circuit_holder = false;
|
||||
templates.push(ObjectTemplate::StructureLogicDeviceMemory(
|
||||
StructureLogicDeviceMemoryTemplate {
|
||||
prefab,
|
||||
structure: structure.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
logic,
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
device: device.into(),
|
||||
@@ -402,20 +757,74 @@ fn generate_templates(pedia: &Stationpedia) -> color_eyre::Result<Vec<ObjectTemp
|
||||
));
|
||||
// println!("Structure")
|
||||
}
|
||||
Page {
|
||||
item: None,
|
||||
structure: Some(structure),
|
||||
logic_info: Some(logic),
|
||||
slot_inserts,
|
||||
memory: Some(memory),
|
||||
device: Some(device),
|
||||
transmission_receiver,
|
||||
wireless_logic,
|
||||
circuit_holder: false,
|
||||
resource_consumer: Some(consumer),
|
||||
internal_atmosphere,
|
||||
thermal,
|
||||
..
|
||||
} => {
|
||||
let mut logic: LogicInfo = logic.into();
|
||||
if !page.mode_insert.is_empty() {
|
||||
logic.modes = Some(mode_inserts_to_info(&page.mode_insert));
|
||||
}
|
||||
logic.transmission_receiver = *transmission_receiver;
|
||||
logic.wireless_logic = *wireless_logic;
|
||||
logic.circuit_holder = false;
|
||||
templates.push(ObjectTemplate::StructureLogicDeviceConsumerMemory(
|
||||
StructureLogicDeviceConsumerMemoryTemplate {
|
||||
prefab,
|
||||
structure: structure.into(),
|
||||
thermal_info: thermal.as_ref().map(Into::into),
|
||||
internal_atmo_info: internal_atmosphere.as_ref().map(Into::into),
|
||||
logic,
|
||||
slots: slot_inserts_to_info(slot_inserts),
|
||||
device: device.into(),
|
||||
consumer_info: consumer.into(),
|
||||
memory: memory.into(),
|
||||
},
|
||||
));
|
||||
// println!("Structure")
|
||||
}
|
||||
_ => panic!(
|
||||
"Non conforming: {:?} \n\titem: {:?}\n\tstructure: {:?}\n\tlogic_info: {:?}\n\tslot_inserts: {:?}\n\tslot_logic: {:?}\n\tmemory: {:?}\n\tdevice: {:?}",
|
||||
page.key,
|
||||
page.item,
|
||||
page.structure,
|
||||
page.logic_info,
|
||||
page.slot_inserts,
|
||||
page.logic_slot_insert,
|
||||
page.memory,
|
||||
page.device,
|
||||
),
|
||||
"\
|
||||
Non conforming: {:?} \n\t\
|
||||
item: {:?}\n\t\
|
||||
structure: {:?}\n\t\
|
||||
logic_info: {:?}\n\t\
|
||||
slot_inserts: {:?}\n\t\
|
||||
slot_logic: {:?}\n\t\
|
||||
memory: {:?}\n\t\
|
||||
circuit_holder: {:?}\n\t\
|
||||
device: {:?}\n\t\
|
||||
resource_consumer: {:?}\n\t\
|
||||
internal_atmosphere: {:?}\n\t\
|
||||
thermal: {:?}\n\t\
|
||||
",
|
||||
page.key,
|
||||
page.item,
|
||||
page.structure,
|
||||
page.logic_info,
|
||||
page.slot_inserts,
|
||||
page.logic_slot_insert,
|
||||
page.memory,
|
||||
page.circuit_holder,
|
||||
page.device,
|
||||
page.resource_consumer,
|
||||
page.internal_atmosphere,
|
||||
page.thermal,
|
||||
),
|
||||
}
|
||||
}
|
||||
Ok(templates)
|
||||
templates
|
||||
}
|
||||
|
||||
fn slot_inserts_to_info(slots: &[stationpedia::SlotInsert]) -> Vec<SlotInfo> {
|
||||
@@ -451,6 +860,34 @@ pub struct ObjectDatabase {
|
||||
pub devices: Vec<String>,
|
||||
pub items: Vec<String>,
|
||||
pub logicable_items: Vec<String>,
|
||||
pub suits: Vec<String>,
|
||||
pub circuit_holders: Vec<String>,
|
||||
}
|
||||
|
||||
impl From<&stationpedia::SuitInfo> for SuitInfo {
|
||||
fn from(value: &stationpedia::SuitInfo) -> Self {
|
||||
SuitInfo {
|
||||
hygine_reduction_multiplier: value.hygine_reduction_multiplier,
|
||||
waste_max_pressure: value.waste_max_pressure,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&stationpedia::ThermalInfo> for ThermalInfo {
|
||||
fn from(value: &stationpedia::ThermalInfo) -> Self {
|
||||
ThermalInfo {
|
||||
convection_factor: value.convection,
|
||||
radiation_factor: value.radiation,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&stationpedia::InternalAtmosphereInfo> for InternalAtmoInfo {
|
||||
fn from(value: &stationpedia::InternalAtmosphereInfo) -> Self {
|
||||
InternalAtmoInfo {
|
||||
volume: value.volume,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&stationpedia::LogicInfo> for LogicInfo {
|
||||
@@ -503,12 +940,13 @@ impl From<&stationpedia::LogicInfo> for LogicInfo {
|
||||
impl From<&stationpedia::Item> for ItemInfo {
|
||||
fn from(item: &stationpedia::Item) -> Self {
|
||||
ItemInfo {
|
||||
consumable: item.consumable.unwrap_or(false),
|
||||
consumable: item.consumable,
|
||||
filter_type: item.filter_type.as_ref().map(|typ| {
|
||||
typ.parse()
|
||||
.unwrap_or_else(|err| panic!("failed to parse filter type: {err}"))
|
||||
}),
|
||||
ingredient: item.ingredient.unwrap_or(false),
|
||||
ingredient: item.ingredient,
|
||||
#[allow(clippy::cast_possible_truncation, clippy::cast_sign_loss)]
|
||||
max_quantity: item.max_quantity.unwrap_or(1.0) as u32,
|
||||
reagents: item
|
||||
.reagents
|
||||
@@ -589,3 +1027,12 @@ impl From<&stationpedia::Memory> for MemoryInfo {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<&stationpedia::ResourceConsumer> for ConsumerInfo {
|
||||
fn from(value: &stationpedia::ResourceConsumer) -> Self {
|
||||
ConsumerInfo {
|
||||
consumed_resouces: value.consumed_resources.clone(),
|
||||
processed_reagents: value.processed_reagents.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,16 +77,26 @@ pub struct Page {
|
||||
pub slot_inserts: Vec<SlotInsert>,
|
||||
#[serde(rename = "Title")]
|
||||
pub title: String,
|
||||
#[serde(rename = "TransmissionReceiver")]
|
||||
pub transmission_receiver: Option<bool>,
|
||||
#[serde(rename = "WirelessLogic")]
|
||||
pub wireless_logic: Option<bool>,
|
||||
#[serde(rename = "CircuitHolder")]
|
||||
pub circuit_holder: Option<bool>,
|
||||
#[serde(rename = "TransmissionReceiver", default)]
|
||||
pub transmission_receiver: bool,
|
||||
#[serde(rename = "WirelessLogic", default)]
|
||||
pub wireless_logic: bool,
|
||||
#[serde(rename = "CircuitHolder", default)]
|
||||
pub circuit_holder: bool,
|
||||
#[serde(rename = "BasePowerDraw")]
|
||||
pub base_power_draw: Option<String>,
|
||||
#[serde(rename = "MaxPressure")]
|
||||
pub max_pressure: Option<String>,
|
||||
#[serde(rename = "SourceCode", default)]
|
||||
pub source_code: bool,
|
||||
#[serde(rename = "Chargeable")]
|
||||
pub chargeable: Option<Chargable>,
|
||||
#[serde(rename = "ResourceConsumer")]
|
||||
pub resource_consumer: Option<ResourceConsumer>,
|
||||
#[serde(rename = "InternalAtmosphere")]
|
||||
pub internal_atmosphere: Option<InternalAtmosphereInfo>,
|
||||
#[serde(rename = "Thermal")]
|
||||
pub thermal: Option<ThermalInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||
@@ -231,14 +241,14 @@ pub struct Instruction {
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Item {
|
||||
#[serde(rename = "Consumable")]
|
||||
pub consumable: Option<bool>,
|
||||
#[serde(rename = "Consumable", default)]
|
||||
pub consumable: bool,
|
||||
#[serde(rename = "FilterType")]
|
||||
pub filter_type: Option<String>,
|
||||
#[serde(rename = "Ingredient")]
|
||||
pub ingredient: Option<bool>,
|
||||
#[serde(rename = "Ingredient", default)]
|
||||
pub ingredient: bool,
|
||||
#[serde(rename = "MaxQuantity")]
|
||||
pub max_quantity: Option<f64>,
|
||||
pub max_quantity: Option<f32>,
|
||||
#[serde(rename = "Reagents")]
|
||||
pub reagents: Option<indexmap::IndexMap<String, f64>>,
|
||||
#[serde(rename = "SlotClass")]
|
||||
@@ -247,6 +257,18 @@ pub struct Item {
|
||||
pub sorting_class: String,
|
||||
#[serde(rename = "Recipes", default)]
|
||||
pub recipes: Vec<Recipe>,
|
||||
#[serde(rename = "Wearable", default)]
|
||||
pub wearable: bool,
|
||||
#[serde(rename = "Suit", default)]
|
||||
pub suit: Option<SuitInfo>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct SuitInfo {
|
||||
#[serde(rename = "HygineReductionMultiplier")]
|
||||
pub hygine_reduction_multiplier: f32,
|
||||
#[serde(rename = "WasteMaxPressure")]
|
||||
pub waste_max_pressure: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
@@ -303,7 +325,7 @@ pub struct RecipeGasMix {
|
||||
pub reagents: BTreeMap<String, f64>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Device {
|
||||
#[serde(rename = "ConnectionList")]
|
||||
pub connection_list: Vec<(String, String)>,
|
||||
@@ -325,4 +347,44 @@ pub struct Device {
|
||||
pub has_open_state: bool,
|
||||
#[serde(rename = "HasReagents")]
|
||||
pub has_reagents: bool,
|
||||
#[serde(rename = "Fabricator")]
|
||||
pub fabricator: Option<Fabricator>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Fabricator {
|
||||
#[serde(rename = "Tier")]
|
||||
tier: u32,
|
||||
#[serde(rename = "TierName")]
|
||||
pub tier_name: String,
|
||||
#[serde(rename = "Recipes", default)]
|
||||
pub recipes: indexmap::IndexMap<String, Recipe>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Serialize, Deserialize)]
|
||||
pub struct Chargable {
|
||||
#[serde(rename = "PowerMaximum")]
|
||||
pub power_maximum: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||
pub struct ResourceConsumer {
|
||||
#[serde(rename = "ConsumedResources", default)]
|
||||
pub consumed_resources: Vec<String>,
|
||||
#[serde(rename = " ProcessedReagents", default)]
|
||||
pub processed_reagents: Vec<i32>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct InternalAtmosphereInfo {
|
||||
#[serde(rename = "Volume")]
|
||||
pub volume: f32,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
|
||||
pub struct ThermalInfo {
|
||||
#[serde(rename = "Convection")]
|
||||
pub convection: f32,
|
||||
#[serde(rename = "Radiation")]
|
||||
pub radiation: f32,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user