From a951d82330cf641a6ee48631e271f61de1492e21 Mon Sep 17 00:00:00 2001 From: "kaosat.dev" Date: Mon, 22 Jul 2024 00:29:17 +0200 Subject: [PATCH] chore(examples): cleanup --- examples/animation/src/main.rs | 26 +++++++++------------ examples/blueprints/src/main.rs | 19 ++++++--------- examples/components/src/main.rs | 9 ++----- examples/demo/src/game/in_game.rs | 2 +- examples/demo/src/game/level_transitions.rs | 2 +- 5 files changed, 22 insertions(+), 36 deletions(-) diff --git a/examples/animation/src/main.rs b/examples/animation/src/main.rs index bd29754..48a771d 100644 --- a/examples/animation/src/main.rs +++ b/examples/animation/src/main.rs @@ -1,7 +1,11 @@ use std::time::Duration; use bevy::prelude::*; -use blenvy::{AddToGameWorld, BlenvyPlugin, BluePrintBundle, BlueprintAnimationPlayerLink, BlueprintAnimations, BlueprintInfo, DynamicBlueprintInstance, GameWorldTag, HideUntilReady, SpawnBlueprint}; +use blenvy::{ + AddToGameWorld, BlenvyPlugin, BluePrintBundle, BlueprintAnimationPlayerLink, + BlueprintAnimations, BlueprintInfo, DynamicBlueprintInstance, GameWorldTag, HideUntilReady, + SpawnBlueprint, +}; use rand::Rng; mod component_examples; @@ -22,31 +26,24 @@ pub struct Fox; /// Demo marker component pub struct Robot; - fn main() { App::new() .add_plugins(( DefaultPlugins.set(AssetPlugin::default()), // our custom plugins ComponentsExamplesPlugin, // Showcases different type of components /structs - BlenvyPlugin::default() + BlenvyPlugin::default(), )) .register_type::() .register_type::() .register_type::() - .add_systems(Startup, setup_game) - .add_systems(Update, - (animation_control,) - ) + .add_systems(Update, (animation_control,)) .run(); } // this is how you setup & spawn a level from a blueprint -fn setup_game( - mut commands: Commands, -) { - +fn setup_game(mut commands: Commands) { // here we actually spawn our game world/level commands.spawn(( BlueprintInfo::from_path("levels/World.glb"), // all we need is a Blueprint info... @@ -56,7 +53,6 @@ fn setup_game( )); } - ////////////////////////////////// pub fn animation_control( @@ -94,7 +90,7 @@ pub fn animation_control( if keycode.just_pressed(KeyCode::KeyW) { for (link, animations) in animated_foxes.iter() { let (mut animation_player, mut animation_transitions) = - animation_players.get_mut(link.0).unwrap(); + animation_players.get_mut(link.0).unwrap(); let anim_name = "Walk"; animation_transitions @@ -114,7 +110,7 @@ pub fn animation_control( if keycode.just_pressed(KeyCode::KeyX) { for (link, animations) in animated_foxes.iter() { let (mut animation_player, mut animation_transitions) = - animation_players.get_mut(link.0).unwrap(); + animation_players.get_mut(link.0).unwrap(); let anim_name = "Run"; animation_transitions @@ -134,7 +130,7 @@ pub fn animation_control( if keycode.just_pressed(KeyCode::KeyC) { for (link, animations) in animated_foxes.iter() { let (mut animation_player, mut animation_transitions) = - animation_players.get_mut(link.0).unwrap(); + animation_players.get_mut(link.0).unwrap(); let anim_name = "Survey"; animation_transitions diff --git a/examples/blueprints/src/main.rs b/examples/blueprints/src/main.rs index 7e80e18..f75b065 100644 --- a/examples/blueprints/src/main.rs +++ b/examples/blueprints/src/main.rs @@ -1,5 +1,8 @@ use bevy::prelude::*; -use blenvy::{AddToGameWorld, BlenvyPlugin, BluePrintBundle, BlueprintInfo, DynamicBlueprintInstance, GameWorldTag, HideUntilReady, SpawnBlueprint}; +use blenvy::{ + AddToGameWorld, BlenvyPlugin, BluePrintBundle, BlueprintInfo, DynamicBlueprintInstance, + GameWorldTag, HideUntilReady, SpawnBlueprint, +}; use rand::Rng; mod component_examples; @@ -11,20 +14,15 @@ fn main() { DefaultPlugins.set(AssetPlugin::default()), // our custom plugins ComponentsExamplesPlugin, // Showcases different type of components /structs - BlenvyPlugin::default() + BlenvyPlugin::default(), )) - .add_systems(Startup, setup_game) .add_systems(Update, spawn_blueprint_instance) - .run(); } // this is how you setup & spawn a level from a blueprint -fn setup_game( - mut commands: Commands, -) { - +fn setup_game(mut commands: Commands) { // here we spawn our game world/level, which is also a blueprint ! commands.spawn(( BlueprintInfo::from_path("levels/World.glb"), // all we need is a Blueprint info... @@ -34,7 +32,6 @@ fn setup_game( )); } - // you can also spawn blueprint instances at runtime pub fn spawn_blueprint_instance( keycode: Res>, @@ -67,10 +64,8 @@ pub fn spawn_blueprint_instance( HideUntilReady, AddToGameWorld, TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)), - )) .id(); // commands.entity(world).add_child(new_entity); - } -} \ No newline at end of file +} diff --git a/examples/components/src/main.rs b/examples/components/src/main.rs index 7c2ad47..a27dc31 100644 --- a/examples/components/src/main.rs +++ b/examples/components/src/main.rs @@ -10,18 +10,13 @@ fn main() { DefaultPlugins.set(AssetPlugin::default()), // our custom plugins ComponentsExamplesPlugin, // Showcases different type of components /structs - BlenvyPlugin::default() + BlenvyPlugin::default(), )) - .add_systems(Startup, setup_game) .run(); } - -fn setup_game( - mut commands: Commands, -) { - +fn setup_game(mut commands: Commands) { // here we actually spawn our game world/level commands.spawn(( BlueprintInfo::from_path("levels/World.glb"), // all we need is a Blueprint info... diff --git a/examples/demo/src/game/in_game.rs b/examples/demo/src/game/in_game.rs index 4232260..ee284a7 100644 --- a/examples/demo/src/game/in_game.rs +++ b/examples/demo/src/game/in_game.rs @@ -1,6 +1,6 @@ use bevy::prelude::*; -use blenvy::{BluePrintBundle, BlueprintName, GameWorldTag}; use bevy_gltf_worlflow_examples_common_rapier::{assets::GameAssets, GameState, InAppRunning}; +use blenvy::{BluePrintBundle, BlueprintName, GameWorldTag}; use bevy_rapier3d::prelude::Velocity; use rand::Rng; diff --git a/examples/demo/src/game/level_transitions.rs b/examples/demo/src/game/level_transitions.rs index 42a6321..03ed955 100644 --- a/examples/demo/src/game/level_transitions.rs +++ b/examples/demo/src/game/level_transitions.rs @@ -1,9 +1,9 @@ use bevy::{gltf::Gltf, prelude::*}; -use blenvy::GameWorldTag; use bevy_gltf_worlflow_examples_common_rapier::{ assets::GameAssets, GameState, InAppRunning, Player, }; use bevy_rapier3d::prelude::*; +use blenvy::GameWorldTag; #[derive(Component, Reflect, Default, Debug)] #[reflect(Component)]