Plan for resources?
Closed this issue · 2 comments
Coming from specs, legion, and bevy they usually have some sort of Resource management within their ECS, is this on the roadmap for Flax?
Yes.
I have deliberately not included a builtin resources mechanism.
The reasoning is that it is easy to accidentally overwrite resources in different systems or libraries to conflict with each other for shared components/resources.
The preferred way of doing it is to create a static resource entity, which holds resources which are scoped and private to your crate, or however you choose to expose the resource entity.
use
flax::component! {
/// Holds the game resources
resources,
}
The resources can then have components added and removed to it.
You can use the world.entity()
to use an entry level api for the components, or use a query with QueryBorrow::get
on a query with the desired resources for the system
The plan for the next release is to include an easier one-off fetch, to get a AtomicRef<(components)>, rather than having to keep the query alive for the lock. This would make resource handling easier