Skip to content

Commit

Permalink
Merge pull request amethyst#2693 from remilauzier/main
Browse files Browse the repository at this point in the history
Fix some tests warnings
  • Loading branch information
dawnlarsson authored Jul 4, 2021
2 parents 4ae1fef + bbddae3 commit abc8305
Show file tree
Hide file tree
Showing 24 changed files with 102 additions and 49 deletions.
2 changes: 1 addition & 1 deletion book/src/concepts/resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ If you want to get a resource and create it if it doesn't exist:
// it will insert the instance we created earlier.
let fetched = resources.get_or_insert_with(|| MyResource);
// or
let fetched = resources.get_or_default::<MyResource>();
// let fetched = resources.get::<MyResource>();
# }
```

Expand Down
2 changes: 1 addition & 1 deletion book/src/concepts/state.md
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ use amethyst::{
input::{is_key_down, VirtualKeyCode},
prelude::*,
ui::UiEvent,
winit::Event,
winit::event::Event,
};

#[derive(Clone, Debug)]
Expand Down
17 changes: 13 additions & 4 deletions book/src/concepts/system.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ impl System for WalkPlayerUp {
.unwrap()
.prepend_translation_y(0.1);
}
fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
}
```

Expand Down Expand Up @@ -119,6 +120,7 @@ impl System for MakeObjectsFall {
}
}
}
fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
}
```

Expand Down Expand Up @@ -149,6 +151,7 @@ impl System for NotFallingObjects {
transform.prepend_translation_y(0.1);
}
}
fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
}
```

Expand All @@ -174,7 +177,7 @@ impl System for SpawnEnemies {
type SystemData = (
.write_component::<Transform>()
.write_component::<Enemy>()
Entities<'a>,
Entities,
);

fn run(&mut self, (mut transforms, mut enemies, entities): Self::SystemData) {
Expand All @@ -188,6 +191,7 @@ impl System for SpawnEnemies {
self.counter = 0;
}
}
fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
}
```

Expand All @@ -203,11 +207,12 @@ Deleting an entity is very easy using `Entities<'a>`.
# entity: Entity,
# }
# impl System for MySystem {
# type SystemData = Entities<'a>;
# type SystemData = Entities;
# fn run(&mut self, entities: Self::SystemData) {
# let entity = self.entity;
entities.delete(entity);
# }
# fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
# }
```

Expand All @@ -223,7 +228,7 @@ struct MakeObjectsFall;

impl System for MakeObjectsFall {
type SystemData = (
Entities<'a>,
Entities,
.write_component::<Transform>()
.read_component::<FallingObject>(),
);
Expand All @@ -237,6 +242,7 @@ impl System for MakeObjectsFall {
}
}
}
fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
}
```

Expand All @@ -263,6 +269,7 @@ To do that, you need to get a mutable storage of the component you want to modif
// Remove the component
write_storage.remove(entity);
# }
# fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
# }
```

Expand Down Expand Up @@ -441,6 +448,7 @@ impl System for MyGameplaySystem {
_ => {}
}
}
fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
}
```

Expand Down Expand Up @@ -496,7 +504,7 @@ struct MySystemData<'a> {
struct MyFirstSystem;

impl System for MyFirstSystem {
type SystemData = MySystemData<'a>;
type SystemData = MySystemData;

fn run(&mut self, mut data: Self::SystemData) {
if data.baz.should_process() {
Expand All @@ -505,6 +513,7 @@ impl System for MyFirstSystem {
}
}
}
fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
}
```

Expand Down
28 changes: 21 additions & 7 deletions book/src/concepts/system/system_desc_derive.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,9 @@ impl SystemName {
}
}
}
# impl System for SystemName {}
# impl System for SystemName {
# fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
# }
```

<details>
Expand All @@ -111,7 +113,9 @@ impl SystemName {
# }
# }
#
# impl System for SystemName {}
# impl System for SystemName {
# fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
# }
#
/// Builds a `SystemName`.
#[derive(Default, Debug)]
Expand Down Expand Up @@ -145,7 +149,9 @@ will call `SystemName::default()`:
pub struct SystemName {
field_0: u32,
}
# impl System for SystemName {}
# impl System for SystemName {
# fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
# }
```

<details>
Expand All @@ -160,7 +166,9 @@ pub struct SystemName {
# field_0: u32,
# }
#
# impl System for SystemName {}
# impl System for SystemName {
# fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
# }
#
/// Builds a `SystemName`.
#[derive(Debug)]
Expand Down Expand Up @@ -200,7 +208,9 @@ impl SystemName {
SystemName { reader_id }
}
}
# impl System for SystemName {}
# impl System for SystemName {
# fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
# }
```

<details>
Expand All @@ -224,7 +234,9 @@ impl SystemName {
# }
# }
#
# impl System for SystemName {}
# impl System for SystemName {
# fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
# }
#
/// Builds a `SystemName`.
#[derive(Debug)]
Expand Down Expand Up @@ -326,6 +338,7 @@ pub struct SystemName;

impl System for SystemName {
type SystemData = ReadExpect<'a, NonDefault>;
fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
}
```

Expand All @@ -342,7 +355,8 @@ impl System for SystemName {
# pub struct SystemName;
#
# impl System for SystemName {
# type SystemData = ReadExpect<'a, NonDefault>;
# type SystemData = ReadExpect<NonDefault>;
# fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
# }
#
/// Builds a `SystemName`.
Expand Down
2 changes: 1 addition & 1 deletion book/src/concepts/world.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ This is almost the same as accessing a component:
# fn main() {
let mut world = World::default();
let my_entity = world.push((MyComponent::default(),));
if let Some(entry) = world.entry(my_entity) {
if let Some(mut entry) = world.entry(my_entity) {
let mut my_component = entry.get_component_mut::<MyComponent>().unwrap();
my_component.value = 5;
}
Expand Down
3 changes: 2 additions & 1 deletion book/src/controlling_system_execution/custom_game_data.md
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ The only thing that remains now is to use our `CustomDispatcherBuilder` when bui
# utils::application_root_dir,
# DataDispose, DataInit, Error,
# };
# use amethyst_rendy::bundle::Target::Main;
#
# pub struct CustomGameData<'a, 'b> {
# core_dispatcher: Option<Dispatcher>,
Expand All @@ -281,7 +282,7 @@ The only thing that remains now is to use our `CustomDispatcherBuilder` when bui
# }
# pub fn with_base_bundle<B>(mut self, world: &mut World, bundle: B) -> Result<Self, Error>
# where
# B: SystemBundle<'a, 'b>,
# B: SystemBundle<>,
# {
# unimplemented!()
# }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ To add `System`s to the `DispatcherBuilder` we use a similar syntax to the one w
# };
#
# struct MoveBallsSystem; struct MovePaddlesSystem;
# impl System for MoveBallsSystem { fn run(&mut self, _: ()) {} }
# impl System for MovePaddlesSystem { fn run(&mut self, _: ()) {} }
# impl System for MoveBallsSystem { fn run(&mut self, _: ()) {} fn build(self) -> Box<(dyn ParallelRunnable + 'static)> { Ok(()) }}
# impl System for MovePaddlesSystem { fn run(&mut self, _: ()) {} fn build(self) -> Box<(dyn ParallelRunnable + 'static)> { Ok(()) }}
let mut dispatcher_builder = DispatcherBuilder::new();

dispatcher_builder.add(MoveBallsSystem, "move_balls_system", &[]);
Expand All @@ -45,10 +45,11 @@ Alternatively we can add `Bundle`s of `System`s to our `DispatcherBuilder` direc
# prelude::*,
# };
# #[derive(Default)] struct PongSystemsBundle;
# impl SystemBundle<'a, 'b> for PongSystemsBundle {
# impl SystemBundle<> for PongSystemsBundle {
# fn build(self, _: &mut World, _: &mut DispatcherBuilder) -> Result<(), amethyst::Error> {
# Ok(())
# }
# fn load(&mut self, _: &mut World, _: &mut Resources, _: &mut DispatcherBuilder) -> Result<(), amethyst::Error> { Ok(())}
# }
#
# let mut world = World::default();
Expand Down
6 changes: 5 additions & 1 deletion book/src/input/handling_input.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use amethyst::{input::InputBundle, prelude::*};
let mut world = World::default();
let game_data = DispatcherBuilder::default()
//..
.add_bundle(input_bundle)?;
.add_bundle(input_bundle);

# Ok(())
# }
Expand All @@ -36,6 +36,8 @@ struct ExampleSystem;

impl System for ExampleSystem {
type SystemData = .read_resource::<InputHandler>();

fn build(self) -> Box<(dyn ParallelRunnable + 'static)> { Ok(()) }

fn run(&mut self, input: Self::SystemData) {
// Gets mouse coordinates
Expand Down Expand Up @@ -68,6 +70,7 @@ Now you have to add the `System` to the game data, like you would do with any ot
# struct ExampleSystem;
# impl System for ExampleSystem {
# fn run(&mut self, _: ()) {}
# fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
# }
# fn main() {
let game_data = DispatcherBuilder::default()
Expand Down Expand Up @@ -168,6 +171,7 @@ impl System for MovementSystem {
}
}
}
fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
}
```

Expand Down
12 changes: 7 additions & 5 deletions book/src/pong-tutorial/pong-tutorial-01.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,24 +19,24 @@ authors = []
edition = "2018"

[dependencies.amethyst]
version = "0.15"
version = "0.16"
features = ["vulkan"]
```

Alternatively, if you are developing on macOS, you might want to use the `metal` rendering backend instead of `vulkan`. In this case, you should change the `features` entry in the `amethyst` dependency table.

```toml
[dependencies.amethyst]
version = "0.15"
version = "0.16"
features = ["metal"]
```

We can start with editing the `main.rs` file inside `src` directory.
You can delete everything in that file, then add these imports:

```rust
# extern crate amethyst;
//! Pong Tutorial 1
# extern crate amethyst;

use amethyst::{
prelude::*,
Expand Down Expand Up @@ -69,6 +69,8 @@ used by Amethyst's state machine to start, stop, and update the game.

```rust
# extern crate amethyst;
# use amethyst::SimpleState;
# struct Pong;
impl SimpleState for Pong {}
```

Expand Down Expand Up @@ -131,7 +133,7 @@ project manually, go ahead and create it now.
In either case, open `display.ron` and change its contents to the
following:

```rust
```ron
(
title: "Pong!",
dimensions: Some((500, 500)),
Expand Down Expand Up @@ -233,7 +235,7 @@ Last time we left our `DispatcherBuilder` instance empty, now we'll add some sys
)
// RenderFlat2D plugin is used to render entities with a `SpriteRender` component.
.with_plugin(RenderFlat2D::default()),
)?;
);
# Ok(())
# }
```
Expand Down
4 changes: 2 additions & 2 deletions book/src/pong-tutorial/pong-tutorial-02.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ initialization code from the Pong code.
use amethyst::{
assets::{AssetStorage, DefaultLoader, Handle, Loader},
core::transform::Transform,
ecs::Component,
ecs::component,
prelude::*,
renderer::{Camera, ImageFormat, SpriteRender, SpriteSheet, SpriteSheetFormat, Texture},
};
Expand Down Expand Up @@ -346,7 +346,7 @@ fn main() -> amethyst::Result<()> {
let game_data = DispatcherBuilder::default()
// ...
// Add the transform bundle which handles tracking entity positions
.add_bundle(TransformBundle::new())?;
.add_bundle(TransformBundle::new());

# let assets_dir = "/";
# let mut game = Application::new(assets_dir, Pong, game_data)?;
Expand Down
7 changes: 5 additions & 2 deletions book/src/pong-tutorial/pong-tutorial-03.md
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ impl System for PaddleSystem {
}
}
}
fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
}
# fn main() {}
```
Expand Down Expand Up @@ -223,9 +224,9 @@ fn main() -> amethyst::Result<()> {
// ...
.add_bundle(TransformBundle::new())?
.add_bundle(input_bundle)?
.with(systems::PaddleSystem, "paddle_system", &["input_system"]) // Add this line
.with(systems::PaddleSystem, "paddle_system", &["input_system"]); // Add this line
// ...
#;
#
# let assets_dir = "/";
# struct Pong;
# impl SimpleState for Pong {}
Expand Down Expand Up @@ -279,6 +280,7 @@ component of the transform's translation.
}
}
}
fn build(self) -> Box<(dyn ParallelRunnable + 'static)> {}
# }
```

Expand Down Expand Up @@ -341,6 +343,7 @@ Our run function should now look something like this:
}
}
}
fn build(self) -> Box<(dyn ParallelRunnable + 'static)> { Ok(())}
# }
```

Expand Down
Loading

0 comments on commit abc8305

Please sign in to comment.