It should be easier to fetch data from resources when constructing a scene
- Dominant language
- Rust
- Stars
- 48.2k
- Forks
- 4.8k
- Avg merge
- 3d 16h
- Merged PRs (30d)
- 171
Description
Goal:
I have a Resource containing Handles and I want to be able to create a Template fetching the Handles from the Resource which I can then pass into a Scene
```Rust
#[derive(Resource, Asset, Clone, TypePath)]
pub struct SomeAssets {
pub image1: Handle,
pub image2: Handle,
}
#[derive(Clone)]
pub enum SomeAssetTemplate {
Image1,
Image2,
}
impl Template for SomeAssetTemplate {
type Output = Handle;
fn build_template(&self, context: &mut TemplateContext) -> Result {
let some_assets = context.resource::();
match self {
SomeAssetTemplate::Image1=> Ok(tank_assets.image1.clone()),
SomeAssetTemplate::Image2=> Ok(tank_assets.image2.clone()),
}
}
fn clone_template(&self) -> Self {
self.clone()
}
}
```
it should be possible to now for example create a sprite with the new template somehow.
```
bsn! {
Sprite {
image: SomeAssetTemplate::Image1
}
}
```
discussion started here: https://discord.com/channels/691052431525675048/1518957482293334156
Contributor guide
Research direction
Start by reading the existing Template and TemplateContext APIs and the bsn! scene-construction syntax shown in the issue. Use the Discord discussion as context for the intended design. Done means a Resource's Handle fields can be fetched through a template and passed to a Sprite while constructing a Scene.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- game-dev
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100