use std::fmt::Debug; use std::marker; use amethyst::core::cgmath::{ Array, EuclideanSpace, InnerSpace, Quaternion, Rotation, Vector3, Zero, }; use amethyst::core::{Result, SystemBundle}; use amethyst::ecs::prelude::DispatcherBuilder; use amethyst_rhusics::Convert; use collision::{Bound, ComputeBound, Primitive, Union}; use rand::Rand; use rhusics_core::Inertia; use super::{BoxDeletionSystem, EmissionSystem}; /// Bundle for box simulation. /// /// Add spawn and deletion systems. /// /// ### Type parameters: /// /// - `P`: Collision primitive (see `collision::primitive` for more information) /// - `B`: Bounding volume (usually `Aabb2`, `Aabb3` or `Sphere`) /// - `R`: Rotational quantity (`Basis2` or `Quaternion`) /// - `A`: Angular velocity quantity (`Scalar` or `Vector3`) /// - `I`: Inertia tensor (`Scalar` or `Matrix3`) pub struct BoxSimulationBundle { primitive: P, m: marker::PhantomData<(B, R, A, I)>, } impl BoxSimulationBundle { pub fn new(primitive: P) -> Self { Self { primitive, m: marker::PhantomData, } } } impl<'a, 'b, P, B, R, A, I> SystemBundle<'a, 'b> for BoxSimulationBundle where B: Bound + Union + Clone + Send + Sync + 'static, P: Primitive + ComputeBound + Clone + Send + Sync + 'static, P::Point: EuclideanSpace + Convert> + Debug + Send + Sync + 'static, ::Diff: Debug + Rand + InnerSpace + Array + Send + Sync + 'static, R: Rotation + Convert> + Send + Sync + 'static, A: Clone + Copy + Zero + Send + Sync + 'static, I: Inertia + Send + Sync + 'static, { fn build(self, dispatcher: &mut DispatcherBuilder<'a, 'b>) -> Result<()> { dispatcher.add( EmissionSystem::::new(self.primitive), "emission_system", &[], ); dispatcher.add( BoxDeletionSystem::::new(), "deletion_system", &["contact_resolution"], ); Ok(()) } }