2025-05-14 23:14:41 +02:00
|
|
|
use bevy::prelude::*;
|
2025-06-26 22:19:05 +02:00
|
|
|
use bevy_rapier3d::prelude::{Collider, RigidBody};
|
2025-05-21 15:56:58 +02:00
|
|
|
use bevy_third_person_camera::ThirdPersonCameraTarget;
|
2025-06-26 22:19:05 +02:00
|
|
|
use log::info;
|
2025-05-14 23:14:41 +02:00
|
|
|
|
2025-06-26 22:19:05 +02:00
|
|
|
use crate::{AppState, cleanup};
|
2025-05-14 23:14:41 +02:00
|
|
|
|
2025-06-26 22:19:05 +02:00
|
|
|
pub fn plugin(app: &mut App) {
|
|
|
|
app.register_type::<StaticColliderConfig>()
|
|
|
|
// .add_systems(OnEnter(AppState::Ingame), test_spawn_on_init)
|
|
|
|
.add_systems(Update, add_colliders_to_things_that_need_them);
|
|
|
|
}
|
|
|
|
|
|
|
|
// uses blender coords
|
|
|
|
#[derive(Component, Clone, Copy, Reflect)]
|
|
|
|
#[reflect(Component)]
|
|
|
|
pub struct StaticColliderConfig {
|
|
|
|
x: f32,
|
|
|
|
y: f32,
|
|
|
|
z: f32,
|
|
|
|
}
|
|
|
|
|
|
|
|
fn add_colliders_to_things_that_need_them(
|
2025-05-14 23:14:41 +02:00
|
|
|
mut c: Commands,
|
2025-06-26 22:19:05 +02:00
|
|
|
to_modify: Query<(Entity, &StaticColliderConfig), Without<Collider>>,
|
2025-05-14 23:14:41 +02:00
|
|
|
) {
|
2025-06-26 22:19:05 +02:00
|
|
|
for (entity, StaticColliderConfig { x, y, z }) in to_modify.iter() {
|
|
|
|
info!("meow");
|
|
|
|
c.entity(entity)
|
|
|
|
.insert(Collider::cuboid(*x / 2., *z / 2., -*y / 2.));
|
|
|
|
}
|
2025-05-14 23:14:41 +02:00
|
|
|
}
|