34 lines
675 B
Rust
34 lines
675 B
Rust
use crate::SystemObject;
|
|
use galactica_content as content;
|
|
use galactica_render::ObjectSprite;
|
|
|
|
pub struct System {
|
|
pub name: String,
|
|
pub bodies: Vec<SystemObject>,
|
|
}
|
|
|
|
impl System {
|
|
pub fn new(ct: &content::Content, handle: content::SystemHandle) -> Self {
|
|
let sys = ct.get_system(handle);
|
|
let mut s = System {
|
|
name: sys.name.clone(),
|
|
bodies: Vec::new(),
|
|
};
|
|
|
|
for o in &sys.objects {
|
|
s.bodies.push(SystemObject {
|
|
pos: o.position,
|
|
sprite_texture: o.sprite_texture,
|
|
size: o.size,
|
|
angle: o.angle,
|
|
});
|
|
}
|
|
|
|
return s;
|
|
}
|
|
|
|
pub fn get_sprites(&self) -> Vec<ObjectSprite> {
|
|
return self.bodies.iter().map(|x| x.get_sprite()).collect();
|
|
}
|
|
}
|