74 lines
2.3 KiB
Rust
74 lines
2.3 KiB
Rust
use std::fs::File;
|
|
use std::io::{self, Write};
|
|
|
|
mod parts;
|
|
mod racegroups;
|
|
mod surgery;
|
|
mod things;
|
|
|
|
use parts::*;
|
|
use racegroups::*;
|
|
use surgery::*;
|
|
use things::*;
|
|
|
|
const CONTENT_PATH: &str = "../Content/Base/Defs/Generated/";
|
|
|
|
fn write(path: &'static str, data: &String) -> io::Result<()> {
|
|
std::fs::DirBuilder::new().recursive(true).create(CONTENT_PATH).unwrap();
|
|
let mut f = File::create(format!("{CONTENT_PATH}{path}.xml"))?;
|
|
let s = format!("<?xml version=\"1.0\" encoding=\"utf-8\"?>
|
|
<!-- This is an automatically generated file. If you are the end user, this is safe to edit. If you are a contributor, please edit the source files instead. -->
|
|
<Defs>{data}</Defs>");
|
|
f.write_all(s.as_bytes())?;
|
|
Ok(())
|
|
}
|
|
|
|
fn main() {
|
|
let animal_parts = part_data_animals();
|
|
let mut animal_hediffs = String::new();
|
|
for part in &animal_parts {
|
|
animal_hediffs.push_str(&(construct_hediff(part, false) + "\n"));
|
|
}
|
|
|
|
let mut human_hediffs = String::new();
|
|
let human_parts = part_data_humans();
|
|
for part in &human_parts {
|
|
human_hediffs.push_str(&(construct_hediff(part, true) + "\n"));
|
|
}
|
|
|
|
let (breasts, breast_hediffs) = part_data_breasts();
|
|
let (parts, part_hediffs) = part_data_other();
|
|
|
|
let mut raceparts = String::new();
|
|
let mut thingdefs = String::new();
|
|
let mut surgeries = String::new();
|
|
for part in animal_parts.iter().chain(human_parts.iter()).chain(breasts.iter()).chain(parts.iter()) {
|
|
raceparts.push_str(&(construct_racepart(part) + "\n"));
|
|
thingdefs.push_str(&(construct_thingdef(part) + "\n"));
|
|
let surg = enumerate_surgeries(&part);
|
|
for surgery in surg {
|
|
surgeries.push_str(&(construct_surgery(&surgery) + "\n"));
|
|
}
|
|
}
|
|
|
|
let mut human_races = String::new();
|
|
for group in racegroup_data_humans() {
|
|
human_races.push_str(&construct_racegroup(&group));
|
|
}
|
|
|
|
let mut animal_races = String::new();
|
|
for group in racegroup_data_animals() {
|
|
animal_races.push_str(&construct_racegroup(&group));
|
|
}
|
|
|
|
write("Hediffs_Animals", &animal_hediffs).unwrap();
|
|
write("Hediffs_Humans", &human_hediffs).unwrap();
|
|
write("Hediffs_Breasts", &breast_hediffs).unwrap();
|
|
write("Hediffs_Misc", &part_hediffs).unwrap();
|
|
write("Parts", &raceparts).unwrap();
|
|
write("Items_BodyParts", &thingdefs).unwrap();
|
|
write("Recipes_Surgery", &surgeries).unwrap();
|
|
write("Races_Humanoids", &human_races).unwrap();
|
|
write("Races_Animals", &animal_races).unwrap();
|
|
}
|