Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, thanks for the PR! I added some comments, and I'd ask you to also do some formatting and import reordering.
examples/03_renderable/main.rs
Outdated
@@ -7,7 +7,7 @@ extern crate cgmath; | |||
use amethyst::{Application, ElementState, Event, State, Trans, VirtualKeyCode, WindowEvent}; | |||
use amethyst::asset_manager::{AssetManager, DirectoryStore}; | |||
use amethyst::project::Config; | |||
use amethyst::ecs::{Join, System, RunArg, World}; | |||
use amethyst::ecs::{Join, System, World, WriteStorage, Fetch, FetchMut}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please order imports alphabetically.
examples/04_pong/main.rs
Outdated
|
||
type SystemData = (WriteStorage<'a, Ball>, WriteStorage<'a, Plank>, WriteStorage<'a, LocalTransform>, Fetch<'a, Camera>, Fetch<'a, Time>, Fetch<'a, InputHandler>, FetchMut<'a, Score>); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would you mind adding a line break here?
src/asset_manager/asset_manager.rs
Outdated
use wavefront_obj::obj::{ObjSet, parse, Primitive}; | ||
|
||
use ecs::{Allocator, Component, Entity, GatedStorage, MaskedStorage, Storage, VecStorage, World}; | ||
use ecs::{Component, Entity, VecStorage, World, ReadStorage}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, please move ReadStorage
before VecStorage
.
src/ecs/resources/broadcaster.rs
Outdated
//! fn main() { | ||
//! use amethyst::ecs::Gate; | ||
//! | ||
//! fn main() {//! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think the //!
is necessary here.
src/ecs/resources/broadcaster.rs
Outdated
use ticketed_lock::ReadTicket; | ||
|
||
use ecs::{World, Component, EntityBuilder, GatedStorage, Allocator, MaskedStorage, Join}; | ||
use ecs::{World, Component, EntityBuilder, Join, ReadStorage}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We didn't have it before, but it would be nice to sort these imports, too.
src/ecs/resources/broadcaster.rs
Outdated
self.world.entities().join().collect::<Vec<_>>() | ||
}; | ||
for entity in entities { | ||
self.world.delete_entity(entity); | ||
} | ||
self.world.maintain(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this call is necessary, dunno why it is there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I should move it to the end of Application::advance_frame
src/engine/app.rs
Outdated
@@ -64,10 +65,11 @@ impl Application { | |||
assets.add_loader::<gfx_types::Factory>(factory); | |||
|
|||
let trans_sys = TransformSystem::new(); | |||
planner.add_system::<TransformSystem>(trans_sys, "transform_system", 0); | |||
|
|||
let dispatcher_builder = dispatcher_builder.add_barrier(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As discussed on Gitter, it would be preferable to give the responsibility of adding "default" systems to the user.
src/engine/app.rs
Outdated
pub fn new(initial_state: T, cfg: DisplayConfig) -> ApplicationBuilder<T> { | ||
let pool = Arc::new(ThreadPool::new(num_cpus::get())); | ||
pub fn new(initial_state: T, cfg: DisplayConfig) -> ApplicationBuilder<'a, T> { | ||
let pool = Arc::new(ThreadPool::new( ::rayon::Configuration::new().num_threads(num_cpus::get())).unwrap()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you format the code in some way? Seems there is unnecessary whitespace. And please add an import statement inside the function.
Additionally, consider using expect
over unwrap
.
src/engine/app.rs
Outdated
{ | ||
self.planner.add_system::<S>(sys, name, pri); | ||
self.dispatcher_builder = self.dispatcher_builder.add(sys, name, dep); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if we should just wrap the functionality. Could we just let the user pass in the dispatcher with all systems already added?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same way we could just let the user to pass world with all Component
s added.
But there is interesting feature in @ebkalderons fork.
SystemExtwhich can be used to add all related components. We could use it in
ApplicationBuilder`'s wrapping functions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not integrate it into Specs? I didn't know about that, but it would be helpful, yeah.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh well, it seems it isn't 100% compatible with our existing builders...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there should be two possibilities for user now
Use ApplicationBuilder
and add System
s and register Component
s through it.
Create Application
instance directly passing Dispatcher
with all System
s and World
with all Components
added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing my comments! I added some more comments.
examples/04_pong/main.rs
Outdated
@@ -3,8 +3,10 @@ extern crate amethyst; | |||
use amethyst::{Application, Event, State, Trans, VirtualKeyCode, WindowEvent}; | |||
use amethyst::asset_manager::AssetManager; | |||
use amethyst::project::Config; | |||
use amethyst::ecs::{World, Join, VecStorage, Component, RunArg, System}; | |||
use amethyst::ecs::{World, Join, VecStorage, Component, System, WriteStorage, Fetch, FetchMut}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs reordering.
examples/04_pong/main.rs
Outdated
if plank.position + plank.dimensions[1] / 2. < 1. { | ||
plank.position += plank.velocity * delta_time; | ||
} | ||
} | ||
// If `S` is pressed and plank is in screen boundaries then move down | ||
if input.key_down(VirtualKeyCode::S) { | ||
if input.key_is_pressed(VirtualKeyCode::S) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need a rebase here.
src/engine/app.rs
Outdated
pub fn with<S>(mut self, sys: S, name: &str, pri: Priority) -> ApplicationBuilder<T> | ||
where S: System<()> + 'static | ||
/// Adds a given thread-local system `sys` | ||
/// All thread-local systems executed sequentially after all non-thread-local systems |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add an "are" in here?
src/lib.rs
Outdated
@@ -84,7 +84,7 @@ extern crate genmesh; | |||
extern crate imagefmt; | |||
extern crate num_cpus; | |||
extern crate specs; | |||
extern crate threadpool; | |||
extern crate rayon; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, have to nitpick here again - please move the rayon line up by one.
src/ecs/systems/transform.rs
Outdated
@@ -3,7 +3,7 @@ | |||
use cgmath::Matrix4; | |||
use fnv::{FnvHashMap as HashMap, FnvHashSet as HashSet}; | |||
|
|||
use ecs::{Join, Entity, RunArg, System}; | |||
use ecs::{Entity, Join, WriteStorage, ReadStorage, Entities, System}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs reordering.
examples/05_assets/main.rs
Outdated
@@ -214,6 +213,8 @@ fn main() { | |||
let path = format!("{}/examples/05_assets/resources/config.yml", | |||
env!("CARGO_MANIFEST_DIR")); | |||
let cfg = DisplayConfig::load(path); | |||
let mut game = Application::build(Example, cfg).done(); | |||
let mut game = Application::build(Example, cfg) | |||
.with_thread_local::<TransformSystem>(TransformSystem::new()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you sure TransformSystem
is thread-local?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well. After you mention that I think it is not :)
examples/04_pong/main.rs
Outdated
@@ -342,7 +335,8 @@ fn main() { | |||
let mut game = Application::build(Pong, cfg) | |||
.register::<Ball>() | |||
.register::<Plank>() | |||
.with::<PongSystem>(PongSystem, "pong_system", 1) | |||
.with::<PongSystem>(PongSystem, "pong_system", &[]) | |||
.with_thread_local::<TransformSystem>(TransformSystem::new()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here (see one of the comments below).
examples/03_renderable/main.rs
Outdated
@@ -292,7 +285,8 @@ fn main() { | |||
env!("CARGO_MANIFEST_DIR")); | |||
let cfg = DisplayConfig::load(path); | |||
let mut game = Application::build(Example, cfg) | |||
.with::<ExampleSystem>(ExampleSystem, "example_system", 1) | |||
.with::<ExampleSystem>(ExampleSystem, "example_system", &[]) | |||
.with_thread_local::<TransformSystem>(TransformSystem::new()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@omni-viral Since you submitted ebkalderon#2, won't this PR conflict when I merge into develop
again? I think we should accept this PR into the mainline and then I'll rebase on my end.
@ebkalderon There might be conflicts. You may rebase and reject ebkalderon/amethyst#2 |
@omni-viral Sweet, I reverted it successfully. I will rebase on top of this PR once it's ready for merge! |
@ebkalderon I'd like to review once more, if that's okay? |
Of course, go right ahead. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks @omni-viral!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks great! Thanks for your work!
Thank you all for your feedback! |
|
||
ApplicationBuilder { | ||
config: cfg, | ||
initial_state: initial_state, | ||
planner: Planner::from_pool(World::new(), pool), | ||
dispatcher_builder: DispatcherBuilder::new().with_pool(pool), | ||
world: World::new(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hold on, shouldn't we give the user the chance to access the World
before starting the game? Not exactly sure about it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think so. There is a space between when the Application is built and when we call .run()
on it, so all it would take is adding a .world_mut()
function to the Application.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or passing in World
instead of creating it inside the ApplicationBuilder
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either or. Both are functionally the same I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@omni-viral I know this didn't exist prior to your pull request, but could you add a way for users to initialize the game world prior to executing .run()
for the application? @torkleyy and I have both suggested some ways to do this, either is fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perfect, thank you!
@ebkalderon How is that? I don't even depend on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can merge now, thanks again @omni-viral!
Convert to specs v0.9.1