-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5ba7785
commit f5ab3e2
Showing
11 changed files
with
148 additions
and
30 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
use bevy::ecs::{entity::Entity, query::With, system::ResMut, world::World}; | ||
|
||
use crate::{ | ||
bindings::ChunkBuffer, | ||
chunk::internal::SavedChunks, | ||
maps::internal::{MapInfo, SavedMaps}, | ||
}; | ||
|
||
pub fn save_chunks(mut world: &mut World) { | ||
// Get the map id's we need | ||
let map_ids: Vec<Entity> = world | ||
.query_filtered::<Entity, With<MapInfo>>() | ||
.iter(world) | ||
.collect(); | ||
|
||
// Get the chunk id's we need | ||
let chunk_ids: Vec<Entity> = world | ||
.query_filtered::<Entity, With<ChunkBuffer>>() | ||
.iter(world) | ||
.collect(); | ||
|
||
// Remove the map entities and put them into our hashmap | ||
let mut saved_maps = SavedMaps::default(); | ||
for map_id in map_ids.into_iter() { | ||
let mut map = world.entity_mut(map_id); | ||
saved_maps.insert(map_id, map.take::<MapInfo>().unwrap()); | ||
} | ||
|
||
// Remove the chunk entities and put them into our hashmap | ||
let mut saved_chunks = SavedChunks::default(); | ||
for chunk_id in chunk_ids.into_iter() { | ||
let mut chunk = world.entity_mut(chunk_id); | ||
saved_chunks.insert(chunk_id, chunk.take::<ChunkBuffer>().unwrap()); | ||
} | ||
|
||
world.insert_resource(saved_maps); | ||
world.insert_resource(saved_chunks); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.