Skip to content

Commit

Permalink
0.10.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ManevilleF committed Jul 15, 2024
1 parent f5bb49e commit 283d0ce
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 8 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

## 0.10.1

* Fixed system ordering
* Fixed potential crash in cell tick for despawned cells
* Added system set labels

## 0.10.0

* Bevy 0.14
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "bevy_life"
version = "0.10.0"
version = "0.10.1"
edition = "2021"
authors = ["Felix de Maneville <[email protected]>"]
license-file = "./LICENSE"
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![unsafe forbidden](https://img.shields.io/badge/unsafe-forbidden-success.svg)](https://github.com/rust-secure-code/safety-dance/)
[![Crates.io](https://img.shields.io/crates/v/bevy_life.svg)](https://crates.io/crates/bevy_life)
[![Docs.rs](https://docs.rs/bevy_life/badge.svg)](https://docs.rs/bevy_life)
[![dependency status](https://deps.rs/crate/bevy_life/0.10.0/status.svg)](https://deps.rs/crate/bevy_life)
[![dependency status](https://deps.rs/crate/bevy_life/0.10.1/status.svg)](https://deps.rs/crate/bevy_life)

<!-- cargo-sync-readme start -->

Expand Down
32 changes: 28 additions & 4 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,17 @@ pub type CyclicColors2dPlugin<const N: usize> =
pub type CyclicColors3dPlugin<const N: usize> =
CellularAutomatonPlugin<components::MooreCell3d, CyclicColorCellState<N>>;

/// System set variant for each cellular automaton step
#[derive(Debug, PartialEq, Eq, Clone, Hash, SystemSet)]
pub enum LifeSystemSet {
/// Spawned Cell insertion in [`CellMap`] (Requires [`CellularAutomatonPlugin::use_cell_map`])
NewCells,
/// Despawned Cell removal from [`CellMap`] (Requires [`CellularAutomatonPlugin::use_cell_map`])
RemovedCells,
/// Cell life tick update system set
CellUpdate,
}

/// Generic Cellular Automaton plugin. It will register systems for the matching
/// `Cell` and `CellState` types.
///
Expand All @@ -196,14 +207,27 @@ impl<C: Cell, S: CellState> Plugin for CellularAutomatonPlugin<C, S> {
// register_type::<CellMap::<C>>();
if self.use_cell_map {
app.insert_resource(CellMap::<C>::default());
app.add_systems(Update, handle_new_cells::<C>);
app.add_systems(PostUpdate, handle_removed_cells::<C>);
app.add_systems(
PostUpdate,
(
handle_new_cells::<C>.in_set(LifeSystemSet::NewCells),
handle_removed_cells::<C>.in_set(LifeSystemSet::RemovedCells),
),
);
}
if let Some(time_step) = self.tick_time_step {
let duration = Duration::from_secs_f64(time_step);
app.add_systems(Update, handle_cells::<C, S>.run_if(on_timer(duration)));
app.add_systems(
Update,
handle_cells::<C, S>
.run_if(on_timer(duration))
.in_set(LifeSystemSet::CellUpdate),
);
} else {
app.add_systems(Update, handle_cells::<C, S>);
app.add_systems(
Update,
handle_cells::<C, S>.in_set(LifeSystemSet::CellUpdate),
);
}

#[cfg(feature = "auto-coloring")]
Expand Down
4 changes: 2 additions & 2 deletions src/systems/cells.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,14 @@ pub fn handle_cells<C, S>(
query.par_iter().for_each(|(entity, cell, state)| {
if let Some(new_state) = handle_cell((cell, state), &map) {
par_commands.command_scope(|mut cmd| {
cmd.entity(entity).insert(new_state);
cmd.entity(entity).try_insert(new_state);
});
}
});
} else {
for (entity, cell, state) in query.iter() {
if let Some(new_state) = handle_cell((cell, state), &map) {
commands.entity(entity).insert(new_state);
commands.entity(entity).try_insert(new_state);
}
}
}
Expand Down

0 comments on commit 283d0ce

Please sign in to comment.