use crate::engine::ecs::ComponentId;
use crate::engine::ecs::component::Component;
use crate::engine::graphics::bounds::Aabb;
pub struct BoundsComponent {
pub local: Aabb,
}
impl BoundsComponent {
pub fn new(local: Aabb) -> Self {
Self { local }
}
}
impl Component for BoundsComponent {
fn name(&self) -> &'static str {
"bounds"
}
fn set_id(&mut self, _component: ComponentId) {}
fn as_any(&self) -> &dyn std::any::Any {
self
}
fn as_any_mut(&mut self) -> &mut dyn std::any::Any {
self
}
fn to_mms_ast(
&self,
_world: &crate::engine::ecs::World,
) -> crate::scripting::ast::ComponentExpression {
use crate::engine::ecs::component::ce_helpers::*;
ce_call(
"Bounds",
"aabb",
vec![
array(nums(self.local.min.iter().map(|&v| v as f64))),
array(nums(self.local.max.iter().map(|&v| v as f64))),
],
)
}
}