Skip to content

Commit

Permalink
Use world::insert instead of world::add_resource in tutorials.
Browse files Browse the repository at this point in the history
  • Loading branch information
azriel91 authored and torkleyy committed Jun 29, 2019
1 parent 8cde339 commit 20d134b
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,14 @@ Number 1 is served by [`shred`](https://github.com/slide-rs/shred); it provides

* `System`; this is the central interface for defining logic
* `Dispatcher` and `DispatcherBuilder` - these are responsible for building a plan for how to run systems
(in parallel & sequentially)
(in parallel & sequentially)

Additionally, `shred` also provides the central piece for number 2:

* `Resources`; everything that a `System` can access is stored inside
* `World`; everything that a `System` can access is stored inside.

Specs itself defines component storages (which are also stored inside the `Resources`).
For those, [`hibitset`](https://github.com/slide-rs/hibitset/) is used to
Specs itself defines component storages (which are also stored inside the `World`).
For those, [`hibitset`](https://github.com/slide-rs/hibitset/) is used to:

* store the indices (= entity ids) with an existing component
* allow efficient joining over sparse component storages
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/src/04_resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl<'a> System<'a> for UpdatePos {
```

Note that all resources that a system accesses must be registered with
`world.add_resource(resource)` before that system is run, or you will get a
`world.insert(resource)` before that system is run, or you will get a
panic. If the resource has a `Default` implementation, this step is usually
done during `setup`, but again we will come back to this in a later chapter.

Expand Down
4 changes: 2 additions & 2 deletions docs/tutorials/src/07_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
So far for all our component storages and resources, we've been adding
them to the `World` manually. In Specs, this is not required if you use
`setup`. This is a manually invoked stage that goes through `SystemData`
and calls `register`, `add_resource`, etc. for all (with some exceptions)
and calls `register`, `insert`, etc. for all (with some exceptions)
components and resources found. The `setup` function can be found in
the following locations:

Expand Down Expand Up @@ -46,7 +46,7 @@ impl<'a> System<'a> for SimulationSystem {
fn main() {
let mut world = World::new();
world.add_resource(Gravity);
world.insert(Gravity);
world.register::<Velocity>();
for _ in 0..5 {
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorials/src/10_rendering.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ This is what your code could look like:
```rust,ignore
struct ResizeEvents(Vec<(u32, u32)>);
world.add_resource(ResizeEvents(Vec::new()));
world.insert(ResizeEvents(Vec::new()));
while let Some(event) = window.poll_event() {
match event {
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/src/13_saveload.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ fn main() {
let mut world = World::new();
world.register::<SimpleMarker<NetworkSync>>();
world.add_resource(SimpleMarkerAllocator::<NetworkSync>::default());
world.insert(SimpleMarkerAllocator::<NetworkSync>::default());
world.register::<SimpleMarker<FilePersistent>>();
world.add_resource(SimpleMarkerAllocator::<FilePersistent>::default());
world.insert(SimpleMarkerAllocator::<FilePersistent>::default());
world
.create_entity()
Expand Down Expand Up @@ -96,7 +96,7 @@ fn main() {
let mut world = World::new();
world.register::<MyMarker>();
world.add_resource(MyMarkerAllocator::default());
world.insert(MyMarkerAllocator::default());
world
.create_entity()
Expand Down

0 comments on commit 20d134b

Please sign in to comment.