use bevy::prelude::*;
use jackdaw::prelude::*;
fn main() -> AppExit {
App::new()
.set_error_handler(bevy::ecs::error::error)
.add_plugins((
DefaultPlugins,
EditorPlugins::default()
.set(ExtensionPlugin::default().with_extension::<OperatorExampleExtension>()),
))
.run()
}
#[derive(Default)]
pub struct OperatorExampleExtension;
impl JackdawExtension for OperatorExampleExtension {
fn id(&self) -> String {
"operator_example".to_string()
}
fn label(&self) -> String {
"Minimal Operator Example".to_string()
}
fn description(&self) -> String {
"Adds a simple operator that logs the elapsed seconds since Jackdaw started.".to_string()
}
fn register(&self, ctx: &mut ExtensionContext) {
ctx.register_operator::<ElapsedSecondsOp>();
}
}
#[operator(
id = "operator_example.elapsed_seconds",
label = "Log Elapsed Seconds",
description = "Logs the elapsed seconds since Jackdaw started."
)]
fn elapsed_seconds(_: In<OperatorParameters>, time: Res<Time>) -> OperatorResult {
info!("Elapsed seconds: {}", time.elapsed_secs());
OperatorResult::Finished
}