Merge branch 'a1phyr/fix_debug_items' into 'master'

Fix debug command

See merge request veloren/veloren!1650
This commit is contained in:
Ben Wallis 2020-12-18 19:15:09 +00:00
commit 44ffd74957
2 changed files with 20 additions and 9 deletions

View File

@ -234,6 +234,7 @@ impl Directory {
impl Compound for Directory {
fn load<S: source::Source>(_: &AssetCache<S>, specifier: &str) -> Result<Self, Error> {
let specifier = specifier.strip_suffix(".*").unwrap_or(specifier);
let root = ASSETS.source().path_of(specifier, "");
let mut files = Vec::new();

View File

@ -206,6 +206,24 @@ impl assets::Asset for RawItemDef {
#[derive(Debug)]
pub struct OperationFailure;
#[derive(Clone)]
struct ItemList(Vec<Item>);
impl assets::Compound for ItemList {
fn load<S: assets::source::Source>(
cache: &assets::AssetCache<S>,
specifier: &str,
) -> Result<Self, Error> {
let list = cache
.load::<assets::Directory>(specifier)?
.read()
.iter()
.map(|spec| Item::new_from_asset(spec))
.collect::<Result<_, Error>>()?;
Ok(ItemList(list))
}
}
impl Item {
// TODO: consider alternatives such as default abilities that can be added to a
// loadout when no weapon is present
@ -229,15 +247,7 @@ impl Item {
/// Creates a Vec containing one of each item that matches the provided
/// asset glob pattern
pub fn new_from_asset_glob(asset_glob: &str) -> Result<Vec<Self>, Error> {
//let items = ItemDef::load_glob(asset_glob)?;
let specifiers = assets::Directory::load(asset_glob)?;
specifiers
.read()
.iter()
.map(|spec| Self::new_from_asset(&spec))
.collect()
Ok(ItemList::load_cloned(asset_glob)?.0)
}
/// Creates a new instance of an `Item from the provided asset identifier if