SystemResources: port of specs' SystemData for resources#211
Draft
vladbat00 wants to merge 3 commits intoamethyst:masterfrom
Draft
SystemResources: port of specs' SystemData for resources#211vladbat00 wants to merge 3 commits intoamethyst:masterfrom
vladbat00 wants to merge 3 commits intoamethyst:masterfrom
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
This PR introduces a new derive macro inspired by specs'
#[derive(SystemData)], that can be used as follows:I see this feature useful in the following scenarious:
ResourceSetandConsAppendlimits of generic arguments number.Timeand my customGameTimeresources: https://github.com/amethyst/grumpy_visitors/blob/f12b85d0dac07c101b43e83711b89777dc69dd58/libs/core/src/ecs/system_data/time.rs.Notable changes
Apart from implementing the feature itself, I had to do some other changes to the codebase.
for<'a>lifetime bounds forResourceSetin favour of just'staticlifetime."Any" lifetime doesn't work well with the fact that
SystemResourceshas its own lifetime. I didn't figure out the way to implementResourceSetforSystemResources, so it supports the HRTB magic. Without this change I was getting the following error:I hope this change won't cause any troubles. I wasn't able to come up with an example when resources can be not static in Legion.
Re-exporting
FetchMutfrom thesystemsmodule. I've just noticed there's another PR for that too: Re-export FetchMut from systems #209ConsConcat
I've added
ConsConcatto the codebase, but it turned out that I didn't need it for my implementation eventually... :) But it works, I was even able to flatten SystemResources to pass their members along with other resources. I figuredConsPrependisn't used anywhere as well, probably they can make friends, lol.This might be useful to users who want to make their own wrappers around
SystemBuilder. Right now they represent a separate module, though probably we should re-export them as a part of thesystemsmodule.Status
This pull request is in a draft state. There are some obvious TODOs:
codegenlevel of reporting errors to a userI'm totally going to work on those if it's decided that this feature is something that would fit Legion and there are no major oversights in the implementation.