Parameterize Rapier user data.

This commit is contained in:
Nolan Darilek 2021-06-10 19:15:50 -05:00
parent 06d47a0a60
commit 16eac466a4

View File

@ -1,10 +1,11 @@
use std::{ use std::{
cmp::{max, min}, cmp::{max, min},
fmt::Display, fmt::Display,
marker::PhantomData,
ops::{Add, AddAssign, Sub, SubAssign}, ops::{Add, AddAssign, Sub, SubAssign},
}; };
use bevy::{core::FloatOrd, prelude::*, transform::TransformSystem}; use bevy::{core::FloatOrd, ecs::query::WorldQuery, prelude::*, transform::TransformSystem};
use bevy_rapier2d::prelude::*; use bevy_rapier2d::prelude::*;
use derive_more::{Deref, DerefMut}; use derive_more::{Deref, DerefMut};
use rand::prelude::*; use rand::prelude::*;
@ -611,14 +612,22 @@ impl Plugin for CorePlugin {
} }
} }
pub struct CorePlugins; pub struct CorePlugins<RapierUserData>(PhantomData<RapierUserData>);
impl PluginGroup for CorePlugins { impl<RapierUserData> Default for CorePlugins<RapierUserData> {
fn default() -> Self {
Self(PhantomData)
}
}
impl<RapierUserData: 'static + WorldQuery + Send + Sync> PluginGroup
for CorePlugins<RapierUserData>
{
fn build(&mut self, group: &mut bevy::app::PluginGroupBuilder) { fn build(&mut self, group: &mut bevy::app::PluginGroupBuilder) {
group group
.add(crate::bevy_tts::TtsPlugin) .add(crate::bevy_tts::TtsPlugin)
.add(crate::bevy_openal::OpenAlPlugin) .add(crate::bevy_openal::OpenAlPlugin)
.add(CorePlugin) .add(RapierPhysicsPlugin::<RapierUserData>::default())
.add(RapierPhysicsPlugin::<NoUserData>::default()); .add(CorePlugin);
} }
} }