@@ -8,6 +8,7 @@ use crate::components::source::Source;
8
8
use crate :: components:: wall:: { CircWall , RectWall } ;
9
9
use crate :: events:: UpdateWalls ;
10
10
use crate :: grid:: grid:: Grid ;
11
+ use crate :: grid:: plugin:: ComponentIDs ;
11
12
12
13
/// Marker component for the file dialog and the corresponding event.
13
14
pub struct SaveFileContents ;
@@ -33,6 +34,7 @@ pub fn file_loaded(
33
34
rect_walls : Query < ( Entity , & RectWall ) > ,
34
35
circ_walls : Query < ( Entity , & CircWall ) > ,
35
36
ui_state : Res < UiState > ,
37
+ mut ids : ResMut < ComponentIDs > ,
36
38
) {
37
39
if let Some ( data) = ev_loaded. read ( ) . next ( ) {
38
40
let save_data = serde_json:: from_slice :: < SaveData > ( & data. contents ) . unwrap ( ) ;
@@ -51,18 +53,24 @@ pub fn file_loaded(
51
53
commands. entity ( entity) . despawn ( ) ;
52
54
}
53
55
56
+ ids. reset ( ) ;
57
+
54
58
// Load entities
55
59
for source in save_data. sources {
56
60
commands. spawn ( source) ;
61
+ ids. get_new_source_id ( ) ;
57
62
}
58
63
for mic in save_data. mics {
59
64
commands. spawn ( mic) ;
65
+ ids. get_new_mic_id ( ) ;
60
66
}
61
67
for rect_wall in save_data. rect_walls {
62
68
commands. spawn ( rect_wall) ;
69
+ ids. get_new_wall_id ( ) ;
63
70
}
64
71
for circ_wall in save_data. circ_walls {
65
72
commands. spawn ( circ_wall) ;
73
+ ids. get_new_wall_id ( ) ;
66
74
}
67
75
68
76
grid. reset_cells ( ui_state. boundary_width ) ;
0 commit comments