Skip to content

Commit

Permalink
Merge #515
Browse files Browse the repository at this point in the history
515: Allow accessing fetched entities of a `Storage` r=Xaeroxe a=torkleyy

I've added `Storage::entities` to allow making extension methods for `Storage` that return `Entity`.

This method is hidden because I'm 100% certain newcomers will be confused by this otherwise. This makes it less visible, yes, but I think that's worth for avoiding this confusion.

<!-- 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/515)
<!-- Reviewable:end -->


Co-authored-by: Thomas Schaller <[email protected]>
  • Loading branch information
bors[bot] and torkleyy committed Nov 22, 2018
2 parents df24334 + 1a730dc commit 384b4d0
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "specs"
version = "0.14.0"
version = "0.14.1"
description = """
Specs is an Entity-Component System library written in Rust.
"""
Expand Down
8 changes: 8 additions & 0 deletions src/storage/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,14 @@ where
&self.data.inner
}

/// Returns the `EntitesRes` resource fetched by this storage.
/// **This does not have anything to do with the components inside.**
/// You only want to use this when implementing additional methods
/// for `Storage` via an extension trait.
pub fn fetched_entities(&self) -> &EntitiesRes {
&self.entities
}

/// Tries to read the data associated with an `Entity`.
pub fn get(&self, e: Entity) -> Option<&T> {
if self.data.mask.contains(e.id()) && self.entities.is_alive(e) {
Expand Down

0 comments on commit 384b4d0

Please sign in to comment.