godot-bevy 0.6.2

Bridge between Bevy ECS and Godot 4 for Rust-powered game development
Documentation
//! Auto-sync bundle system for automatic plugin registration
//!
//! This module provides a trait-based system for automatically discovering and registering
//! Bevy bundle auto-sync plugins generated by the `#[derive(BevyBundle)]` macro when
//! `autosync=true` is specified.
//!
//! ## Overview
//!
//! The auto-sync system eliminates the need to manually register bundle sync plugins in your
//! Bevy app. When you use `#[derive(BevyBundle)]` with `autosync=true`, the macro automatically
//! generates the necessary plugin and registers it with the global registry.

use bevy::app::App;

/// Trait for auto-sync bundle plugins that can be automatically registered
pub trait AutoSyncBundle {
    /// Register this auto-sync plugin with the given Bevy app
    fn register(app: &mut App);
}

/// Registry entry for auto-sync bundles using the inventory crate
pub struct AutoSyncBundleRegistry {
    pub register_fn: fn(&mut App),
}

// Collect all auto-sync bundle registrations
crate::inventory::collect!(AutoSyncBundleRegistry);

/// Register all discovered auto-sync bundles with the given Bevy app
///
/// This function is called automatically by the `GodotPlugin` and will discover
/// all auto-sync bundle plugins that were generated with `autosync=true`.
pub fn register_all_autosync_bundles(app: &mut App) {
    for registry_entry in crate::inventory::iter::<AutoSyncBundleRegistry> {
        (registry_entry.register_fn)(app);
        bevy::log::debug!("Auto-registered AutoSyncBundle plugin");
    }
}