EmiOnGit / warbler_grass

A bevy plugin for creating 3d grass in your game
Apache License 2.0
137 stars 11 forks source link

Color of grass as compont instead of a resource #11

Closed EmiOnGit closed 1 year ago

EmiOnGit commented 1 year ago

What problem does this solve or what need does it fill?

A user might want define grass fields with dead brown grass and healthy green grass or other combinations next to each other. Currently however, the grass color is defined by the RegionConfiguration globally for all grass. I do believe this should be reworked to work on a entity basis.

Describe the solution you'd like

Instead of having the color defined by the RegionConfiguration the RegionConfiguration should let the user define multiple colors and the entity needs to hold an id to the colors it wants the grass to have. As high level construct, it would be something around:

pub struct RegionConfiguration {
    pub color_manager: ColorManager, // could be a Hashmap internally
    ...
}
impl RegionConfiguration {
pub fn add_color(id: ColorId, color: Color);
}
// The Color should then be part of the WarblersBundle
#[derive(Component)
pub struct GrassColor {
    main_color: ColorId,
    bottom_color: ColorId
}

Be aware however that the extraction of the color will also need to be adapted. If you have questions or are stuck don't hesitate to ask questions! :)

Additional context

Please provide at least basic doc comments! :)