Skip to content

Commit

Permalink
Rename InnerSceneHandle into SceneHandle
Browse files Browse the repository at this point in the history
  • Loading branch information
nicopap committed Apr 27, 2022
1 parent c9a5e95 commit c033ee7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions crates/bevy_scene/src/scene_spawner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ impl InstanceId {
}

#[derive(Hash, Debug, Clone, PartialEq, Eq)]
enum InnerSceneHandle {
enum SceneHandle {
World(Handle<Scene>),
Reflected(Handle<DynamicScene>),
}
impl InnerSceneHandle {
impl SceneHandle {
fn write_to_world(
&self,
world: &mut World,
Expand Down Expand Up @@ -63,24 +63,24 @@ impl InnerSceneHandle {
}
}
}
impl From<Handle<Scene>> for InnerSceneHandle {
impl From<Handle<Scene>> for SceneHandle {
fn from(handle: Handle<Scene>) -> Self {
Self::World(handle)
}
}
impl From<Handle<DynamicScene>> for InnerSceneHandle {
impl From<Handle<DynamicScene>> for SceneHandle {
fn from(handle: Handle<DynamicScene>) -> Self {
Self::Reflected(handle)
}
}

#[derive(Default)]
pub struct SceneSpawner {
instances: HashMap<InnerSceneHandle, Vec<InstanceId>>,
instances: HashMap<SceneHandle, Vec<InstanceId>>,
instances_info: HashMap<InstanceId, InstanceInfo>,
readers: SceneEventReaders,
scenes_to_spawn: Vec<(InnerSceneHandle, InstanceId)>,
scenes_to_despawn: Vec<InnerSceneHandle>,
scenes_to_spawn: Vec<(SceneHandle, InstanceId)>,
scenes_to_despawn: Vec<SceneHandle>,
scenes_with_parent: Vec<(InstanceId, Entity)>,
}

Expand Down Expand Up @@ -194,7 +194,7 @@ impl SceneSpawner {
fn despawn_sync_internal(
&mut self,
world: &mut World,
scene_handle: InnerSceneHandle,
scene_handle: SceneHandle,
) -> Result<(), SceneSpawnError> {
let err = || scene_handle.non_existing();
for instance_id in self.instances.get(&scene_handle).ok_or_else(err)? {
Expand Down Expand Up @@ -234,7 +234,7 @@ impl SceneSpawner {
fn spawn_instance(
&mut self,
world: &mut World,
scene_handle: InnerSceneHandle,
scene_handle: SceneHandle,
instance_id: InstanceId,
) -> Result<InstanceId, SceneSpawnError> {
let mut entity_map = EntityMap::default();
Expand All @@ -250,7 +250,7 @@ impl SceneSpawner {
fn update_spawned_scenes(
&mut self,
world: &mut World,
scene_handles: &[InnerSceneHandle],
scene_handles: &[SceneHandle],
) -> Result<(), SceneSpawnError> {
for scene_handle in scene_handles {
let err = || scene_handle.non_existing();
Expand Down Expand Up @@ -345,15 +345,15 @@ pub fn scene_spawner_system(world: &mut World) {
let mut updated_spawned_scenes = Vec::new();
for event in scene_spawner.readers.dynamic.iter(world.resource()) {
if let AssetEvent::Modified { handle } = event {
let scene_handle = InnerSceneHandle::Reflected(handle.clone_weak());
let scene_handle = SceneHandle::Reflected(handle.clone_weak());
if scene_spawner.instances.contains_key(&scene_handle) {
updated_spawned_scenes.push(scene_handle);
}
}
}
for event in scene_spawner.readers.real.iter(world.resource()) {
if let AssetEvent::Modified { handle } = event {
let scene_handle = InnerSceneHandle::World(handle.clone_weak());
let scene_handle = SceneHandle::World(handle.clone_weak());
if scene_spawner.instances.contains_key(&scene_handle) {
updated_spawned_scenes.push(scene_handle);
}
Expand Down

0 comments on commit c033ee7

Please sign in to comment.