-
Notifications
You must be signed in to change notification settings - Fork 221
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix errors with tests, impl HasMeta for Self
- Loading branch information
Showing
10 changed files
with
146 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
|
||
extern crate specs; | ||
#[macro_use] | ||
extern crate specs_derive; | ||
|
||
use specs::*; | ||
|
||
#[derive(Default, Metadata)] | ||
struct Other { | ||
flagged: Flagged, | ||
} | ||
|
||
#[derive(Default, Metadata)] | ||
struct TestMetadata { | ||
flagged: Flagged, | ||
other: Other, | ||
} | ||
|
||
#[derive(Default, Metadata)] | ||
struct TupleMetadata(Flagged, Other); | ||
|
||
#[derive(Debug, Default)] | ||
struct TestComp; | ||
impl Component for TestComp { | ||
type Storage = DenseVecStorage<Self>; | ||
type Metadata = TupleMetadata; | ||
} | ||
|
||
fn main() { | ||
let mut world = World::new(); | ||
world.register::<TestComp>(); | ||
|
||
let e1 = world.create_entity() | ||
.with(TestComp) | ||
.build(); | ||
let _e2 = world.create_entity() | ||
.with(TestComp) | ||
.build(); | ||
let _e3 = world.create_entity() | ||
.with(TestComp) | ||
.build(); | ||
let e4 = world.create_entity() | ||
.with(TestComp) | ||
.build(); | ||
{ | ||
let mut storage = world.write::<TestComp>(); | ||
storage.find_mut::<Flagged>().clear_flags(); | ||
storage.get_mut(e1); | ||
storage.get_mut(e4); | ||
} | ||
|
||
{ | ||
let storage = world.read::<TestComp>(); | ||
|
||
// Grab the metadata. | ||
let flagged = storage.find::<Flagged>(); | ||
|
||
for (entity, comp, _) in (&*world.entities(), &storage, flagged).join() { | ||
println!("({:?}, {:?}): {:?}", entity.id(), entity.gen().id(), comp); | ||
} | ||
} | ||
|
||
{ | ||
let mut storage = world.write::<TestComp>(); | ||
storage.find::<Flagged>(); | ||
let _inner_flagged: &mut Flagged = storage.find_mut::<Other>().find_mut(); | ||
} | ||
|
||
{ | ||
let mut storage = world.write::<TestComp>(); | ||
|
||
{ | ||
// Grab the metadata and clone it to avoid borrow issues | ||
let flagged = storage.find::<Flagged>().clone(); | ||
|
||
// Iterate over all flagged components | ||
for (entity, comp, _) in (&*world.entities(), &mut storage, flagged).join() { | ||
println!("({:?}, {:?}): {:?}", entity.id(), entity.gen().id(), comp); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.