|
|
|
|
@ -100,7 +100,6 @@ impl SaveEntity {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// Check for duplicate component types and emit an error
|
|
|
|
|
// TODO: It would be nice if this emitted a line refernece instead of a parsed struct!
|
|
|
|
|
let l = entity.components.len();
|
|
|
|
|
@ -111,12 +110,20 @@ impl SaveEntity {
|
|
|
|
|
let c2 = &entity.components[j];
|
|
|
|
|
let t1 = c1.type_id;
|
|
|
|
|
let t2 = c2.type_id;
|
|
|
|
|
if t1 == t2 {
|
|
|
|
|
if cfg!(debug_assertions) {
|
|
|
|
|
debug_assert!(
|
|
|
|
|
t1 != t2,
|
|
|
|
|
"Duplicate components in {:?}: \n\t{:?}\n\t{:?}",
|
|
|
|
|
load_context.asset_path(),
|
|
|
|
|
c1.data,
|
|
|
|
|
c2.data
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
error!(
|
|
|
|
|
"Duplicate components in {:?}: \n\t{:?}\n\t{:?}",
|
|
|
|
|
load_context.asset_path(),
|
|
|
|
|
c1.data,
|
|
|
|
|
c2.data,
|
|
|
|
|
c2.data
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -198,6 +205,37 @@ impl AssetLoader for SaveSceneLoader {
|
|
|
|
|
.map(|path| load_context.load(path))
|
|
|
|
|
.collect();
|
|
|
|
|
|
|
|
|
|
// Assert there are no duplicate entities in the file
|
|
|
|
|
{
|
|
|
|
|
let l = entities.len();
|
|
|
|
|
(0..l).for_each(|i| {
|
|
|
|
|
(i..l).for_each(|j| {
|
|
|
|
|
if i != j {
|
|
|
|
|
let e1 = &entities[i];
|
|
|
|
|
let e2 = &entities[j];
|
|
|
|
|
if cfg!(debug_assertions) {
|
|
|
|
|
debug_assert!(
|
|
|
|
|
e1 != e2,
|
|
|
|
|
"Duplicate entities in scene {:?}:\n\t{:?}\n\t{:?}",
|
|
|
|
|
load_context.asset_path(),
|
|
|
|
|
e1,
|
|
|
|
|
e2
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
if e1 == e2 {
|
|
|
|
|
error!(
|
|
|
|
|
"Duplicate entities in scene {:?}:\n\t{:?}\n\t{:?}",
|
|
|
|
|
load_context.asset_path(),
|
|
|
|
|
e1,
|
|
|
|
|
e2
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Ok(SaveScene { entities })
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|