Skip to content
Prev Previous commit
Next Next commit
Set a needs update flag on sketch updates
  • Loading branch information
catilac committed Feb 15, 2026
commit f2fa7be34c6f347ca705fc74fcce50b4a735cf57
18 changes: 13 additions & 5 deletions crates/processing_render/src/sketch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,28 +9,36 @@ use bevy::{
};
use std::path::Path;

#[derive(Resource)]
struct SketchNeedsReload(bool);

/// Plugin that registers the Sketch asset type and its loader.
pub struct LivecodePlugin;

impl Plugin for LivecodePlugin {
fn build(&self, app: &mut App) {
app.init_asset::<Sketch>()
.init_asset_loader::<SketchLoader>();

app.add_systems(PreStartup, load_current_sketch)
.init_asset_loader::<SketchLoader>()
.insert_resource(SketchNeedsReload(false))
.add_systems(PreStartup, load_current_sketch)
.add_systems(Update, sketch_update_handler);
}
}

// TODO: A better name is possible
fn sketch_update_handler(mut events: MessageReader<AssetEvent<Sketch>>) {
fn sketch_update_handler(
mut events: MessageReader<AssetEvent<Sketch>>,
mut needs_reload: ResMut<SketchNeedsReload>,
) {
for event in events.read() {
match event {
AssetEvent::Added { id } => {
info!("Added: {id}")
}
AssetEvent::Modified { id } => {
info!("Modified: {id}")
info!("Modified: {id}");
// we want to emit some event to bevy??
needs_reload.0 = true;
}
AssetEvent::Removed { id } => {
info!("Removed: {id}")
Expand Down