save
This commit is contained in:
parent
895b56c326
commit
ee8799c324
8 changed files with 177 additions and 38 deletions
|
|
@ -52,7 +52,7 @@ pub fn init_density_object(mut density_grid: ResMut<DensityGrid>, mut query: Que
|
|||
}
|
||||
}
|
||||
|
||||
pub fn density_grid_update(mut density_grid: ResMut<DensityGrid>, query: Query<&Transform>) {
|
||||
pub fn density_grid_update(mut density_grid: ResMut<DensityGrid>, query: Query<&Transform, With<DensityObject>>) {
|
||||
density_grid.grid.fill(0);
|
||||
|
||||
for transform in &query {
|
||||
|
|
@ -86,3 +86,13 @@ pub fn density_grid_force(
|
|||
physics_body.force -= density_gradient * DENSITY_FORCE_SCALE;
|
||||
}
|
||||
}
|
||||
|
||||
pub struct DensityGridPlugin;
|
||||
|
||||
impl Plugin for DensityGridPlugin {
|
||||
fn build(&self, app: &mut App) {
|
||||
app.insert_resource(DensityGrid::new())
|
||||
.add_systems(PostStartup, init_density_object)
|
||||
.add_systems(FixedUpdate, (density_grid_update, density_grid_force).chain());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue