Skip to content
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

Merged
merged 1 commit into from
Nov 7, 2017
Merged

Add trait for easy registration with the World #296

merged 1 commit into from
Nov 7, 2017

Conversation

Rhuagh
Copy link
Member

@Rhuagh Rhuagh commented Nov 1, 2017

No description provided.

@WaDelma
Copy link
Member

WaDelma commented Nov 1, 2017

So this is basically simpler version of #155? Should we just resurrect that one or simplify it to something like this?

@torkleyy
Copy link
Member

torkleyy commented Nov 2, 2017

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 {
Copy link
Member

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);
Copy link
Member

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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could add an impl for World here which adds an add_bundle method. Do you think that's useful @Rhuagh @WaDelma ?

@torkleyy torkleyy self-assigned this Nov 2, 2017
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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing docs

Copy link
Member Author

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 :/

@torkleyy
Copy link
Member

torkleyy commented Nov 2, 2017

r? @Aceeri @WaDelma

@torkleyy torkleyy added ready and removed in progress labels Nov 2, 2017
@torkleyy torkleyy changed the title feat(common): Add trait for easy registration with the World Add trait for easy registration with the World Nov 2, 2017
Copy link
Member

@Xaeroxe Xaeroxe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Member

@Aceeri Aceeri left a 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);
}
Copy link
Member

@Aceeri Aceeri Nov 2, 2017

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

Copy link
Member Author

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.

@Xaeroxe
Copy link
Member

Xaeroxe commented Nov 7, 2017

What's blocking merging here? This looks ready to go.

@torkleyy
Copy link
Member

torkleyy commented Nov 7, 2017

@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.

Copy link
Member

@kvark kvark left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bors r+

bors bot added a commit that referenced this pull request Nov 7, 2017
296: Add trait for easy registration with the World r=kvark a=Rhuagh
@bors
Copy link
Contributor

bors bot commented Nov 7, 2017

Build succeeded

@bors bors bot merged commit 1ad81a6 into amethyst:master Nov 7, 2017
@Rhuagh Rhuagh deleted the world-initialisatino branch November 7, 2017 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants