-
Notifications
You must be signed in to change notification settings - Fork 220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add trait for easy registration with the World #296
Conversation
So this is basically simpler version of #155? Should we just resurrect that one or simplify it to something like this? |
The main motivation of @Aceeri's version was serialization and deserialization AFAIK (which has been solved by @omni-viral ), so I think a simpler solution is both sufficient and more practical. |
src/common.rs
Outdated
@@ -150,6 +150,11 @@ impl Errors { | |||
} | |||
} | |||
|
|||
/// Trait used to bundle up resources/components for easy registration with the `World`. | |||
pub trait WorldResourceRegistrator { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got a better name, today ;) You're already using "bundle" in the documentation, maybe that'd justify calling the trait Bundle
?
src/common.rs
Outdated
@@ -150,6 +150,11 @@ impl Errors { | |||
} | |||
} | |||
|
|||
/// Trait used to bundle up resources/components for easy registration with the `World`. | |||
pub trait WorldResourceRegistrator { | |||
fn register_with_world(self, world: &mut World); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Register implies a restriction to components, could you rename it to add*
, please?
src/common.rs
Outdated
} | ||
} | ||
|
||
TestRegistrator.register_with_world(&mut world); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/world/mod.rs
Outdated
|
||
/// Trait used to bundle up resources/components for easy registration with `World`. | ||
pub trait Bundle { | ||
fn add_to_world(self, world: &mut World); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing docs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I didn't know what to write :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, standardizing this is great.
|
||
world.add_bundle(TestBundle); | ||
assert_eq!(12, world.read_resource::<SomeResource>().v); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New line is missing? Or github being picky
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's missing .. fixed now.
What's blocking merging here? This looks ready to go. |
@kvark is on vacation and wants to approve it before merging, otherwise it's ready. Besides, we can't release anyways since there are still soundness issues with saveload stuff. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bors r+
Build succeeded |
No description provided.