Skip to content

Commit bf77da5

Browse files
bors[bot]torkleyyazriel91
committed
Merge #606
606: Prepare for 0.15.0 release r=azriel91 a=torkleyy ## Checklist * [x] I've added tests for all code changes and additions (where applicable) * [x] I've added a demonstration of the new feature to one or more examples * [x] I've updated the book to reflect my changes * [x] Usage of new public items is shown in the API docs ## API changes * Remove multiple methods from `WorldExt` which were moved to `shred::World` (see amethyst/shred#141) Co-authored-by: Thomas Schaller <torkleyy@gmail.com> Co-authored-by: Azriel Hoh <azriel91@gmail.com>
2 parents ae6d4cd + 20d134b commit bf77da5

35 files changed

Lines changed: 223 additions & 517 deletions

.rustfmt.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ merge_imports = true
33
reorder_impl_items = true
44
use_field_init_shorthand = true
55
use_try_shorthand = true
6-
format_doc_comments = true
6+
format_code_in_doc_comments = true
77
wrap_comments = true
88
edition = "2018"
99
version = "Two"

CHANGELOG.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
# 0.15.0
2+
3+
* Moved `World` to `shred`, added `WorldExt` trait for Specs functionality ([#550])
4+
* Add `UuidMarker` for UUID <-> `Entity` mappings ([#584])
5+
* Implement `Join` on `BitSetLike` trait object ([#599])
6+
* Expose inner field of `AntiStorage` ([#603])
7+
* Remove `fnv` in favour of `hashbrown` ([#606])
8+
* Reexport `hibitset`, `rayon`, `shred` and `shrev` ([#606])
9+
* Reexport `shred_derive::SystemData` when `shred-derive` feature is enabled ([#606])
10+
* Reexport `specs_derive::{Component, ConvertSaveload}` when `specs-derive` feature is enabled
11+
([#606])
12+
13+
[#550]: https://github.com/slide-rs/specs/pull/550
14+
[#584]: https://github.com/slide-rs/specs/pull/584
15+
[#599]: https://github.com/slide-rs/specs/pull/599
16+
[#603]: https://github.com/slide-rs/specs/pull/603
17+
[#606]: https://github.com/slide-rs/specs/pull/606
18+
119
# 0.14.2
220

321
* Add `Join`-able entries API to `Storage` ([#518])

CONTRIBUTING.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,14 @@ Number 1 is served by [`shred`](https://github.com/slide-rs/shred); it provides
5454

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

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

61-
* `Resources`; everything that a `System` can access is stored inside
61+
* `World`; everything that a `System` can access is stored inside.
6262

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

6666
* store the indices (= entity ids) with an existing component
6767
* allow efficient joining over sparse component storages

Cargo.toml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "specs"
3-
version = "0.14.3"
3+
version = "0.15.0"
44
description = """
55
Specs is an Entity-Component-System library written in Rust.
66
"""
@@ -22,21 +22,21 @@ autobenches = false
2222
travis-ci = { repository = "slide-rs/specs" }
2323

2424
[dependencies]
25-
crossbeam = "0.7.1"
25+
crossbeam-queue = "0.1"
2626
derivative = "1"
27-
fnv = "1.0"
28-
hibitset = { version = "0.6.0", default-features = false }
27+
hashbrown = "0.5.0"
28+
hibitset = { version = "0.6.1", default-features = false }
2929
log = "0.4"
3030
mopa = "0.2"
31-
shred = { version = "0.8.0", default-features = false }
31+
shred = { version = "0.9.1", default-features = false }
3232
shrev = "1.0.0"
33-
shred-derive = "0.6.0"
3433
tuple_utils = "0.3"
35-
rayon = { version = "1.0.0", optional = true }
3634
nonzero_signed = "1.0.1"
37-
uuid = { version = "0.7.4", optional = true, features = ["v4", "serde"] }
3835

36+
rayon = { version = "1.1.0", optional = true }
3937
serde = { version = "1.0", optional = true, features = ["serde_derive"] }
38+
specs-derive = { version = "0.4.0", path = "specs-derive", optional = true }
39+
uuid = { version = "0.7.4", optional = true, features = ["v4", "serde"] }
4040

4141
[features]
4242
default = ["parallel"]
@@ -46,15 +46,18 @@ uuid_entity = ["uuid", "serde"]
4646
stdweb = ["uuid/stdweb"]
4747
wasm-bindgen = ["uuid/wasm-bindgen"]
4848

49+
shred-derive = ["shred/shred-derive"]
50+
4951
[package.metadata.docs.rs]
50-
features = ["parallel", "nightly", "uuid_entity"]
52+
features = ["parallel", "serde", "shred-derive", "specs-derive", "nightly", "uuid_entity"]
5153

5254
[dev-dependencies]
5355
cgmath = { version = "0.17" }
5456
criterion = "0.2"
5557
ron = "0.5"
56-
rand = "0.6.1"
58+
rand = "0.7"
5759
serde_json = "1.0"
60+
shred = { version = "0.9.0", features = ["shred-derive"] }
5861
specs-derive = { path = "specs-derive", version = "0.4.0" }
5962

6063
[[example]]

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,10 @@ fn main() {
105105
let mut dispatcher = DispatcherBuilder::new().with(SysA, "sys_a", &[]).build();
106106
// This will call the `setup` function of every system.
107107
// In this example this has no effect since we already registered our components.
108-
dispatcher.setup(&mut world.res);
108+
dispatcher.setup(&mut world);
109109

110110
// This dispatches all the systems in parallel (but blocking).
111-
dispatcher.dispatch(&mut world.res);
111+
dispatcher.dispatch(&mut world);
112112
}
113113
```
114114

@@ -121,6 +121,7 @@ Please look into [the examples directory](examples) for more.
121121
| hibitset | [![hibitset](https://img.shields.io/crates/v/hibitset.svg)](https://crates.rs/crates/hibitset) |
122122
| rayon | [![rayon](https://img.shields.io/crates/v/rayon.svg)](https://crates.rs/crates/rayon) |
123123
| shred | [![shred](https://img.shields.io/crates/v/shred.svg)](https://crates.rs/crates/shred) |
124+
| shrev | [![shrev](https://img.shields.io/crates/v/shrev.svg)](https://crates.rs/crates/shrev) |
124125

125126
## Contribution
126127

benches/parallel.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ fn bench_parallel(b: &mut Bencher) {
294294
w.register::<SpawnRequests>();
295295
w.register::<Collision>();
296296

297-
w.add_resource(DeltaTime(0.02));
297+
w.insert(DeltaTime(0.02));
298298

299299
for x in -50i32..50i32 {
300300
for y in -50i32..50i32 {

docs/tutorials/src/02_hello_world.md

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,24 @@
22

33
## Setting up
44

5-
First of all, thanks for trying out `specs`. Let's
6-
set it up first. Add the following line to your `Cargo.toml`:
5+
First of all, thanks for trying out `specs`.
6+
Before setting up the project, please make sure you're using the latest Rust version:
77

8-
```toml
9-
[dependencies]
10-
specs = "0.14.0"
8+
```bash
9+
rustup update
1110
```
1211

13-
And add this to your crate root (`main.rs` or `lib.rs`):
12+
Okay, now let's set up the project!
1413

15-
```rust,ignore
16-
extern crate specs;
14+
```bash
15+
cargo new --bin my_game
16+
```
17+
18+
Add the following line to your `Cargo.toml`:
19+
20+
```toml
21+
[dependencies]
22+
specs = "0.15.0"
1723
```
1824

1925
## Components
@@ -46,23 +52,18 @@ impl Component for Velocity {
4652

4753
These will be our two component types. Optionally, the `specs-derive` crate
4854
provides a convenient custom `#[derive]` you can use to define component types
49-
more succinctly.
55+
more succinctly.
5056

51-
But first, you will need to add specs-derive to your crate
57+
But first, you will need to enable the `specs-derive` feature:
5258

5359
```toml
5460
[dependencies]
55-
specs = "0.14.0"
56-
specs-derive = "0.4.0"
61+
specs = { version = "0.15.0", features = ["specs-derive"] }
5762
```
5863

59-
Now you can use this:
64+
Now you can do this:
6065

6166
```rust,ignore
62-
extern crate specs;
63-
#[macro_use]
64-
extern crate specs_derive;
65-
6667
use specs::{Component, VecStorage};
6768
6869
#[derive(Component, Debug)]
@@ -91,7 +92,7 @@ need to create a world in which to store all of our components.
9192
## The `World`
9293

9394
```rust,ignore
94-
use specs::{World, Builder};
95+
use specs::{World, WorldExt, Builder};
9596
9697
let mut world = World::new();
9798
world.register::<Position>();
@@ -106,6 +107,10 @@ let ball = world.create_entity().with(Position { x: 4.0, y: 7.0 }).build();
106107

107108
Now you have an `Entity`, associated with a position.
108109

110+
> **Note:** `World` is a struct coming from `shred`, an important dependency of Specs.
111+
> Whenever you call functions specific to Specs, you will need to import the `WorldExt`
112+
> trait.
113+
109114
So far this is pretty boring. We just have some data,
110115
but we don't do anything with it. Let's change that!
111116

@@ -169,7 +174,7 @@ them. To execute the system, you can use `RunNow` like this:
169174
use specs::RunNow;
170175
171176
let mut hello_world = HelloWorld;
172-
hello_world.run_now(&world.res);
177+
hello_world.run_now(&world);
173178
world.maintain();
174179
```
175180

@@ -182,7 +187,7 @@ will record the changes in its internal data structure.
182187
Here the complete example of this chapter:
183188

184189
```rust,ignore
185-
use specs::{Builder, Component, ReadStorage, System, VecStorage, World, RunNow};
190+
use specs::{Builder, Component, ReadStorage, System, VecStorage, World, WorldExt, RunNow};
186191
187192
#[derive(Debug)]
188193
struct Position {
@@ -226,7 +231,7 @@ fn main() {
226231
world.create_entity().with(Position { x: 4.0, y: 7.0 }).build();
227232
228233
let mut hello_world = HelloWorld;
229-
hello_world.run_now(&world.res);
234+
hello_world.run_now(&world);
230235
world.maintain();
231236
}
232237
```

docs/tutorials/src/03_dispatcher.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ be executed after the dependency has finished. The final `HelloWorld` system pri
9292
Now to execute all the systems, just do
9393

9494
```rust,ignore
95-
dispatcher.dispatch(&mut world.res);
95+
dispatcher.dispatch(&mut world);
9696
```
9797

9898
## Full example code
@@ -101,7 +101,7 @@ Here the code for this chapter:
101101

102102
```rust,ignore
103103
use specs::{Builder, Component, DispatcherBuilder, ReadStorage,
104-
System, VecStorage, World, WriteStorage};
104+
System, VecStorage, World, WorldExt, WriteStorage};
105105
106106
#[derive(Debug)]
107107
struct Position {
@@ -172,7 +172,7 @@ fn main() {
172172
.with(HelloWorld, "hello_updated", &["update_pos"])
173173
.build();
174174
175-
dispatcher.dispatch(&mut world.res);
175+
dispatcher.dispatch(&mut world);
176176
world.maintain();
177177
}
178178
```

docs/tutorials/src/04_resources.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,14 @@ struct DeltaTime(f32);
2121
Adding this resource to our world is pretty easy:
2222

2323
```rust,ignore
24-
world.add_resource(DeltaTime(0.05)); // Let's use some start value
24+
world.insert(DeltaTime(0.05)); // Let's use some start value
2525
```
2626

2727
To update the delta time, just use
2828

2929
```rust,ignore
30+
use specs::WorldExt;
31+
3032
let mut delta = world.write_resource::<DeltaTime>();
3133
*delta = DeltaTime(0.04);
3234
```
@@ -65,7 +67,7 @@ impl<'a> System<'a> for UpdatePos {
6567
```
6668

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

docs/tutorials/src/06_system_data.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,6 @@ more, you could even nest these tuples. However, at some point it becomes hard t
9191
That's why you can also create your own `SystemData` bundle using a struct:
9292

9393
```rust,ignore
94-
extern crate shred;
95-
#[macro_use]
96-
extern crate shred_derive;
9794
extern crate specs;
9895
9996
use specs::prelude::*;
@@ -109,3 +106,8 @@ pub struct MySystemData<'a> {
109106
}
110107
```
111108

109+
Make sure to enable the `shred-derive` feature in your `Cargo.toml`:
110+
111+
```toml
112+
specs = { version = "*", features = ["shred-derive"] }
113+
```

0 commit comments

Comments
 (0)