1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
use bevy::{
prelude::*,
scene::DynamicEntity,
};
pub trait CloneReflect {
#[must_use]
fn clone_value(&self) -> Self;
}
impl CloneReflect for Vec<Box<dyn Reflect>> {
fn clone_value(&self) -> Self {
let mut result = Vec::new();
for reflect in self {
result.push(reflect.clone_value());
}
result
}
}
impl CloneReflect for DynamicEntity {
fn clone_value(&self) -> Self {
Self {
entity: self.entity,
components: self.components.clone_value(),
}
}
}
impl CloneReflect for DynamicScene {
fn clone_value(&self) -> Self {
let mut entities = Vec::new();
for entity in &self.entities {
entities.push(entity.clone_value());
}
Self { entities }
}
}