chore(testing): updated the testing bevy project

This commit is contained in:
kaosat.dev 2024-03-12 23:46:08 +01:00
parent 5192518b12
commit f5b063cd34
4 changed files with 12 additions and 21 deletions

View File

@ -1,6 +1,6 @@
({
"world":File (path: "models/World.glb"),
/*"world":File (path: "models/World.glb"),
"models": Folder (
path: "models/library",
),
),*/
})

View File

@ -11,6 +11,7 @@ impl Plugin for CorePlugin {
legacy_mode: false,
library_folder: "models/library".into(),
format: GltfFormat::GLB,
material_library:true,
aabbs: true,
..Default::default()
},

View File

@ -1,5 +1,5 @@
use bevy::prelude::*;
use bevy_gltf_blueprints::{BluePrintBundle, BlueprintName, GameWorldTag};
use bevy::{prelude::*, utils::hashbrown::HashMap};
use bevy_gltf_blueprints::{BluePrintBundle, BlueprintName, BlueprintsList, GameWorldTag, Library, SpawnHere};
use bevy_gltf_worlflow_examples_common_rapier::{assets::GameAssets, GameState, InAppRunning};
use bevy_rapier3d::prelude::Velocity;
@ -7,31 +7,19 @@ use rand::Rng;
pub fn setup_game(
mut commands: Commands,
game_assets: Res<GameAssets>,
models: Res<Assets<bevy::gltf::Gltf>>,
asset_server: Res<AssetServer>,
mut next_game_state: ResMut<NextState<GameState>>,
) {
commands.insert_resource(AmbientLight {
color: Color::WHITE,
brightness: 0.2,
});
// here we actually spawn our game world/level
commands.spawn((
SceneBundle {
// note: because of this issue https://github.com/bevyengine/bevy/issues/10436, "world" is now a gltf file instead of a scene
scene: models
.get(game_assets.world.id())
.expect("main level should have been loaded")
.scenes[0]
.clone(),
SceneBundle{
scene: asset_server.load("models/World.glb#Scene0"),
..default()
},
bevy::prelude::Name::from("world"),
GameWorldTag,
InAppRunning,
));
next_game_state.set(GameState::InGame)
}

View File

@ -97,13 +97,15 @@ impl Plugin for GamePlugin {
fn build(&self, app: &mut App) {
app.add_systems(Update, (spawn_test).run_if(in_state(GameState::InGame)))
.add_systems(Update, validate_export)
.add_systems(Update, generate_screenshot.run_if(on_timer(Duration::from_secs_f32(0.2)))) // TODO: run once
.add_systems(OnEnter(AppState::MenuRunning), start_game)
.add_systems(OnEnter(AppState::AppRunning), setup_game)
/* .add_systems(Update, generate_screenshot.run_if(on_timer(Duration::from_secs_f32(0.2)))) // TODO: run once
.add_systems(
Update,
exit_game.run_if(on_timer(Duration::from_secs_f32(0.5))),
) // shut down the app after this time
) // shut down the app after this time*/
;
}
}