use bevy::{asset::AssetPlugin, prelude::*};
use hanabi_effect_graph::{
bake, demo,
model::{EffectGraph, EffectGraphAsset},
modifier_registry::ModifierRegistryPlugin,
};
fn main() {
let graph: EffectGraph = match std::env::args().nth(1) {
Some(path) => {
let bytes = std::fs::read(&path).expect("read input file");
let asset: EffectGraphAsset =
ron::de::from_bytes(&bytes).expect("deserialize EffectGraphAsset");
asset.graph
}
None => demo::demo_graph(),
};
let mut app = App::new();
app.add_plugins((
MinimalPlugins,
AssetPlugin::default(),
ModifierRegistryPlugin,
));
let registry = app.world().resource::<AppTypeRegistry>().read();
match bake::bake(&graph, ®istry) {
Ok(effect) => {
let ron = effect.serialize(®istry).expect("serialize EffectAsset");
println!("{ron}");
}
Err(errors) => {
eprintln!("bake failed:");
for e in errors {
eprintln!(" - {e:?}");
}
std::process::exit(1);
}
}
}