kon/
lib.rs

1//! # Kon Engine
2//!
3//! Modular, plugin-based 2D game engine.
4//!
5//! # Example
6//! ```ignore
7//! use kon::prelude::*;
8//!
9//! #[component]
10//! struct Position { x: f32, y: f32 }
11//!
12//! #[system]
13//! fn setup(ctx: &mut Context) {
14//!     ctx.world_mut()
15//!         .spawn()
16//!         .insert(Position { x: 0.0, y: 0.0 })
17//!         .tag("player")
18//!         .id();
19//! }
20//!
21//! fn main() {
22//!     kon::init_logger();
23//!
24//!     Kon::new()
25//!         .add_plugin(DefaultPlugins)
26//!         .add_startup_system(setup)
27//!         .run();
28//! }
29//! ```
30
31pub use kon_core;
32pub use kon_ecs;
33pub use kon_macros::{component, system};
34pub use log;
35
36use kon_core::Plugin;
37
38pub mod prelude {
39    //! Common imports for Kon Engine
40    pub use crate::DefaultPlugins;
41    pub use crate::{component, system};
42    pub use kon_core::{App, Context, Event, Events, Globals, Kon, Plugin, Time};
43    pub use kon_ecs::{ContextEcsExt, EcsPlugin, Entity, EntityBuilder, Query, World};
44}
45
46/// Engine version
47pub const VERSION: &str = env!("CARGO_PKG_VERSION");
48
49/// Default plugins bundle
50///
51/// Includes:
52/// - `EcsPlugin` - Entity Component System
53pub struct DefaultPlugins;
54
55impl Plugin for DefaultPlugins {
56    fn build(&self, app: &mut kon_core::App) {
57        app.add_plugin(kon_ecs::EcsPlugin);
58    }
59
60    fn is_plugin_group(&self) -> bool {
61        true
62    }
63}