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::<CallOperatorExampleExtension>()),
))
.run()
}
#[derive(Default)]
pub struct CallOperatorExampleExtension;
impl JackdawExtension for CallOperatorExampleExtension {
fn id(&self) -> String {
"call_operator_example".to_string()
}
fn label(&self) -> String {
"Call Operator Example".to_string()
}
fn description(&self) -> String {
"Adds a cube by calling a builtin operator for it.".to_string()
}
fn register(&self, ctx: &mut ExtensionContext) {
ctx.register_operator::<SpawnCubeOp>();
}
}
#[operator(
id = "call_operator_example.spawn_cube",
label = "Spawn a cube",
description = "Spawn a cube at the origin of the scene by using the builtin cube spawning operator."
)]
fn spawn_cube(_: In<OperatorParameters>, mut commands: Commands) -> OperatorResult {
commands.operator("entity.add.cube").call();
OperatorResult::Finished
}