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 docs to the book how to retrieve a component for a given entity #310

Closed
tomc1998 opened this issue Dec 7, 2017 · 7 comments
Closed
Labels

Comments

@tomc1998
Copy link
Contributor

tomc1998 commented Dec 7, 2017

Hey!

So, unless I'm seriously misunderstanding something here, these types are mismatched!

Is there any reason why world doesn't use Index, and Index is not a usize?

To be clear, here is the read_with_id() method:

https://docs.rs/specs/0.10.0/specs/struct.World.html#method.read_with_id

And here is the Entity's id() method:

https://docs.rs/specs/0.10.0/specs/struct.Entity.html#method.id

Here is the definition of the Index typedef:

https://docs.rs/specs/0.10.0/specs/type.Index.html

I'd want to try & fix this myself, but i'm so new to the library I'm worried it's a misunderstanding - plus I wouldn't know whether to go with usize / u32, do you have any pointers?:P

@tomc1998
Copy link
Contributor Author

tomc1998 commented Dec 7, 2017

So, I just cloned and changed the world method to take an Index then changed Index to a usize, and was met with loads of compile errors - is there a reason for this discrepancy, or is it just a bit messy? (i.e. should I even bother trying to clean up or is there a deeper reason they're different here)

@tomc1998
Copy link
Contributor Author

tomc1998 commented Dec 7, 2017

Nevermind, figured it out. The 'id' is referring to a component id.

@tomc1998 tomc1998 closed this as completed Dec 7, 2017
@torkleyy
Copy link
Member

torkleyy commented Dec 7, 2017

Yes you could basically have multiple component storages of the same type, which is useful for scripting. Let's reopen it so the docs get improved.

@torkleyy torkleyy reopened this Dec 7, 2017
bors bot added a commit that referenced this issue Dec 7, 2017
312: Added more documentation to world read / write methods. r=torkleyy a=tomc1998

Whilst there was already documentation explaining component / resource
IDs, it was easy to skim over and no reference was made by the
read_with_id and write_with_id methods. This made it seem like it
expected an entity ID to search for a component, whereas in reality it's
used for more complex component / resource setups.

This is meant to address #310 .

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/slide-rs/specs/312)
<!-- Reviewable:end -->
@torkleyy torkleyy changed the title World read_with_id and write_with_id takes usize - Entity::id() returns Index, which is a u32? Add docs to the book how to retrieve a component for a given entity Dec 22, 2017
@Rhuagh
Copy link
Member

Rhuagh commented Apr 26, 2018

Is this still relevant?

@Rhuagh Rhuagh mentioned this issue Apr 26, 2018
9 tasks
@torkleyy
Copy link
Member

@Rhuagh I'm not sure. If you're reading the book very closely you can see how to do it, but it should be more obvious I think. Probably worth its own chapter together with how relationships shall be modeled.

@Rhuagh
Copy link
Member

Rhuagh commented May 7, 2018

What I was getting at here is that this ticket refers to a feature that no longer exists (read_with_id).

@Xaeroxe
Copy link
Member

Xaeroxe commented May 7, 2018

I concur with @Rhuagh , the ambiguity no longer exists because the function that caused confusion has been removed.

So I'll close this

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

No branches or pull requests

4 participants