chore(examples): cleanup
This commit is contained in:
parent
382759d71f
commit
a951d82330
|
@ -1,7 +1,11 @@
|
||||||
use std::time::Duration;
|
use std::time::Duration;
|
||||||
|
|
||||||
use bevy::prelude::*;
|
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;
|
use rand::Rng;
|
||||||
|
|
||||||
mod component_examples;
|
mod component_examples;
|
||||||
|
@ -22,31 +26,24 @@ pub struct Fox;
|
||||||
/// Demo marker component
|
/// Demo marker component
|
||||||
pub struct Robot;
|
pub struct Robot;
|
||||||
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
App::new()
|
App::new()
|
||||||
.add_plugins((
|
.add_plugins((
|
||||||
DefaultPlugins.set(AssetPlugin::default()),
|
DefaultPlugins.set(AssetPlugin::default()),
|
||||||
// our custom plugins
|
// our custom plugins
|
||||||
ComponentsExamplesPlugin, // Showcases different type of components /structs
|
ComponentsExamplesPlugin, // Showcases different type of components /structs
|
||||||
BlenvyPlugin::default()
|
BlenvyPlugin::default(),
|
||||||
))
|
))
|
||||||
.register_type::<Player>()
|
.register_type::<Player>()
|
||||||
.register_type::<Fox>()
|
.register_type::<Fox>()
|
||||||
.register_type::<Robot>()
|
.register_type::<Robot>()
|
||||||
|
|
||||||
.add_systems(Startup, setup_game)
|
.add_systems(Startup, setup_game)
|
||||||
.add_systems(Update,
|
.add_systems(Update, (animation_control,))
|
||||||
(animation_control,)
|
|
||||||
)
|
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is how you setup & spawn a level from a blueprint
|
// this is how you setup & spawn a level from a blueprint
|
||||||
fn setup_game(
|
fn setup_game(mut commands: Commands) {
|
||||||
mut commands: Commands,
|
|
||||||
) {
|
|
||||||
|
|
||||||
// here we actually spawn our game world/level
|
// here we actually spawn our game world/level
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
BlueprintInfo::from_path("levels/World.glb"), // all we need is a Blueprint info...
|
BlueprintInfo::from_path("levels/World.glb"), // all we need is a Blueprint info...
|
||||||
|
@ -56,7 +53,6 @@ fn setup_game(
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
|
|
||||||
pub fn animation_control(
|
pub fn animation_control(
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
use bevy::prelude::*;
|
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;
|
use rand::Rng;
|
||||||
|
|
||||||
mod component_examples;
|
mod component_examples;
|
||||||
|
@ -11,20 +14,15 @@ fn main() {
|
||||||
DefaultPlugins.set(AssetPlugin::default()),
|
DefaultPlugins.set(AssetPlugin::default()),
|
||||||
// our custom plugins
|
// our custom plugins
|
||||||
ComponentsExamplesPlugin, // Showcases different type of components /structs
|
ComponentsExamplesPlugin, // Showcases different type of components /structs
|
||||||
BlenvyPlugin::default()
|
BlenvyPlugin::default(),
|
||||||
))
|
))
|
||||||
|
|
||||||
.add_systems(Startup, setup_game)
|
.add_systems(Startup, setup_game)
|
||||||
.add_systems(Update, spawn_blueprint_instance)
|
.add_systems(Update, spawn_blueprint_instance)
|
||||||
|
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
// this is how you setup & spawn a level from a blueprint
|
// this is how you setup & spawn a level from a blueprint
|
||||||
fn setup_game(
|
fn setup_game(mut commands: Commands) {
|
||||||
mut commands: Commands,
|
|
||||||
) {
|
|
||||||
|
|
||||||
// here we spawn our game world/level, which is also a blueprint !
|
// here we spawn our game world/level, which is also a blueprint !
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
BlueprintInfo::from_path("levels/World.glb"), // all we need is a Blueprint info...
|
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
|
// you can also spawn blueprint instances at runtime
|
||||||
pub fn spawn_blueprint_instance(
|
pub fn spawn_blueprint_instance(
|
||||||
keycode: Res<ButtonInput<KeyCode>>,
|
keycode: Res<ButtonInput<KeyCode>>,
|
||||||
|
@ -67,10 +64,8 @@ pub fn spawn_blueprint_instance(
|
||||||
HideUntilReady,
|
HideUntilReady,
|
||||||
AddToGameWorld,
|
AddToGameWorld,
|
||||||
TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)),
|
TransformBundle::from_transform(Transform::from_xyz(x, 2.0, y)),
|
||||||
|
|
||||||
))
|
))
|
||||||
.id();
|
.id();
|
||||||
// commands.entity(world).add_child(new_entity);
|
// commands.entity(world).add_child(new_entity);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -10,18 +10,13 @@ fn main() {
|
||||||
DefaultPlugins.set(AssetPlugin::default()),
|
DefaultPlugins.set(AssetPlugin::default()),
|
||||||
// our custom plugins
|
// our custom plugins
|
||||||
ComponentsExamplesPlugin, // Showcases different type of components /structs
|
ComponentsExamplesPlugin, // Showcases different type of components /structs
|
||||||
BlenvyPlugin::default()
|
BlenvyPlugin::default(),
|
||||||
))
|
))
|
||||||
|
|
||||||
.add_systems(Startup, setup_game)
|
.add_systems(Startup, setup_game)
|
||||||
.run();
|
.run();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn setup_game(mut commands: Commands) {
|
||||||
fn setup_game(
|
|
||||||
mut commands: Commands,
|
|
||||||
) {
|
|
||||||
|
|
||||||
// here we actually spawn our game world/level
|
// here we actually spawn our game world/level
|
||||||
commands.spawn((
|
commands.spawn((
|
||||||
BlueprintInfo::from_path("levels/World.glb"), // all we need is a Blueprint info...
|
BlueprintInfo::from_path("levels/World.glb"), // all we need is a Blueprint info...
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use bevy::prelude::*;
|
use bevy::prelude::*;
|
||||||
use blenvy::{BluePrintBundle, BlueprintName, GameWorldTag};
|
|
||||||
use bevy_gltf_worlflow_examples_common_rapier::{assets::GameAssets, GameState, InAppRunning};
|
use bevy_gltf_worlflow_examples_common_rapier::{assets::GameAssets, GameState, InAppRunning};
|
||||||
|
use blenvy::{BluePrintBundle, BlueprintName, GameWorldTag};
|
||||||
|
|
||||||
use bevy_rapier3d::prelude::Velocity;
|
use bevy_rapier3d::prelude::Velocity;
|
||||||
use rand::Rng;
|
use rand::Rng;
|
||||||
|
|
|
@ -1,9 +1,9 @@
|
||||||
use bevy::{gltf::Gltf, prelude::*};
|
use bevy::{gltf::Gltf, prelude::*};
|
||||||
use blenvy::GameWorldTag;
|
|
||||||
use bevy_gltf_worlflow_examples_common_rapier::{
|
use bevy_gltf_worlflow_examples_common_rapier::{
|
||||||
assets::GameAssets, GameState, InAppRunning, Player,
|
assets::GameAssets, GameState, InAppRunning, Player,
|
||||||
};
|
};
|
||||||
use bevy_rapier3d::prelude::*;
|
use bevy_rapier3d::prelude::*;
|
||||||
|
use blenvy::GameWorldTag;
|
||||||
|
|
||||||
#[derive(Component, Reflect, Default, Debug)]
|
#[derive(Component, Reflect, Default, Debug)]
|
||||||
#[reflect(Component)]
|
#[reflect(Component)]
|
||||||
|
|
Loading…
Reference in New Issue