aboutsummaryrefslogtreecommitdiff
path: root/plugins/glues
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-08-08 15:49:38 +0800
committer魏曹先生 <1992414357@qq.com>2026-08-08 15:49:38 +0800
commit8ff60fdeb0dda7cb6eb7ed91c5084fc107f33365 (patch)
tree8b72bc3e2aa684b28e5623ac91653ee713fd638e /plugins/glues
parentebd8f440ae5a2d131cd4e6c064b2d97209cf0858 (diff)
feat: add gravity and gravity-movement plugins
Add CHGravityPlugin to manage the global gravity resource and CHGravityMovementGluePlugin to apply gravity to movement velocity each fixed update. Update workspace dependencies and include the new crates in the main app.
Diffstat (limited to 'plugins/glues')
-rw-r--r--plugins/glues/gravity_movement/Cargo.toml9
-rw-r--r--plugins/glues/gravity_movement/src/lib.rs29
2 files changed, 38 insertions, 0 deletions
diff --git a/plugins/glues/gravity_movement/Cargo.toml b/plugins/glues/gravity_movement/Cargo.toml
new file mode 100644
index 0000000..4b5790c
--- /dev/null
+++ b/plugins/glues/gravity_movement/Cargo.toml
@@ -0,0 +1,9 @@
+[package]
+name = "ch-gravity-movement"
+version.workspace = true
+edition.workspace = true
+
+[dependencies]
+bevy.workspace = true
+ch-movement.workspace = true
+ch-gravity.workspace = true
diff --git a/plugins/glues/gravity_movement/src/lib.rs b/plugins/glues/gravity_movement/src/lib.rs
new file mode 100644
index 0000000..da31061
--- /dev/null
+++ b/plugins/glues/gravity_movement/src/lib.rs
@@ -0,0 +1,29 @@
+//! CH Glue - Gravity & Movement
+//!
+//! This module provides the glue layer for the Gravity and Movement modules.
+
+#![deny(missing_docs)]
+
+use bevy::{
+ app::{FixedUpdate, Plugin},
+ ecs::system::{Query, Res},
+};
+use ch_gravity::Gravity;
+use ch_movement::{Movement, Velocity};
+
+/// Cigarette Hacker gravity movement glue
+pub struct CHGravityMovementGluePlugin;
+
+impl Plugin for CHGravityMovementGluePlugin {
+ fn build(&self, app: &mut bevy::app::App) {
+ app.add_systems(FixedUpdate, apply_gravity_to_movement);
+ }
+}
+
+fn apply_gravity_to_movement(mut query: Query<(&mut Velocity, &Movement)>, gravity: Res<Gravity>) {
+ for (mut velocity, _movement) in query.iter_mut() {
+ velocity.x += gravity.x;
+ velocity.y += gravity.y;
+ velocity.z += gravity.z;
+ }
+}