Galactica/crates/gameobject/src/system.rs

38 lines
651 B
Rust
Raw Normal View History

2024-01-08 22:38:36 -08:00
use cgmath::{Point3, Rad};
2024-01-01 15:46:39 -08:00
use galactica_content as content;
2023-12-21 11:26:44 -08:00
2024-01-08 22:38:36 -08:00
// TODO: rework
2023-12-21 11:26:44 -08:00
pub struct System {
2023-12-25 09:01:59 -08:00
pub name: String,
2024-01-02 15:59:50 -08:00
pub bodies: Vec<SystemObject>,
2023-12-21 11:26:44 -08:00
}
impl System {
2024-01-01 15:46:39 -08:00
pub fn new(ct: &content::Content, handle: content::SystemHandle) -> Self {
let sys = ct.get_system(handle);
2023-12-23 23:24:04 -08:00
let mut s = System {
2024-01-01 15:46:39 -08:00
name: sys.name.clone(),
2023-12-23 23:24:04 -08:00
bodies: Vec::new(),
};
2023-12-22 16:51:21 -08:00
2024-01-01 15:46:39 -08:00
for o in &sys.objects {
2023-12-25 16:21:14 -08:00
s.bodies.push(SystemObject {
2023-12-25 10:30:27 -08:00
pos: o.position,
sprite: o.sprite,
2023-12-25 09:01:12 -08:00
size: o.size,
2023-12-25 10:30:27 -08:00
angle: o.angle,
2023-12-25 09:01:12 -08:00
});
}
2023-12-22 16:51:21 -08:00
2023-12-21 11:26:44 -08:00
return s;
}
2024-01-08 22:38:36 -08:00
}
2023-12-21 11:26:44 -08:00
2024-01-08 22:38:36 -08:00
pub struct SystemObject {
pub sprite: content::SpriteHandle,
pub pos: Point3<f32>,
pub size: f32,
pub angle: Rad<f32>,
2023-12-21 11:26:44 -08:00
}