shura/
lib.rs

1#![crate_type = "lib"]
2#![crate_name = "shura"]
3
4/// Shura version
5pub const VERSION: &str = env!("CARGO_PKG_VERSION");
6
7mod component;
8mod data;
9mod graphics;
10mod input;
11mod math;
12mod scene;
13mod shura;
14mod state;
15
16pub use instant::Duration;
17pub use rustc_hash::{FxHashMap, FxHashSet};
18pub use shura_proc::*;
19
20#[cfg(target_os = "android")]
21pub use ::winit::platform::android::activity::AndroidApp;
22
23pub(crate) use data::arena::*;
24
25pub use crate::{
26    component::{
27        component_config::*, component_derive::*, component_handle::*, component_manager::*,
28        component_set::*, component_type::*, empty_component::*, group::*, position_component::*,
29    },
30    graphics::{
31        camera::*, color::*, frame_manager::*, gpu::*, instance_buffer::*, model::*,
32        render_encoder::*, render_target::*, renderer::*, screen_config::*, shader::*, sprite::*,
33        sprite_sheet::*, uniform::*, vertex::*,
34    },
35    input::input::{Input, InputEvent, InputTrigger, Key, Modifier, MouseButton, ScreenTouch},
36    math::{aabb::*, math::*},
37    scene::{context::Context, scene::*, scene_manager::*},
38    shura::*,
39    state::{state::*, state_manager::*},
40};
41
42/// Access to [wgpu](https://github.com/gfx-rs/wgpu) for creating custom graphics.
43pub mod wgpu {
44    pub use wgpu::*;
45}
46
47/// Access to [winit](https://github.com/rust-windowing/winit).
48pub mod winit {
49    pub use winit::*;
50}
51
52// Rodio
53#[cfg(feature = "audio")]
54mod sound;
55#[cfg(feature = "audio")]
56/// Access to [rodio](https://github.com/RustAudio/rodio)
57pub mod audio {
58    pub use crate::sound::audio_manager::*;
59    pub use crate::sound::sound::*;
60    pub use rodio::Sink as AudioSink;
61    pub use rodio::*;
62}
63
64/// Access to [image](https://github.com/image-rs/image)
65pub mod image {
66    pub use image::*;
67}
68
69pub mod bytmuck {
70    pub use bytemuck::*;
71}
72
73// Rapier2d
74#[cfg(feature = "physics")]
75mod world;
76#[cfg(feature = "physics")]
77/// Access to the to [rapier2d](https://github.com/dimforge/rapier)
78pub mod physics {
79    pub(crate) use crate::world::world_changes::*;
80    pub use crate::world::{collider_component::*, rigid_body_component::*, world::*};
81    pub use rapier2d::geometry::*;
82    pub use rapier2d::parry;
83    pub use rapier2d::prelude::{
84        ActiveCollisionTypes, ActiveEvents, ActiveHooks, CoefficientCombineRule, Collider,
85        ColliderBroadPhaseData, ColliderBuilder, ColliderChanges, ColliderFlags, ColliderHandle,
86        ColliderMaterial, ColliderParent, ColliderSet, ColliderShape, ColliderType, FixedJoint,
87        FixedJointBuilder, GenericJoint, GenericJointBuilder, Group, ImpulseJoint,
88        ImpulseJointHandle, InteractionGroups, LockedAxes, MassProperties, MotorModel,
89        PrismaticJoint, QueryFilter, QueryFilterFlags, Ray, RayIntersection, RevoluteJoint,
90        RevoluteJointBuilder, RigidBody, RigidBodyActivation, RigidBodyBuilder, RigidBodyHandle,
91        RigidBodySet, RigidBodyType, Shape, ShapeType, SharedShape, SpacialVector, TypedShape, TOI,
92    };
93    pub mod rapier {
94        pub use rapier2d::*;
95    }
96}
97
98// egui
99#[cfg(feature = "gui")]
100/// Access to [egui](https://github.com/emilk/egui)
101pub mod gui {
102    pub(crate) use crate::graphics::gui::gui::*;
103    pub use egui::Context as GuiContext;
104    pub use egui::*;
105}
106
107// text
108#[cfg(feature = "text")]
109/// Text rendering inspired by [wgpu_text](https://github.com/Blatko1/wgpu-text)
110pub mod text {
111    pub use crate::graphics::text::{font::*, text::*, text_pipeline::*};
112    pub use glyph_brush::{
113        BuiltInLineBreaker, FontId, GlyphCruncher, HorizontalAlign, Layout, LineBreak,
114        OwnedSection, OwnedText, Section, SectionGlyphIter, SectionText, Text, VerticalAlign,
115    };
116}
117
118// gamepad
119#[cfg(feature = "gamepad")]
120/// Access to [gilrs](https://gitlab.com/gilrs-project/gilrs)
121pub mod gamepad {
122    pub use crate::input::input::{GamepadButton, GamepadStick};
123    pub use gilrs::{
124        ev, ff, Axis, Button, ConnectedGamepadsIterator, Gamepad, GamepadId, Mapping, MappingError,
125        MappingSource, PowerInfo,
126    };
127}
128
129// serde
130#[cfg(feature = "serde")]
131pub use crate::scene::scene_serde::*;
132
133// animation
134#[cfg(feature = "animation")]
135mod tween;
136/// Access to animations inspired by [bevy_tweening](https://github.com/djeedai/bevy_tweening)
137#[cfg(feature = "animation")]
138pub mod animation {
139    pub use crate::tween::{ease::*, tween::*};
140}
141
142/// Access to [nalgebra](https://github.com/dimforge/nalgebra), the math library used by shura
143pub mod na {
144    pub use nalgebra::*;
145}
146
147/// Access to [mint](https://github.com/kvark/mint) to convert between the diffrent math types
148pub mod mint {
149    pub use mint::*;
150}
151
152/// Access to some easy randomizer functions
153pub mod rand {
154    pub fn gen_range<
155        T: distributions::uniform::SampleUniform,
156        R: distributions::uniform::SampleRange<T>,
157    >(
158        range: R,
159    ) -> T {
160        return thread_rng().gen_range(range);
161    }
162    pub fn gen_bool(p: f64) -> bool {
163        return thread_rng().gen_bool(p);
164    }
165
166    pub use rand::*;
167}
168
169#[cfg(feature = "log")]
170mod logging;
171
172#[cfg(feature = "log")]
173/// Access to the logging abstraction over [env_logger](https://github.com/rust-cli/env_logger) and modified version of [wasm_logger](https://gitlab.com/limira-rs/wasm-logger)
174pub mod log {
175    pub use crate::logging::logging::LoggerBuilder;
176    pub use log::{debug, error, info, trace, warn, Level, LevelFilter, SetLoggerError};
177    pub mod env_logger {
178        pub use env_logger::*;
179    }
180}