summaryrefslogtreecommitdiff
path: root/engine/src
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src')
-rw-r--r--engine/src/asset.rs25
1 files changed, 21 insertions, 4 deletions
diff --git a/engine/src/asset.rs b/engine/src/asset.rs
index db4d23c..e78b6d8 100644
--- a/engine/src/asset.rs
+++ b/engine/src/asset.rs
@@ -1,4 +1,4 @@
-use std::any::{type_name, Any};
+use std::any::{Any, type_name};
use std::borrow::Cow;
use std::cell::RefCell;
use std::collections::HashMap;
@@ -8,16 +8,16 @@ use std::fmt::{Debug, Display};
use std::hash::{DefaultHasher, Hash, Hasher};
use std::marker::PhantomData;
use std::path::{Path, PathBuf};
+use std::sync::Arc;
use std::sync::mpsc::{
- channel as mpsc_channel,
Receiver as MpscReceiver,
Sender as MpscSender,
+ channel as mpsc_channel,
};
-use std::sync::Arc;
+use ecs::Sole;
use ecs::phase::PRE_UPDATE as PRE_UPDATE_PHASE;
use ecs::sole::Single;
-use ecs::Sole;
use crate::work_queue::{Work, WorkQueue};
@@ -293,6 +293,23 @@ impl Assets
)
}
+ pub fn store_with_name_with<'name, Asset: 'static + Send + Sync>(
+ &mut self,
+ name: impl Into<Cow<'name, str>>,
+ func: impl FnOnce(&mut Self) -> Asset,
+ ) -> Handle<Asset>
+ {
+ let asset = func(self);
+
+ self.store_with_label(
+ Label {
+ path: Path::new("").into(),
+ name: Some(name.into()),
+ },
+ asset,
+ )
+ }
+
#[tracing::instrument(skip(self, asset), fields(asset_type=type_name::<Asset>()))]
pub fn store_with_label<'i, Asset: 'static + Send + Sync>(
&mut self,