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

#50: Add convenience Entity.getFor(Class<? extends Component>) method #51

Merged
merged 3 commits into from
Aug 30, 2014
Merged

#50: Add convenience Entity.getFor(Class<? extends Component>) method #51

merged 3 commits into from
Aug 30, 2014

Conversation

SgtCoDFish
Copy link
Contributor

As mentioned in #50 - "New getComponent overload for Entity". Includes unit test for the new method. Unsure if adding this method pollutes the public API of the library, but since it's so simple to add here's the code anyway.

@@ -138,10 +138,24 @@ public void removeAll() {
}

/**
* Retrieve a component from this {@link Entity} by class.
*
* <em>Note:</em> the preferred way of retrieving {@link Component}s is using {@link ComponentMapper}s. This method
Copy link
Member

Choose a reason for hiding this comment

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

Could you please add the reason for this? ComponentMapper has O(1) time for component retrieval while Entity.getComponent() has O(logn).

@dsaltares
Copy link
Member

Other than these small comments, it looks good, thanks a lot! Will merge when resubmitted and rebased :-).

@SgtCoDFish
Copy link
Contributor Author

Sorry about those problems, I didn't mean to include the second commit in the first place; this is my first time using pull requests. I hope I've fixed it, if not I'll be available to sort my mess out!

dsaltares added a commit that referenced this pull request Aug 30, 2014
#50: Add convenience Entity.getFor(Class<? extends Component>) method
@dsaltares dsaltares merged commit e48b80e into libgdx:master Aug 30, 2014
@dsaltares
Copy link
Member

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants