mirror of
https://gitlab.com/veloren/veloren.git
synced 2024-08-30 18:12:32 +00:00
Merge branch 'swilliams/entity-drops-csv-names' into 'master'
Changed entity drops csv export to export names instead of asset paths See merge request veloren/veloren!3161
This commit is contained in:
commit
3120a64be2
@ -17,10 +17,12 @@ use veloren_common::{
|
|||||||
Item, ItemKind,
|
Item, ItemKind,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
generation::EntityConfig,
|
generation::{EntityConfig, EntityInfo},
|
||||||
lottery::{LootSpec, Lottery},
|
lottery::{LootSpec, Lottery},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use vek::Vec3;
|
||||||
|
|
||||||
#[derive(StructOpt)]
|
#[derive(StructOpt)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
/// Available arguments: "armor-stats", "weapon-stats", "all-items",
|
/// Available arguments: "armor-stats", "weapon-stats", "all-items",
|
||||||
@ -281,13 +283,22 @@ fn loot_table(loot_table: &str) -> Result<(), Box<dyn Error>> {
|
|||||||
|
|
||||||
fn entity_drops(entity_config: &str) -> Result<(), Box<dyn Error>> {
|
fn entity_drops(entity_config: &str) -> Result<(), Box<dyn Error>> {
|
||||||
let mut wtr = csv::Writer::from_path("drop_table.csv")?;
|
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<W: std::io::Write>(
|
fn write_entity_loot<W: std::io::Write>(
|
||||||
wtr: &mut csv::Writer<W>,
|
wtr: &mut csv::Writer<W>,
|
||||||
asset_path: &str,
|
asset_path: &str,
|
||||||
) -> Result<(), Box<dyn Error>> {
|
) -> Result<(), Box<dyn Error>> {
|
||||||
let entity_config = EntityConfig::load_expect(asset_path).read();
|
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
|
// Create initial entry in drop table
|
||||||
let entry: (f32, LootSpec<String>) = (1.0, entity_config.loot.clone());
|
let entry: (f32, LootSpec<String>) = (1.0, entity_config.loot.clone());
|
||||||
@ -379,7 +390,13 @@ fn entity_drops(entity_config: &str) -> Result<(), Box<dyn Error>> {
|
|||||||
"Nothing"
|
"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(())
|
Ok(())
|
||||||
|
Loading…
Reference in New Issue
Block a user