-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
141 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
pub mod insert_on_asset_event; | ||
#[allow(unused_imports)] | ||
pub use self::insert_on_asset_event::*; | ||
pub mod reflected_asset_event; | ||
#[allow(unused_imports)] | ||
pub use self::reflected_asset_event::*; |
56 changes: 56 additions & 0 deletions
56
crates/beet_core/src/asset_actions/reflected_asset_event.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
use bevy::prelude::*; | ||
|
||
|
||
|
||
/// The vanilla asset event doesnt implement reflect so.. | ||
#[derive(Debug, Reflect, PartialEq, Event)] | ||
pub enum ReflectedAssetEvent<A: Asset> { | ||
/// Emitted whenever an [`Asset`] is added. | ||
Added { id: AssetId<A> }, | ||
/// Emitted whenever an [`Asset`] value is modified. | ||
Modified { id: AssetId<A> }, | ||
/// Emitted whenever an [`Asset`] is removed. | ||
Removed { id: AssetId<A> }, | ||
/// Emitted when the last [`super::Handle::Strong`] of an [`Asset`] is dropped. | ||
Unused { id: AssetId<A> }, | ||
/// Emitted whenever an [`Asset`] has been fully loaded (including its dependencies and all "recursive dependencies"). | ||
LoadedWithDependencies { id: AssetId<A> }, | ||
} | ||
|
||
|
||
impl<A: Asset> Into<AssetEvent<A>> for ReflectedAssetEvent<A> { | ||
fn into(self) -> AssetEvent<A> { | ||
match self { | ||
ReflectedAssetEvent::Added { id } => AssetEvent::Added { id }, | ||
ReflectedAssetEvent::Modified { id } => AssetEvent::Modified { id }, | ||
ReflectedAssetEvent::Removed { id } => AssetEvent::Removed { id }, | ||
ReflectedAssetEvent::Unused { id } => AssetEvent::Unused { id }, | ||
ReflectedAssetEvent::LoadedWithDependencies { id } => { | ||
AssetEvent::LoadedWithDependencies { id } | ||
} | ||
} | ||
} | ||
} | ||
|
||
impl<A: Asset> From<AssetEvent<A>> for ReflectedAssetEvent<A> { | ||
fn from(event: AssetEvent<A>) -> Self { | ||
match event { | ||
AssetEvent::Added { id } => ReflectedAssetEvent::Added { id }, | ||
AssetEvent::Modified { id } => ReflectedAssetEvent::Modified { id }, | ||
AssetEvent::Removed { id } => ReflectedAssetEvent::Removed { id }, | ||
AssetEvent::Unused { id } => ReflectedAssetEvent::Unused { id }, | ||
AssetEvent::LoadedWithDependencies { id } => { | ||
ReflectedAssetEvent::LoadedWithDependencies { id } | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
impl<A: Asset> Clone for ReflectedAssetEvent<A> { | ||
fn clone(&self) -> Self { | ||
*self | ||
} | ||
} | ||
|
||
impl<A: Asset> Copy for ReflectedAssetEvent<A> {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.