chore(examples): updated examples for bevy 0.13

* updated dependencies
 * updated code where relevant
 * temporary removed editor
 * attempting to tweak lighting/camera proxies to match Bevy's new defaults
 * updated assets where relevant
 * still wip, as bevy_xpbd is not yet updated for 0.13
 * all work except the above & save/load
This commit is contained in:
kaosat.dev 2024-02-20 14:52:00 +01:00
parent cc2718ffd2
commit 3bc1a87d1e
50 changed files with 2832 additions and 928 deletions

View File

@ -5,11 +5,8 @@ edition = "2021"
license = "MIT OR Apache-2.0"
[dependencies]
bevy="0.12"
bevy="0.13"
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_gltf_worlflow_examples_common = { path = "../../common" }
bevy_rapier3d = { version = "0.23.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
bevy_asset_loader = { version = "0.18", features = ["standard_dynamic_assets" ]}
bevy_editor_pls = { version = "0.6" }
bevy_rapier3d = { version = "0.25.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
rand = "0.8.5"

View File

@ -43,12 +43,12 @@ pub fn setup_game(
}
pub fn spawn_test(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut commands: Commands,
mut game_world: Query<(Entity, &Children), With<GameWorldTag>>,
) {
if keycode.just_pressed(KeyCode::T) {
if keycode.just_pressed(KeyCode::KeyT) {
let world = game_world.single_mut();
let world = world.1[0];
@ -165,11 +165,11 @@ pub fn animation_control(
mut animation_players: Query<&mut AnimationPlayer>,
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
// mut entities_with_animations : Query<(&mut AnimationPlayer, &mut Animations)>,
) {
// robots
if keycode.just_pressed(KeyCode::B) {
if keycode.just_pressed(KeyCode::KeyB) {
for (link, animations) in animated_enemies.iter() {
let mut animation_player = animation_players.get_mut(link.0).unwrap();
let anim_name = "Scan";
@ -187,7 +187,7 @@ pub fn animation_control(
}
// foxes
if keycode.just_pressed(KeyCode::W) {
if keycode.just_pressed(KeyCode::KeyW) {
for (link, animations) in animated_foxes.iter() {
let mut animation_player = animation_players.get_mut(link.0).unwrap();
let anim_name = "Walk";
@ -204,7 +204,7 @@ pub fn animation_control(
}
}
if keycode.just_pressed(KeyCode::X) {
if keycode.just_pressed(KeyCode::KeyX) {
for (link, animations) in animated_foxes.iter() {
let mut animation_player = animation_players.get_mut(link.0).unwrap();
let anim_name = "Run";
@ -221,7 +221,7 @@ pub fn animation_control(
}
}
if keycode.just_pressed(KeyCode::C) {
if keycode.just_pressed(KeyCode::KeyC) {
for (link, animations) in animated_foxes.iter() {
let mut animation_player = animation_players.get_mut(link.0).unwrap();
let anim_name = "Survey";

View File

@ -89,22 +89,10 @@ pub fn teardown_main_menu(bla: Query<Entity, With<InMainMenu>>, mut commands: Co
}
pub fn main_menu(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut next_app_state: ResMut<NextState<AppState>>,
// mut next_game_state: ResMut<NextState<GameState>>,
) {
if keycode.just_pressed(KeyCode::Return) {
if keycode.just_pressed(KeyCode::Enter) {
next_app_state.set(AppState::AppLoading);
// next_game_state.set(GameState::None);
}
if keycode.just_pressed(KeyCode::L) {
next_app_state.set(AppState::AppLoading);
// load_requested_events.send(LoadRequest { path: "toto".into() })
}
if keycode.just_pressed(KeyCode::S) {
// save_requested_events.send(SaveRequest { path: "toto".into() })
}
}

View File

@ -1,5 +1,4 @@
use bevy::prelude::*;
use bevy_editor_pls::prelude::*;
use bevy_gltf_worlflow_examples_common::CommonPlugin;
mod core;
@ -15,8 +14,6 @@ fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin::default()),
// editor
EditorPlugin::default(),
// our custom plugins
CommonPlugin,
CorePlugin, // reusable plugins

View File

@ -5,11 +5,8 @@ edition = "2021"
license = "MIT OR Apache-2.0"
[dependencies]
bevy="0.12"
bevy="0.13"
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_gltf_worlflow_examples_common = { path = "../../common" }
bevy_rapier3d = { version = "0.23.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
bevy_asset_loader = { version = "0.18", features = ["standard_dynamic_assets" ]}
bevy_editor_pls = { version = "0.6" }
bevy_rapier3d = { version = "0.25.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
rand = "0.8.5"

View File

@ -1,7 +1,6 @@
use bevy::prelude::*;
use bevy_gltf_blueprints::{BluePrintBundle, BlueprintName, GameWorldTag};
use bevy_gltf_worlflow_examples_common::{assets::GameAssets, GameState, InAppRunning};
use bevy_rapier3d::prelude::Velocity;
use rand::Rng;
@ -40,12 +39,12 @@ pub fn setup_game(
struct UnregisteredComponent;
pub fn spawn_test(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut commands: Commands,
mut game_world: Query<(Entity, &Children), With<GameWorldTag>>,
) {
if keycode.just_pressed(KeyCode::T) {
if keycode.just_pressed(KeyCode::KeyT) {
let world = game_world.single_mut();
let world = world.1[0];
@ -83,12 +82,12 @@ pub fn spawn_test(
}
pub fn spawn_test_unregisted_components(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut commands: Commands,
mut game_world: Query<(Entity, &Children), With<GameWorldTag>>,
) {
if keycode.just_pressed(KeyCode::U) {
if keycode.just_pressed(KeyCode::KeyU) {
let world = game_world.single_mut();
let world = world.1[0];

View File

@ -89,24 +89,24 @@ pub fn teardown_main_menu(bla: Query<Entity, With<InMainMenu>>, mut commands: Co
}
pub fn main_menu(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut next_app_state: ResMut<NextState<AppState>>,
// mut next_game_state: ResMut<NextState<GameState>>,
// mut save_requested_events: EventWriter<SaveRequest>,
// mut load_requested_events: EventWriter<LoadRequest>,
) {
if keycode.just_pressed(KeyCode::Return) {
if keycode.just_pressed(KeyCode::Enter) {
next_app_state.set(AppState::AppLoading);
// next_game_state.set(GameState::None);
}
if keycode.just_pressed(KeyCode::L) {
if keycode.just_pressed(KeyCode::KeyL) {
next_app_state.set(AppState::AppLoading);
// load_requested_events.send(LoadRequest { path: "toto".into() })
}
if keycode.just_pressed(KeyCode::S) {
if keycode.just_pressed(KeyCode::KeyS) {
// save_requested_events.send(SaveRequest { path: "toto".into() })
}
}

View File

@ -1,5 +1,4 @@
use bevy::prelude::*;
use bevy_editor_pls::prelude::*;
use bevy_gltf_worlflow_examples_common::CommonPlugin;
mod core;
@ -15,8 +14,6 @@ fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin::default()),
// editor
EditorPlugin::default(),
// our custom plugins
CommonPlugin,
CorePlugin, // reusable plugins

View File

@ -5,11 +5,6 @@ edition = "2021"
license = "MIT OR Apache-2.0"
[dependencies]
bevy="0.12"
bevy="0.13"
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_gltf_worlflow_examples_common = { path = "../../common" }
bevy_xpbd_3d = "0.3"
bevy_asset_loader = { version = "0.18", features = ["standard_dynamic_assets" ]}
bevy_editor_pls = { version = "0.6" }
rand = "0.8.5"
bevy_gltf_worlflow_examples_common = { path = "../../common" }

View File

@ -5,11 +5,8 @@ edition = "2021"
license = "MIT OR Apache-2.0"
[dependencies]
bevy="0.12"
bevy="0.13"
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_gltf_worlflow_examples_common = { path = "../../common" }
bevy_rapier3d = { version = "0.23.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
bevy_asset_loader = { version = "0.18", features = ["standard_dynamic_assets" ]}
bevy_editor_pls = { version = "0.6" }
rand = "0.8.5"
bevy_rapier3d = { version = "0.25.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
rand = "0.8.5"

View File

@ -41,12 +41,12 @@ pub fn setup_game(
struct UnregisteredComponent;
pub fn spawn_test(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut commands: Commands,
mut game_world: Query<(Entity, &Children), With<GameWorldTag>>,
) {
if keycode.just_pressed(KeyCode::T) {
if keycode.just_pressed(KeyCode::KeyT) {
let world = game_world.single_mut();
let world = world.1[0];
@ -66,7 +66,7 @@ pub fn spawn_test(
let new_entity = commands
.spawn((
BluePrintBundle {
blueprint: BlueprintName("Health_Pickup".to_string()),
blueprint: BlueprintName("Watermelon2".to_string()),
..Default::default()
},
bevy::prelude::Name::from(format!("test{}", name_index)),
@ -81,48 +81,4 @@ pub fn spawn_test(
.id();
commands.entity(world).add_child(new_entity);
}
}
pub fn spawn_test_unregisted_components(
keycode: Res<Input<KeyCode>>,
mut commands: Commands,
mut game_world: Query<(Entity, &Children), With<GameWorldTag>>,
) {
if keycode.just_pressed(KeyCode::U) {
let world = game_world.single_mut();
let world = world.1[0];
let mut rng = rand::thread_rng();
let range = 5.5;
let x: f32 = rng.gen_range(-range..range);
let y: f32 = rng.gen_range(-range..range);
let mut rng = rand::thread_rng();
let range = 0.8;
let vel_x: f32 = rng.gen_range(-range..range);
let vel_y: f32 = rng.gen_range(2.0..2.5);
let vel_z: f32 = rng.gen_range(-range..range);
let name_index: u64 = rng.gen();
let new_entity = commands
.spawn((
BluePrintBundle {
blueprint: BlueprintName("Health_Pickup".to_string()),
..Default::default()
},
bevy::prelude::Name::from(format!("test{}", name_index)),
// BlueprintName("Health_Pickup".to_string()),
// SpawnHere,
TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)),
Velocity {
linvel: Vec3::new(vel_x, vel_y, vel_z),
angvel: Vec3::new(0.0, 0.0, 0.0),
},
UnregisteredComponent,
))
.id();
commands.entity(world).add_child(new_entity);
}
}
}

View File

@ -89,24 +89,11 @@ pub fn teardown_main_menu(bla: Query<Entity, With<InMainMenu>>, mut commands: Co
}
pub fn main_menu(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut next_app_state: ResMut<NextState<AppState>>,
// mut next_game_state: ResMut<NextState<GameState>>,
// mut save_requested_events: EventWriter<SaveRequest>,
// mut load_requested_events: EventWriter<LoadRequest>,
) {
if keycode.just_pressed(KeyCode::Return) {
if keycode.just_pressed(KeyCode::Enter) {
next_app_state.set(AppState::AppLoading);
// next_game_state.set(GameState::None);
}
if keycode.just_pressed(KeyCode::L) {
next_app_state.set(AppState::AppLoading);
// load_requested_events.send(LoadRequest { path: "toto".into() })
}
if keycode.just_pressed(KeyCode::S) {
// save_requested_events.send(SaveRequest { path: "toto".into() })
}
}

View File

@ -12,7 +12,7 @@ impl Plugin for GamePlugin {
fn build(&self, app: &mut App) {
app.add_systems(
Update,
(spawn_test, spawn_test_unregisted_components).run_if(in_state(GameState::InGame)),
(spawn_test).run_if(in_state(GameState::InGame)),
)
.add_systems(OnEnter(AppState::MenuRunning), setup_main_menu)
.add_systems(OnExit(AppState::MenuRunning), teardown_main_menu)

View File

@ -1,5 +1,4 @@
use bevy::prelude::*;
use bevy_editor_pls::prelude::*;
use bevy_gltf_worlflow_examples_common::CommonPlugin;
mod core;
@ -15,8 +14,6 @@ fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin::default()),
// editor
EditorPlugin::default(),
// our custom plugins
CommonPlugin,
CorePlugin, // reusable plugins

View File

@ -5,11 +5,8 @@ edition = "2021"
license = "MIT OR Apache-2.0"
[dependencies]
bevy="0.12"
bevy="0.13"
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_gltf_worlflow_examples_common = { path = "../../common" }
bevy_rapier3d = { version = "0.23.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
bevy_asset_loader = { version = "0.18", features = ["standard_dynamic_assets" ]}
bevy_editor_pls = { version = "0.6" }
rand = "0.8.5"
bevy_rapier3d = { version = "0.25.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
rand = "0.8.5"

View File

@ -41,12 +41,12 @@ pub fn setup_game(
struct UnregisteredComponent;
pub fn spawn_test(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut commands: Commands,
mut game_world: Query<(Entity, &Children), With<GameWorldTag>>,
) {
if keycode.just_pressed(KeyCode::T) {
if keycode.just_pressed(KeyCode::KeyT) {
let world = game_world.single_mut();
let world = world.1[0];
@ -82,47 +82,3 @@ pub fn spawn_test(
commands.entity(world).add_child(new_entity);
}
}
pub fn spawn_test_unregisted_components(
keycode: Res<Input<KeyCode>>,
mut commands: Commands,
mut game_world: Query<(Entity, &Children), With<GameWorldTag>>,
) {
if keycode.just_pressed(KeyCode::U) {
let world = game_world.single_mut();
let world = world.1[0];
let mut rng = rand::thread_rng();
let range = 5.5;
let x: f32 = rng.gen_range(-range..range);
let y: f32 = rng.gen_range(-range..range);
let mut rng = rand::thread_rng();
let range = 0.8;
let vel_x: f32 = rng.gen_range(-range..range);
let vel_y: f32 = rng.gen_range(2.0..2.5);
let vel_z: f32 = rng.gen_range(-range..range);
let name_index: u64 = rng.gen();
let new_entity = commands
.spawn((
BluePrintBundle {
blueprint: BlueprintName("Health_Pickup".to_string()),
..Default::default()
},
bevy::prelude::Name::from(format!("test{}", name_index)),
// BlueprintName("Health_Pickup".to_string()),
// SpawnHere,
TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)),
Velocity {
linvel: Vec3::new(vel_x, vel_y, vel_z),
angvel: Vec3::new(0.0, 0.0, 0.0),
},
UnregisteredComponent,
))
.id();
commands.entity(world).add_child(new_entity);
}
}

View File

@ -89,24 +89,10 @@ pub fn teardown_main_menu(bla: Query<Entity, With<InMainMenu>>, mut commands: Co
}
pub fn main_menu(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut next_app_state: ResMut<NextState<AppState>>,
// mut next_game_state: ResMut<NextState<GameState>>,
// mut save_requested_events: EventWriter<SaveRequest>,
// mut load_requested_events: EventWriter<LoadRequest>,
) {
if keycode.just_pressed(KeyCode::Return) {
if keycode.just_pressed(KeyCode::Enter) {
next_app_state.set(AppState::AppLoading);
// next_game_state.set(GameState::None);
}
if keycode.just_pressed(KeyCode::L) {
next_app_state.set(AppState::AppLoading);
// load_requested_events.send(LoadRequest { path: "toto".into() })
}
if keycode.just_pressed(KeyCode::S) {
// save_requested_events.send(SaveRequest { path: "toto".into() })
}
}

View File

@ -103,7 +103,9 @@ pub fn trigger_level_transition(
pub struct LevelsPlugin;
impl Plugin for LevelsPlugin {
fn build(&self, app: &mut App) {
app.register_type::<LevelTransition>().add_systems(
app
.register_type::<LevelTransition>()
.add_systems(
Update,
(trigger_level_transition,).run_if(in_state(GameState::InGame)),
);

View File

@ -16,7 +16,7 @@ impl Plugin for GamePlugin {
app.add_plugins(LevelsPlugin)
.add_systems(
Update,
(spawn_test, spawn_test_unregisted_components).run_if(in_state(GameState::InGame)),
(spawn_test).run_if(in_state(GameState::InGame)),
)
.add_systems(OnEnter(AppState::MenuRunning), setup_main_menu)
.add_systems(OnExit(AppState::MenuRunning), teardown_main_menu)

View File

@ -1,5 +1,4 @@
use bevy::prelude::*;
use bevy_editor_pls::prelude::*;
use bevy_gltf_worlflow_examples_common::CommonPlugin;
mod core;
@ -15,8 +14,6 @@ fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin::default()),
// editor
EditorPlugin::default(),
// our custom plugins
CommonPlugin,
CorePlugin, // reusable plugins

View File

@ -5,9 +5,6 @@ edition = "2021"
license = "MIT OR Apache-2.0"
[dependencies]
bevy="0.12"
bevy="0.13"
bevy_gltf_components = { path = "../../../crates/bevy_gltf_components" }
bevy_gltf_worlflow_examples_common = { path = "../../common" }
bevy_rapier3d = { version = "0.23.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
bevy_editor_pls = { version = "0.6" }

View File

@ -1,5 +1,4 @@
use bevy::{gltf::Gltf, prelude::*};
use bevy_editor_pls::prelude::*;
use bevy_gltf_components::ComponentsFromGltfPlugin;
use bevy_gltf_worlflow_examples_common::CorePlugin;
@ -61,14 +60,14 @@ fn main() {
.add_plugins((
DefaultPlugins.set(AssetPlugin::default()),
// editor
EditorPlugin::default(),
// EditorPlugin::default(),
// physics
// our custom plugins
ComponentsFromGltfPlugin::default(),
CorePlugin, // reusable plugins
ComponentsTestPlugin, // Showcases different type of components /structs
))
.add_state::<AppState>()
.init_state::<AppState>()
.add_systems(Startup, setup)
.add_systems(Update, (spawn_level.run_if(in_state(AppState::Loading)),))
.run();

View File

@ -5,14 +5,13 @@ edition = "2021"
license = "MIT OR Apache-2.0"
[dependencies]
bevy="0.12"
bevy_gltf_blueprints = "0.7"
bevy="0.13"
#bevy_gltf_blueprints = "0.7"
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_gltf_save_load = { path = "../../../crates/bevy_gltf_save_load" }
bevy_gltf_worlflow_examples_common = { path = "../../common" }
bevy_rapier3d = { version = "0.23.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
bevy_asset_loader = { version = "0.18", features = ["standard_dynamic_assets" ]}
bevy_editor_pls = { version = "0.6" }
rand = "0.8.5"
serde_json="1.0.108"
serde="1.0.193"
serde="1.0.193"
bevy_rapier3d = { version = "0.25.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
rand = "0.8.5"

View File

@ -60,16 +60,16 @@ pub fn unload_world(mut commands: Commands, gameworlds: Query<Entity, With<GameW
}
}
pub fn should_reset(keycode: Res<Input<KeyCode>>) -> bool {
keycode.just_pressed(KeyCode::N)
pub fn should_reset(keycode: Res<ButtonInput<KeyCode>>) -> bool {
keycode.just_pressed(KeyCode::KeyN)
}
pub fn spawn_test(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut dynamic_entities_world: Query<Entity, With<DynamicEntitiesRoot>>,
mut commands: Commands,
) {
if keycode.just_pressed(KeyCode::T) {
if keycode.just_pressed(KeyCode::KeyT) {
let world = dynamic_entities_world.single_mut();
let mut rng = rand::thread_rng();
@ -109,12 +109,12 @@ pub fn spawn_test(
struct UnregisteredComponent;
pub fn spawn_test_unregisted_components(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut commands: Commands,
mut dynamic_entities_world: Query<Entity, With<DynamicEntitiesRoot>>,
) {
if keycode.just_pressed(KeyCode::U) {
if keycode.just_pressed(KeyCode::KeyU) {
let world = dynamic_entities_world.single_mut();
let mut rng = rand::thread_rng();
@ -152,13 +152,13 @@ pub fn spawn_test_unregisted_components(
}
pub fn spawn_test_parenting(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
players: Query<Entity, With<Player>>,
mut commands: Commands,
names: Query<(Entity, &Name)>,
) {
if keycode.just_pressed(KeyCode::P) {
if keycode.just_pressed(KeyCode::KeyP) {
let mut rng = rand::thread_rng();
let range = 5.5;
let x: f32 = rng.gen_range(-range..range);

View File

@ -1,13 +1,11 @@
use bevy::{core_pipeline::clear_color::ClearColorConfig, prelude::*};
use bevy::{prelude::*};
use bevy_gltf_worlflow_examples_common::InGameLoading;
pub fn setup_loading_screen(mut commands: Commands) {
commands.spawn((
Camera2dBundle {
camera_2d: Camera2d {
clear_color: ClearColorConfig::Custom(Color::BLACK),
},
camera: Camera {
clear_color: ClearColorConfig::Custom(Color::BLACK),
// renders after / on top of the main camera
order: 2,
..default()

View File

@ -92,24 +92,15 @@ pub fn teardown_main_menu(in_main_menu: Query<Entity, With<InMainMenu>>, mut com
}
pub fn main_menu(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut next_app_state: ResMut<NextState<AppState>>,
// mut next_game_state: ResMut<NextState<GameState>>,
// mut save_requested_events: EventWriter<SaveRequest>,
// mut load_requested_events: EventWriter<LoadRequest>,
) {
if keycode.just_pressed(KeyCode::Return) {
if keycode.just_pressed(KeyCode::Enter) {
next_app_state.set(AppState::AppLoading);
// next_game_state.set(GameState::None);
}
if keycode.just_pressed(KeyCode::L) {
if keycode.just_pressed(KeyCode::KeyL) {
next_app_state.set(AppState::AppLoading);
// load_requested_events.send(LoadRequest { path: "toto".into() })
}
if keycode.just_pressed(KeyCode::S) {
// save_requested_events.send(SaveRequest { path: "toto".into() })
}
}

View File

@ -16,19 +16,19 @@ use bevy_gltf_save_load::{LoadRequest, LoadingFinished, SaveRequest, SavingFinis
pub fn request_save(
mut save_requests: EventWriter<SaveRequest>,
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
current_state: Res<State<GameState>>,
mut next_game_state: ResMut<NextState<GameState>>,
) {
if keycode.just_pressed(KeyCode::S)
if keycode.just_pressed(KeyCode::KeyS)
&& (current_state.get() != &GameState::InLoading)
&& (current_state.get() != &GameState::InSaving)
{
next_game_state.set(GameState::InSaving);
save_requests.send(SaveRequest {
path: "save.scn.ron".into(),
})
});
}
}
@ -43,18 +43,18 @@ pub fn on_saving_finished(
pub fn request_load(
mut load_requests: EventWriter<LoadRequest>,
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
current_state: Res<State<GameState>>,
mut next_game_state: ResMut<NextState<GameState>>,
) {
if keycode.just_pressed(KeyCode::L)
if keycode.just_pressed(KeyCode::KeyL)
&& (current_state.get() != &GameState::InLoading)
&& (current_state.get() != &GameState::InSaving)
{
next_game_state.set(GameState::InLoading);
load_requests.send(LoadRequest {
path: "save.scn.ron".into(),
})
});
}
}

View File

@ -1,5 +1,4 @@
use bevy::prelude::*;
use bevy_editor_pls::prelude::*;
use bevy_gltf_worlflow_examples_common::CommonPlugin;
mod core;
@ -15,8 +14,6 @@ fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin::default()),
// editor
EditorPlugin::default(),
// our custom plugins
CommonPlugin,
CorePlugin, // reusable plugins

View File

@ -5,12 +5,9 @@ edition = "2021"
license = "MIT OR Apache-2.0"
[dependencies]
bevy="0.12"
bevy="0.13"
bevy_gltf_blueprints = { path = "../../../crates/bevy_gltf_blueprints" }
bevy_registry_export = { path = "../../../crates/bevy_registry_export" }
bevy_gltf_worlflow_examples_common = { path = "../../common" }
bevy_rapier3d = { version = "0.23.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
bevy_asset_loader = { version = "0.18", features = ["standard_dynamic_assets" ]}
bevy_editor_pls = { version = "0.6" }
rand = "0.8.5"
bevy_rapier3d = { version = "0.25.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
rand = "0.8.5"

File diff suppressed because it is too large Load Diff

View File

@ -41,12 +41,12 @@ pub fn setup_game(
struct UnregisteredComponent;
pub fn spawn_test(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut commands: Commands,
mut game_world: Query<(Entity, &Children), With<GameWorldTag>>,
) {
if keycode.just_pressed(KeyCode::T) {
if keycode.just_pressed(KeyCode::KeyT) {
let world = game_world.single_mut();
let world = world.1[0];
@ -81,48 +81,4 @@ pub fn spawn_test(
.id();
commands.entity(world).add_child(new_entity);
}
}
pub fn spawn_test_unregisted_components(
keycode: Res<Input<KeyCode>>,
mut commands: Commands,
mut game_world: Query<(Entity, &Children), With<GameWorldTag>>,
) {
if keycode.just_pressed(KeyCode::U) {
let world = game_world.single_mut();
let world = world.1[0];
let mut rng = rand::thread_rng();
let range = 5.5;
let x: f32 = rng.gen_range(-range..range);
let y: f32 = rng.gen_range(-range..range);
let mut rng = rand::thread_rng();
let range = 0.8;
let vel_x: f32 = rng.gen_range(-range..range);
let vel_y: f32 = rng.gen_range(2.0..2.5);
let vel_z: f32 = rng.gen_range(-range..range);
let name_index: u64 = rng.gen();
let new_entity = commands
.spawn((
BluePrintBundle {
blueprint: BlueprintName("Health_Pickup".to_string()),
..Default::default()
},
bevy::prelude::Name::from(format!("test{}", name_index)),
// BlueprintName("Health_Pickup".to_string()),
// SpawnHere,
TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)),
Velocity {
linvel: Vec3::new(vel_x, vel_y, vel_z),
angvel: Vec3::new(0.0, 0.0, 0.0),
},
UnregisteredComponent,
))
.id();
commands.entity(world).add_child(new_entity);
}
}
}

View File

@ -89,24 +89,10 @@ pub fn teardown_main_menu(bla: Query<Entity, With<InMainMenu>>, mut commands: Co
}
pub fn main_menu(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut next_app_state: ResMut<NextState<AppState>>,
// mut next_game_state: ResMut<NextState<GameState>>,
// mut save_requested_events: EventWriter<SaveRequest>,
// mut load_requested_events: EventWriter<LoadRequest>,
) {
if keycode.just_pressed(KeyCode::Return) {
if keycode.just_pressed(KeyCode::Enter) {
next_app_state.set(AppState::AppLoading);
// next_game_state.set(GameState::None);
}
if keycode.just_pressed(KeyCode::L) {
next_app_state.set(AppState::AppLoading);
// load_requested_events.send(LoadRequest { path: "toto".into() })
}
if keycode.just_pressed(KeyCode::S) {
// save_requested_events.send(SaveRequest { path: "toto".into() })
}
}

View File

@ -12,7 +12,7 @@ impl Plugin for GamePlugin {
fn build(&self, app: &mut App) {
app.add_systems(
Update,
(spawn_test, spawn_test_unregisted_components).run_if(in_state(GameState::InGame)),
(spawn_test).run_if(in_state(GameState::InGame)),
)
.add_systems(OnEnter(AppState::MenuRunning), setup_main_menu)
.add_systems(OnExit(AppState::MenuRunning), teardown_main_menu)

View File

@ -1,5 +1,4 @@
use bevy::prelude::*;
use bevy_editor_pls::prelude::*;
use bevy_gltf_worlflow_examples_common::CommonPlugin;
mod core;
@ -15,8 +14,6 @@ fn main() {
App::new()
.add_plugins((
DefaultPlugins.set(AssetPlugin::default()),
// editor
EditorPlugin::default(),
// our custom plugins
CommonPlugin,
CorePlugin, // reusable plugins

View File

@ -5,9 +5,9 @@ edition = "2021"
license = "MIT OR Apache-2.0"
[dependencies]
bevy="0.12"
bevy="0.13"
bevy_gltf_blueprints = { path = "../../crates/bevy_gltf_blueprints" }
bevy_rapier3d = { version = "0.23.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
bevy_asset_loader = { version = "0.18", features = ["standard_dynamic_assets" ]}
bevy_editor_pls = { version = "0.6" }
bevy_rapier3d = { version = "0.25.0", features = [ "serde-serialize", "debug-render-3d", "enhanced-determinism"] }
bevy_asset_loader = { version = "0.20", features = ["standard_dynamic_assets" ]}
#bevy_editor_pls = { version = "0.6" }
rand = "0.8.5"

View File

@ -2,6 +2,7 @@ use bevy::core_pipeline::bloom::{BloomCompositeMode, BloomSettings};
use bevy::core_pipeline::experimental::taa::TemporalAntiAliasBundle;
use bevy::core_pipeline::tonemapping::{DebandDither, Tonemapping};
use bevy::pbr::ScreenSpaceAmbientOcclusionBundle;
use bevy::render::camera::Exposure;
use bevy::prelude::*;
use super::CameraTrackingOffset;
@ -17,6 +18,7 @@ pub fn camera_replace_proxies(
(
Entity,
&mut Camera,
&mut Exposure,
Option<&BloomSettings>,
Option<&SSAOSettings>,
),
@ -26,9 +28,10 @@ pub fn camera_replace_proxies(
added_bloom_settings: Query<&BloomSettings, Added<BloomSettings>>,
added_ssao_settings: Query<&SSAOSettings, Added<SSAOSettings>>, // Move to camera
) {
for (entity, mut camera, bloom_settings, ssao_setting) in added_cameras.iter_mut() {
for (entity, mut camera, mut exposure, bloom_settings, ssao_setting) in added_cameras.iter_mut() {
info!("detected added camera, updating proxy");
camera.hdr = true;
// exposure.ev100 *= 0.8;
commands
.entity(entity)
.insert(DebandDither::Enabled)

View File

@ -26,7 +26,7 @@ pub fn lighting_replace_proxies(
mut commands: Commands,
) {
for (entity, mut light) in added_dirights.iter_mut() {
light.illuminance *= 5.0;
// light.illuminance *= 5.0; // arbitrary/ eyeballed to match the levels of Blender
light.shadows_enabled = true;
let shadow_config: CascadeShadowConfig = CascadeShadowConfigBuilder {
first_cascade_far_bound: 15.0,
@ -41,7 +41,7 @@ pub fn lighting_replace_proxies(
}
for mut light in added_pointlights.iter_mut() {
light.intensity *= 0.001; // arbitrary/ eyeballed to match the levels of Blender
// light.intensity *= 0.001; // arbitrary/ eyeballed to match the levels of Blender
light.shadows_enabled = true;
}
@ -50,9 +50,10 @@ pub fn lighting_replace_proxies(
}
for ambient in added_ambient_proxies.iter() {
println!("AMBIENT {:?} {}", ambient.color, ambient.brightness);
commands.insert_resource(AmbientLight {
color: ambient.color,
brightness: ambient.brightness,
brightness: ambient.brightness,// * 4000.,
});
// FIXME: does this belong here ?
commands.insert_resource(ClearColor(ambient.color * ambient.brightness));

View File

@ -1,6 +1,6 @@
use bevy::{
ecs::system::Res,
input::{keyboard::KeyCode, Input},
input::{keyboard::KeyCode, ButtonInput},
log::info,
prelude::ResMut,
};
@ -18,9 +18,9 @@ pub fn resume_physics(mut physics_config: ResMut<RapierConfiguration>) {
pub fn toggle_physics_debug(
mut debug_config: ResMut<DebugRenderContext>,
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
) {
if keycode.just_pressed(KeyCode::D) {
if keycode.just_pressed(KeyCode::KeyD) {
debug_config.enabled = !debug_config.enabled;
}
}

View File

@ -8,22 +8,22 @@ use crate::GameState;
pub struct Player;
fn player_move_demo(
keycode: Res<Input<KeyCode>>,
keycode: Res<ButtonInput<KeyCode>>,
mut players: Query<&mut Transform, With<Player>>,
) {
let speed = 0.2;
if let Ok(mut player) = players.get_single_mut() {
if keycode.pressed(KeyCode::Left) {
if keycode.pressed(KeyCode::ArrowLeft) {
player.translation.x += speed;
}
if keycode.pressed(KeyCode::Right) {
if keycode.pressed(KeyCode::ArrowRight) {
player.translation.x -= speed;
}
if keycode.pressed(KeyCode::Up) {
if keycode.pressed(KeyCode::ArrowUp) {
player.translation.z += speed;
}
if keycode.pressed(KeyCode::Down) {
if keycode.pressed(KeyCode::ArrowDown) {
player.translation.z -= speed;
}
}

View File

@ -11,6 +11,7 @@ pub mod game;
pub use game::*;
use bevy::prelude::*;
// use bevy_editor_pls::prelude::*;
pub struct CommonPlugin;
impl Plugin for CommonPlugin {

View File

@ -52,6 +52,6 @@ pub struct InGameLoading;
pub struct StatePlugin;
impl Plugin for StatePlugin {
fn build(&self, app: &mut App) {
app.add_state::<AppState>().add_state::<GameState>();
app.init_state::<AppState>().init_state::<GameState>();
}
}