Skip to content

Commit

Permalink
Merge #606
Browse files Browse the repository at this point in the history
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 <[email protected]>
Co-authored-by: Azriel Hoh <[email protected]>
  • Loading branch information
3 people committed Jun 29, 2019
2 parents ae6d4cd + 20d134b commit bf77da5
Show file tree
Hide file tree
Showing 35 changed files with 223 additions and 517 deletions.
2 changes: 1 addition & 1 deletion .rustfmt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ merge_imports = true
reorder_impl_items = true
use_field_init_shorthand = true
use_try_shorthand = true
format_doc_comments = true
format_code_in_doc_comments = true
wrap_comments = true
edition = "2018"
version = "Two"
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
# 0.15.0

* Moved `World` to `shred`, added `WorldExt` trait for Specs functionality ([#550])
* Add `UuidMarker` for UUID <-> `Entity` mappings ([#584])
* Implement `Join` on `BitSetLike` trait object ([#599])
* Expose inner field of `AntiStorage` ([#603])
* Remove `fnv` in favour of `hashbrown` ([#606])
* Reexport `hibitset`, `rayon`, `shred` and `shrev` ([#606])
* Reexport `shred_derive::SystemData` when `shred-derive` feature is enabled ([#606])
* Reexport `specs_derive::{Component, ConvertSaveload}` when `specs-derive` feature is enabled
([#606])

[#550]: https://github.com/slide-rs/specs/pull/550
[#584]: https://github.com/slide-rs/specs/pull/584
[#599]: https://github.com/slide-rs/specs/pull/599
[#603]: https://github.com/slide-rs/specs/pull/603
[#606]: https://github.com/slide-rs/specs/pull/606

# 0.14.2

* Add `Join`-able entries API to `Storage` ([#518])
Expand Down
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
23 changes: 13 additions & 10 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "specs"
version = "0.14.3"
version = "0.15.0"
description = """
Specs is an Entity-Component-System library written in Rust.
"""
Expand All @@ -22,21 +22,21 @@ autobenches = false
travis-ci = { repository = "slide-rs/specs" }

[dependencies]
crossbeam = "0.7.1"
crossbeam-queue = "0.1"
derivative = "1"
fnv = "1.0"
hibitset = { version = "0.6.0", default-features = false }
hashbrown = "0.5.0"
hibitset = { version = "0.6.1", default-features = false }
log = "0.4"
mopa = "0.2"
shred = { version = "0.8.0", default-features = false }
shred = { version = "0.9.1", default-features = false }
shrev = "1.0.0"
shred-derive = "0.6.0"
tuple_utils = "0.3"
rayon = { version = "1.0.0", optional = true }
nonzero_signed = "1.0.1"
uuid = { version = "0.7.4", optional = true, features = ["v4", "serde"] }

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

[features]
default = ["parallel"]
Expand All @@ -46,15 +46,18 @@ uuid_entity = ["uuid", "serde"]
stdweb = ["uuid/stdweb"]
wasm-bindgen = ["uuid/wasm-bindgen"]

shred-derive = ["shred/shred-derive"]

[package.metadata.docs.rs]
features = ["parallel", "nightly", "uuid_entity"]
features = ["parallel", "serde", "shred-derive", "specs-derive", "nightly", "uuid_entity"]

[dev-dependencies]
cgmath = { version = "0.17" }
criterion = "0.2"
ron = "0.5"
rand = "0.6.1"
rand = "0.7"
serde_json = "1.0"
shred = { version = "0.9.0", features = ["shred-derive"] }
specs-derive = { path = "specs-derive", version = "0.4.0" }

[[example]]
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ fn main() {
let mut dispatcher = DispatcherBuilder::new().with(SysA, "sys_a", &[]).build();
// This will call the `setup` function of every system.
// In this example this has no effect since we already registered our components.
dispatcher.setup(&mut world.res);
dispatcher.setup(&mut world);

// This dispatches all the systems in parallel (but blocking).
dispatcher.dispatch(&mut world.res);
dispatcher.dispatch(&mut world);
}
```

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

## Contribution

Expand Down
2 changes: 1 addition & 1 deletion benches/parallel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ fn bench_parallel(b: &mut Bencher) {
w.register::<SpawnRequests>();
w.register::<Collision>();

w.add_resource(DeltaTime(0.02));
w.insert(DeltaTime(0.02));

for x in -50i32..50i32 {
for y in -50i32..50i32 {
Expand Down
47 changes: 26 additions & 21 deletions docs/tutorials/src/02_hello_world.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,24 @@

## Setting up

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

```toml
[dependencies]
specs = "0.14.0"
```bash
rustup update
```

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

```rust,ignore
extern crate specs;
```bash
cargo new --bin my_game
```

Add the following line to your `Cargo.toml`:

```toml
[dependencies]
specs = "0.15.0"
```

## Components
Expand Down Expand Up @@ -46,23 +52,18 @@ impl Component for Velocity {

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

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

```toml
[dependencies]
specs = "0.14.0"
specs-derive = "0.4.0"
specs = { version = "0.15.0", features = ["specs-derive"] }
```

Now you can use this:
Now you can do this:

```rust,ignore
extern crate specs;
#[macro_use]
extern crate specs_derive;
use specs::{Component, VecStorage};
#[derive(Component, Debug)]
Expand Down Expand Up @@ -91,7 +92,7 @@ need to create a world in which to store all of our components.
## The `World`

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

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

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

Expand Down Expand Up @@ -169,7 +174,7 @@ them. To execute the system, you can use `RunNow` like this:
use specs::RunNow;
let mut hello_world = HelloWorld;
hello_world.run_now(&world.res);
hello_world.run_now(&world);
world.maintain();
```

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

```rust,ignore
use specs::{Builder, Component, ReadStorage, System, VecStorage, World, RunNow};
use specs::{Builder, Component, ReadStorage, System, VecStorage, World, WorldExt, RunNow};
#[derive(Debug)]
struct Position {
Expand Down Expand Up @@ -226,7 +231,7 @@ fn main() {
world.create_entity().with(Position { x: 4.0, y: 7.0 }).build();
let mut hello_world = HelloWorld;
hello_world.run_now(&world.res);
hello_world.run_now(&world);
world.maintain();
}
```
Expand Down
6 changes: 3 additions & 3 deletions docs/tutorials/src/03_dispatcher.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ be executed after the dependency has finished. The final `HelloWorld` system pri
Now to execute all the systems, just do

```rust,ignore
dispatcher.dispatch(&mut world.res);
dispatcher.dispatch(&mut world);
```

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

```rust,ignore
use specs::{Builder, Component, DispatcherBuilder, ReadStorage,
System, VecStorage, World, WriteStorage};
System, VecStorage, World, WorldExt, WriteStorage};
#[derive(Debug)]
struct Position {
Expand Down Expand Up @@ -172,7 +172,7 @@ fn main() {
.with(HelloWorld, "hello_updated", &["update_pos"])
.build();
dispatcher.dispatch(&mut world.res);
dispatcher.dispatch(&mut world);
world.maintain();
}
```
Expand Down
6 changes: 4 additions & 2 deletions docs/tutorials/src/04_resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,14 @@ struct DeltaTime(f32);
Adding this resource to our world is pretty easy:

```rust,ignore
world.add_resource(DeltaTime(0.05)); // Let's use some start value
world.insert(DeltaTime(0.05)); // Let's use some start value
```

To update the delta time, just use

```rust,ignore
use specs::WorldExt;
let mut delta = world.write_resource::<DeltaTime>();
*delta = DeltaTime(0.04);
```
Expand Down Expand Up @@ -65,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
8 changes: 5 additions & 3 deletions docs/tutorials/src/06_system_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@ more, you could even nest these tuples. However, at some point it becomes hard t
That's why you can also create your own `SystemData` bundle using a struct:

```rust,ignore
extern crate shred;
#[macro_use]
extern crate shred_derive;
extern crate specs;
use specs::prelude::*;
Expand All @@ -109,3 +106,8 @@ pub struct MySystemData<'a> {
}
```

Make sure to enable the `shred-derive` feature in your `Cargo.toml`:

```toml
specs = { version = "*", features = ["shred-derive"] }
```
Loading

0 comments on commit bf77da5

Please sign in to comment.