Skip to content

Commit

Permalink
Merge pull request #562 from ChristopherBiscardi/after-time
Browse files Browse the repository at this point in the history
Run systems in First after Time set
  • Loading branch information
ChristopherBiscardi authored Sep 16, 2024
2 parents 4ad090e + f8d25c6 commit 42b74a3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 6 deletions.
18 changes: 13 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,13 @@
//! - Built in animation support – see [`animation` example](https://github.com/StarArawn/bevy_ecs_tilemap/blob/main/examples/animation.rs).
//! - Texture array support.

use bevy::prelude::{
Bundle, Changed, Component, Deref, First, GlobalTransform, InheritedVisibility, Plugin, Query,
Reflect, ReflectComponent, Transform, ViewVisibility, Visibility,
use bevy::{
prelude::{
Bundle, Changed, Component, Deref, First, GlobalTransform, InheritedVisibility,
IntoSystemConfigs, IntoSystemSetConfigs, Plugin, Query, Reflect, ReflectComponent,
SystemSet, Transform, ViewVisibility, Visibility,
},
time::TimeSystem,
};

#[cfg(feature = "render")]
Expand Down Expand Up @@ -58,7 +62,7 @@ impl Plugin for TilemapPlugin {
#[cfg(feature = "render")]
app.add_plugins(render::TilemapRenderingPlugin);

app.add_systems(First, update_changed_tile_positions);
app.add_systems(First, update_changed_tile_positions.in_set(TilemapFirstSet));

#[cfg(all(not(feature = "atlas"), feature = "render"))]
{
Expand All @@ -83,10 +87,14 @@ impl Plugin for TilemapPlugin {
.register_type::<TileFlip>()
.register_type::<TileStorage>()
.register_type::<TilePosOld>()
.register_type::<AnimatedTile>();
.register_type::<AnimatedTile>()
.configure_sets(First, TilemapFirstSet.after(TimeSystem));
}
}

#[derive(SystemSet, Debug, Clone, PartialEq, Eq, Hash)]
pub struct TilemapFirstSet;

#[derive(Component, Reflect, Debug, Clone, Copy, Deref)]
#[reflect(Component)]
pub struct FrustumCulling(pub bool);
Expand Down
3 changes: 2 additions & 1 deletion src/render/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ use bevy::render::texture::GpuImage;
use crate::{
prelude::TilemapRenderSettings,
tiles::{TilePos, TileStorage},
TilemapFirstSet,
};
use crate::{
prelude::TilemapTexture,
Expand Down Expand Up @@ -112,7 +113,7 @@ impl Plugin for TilemapRenderingPlugin {
#[cfg(not(feature = "atlas"))]
app.add_systems(Update, set_texture_to_copy_src);

app.add_systems(First, clear_removed);
app.add_systems(First, clear_removed.in_set(TilemapFirstSet));
app.add_systems(PostUpdate, (removal_helper, removal_helper_tilemap));

app.add_plugins(MaterialTilemapPlugin::<StandardTilemapMaterial>::default());
Expand Down

0 comments on commit 42b74a3

Please sign in to comment.