Skip to content

Commit d296565

Browse files
committed
Set a needs update flag on sketch updates
1 parent dd57a85 commit d296565

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

crates/processing_render/src/sketch.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,28 +9,36 @@ use bevy::{
99
};
1010
use std::path::Path;
1111

12+
#[derive(Resource)]
13+
struct SketchNeedsReload(bool);
14+
1215
/// Plugin that registers the Sketch asset type and its loader.
1316
pub struct LivecodePlugin;
1417

1518
impl Plugin for LivecodePlugin {
1619
fn build(&self, app: &mut App) {
1720
app.init_asset::<Sketch>()
18-
.init_asset_loader::<SketchLoader>();
19-
20-
app.add_systems(PreStartup, load_current_sketch)
21+
.init_asset_loader::<SketchLoader>()
22+
.insert_resource(SketchNeedsReload(false))
23+
.add_systems(PreStartup, load_current_sketch)
2124
.add_systems(Update, sketch_update_handler);
2225
}
2326
}
2427

2528
// TODO: A better name is possible
26-
fn sketch_update_handler(mut events: MessageReader<AssetEvent<Sketch>>) {
29+
fn sketch_update_handler(
30+
mut events: MessageReader<AssetEvent<Sketch>>,
31+
mut needs_reload: ResMut<SketchNeedsReload>,
32+
) {
2733
for event in events.read() {
2834
match event {
2935
AssetEvent::Added { id } => {
3036
info!("Added: {id}")
3137
}
3238
AssetEvent::Modified { id } => {
33-
info!("Modified: {id}")
39+
info!("Modified: {id}");
40+
// we want to emit some event to bevy??
41+
needs_reload.0 = true;
3442
}
3543
AssetEvent::Removed { id } => {
3644
info!("Removed: {id}")

0 commit comments

Comments
 (0)