use bevy::prelude::PluginGroup;
use bevy::{DefaultPlugins, app::App, ecs::reflect::AppTypeRegistry};
use bevy_mod_scripting::BMSPlugin;
use bevy_mod_scripting_bindings::{
DummyScriptFunctionRegistry, function::script_function::AppScriptFunctionRegistry,
globals::AppScriptGlobalsRegistry,
};
use ladfile_builder::plugin::{
LadFileSettingsArc, ScriptingFilesGenerationPlugin, generate_lad_file,
};
use std::path::PathBuf;
fn main() -> std::io::Result<()> {
let mut app = App::new();
app.add_plugins(DefaultPlugins);
app.add_plugins(BMSPlugin.set::<ScriptingFilesGenerationPlugin>(
ScriptingFilesGenerationPlugin::new(
true, PathBuf::from("assets").join("definitions"),
Some(PathBuf::from("bindings.lad.json")), "Core BMS framework bindings",
true,
true,
),
));
app.finish();
app.cleanup();
let type_registry = app
.world()
.get_resource::<AppTypeRegistry>()
.unwrap()
.clone();
let function_registry = app
.world()
.get_resource::<AppScriptFunctionRegistry>()
.unwrap()
.clone();
let dummy_function_registry = app
.world()
.get_resource::<DummyScriptFunctionRegistry>()
.unwrap()
.clone();
let global_registry = app
.world()
.get_resource::<AppScriptGlobalsRegistry>()
.unwrap()
.clone();
let settings = app
.world()
.get_resource::<LadFileSettingsArc>()
.unwrap()
.clone();
generate_lad_file(
&type_registry,
&function_registry,
&dummy_function_registry,
&global_registry,
&settings.0,
);
Ok(())
}