You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Certain types of games dynamically load and unload assets as you move between areas. Currently, this crate assumes all assets are loaded at startup and persist until shut down.
Solution
We can support dynamic assets for game areas with the following API:
Add a resource GameAreas that tracks currently-active areas. You can add/remove/clear areas from this.
Add asset manifest loaders that are type-bound to specific 'area tags'. For example, LoadAreaImages<MyHome>. When a manifest is loaded, asset paths are cached in an areas map and only immediately loaded if the corresponding areas are active.
When the GameAreas resource changes, send a reactive event GameAreasUpdated. On GameAreasUpdated, enter LoadState::Loading and run systems to update all asset managers (unload assets in non-existent areas, load assets for new layers (this would be smart enough to retain assets used in multiple areas)). The user is responsible for displaying a loading screen and deciding when to switch areas.
Add AreaTag<T> loadable that can be used to mark scene nodes in cobweb asset files for cleanup when leaving an area.
It's also possible to load cobweb asset file manifests separately per area, e.g. with app.load_for_area::<T>(manifest/path.caf.json). Then when any scene root node referenced by a file loaded recursively from that manifest is spawned, we can insert AreaTag<T> automatically. We could even dynamically load and unload caf files at area transitions (to implement this we'd need to limit caf file imports to only files in the 'global area' and the 'current area'). To implement this we'd need to update how data is cleaned up post-loading, since new data could be loaded now.
Implementing this is not high priority for me, but it would address a major feature gap in this library.
The text was updated successfully, but these errors were encountered:
Problem
Certain types of games dynamically load and unload assets as you move between areas. Currently, this crate assumes all assets are loaded at startup and persist until shut down.
Solution
We can support dynamic assets for game areas with the following API:
GameAreas
that tracks currently-active areas. You can add/remove/clear areas from this.LoadAreaImages<MyHome>
. When a manifest is loaded, asset paths are cached in an areas map and only immediately loaded if the corresponding areas are active.GameAreas
resource changes, send a reactive eventGameAreasUpdated
. OnGameAreasUpdated
, enterLoadState::Loading
and run systems to update all asset managers (unload assets in non-existent areas, load assets for new layers (this would be smart enough to retain assets used in multiple areas)). The user is responsible for displaying a loading screen and deciding when to switch areas.AreaTag<T>
loadable that can be used to mark scene nodes in cobweb asset files for cleanup when leaving an area.app.load_for_area::<T>(manifest/path.caf.json)
. Then when any scene root node referenced by a file loaded recursively from that manifest is spawned, we can insertAreaTag<T>
automatically. We could even dynamically load and unload caf files at area transitions (to implement this we'd need to limit caf file imports to only files in the 'global area' and the 'current area'). To implement this we'd need to update how data is cleaned up post-loading, since new data could be loaded now.Implementing this is not high priority for me, but it would address a major feature gap in this library.
The text was updated successfully, but these errors were encountered: