mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-12-22 15:44:11 +00:00
chore(examples): cleanup
This commit is contained in:
parent
382759d71f
commit
a951d82330
@ -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::<Player>()
|
||||
.register_type::<Fox>()
|
||||
.register_type::<Robot>()
|
||||
|
||||
.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
|
||||
|
@ -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<ButtonInput<KeyCode>>,
|
||||
@ -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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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...
|
||||
|
@ -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;
|
||||
|
@ -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)]
|
||||
|
Loading…
Reference in New Issue
Block a user