From 21fd2964073c0204c21fb1ea6a700df65af9bb2f Mon Sep 17 00:00:00 2001 From: Scott Williams Date: Sat, 29 Jan 2022 17:37:45 +0000 Subject: [PATCH] Changed entity drops csv export to export names instead of asset paths --- common/src/bin/csv_export/main.rs | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/common/src/bin/csv_export/main.rs b/common/src/bin/csv_export/main.rs index 3040e8aa76..99a167b014 100644 --- a/common/src/bin/csv_export/main.rs +++ b/common/src/bin/csv_export/main.rs @@ -17,10 +17,12 @@ use veloren_common::{ Item, ItemKind, }, }, - generation::EntityConfig, + generation::{EntityConfig, EntityInfo}, lottery::{LootSpec, Lottery}, }; +use vek::Vec3; + #[derive(StructOpt)] struct Cli { /// Available arguments: "armor-stats", "weapon-stats", "all-items", @@ -281,13 +283,22 @@ fn loot_table(loot_table: &str) -> Result<(), Box> { fn entity_drops(entity_config: &str) -> Result<(), Box> { let mut wtr = csv::Writer::from_path("drop_table.csv")?; - wtr.write_record(&["Entity Path", "Percent Chance", "Item Path", "Quantity"])?; + wtr.write_record(&[ + "Entity Name", + "Entity Path", + "Percent Chance", + "Item Path", + "Quantity", + ])?; fn write_entity_loot( wtr: &mut csv::Writer, asset_path: &str, ) -> Result<(), Box> { let entity_config = EntityConfig::load_expect(asset_path).read(); + let entity_info = EntityInfo::at(Vec3::new(0.0, 0.0, 0.0)) + .with_asset_expect(asset_path, &mut rand::thread_rng()); + let name = entity_info.name.unwrap_or_else(|| "".to_string()); // Create initial entry in drop table let entry: (f32, LootSpec) = (1.0, entity_config.loot.clone()); @@ -379,7 +390,13 @@ fn entity_drops(entity_config: &str) -> Result<(), Box> { "Nothing" }; - wtr.write_record(&[asset_path, &percent_chance, item_name, &quantity])? + wtr.write_record(&[ + name.clone(), + asset_path.to_string(), + percent_chance, + item_name.to_string(), + quantity, + ])? } Ok(())