bevy-ichun 0.6.0

A simple kinematic character controller for avian3d
Documentation
//! # Kinematic Character Controller for Bevy and Avian3D
//!
//! Ichun provides a modular kinematic character controller (KCC) implementation
//! for the Bevy engine using the Avian3D physics backend. It handles common gameplay
//! features like character movement, jumping, running, and interaction with the environment.
//!
//! ## Features
//!
//! * Kinematic character controller with physics-based collision response
//! * Modular design with separate movement and input systems
//! * Support for slopes, moving platforms and static geometry
//! * Configurable gravity, jump physics, and movement parameters
//! * Optional input handling with customizable key bindings
//!
//! ## Module Structure
//!
//! * `kcc`: Core kinematic character controller functionality and physics
//! * `movement_events`: Movement systems that generate actions to apply velocity from input
//! * `input`: Input handling systems that generate movement events
//! * `actions`: action systems execute movement actions to the character
//! * `system_sets`: Bevy system sets for proper execution ordering
//!
//! ## Usage
//!
//! Add the plugin to your Bevy app:
//!
//! ```rust
//! use bevy::prelude::*;
//! use ichun::IchunPlugin;
//!
//! fn main() {
//!     App::new()
//!         .add_plugins(DefaultPlugins)
//!         .add_plugins(IchunPlugin)
//!         .run();
//! }
//! ```
//!
//! Then add the KCC components to your character entity:
//!
//! ```rust
//! use bevy::prelude::*;
//! use bevy_ichun::{IchunPlugin, input::KccInputConfig, kcc::Kcc, movement::KccMovementConfig};
//!
//! fn spawn_character(mut commands: Commands) {
//!    commands.spawn((
//!        Kcc::default(),
//!        KccMovementConfig::default(),
//!        KccInputConfig::default(),
//!        Mesh3d(meshes.add(Capsule3d::new(0.4, 1.0))),
//!        MeshMaterial3d(matl.add(Color::srgb(0.8, 0.7, 0.6))),
//!        Transform::from_xyz(0.0, 3.0, 0.0),
//!    ));
//! }
//! ```
use bevy::prelude::*;
use kcc::IchunKccPlugin;

#[cfg(feature = "kcc_movement_events")]
use movement_events::IchunMovementEventsPlugin;

#[cfg(feature = "kcc_input")]
use input::IchunInputPlugin;
use system_sets::IchunSystemSetsPlugin;

#[cfg(feature = "kcc_actions")]
use actions::IchunActionsPlugin;

pub mod kcc;
#[cfg(feature = "kcc_movement_events")]
pub mod movement_events;
pub mod system_sets;

#[cfg(feature = "kcc_input")]
pub mod input;

#[cfg(feature = "kcc_actions")]
pub mod actions;

pub struct IchunPlugin;

/// Main plugin for the Ichun character controller.
///
/// This plugin adds all necessary systems and components for the character controller
/// to function. It automatically configures the proper system execution order and
/// adds all required plugins.
///
/// # Features
///
/// The plugin's behavior can be configured using Cargo features:
/// - `kcc_movement_events`: Enables the movement systems (enabled by default)
/// - `kcc_input`: Enables input handling systems (enabled by default)
///
/// # Example
///
/// ```rust
/// use bevy::prelude::*;
/// use bevy_ichun::IchunPlugin;
///
/// fn main() {
///     App::new()
///         .add_plugins(DefaultPlugins)
///         .add_plugins(IchunPlugin)
///         .run();
/// }
/// ```
impl Plugin for IchunPlugin {
    fn build(&self, app: &mut bevy::app::App) {
        app.add_plugins((
            IchunSystemSetsPlugin,
            IchunKccPlugin,
            #[cfg(feature = "kcc_movement_events")]
            IchunMovementEventsPlugin,
            #[cfg(feature = "kcc_input")]
            IchunInputPlugin,
            #[cfg(feature = "kcc_actions")]
            IchunActionsPlugin,
        ));
    }
}