remove "asset scopes" now that resources are separate from world

This commit is contained in:
Carter Anderson 2020-03-09 01:40:04 -07:00
parent f6dd6a5ca9
commit 91a6c0d9db
9 changed files with 26 additions and 55 deletions

View file

@ -74,10 +74,8 @@ fn main() {
}
fn setup(world: &mut World, resources: &mut Resources) {
let cube_handle = {
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap();
mesh_storage.add(Mesh::load(MeshType::Cube))
};
let cube_handle = mesh_storage.add(Mesh::load(MeshType::Cube));
world
.build()

View file

@ -161,13 +161,9 @@ fn create_entities_builder_archetype(
}
fn setup(world: &mut World, resources: &mut Resources) {
let cube = Mesh::load(MeshType::Cube);
let plane = Mesh::load(MeshType::Plane { size: 10.0 });
let (cube_handle, plane_handle) = {
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap();
(mesh_storage.add(cube), mesh_storage.add(plane))
};
let cube_handle = mesh_storage.add(Mesh::load(MeshType::Cube));
let plane_handle = mesh_storage.add(Mesh::load(MeshType::Plane { size: 10.0 }));
// no-archetype precompile: 1.24 sec
// archetype precompile: 1.07 sec

View file

@ -30,11 +30,8 @@ fn main() {
}
fn setup(world: &mut World, resources: &mut Resources) {
let cube = Mesh::load(MeshType::Cube);
let cube_handle = {
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap();
mesh_storage.add(cube)
};
let cube_handle = mesh_storage.add(Mesh::load(MeshType::Cube));
world.insert(
(),

View file

@ -23,9 +23,8 @@ fn build_rotator_system() -> Box<dyn Schedulable> {
}
fn setup(world: &mut World, resources: &mut Resources) {
let cube = Mesh::load(MeshType::Cube);
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap();
let cube_handle = mesh_storage.add(cube);
let cube_handle = mesh_storage.add(Mesh::load(MeshType::Cube));
world
.build()

View file

@ -15,13 +15,9 @@ impl AppPlugin for ExamplePlugin {
}
pub fn setup(world: &mut World, resources: &mut Resources) {
let cube = Mesh::load(MeshType::Cube);
let plane = Mesh::load(MeshType::Plane { size: 10.0 });
let (cube_handle, plane_handle) = {
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap();
(mesh_storage.add(cube), mesh_storage.add(plane))
};
let cube_handle = mesh_storage.add(Mesh::load(MeshType::Cube));
let plane_handle = mesh_storage.add(Mesh::load(MeshType::Plane { size: 10.0 }));
world.build()
// plane

View file

@ -5,13 +5,9 @@ fn main() {
}
fn setup(world: &mut World, resources: &mut Resources) {
let cube = Mesh::load(MeshType::Cube);
let plane = Mesh::load(MeshType::Plane { size: 10.0 });
let (cube_handle, plane_handle) = {
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap();
(mesh_storage.add(cube), mesh_storage.add(plane))
};
let cube_handle = mesh_storage.add(Mesh::load(MeshType::Cube));
let plane_handle = mesh_storage.add(Mesh::load(MeshType::Plane { size: 10.0 }));
world
.build()

View file

@ -62,13 +62,9 @@ fn build_print_status_system() -> Box<dyn Schedulable> {
}
fn setup(world: &mut World, resources: &mut Resources) {
let cube = Mesh::load(MeshType::Cube);
let plane = Mesh::load(MeshType::Plane { size: 10.0 });
let (cube_handle, plane_handle) = {
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap();
(mesh_storage.add(cube), mesh_storage.add(plane))
};
let cube_handle = mesh_storage.add(Mesh::load(MeshType::Cube));
let plane_handle = mesh_storage.add(Mesh::load(MeshType::Plane { size: 10.0 }));
let mut builder = world
.build()

View file

@ -5,18 +5,14 @@ fn main() {
}
fn setup(world: &mut World, resources: &mut Resources) {
let cube_handle = {
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap();
mesh_storage.add(Mesh::load(MeshType::Cube))
};
let cube_handle = mesh_storage.add(Mesh::load(MeshType::Cube));
let texture_handle = {
let mut texture_storage = resources.get_mut::<AssetStorage<Texture>>().unwrap();
let texture = Texture::load(TextureType::Png(
concat!(env!("CARGO_MANIFEST_DIR"), "/assets/temp_bevy_logo.png").to_string(),
));
texture_storage.add(texture)
};
let texture_handle = texture_storage.add(texture);
world
.build()

View file

@ -5,11 +5,8 @@ fn main() {
}
fn setup(world: &mut World, resources: &mut Resources) {
let cube = Mesh::load(MeshType::Cube);
let cube_handle = {
let mut mesh_storage = resources.get_mut::<AssetStorage<Mesh>>().unwrap();
mesh_storage.add(cube)
};
let cube_handle = mesh_storage.add(Mesh::load(MeshType::Cube));
world
.build()