start map stuff

This commit is contained in:
Schrottkatze 2025-06-16 17:21:13 +02:00
parent 684fdd5558
commit 67383ac1db
Signed by: schrottkatze
SSH key fingerprint: SHA256:FPOYVeBy3QP20FEM42uWF1Wa/Qhlk+L3S2+Wuau/Auo
8 changed files with 476 additions and 123 deletions

View file

@ -3,7 +3,7 @@
use bevy::prelude::*;
use bevy_third_person_camera::*;
use crate::AppState;
use crate::{AppState, TPCTarget};
use super::GameplaySet;
@ -13,6 +13,7 @@ pub fn plugin(app: &mut App) {
OnEnter(AppState::Ingame),
setup_game_camera.in_set(GameplaySet),
)
// .add_systems(Update, auto_target)
.add_systems(OnExit(AppState::Ingame), remove_tpc.in_set(GameplaySet));
}
@ -39,6 +40,21 @@ pub fn setup_game_camera(mut c: Commands, cam: Single<Entity, With<Camera3d>>) {
info!("Third person camera set up!")
}
// fn auto_target(
// mut c: Commands,
// without_custom: Query<Entity, (With<ThirdPersonCameraTarget>, Without<TPCTarget>)>,
// without_lib: Query<Entity, (Without<ThirdPersonCameraTarget>, With<TPCTarget>)>,
// ) {
// without_custom.iter().for_each(|e| {
// info!("Deleting ThirdPersonCameraTarget from {e}");
// c.entity(e).remove::<ThirdPersonCameraTarget>();
// });
// without_lib.iter().for_each(|e| {
// info!("Inserting TPCTarget into {e}");
// c.entity(e).insert(ThirdPersonCameraTarget);
// });
// }
/// Removes [ThirdPersonCamera] from the camera.
pub fn remove_tpc(mut c: Commands, cam: Single<Entity, (With<Camera3d>, With<ThirdPersonCamera>)>) {
c.entity(*cam).remove::<ThirdPersonCamera>();

View file

@ -3,26 +3,19 @@ use bevy_third_person_camera::ThirdPersonCameraTarget;
use crate::cleanup;
const NORMALSPUR: f32 = 1.435;
pub fn setup(
mut c: Commands,
asset_server: Res<AssetServer>,
mut meshes: ResMut<Assets<Mesh>>,
mut materials: ResMut<Assets<StandardMaterial>>,
) {
// spawn in floor plane
let scene_handle = asset_server.load(GltfAssetLabel::Scene(0).from_asset("gltf/test.glb"));
c.spawn((
Mesh3d(meshes.add(Plane3d::default().mesh().size(128., 128.))),
MeshMaterial3d(materials.add(Color::srgb(0.3, 0.8, 0.4))),
cleanup::Scene,
));
// track (temporary)
c.spawn((
Mesh3d(meshes.add(Cuboid::new(NORMALSPUR, 0.25, 96.))),
Mesh3d(meshes.add(Cuboid::new(1., 1., 1.))),
MeshMaterial3d(materials.add(Color::BLACK)),
ThirdPersonCameraTarget,
cleanup::Scene,
));
c.spawn(SceneRoot(scene_handle));
info!("Scene spawned!")
}