mirror of
https://github.com/kaosat-dev/Blender_bevy_components_workflow.git
synced 2024-12-04 08:36:59 +00:00
528e13a250
* feat(bevy_gltf_components): * create crate * added SystemSet (GltfComponentsSet) to run process_loaded_scenes (where components are injected) in a specific systemset & allow ordering other systems relative to it * feat(bevy_gltf_blueprints): * created crate * made the blueprint library path configurable * added BluePrintBundle helper * added SystemSet (GltfBlueprintsSet) for better system ordering * integrated into advanced demo * feat(tools-blender-auto-export): * renamed blender tool to gltf_auto_export * rewritten auto_export * added blueprint / prefab support * creates scene with empties with BlueprintName components in the scene * export of the main scene now exports this scene instead of real main scene * changes collection stand in names in original scene & sets them back after export to have correctly named collection instance exports * also added an additional 'SpawnHere' component to not conflate BlueprintNames & spawning requests * toggling & blueprint library output parameters added * added correct handling/ restoring of saved selection when using blueprints * feat(examples): * added advanced example * general example renamed to "basic", and cleaned up * feat(various): a lot of experiments with saving & loading etc * chore(assets): updated blend & generated assets * fix(examples-advanced): disabling hot reloading as it messes up scenes in experiments with save & loading * docs(): * added & fleshing out docs for the various crates & main README * added process doc image & tweaks to README * added missing licence info where relevant * fixed broken links * clarified some aspects * added updated screenshots where relevant * added tweaks & improvements etc
41 lines
987 B
Rust
41 lines
987 B
Rust
|
|
use bevy::prelude::*;
|
|
use super::Player;
|
|
|
|
#[derive(Component, Reflect, Default, Debug, )]
|
|
#[reflect(Component)]
|
|
pub struct Pickable;
|
|
|
|
// very simple, crude picking (as in picking up objects) implementation
|
|
|
|
pub fn picking(
|
|
players: Query<&GlobalTransform, With<Player>>,
|
|
pickables: Query<(Entity, &GlobalTransform), With<Pickable>>,
|
|
mut commands: Commands
|
|
){
|
|
for player_transforms in players.iter(){
|
|
for (pickable, pickable_transforms) in pickables.iter(){
|
|
let distance = player_transforms.translation().distance(pickable_transforms.translation());
|
|
if distance < 2.5 {
|
|
commands.entity(pickable).despawn_recursive();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
pub struct PickingPlugin;
|
|
impl Plugin for PickingPlugin {
|
|
fn build(&self, app: &mut App) {
|
|
app
|
|
.register_type::<Pickable>()
|
|
|
|
.add_systems(Update, (
|
|
picking, //.run_if(in_state(AppState::Running)),
|
|
))
|
|
|
|
|
|
|
|
;
|
|
}
|
|
}
|