Path: blob/main/crates/bevy_animation/macros/src/animation_event.rs
9423 views
use bevy_macro_utils::BevyManifest;1use proc_macro::TokenStream;2use quote::quote;3use syn::{parse_macro_input, DeriveInput};45pub fn derive_animation_event(input: TokenStream) -> TokenStream {6let ast = parse_macro_input!(input as DeriveInput);7let (bevy_ecs, bevy_animation) = BevyManifest::shared(|manifest| {8let bevy_ecs = manifest.get_path("bevy_ecs");9let bevy_animation = manifest.get_path("bevy_animation");10(bevy_ecs, bevy_animation)11});1213let generics = ast.generics;14let (impl_generics, type_generics, where_clause) = generics.split_for_impl();1516let struct_name = &ast.ident;1718quote! {19impl #impl_generics #bevy_ecs::event::Event for #struct_name #type_generics #where_clause {20type Trigger<'a> = #bevy_animation::AnimationEventTrigger;21}2223impl #impl_generics #bevy_animation::AnimationEvent for #struct_name #type_generics #where_clause {24}25}26.into()27}282930