Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upAdd ECS bundle concept #364
Conversation
Rhuagh
added some commits
Sep 17, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jojolepro
Sep 17, 2017
Collaborator
@Rhuagh Basically they are code wrappers to make the code less heavy and reduce the boiler plate?
I'd like to know how that handles conflicts between dependencies and component registration too.
|
@Rhuagh Basically they are code wrappers to make the code less heavy and reduce the boiler plate? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Sep 18, 2017
Member
Well, they're a generification of with_renderer in the ApplicationBuilder, so instead of adding functions there for every single concept (with_audio, with_transform), we can add bundles instead.
Conflicts are handled by specs for the most part. Resources are overridden, component registration is essentially a NOP for any duplicate registration. System registration is a panic if the name given already exists. When it comes to dependencies and system names, each bundle handles that on it's own. Look at the TransformBundle for example, it has support for dependencies.
|
Well, they're a generification of with_renderer in the ApplicationBuilder, so instead of adding functions there for every single concept (with_audio, with_transform), we can add bundles instead. Conflicts are handled by specs for the most part. Resources are overridden, component registration is essentially a NOP for any duplicate registration. System registration is a panic if the name given already exists. When it comes to dependencies and system names, each bundle handles that on it's own. Look at the TransformBundle for example, it has support for dependencies. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Sep 18, 2017
Member
An alternative would be to have the build() function take the ApplicationBuilder as argument and return it wrapped in a Result.
|
An alternative would be to have the build() function take the ApplicationBuilder as argument and return it wrapped in a Result. |
| + /// | ||
| + pub fn with_bundle<B>(mut self, bundle: B) -> Result<Self> | ||
| + where | ||
| + B: for<'c> ECSBundle<'a, 'b, (&'c EventsLoop)>, |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
omni-viral
Sep 18, 2017
Member
RenderSystem is special as it the only one that need access to EventsLoop during building.
What should we do if there will be new bundle that will require some other data from Application to build?
omni-viral
Sep 18, 2017
Member
RenderSystem is special as it the only one that need access to EventsLoop during building.
What should we do if there will be new bundle that will require some other data from Application to build?
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Sep 18, 2017
Member
Yeah, it's not perfect, but I haven't figured out a good solution to that yet.
Rhuagh
Sep 18, 2017
Member
Yeah, it's not perfect, but I haven't figured out a good solution to that yet.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| + /// | ||
| + pub fn with_bundle<B>(mut self, bundle: B) -> Result<Self> | ||
| + where | ||
| + B: for<'c> ECSBundle<'a, 'b, (&'c EventsLoop)>, |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
omni-viral
Sep 18, 2017
Member
Parentheses are unnecessary. If you want to make a tuple with single element you need to make it like this (A,)
omni-viral
Sep 18, 2017
Member
Parentheses are unnecessary. If you want to make a tuple with single element you need to make it like this (A,)
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Refactored to use ApplicationBuilder directly. |
| - where | ||
| - Self: Sized; | ||
| +/// Describes a bundle of ECS components, resources and systems | ||
| +pub trait ECSBundle<'a, 'b, T: ::state::State + 'a> { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
omni-viral
Sep 18, 2017
Member
This bound shouldn't be here. Please, remove it from ApplicationBuilder's functions where T: State is not required so that it's not enforced everywhere. I believe the only function that requires T: State is ApplicationBuilder::build
omni-viral
Sep 18, 2017
•
Member
This bound shouldn't be here. Please, remove it from ApplicationBuilder's functions where T: State is not required so that it's not enforced everywhere. I believe the only function that requires T: State is ApplicationBuilder::build
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Sep 18, 2017
Member
Well, ApplicationBuilder requires it at the moment, and that's a separate change from this PR imho.
Rhuagh
Sep 18, 2017
Member
Well, ApplicationBuilder requires it at the moment, and that's a separate change from this PR imho.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
omni-viral
self-assigned this
Sep 18, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Xaeroxe
Sep 18, 2017
Member
Looks good so far! What would you consider the remaining tasks on this PR?
|
Looks good so far! What would you consider the remaining tasks on this PR? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Sep 18, 2017
Member
A bit of cleanup, and making a bundle for the pong stuff. And more documentation
|
A bit of cleanup, and making a bundle for the pong stuff. And more documentation |
Rhuagh
changed the title from
[WIP] Add ECS bundle concept
to
Add ECS bundle concept
Sep 18, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Ready to go after rereview. |
bot
added a commit
that referenced
this pull request
Sep 18, 2017
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Timed out |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Override. |
Xaeroxe
merged commit 60107f5
into
amethyst:develop
Sep 19, 2017
Rhuagh
deleted the
Rhuagh:bundles
branch
Sep 19, 2017
| - .register_texture_asset() | ||
| - .register_material_not_yet_asset(), | ||
| - ) | ||
| + pub fn with_bundle<B>(self, bundle: B) -> Result<Self> |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Sep 19, 2017
Member
If a bundle offers multiple systems, how would one manage dependencies? Should maybe the documentation list the system names it adds?
torkleyy
Sep 19, 2017
Member
If a bundle offers multiple systems, how would one manage dependencies? Should maybe the documentation list the system names it adds?
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Sep 19, 2017
Member
I'd put all the information that the user could need in the documentation for each bundle.
Rhuagh
Sep 19, 2017
Member
I'd put all the information that the user could need in the documentation for each bundle.
| + ResourceId::new::<Option<Output>>(), | ||
| + ) | ||
| + { | ||
| + builder = builder.with_resource(default_output()); |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| + builder = builder.with_resource(default_output()); | ||
| + } | ||
| + | ||
| + let dj = match *builder.world.read_resource::<Option<Output>>() { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| + }; | ||
| + | ||
| + if let Some(dj) = dj { | ||
| + builder = builder.with_resource(dj).with( |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| + | ||
| +/// Bundle for adding the InputHandler and input bindings | ||
| +/// | ||
| +/// # Errors |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Sep 19, 2017
Member
I just followed what @csherratt has done with the ApplicationBuilder etc.
Rhuagh
Sep 19, 2017
Member
I just followed what @csherratt has done with the ApplicationBuilder etc.
| @@ -1,9 +1,11 @@ | ||
| //! `amethyst` rendering ecs module | ||
| +pub use self::bundle::RenderBundle; |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Sep 19, 2017
Member
I think we should decide on whether we want to have a public module or reexported items. Given these bundles all have the same postfix, a conflict is impossible. I just see this inconsistency existed before the PR
torkleyy
Sep 19, 2017
Member
I think we should decide on whether we want to have a public module or reexported items. Given these bundles all have the same postfix, a conflict is impossible. I just see this inconsistency existed before the PR
| +/// Will register transform components, and the TransformSystem. | ||
| +/// TransformSystem will be registered with name "transform_system". | ||
| +/// | ||
| +/// # Errors |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| +/// | ||
| +/// No errors will be returned by this bundle. | ||
| +/// | ||
| +/// # Panics |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| +/// | ||
| +/// # Panics | ||
| +/// | ||
| +/// Panics in TransformSystem registration if the bundle is applied twice in the same dispatcher. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| + } | ||
| + | ||
| + /// Set dependencies for the TransformSystem | ||
| + pub fn with_dep(mut self, dep: &'a [&'a str]) -> Self { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
torkleyy
Sep 19, 2017
Member
This is something that makes the new bundle system more complex and gives the user less control. Also see my comment above. But well, let's see how it works out.
torkleyy
Sep 19, 2017
Member
This is something that makes the new bundle system more complex and gives the user less control. Also see my comment above. But well, let's see how it works out.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
Rhuagh
Sep 19, 2017
Member
You are not forced to use the bundle system, you can do all it does on your own, and the code is open so you can see what goes on inside.
I feel this is a way of lowering the threshold to start using the engine, without giving anything up really.
Rhuagh
Sep 19, 2017
•
Member
You are not forced to use the bundle system, you can do all it does on your own, and the code is open so you can see what goes on inside.
I feel this is a way of lowering the threshold to start using the engine, without giving anything up really.
Rhuagh commentedSep 17, 2017
Opening this early to get feedback. Is this a viable concept or should I trash it immediately?