summaryrefslogtreecommitdiff
path: root/engine/src/asset.rs
diff options
context:
space:
mode:
Diffstat (limited to 'engine/src/asset.rs')
-rw-r--r--engine/src/asset.rs18
1 files changed, 16 insertions, 2 deletions
diff --git a/engine/src/asset.rs b/engine/src/asset.rs
index ea0037c..e1f699a 100644
--- a/engine/src/asset.rs
+++ b/engine/src/asset.rs
@@ -29,7 +29,7 @@ pub HANDLE_ASSETS_PHASE: (Phase, pair!(ChildOf, { *PRE_UPDATE_PHASE }));
pub trait Asset: Send + Sync + 'static
{
- fn dependencies(&self) -> impl Iterator<Item = Dependency<'_>>;
+ fn visit_dependencies<'this>(&'this self, func: &mut dyn FnMut(Dependency<'this>));
}
#[derive(Debug)]
@@ -61,6 +61,14 @@ pub struct Label<'a>
impl Label<'_>
{
+ pub fn borrow(&self) -> Label<'_>
+ {
+ Label {
+ path: (&*self.path).into(),
+ name: self.name.as_deref().map(Into::into),
+ }
+ }
+
#[must_use]
fn to_owned(&self) -> LabelOwned
{
@@ -373,7 +381,13 @@ impl Assets
let mut missing_dependencies = 0;
- for dependency in asset.dependencies() {
+ let mut dependencies = Vec::new();
+
+ asset.visit_dependencies(&mut |dependency| {
+ dependencies.push(dependency);
+ });
+
+ for dependency in dependencies {
match self.get_asset_by_label_mut(&dependency.label) {
Some((Some(StoredAsset { state: AssetState::Ready { .. }, .. }), _)) => {}
Some((