From 7d5b7ecf382327ee93e872b4088d70b9cec4eb87 Mon Sep 17 00:00:00 2001 From: Matthew Pomes Date: Mon, 12 Sep 2022 15:09:49 -0500 Subject: [PATCH] Add type to conviently lookup entities by name --- crates/bevy_animation/src/lib.rs | 45 +++------- crates/bevy_core/src/name.rs | 148 +++++++++++++++++++++++++++++++ crates/bevy_gltf/src/loader.rs | 2 +- 3 files changed, 162 insertions(+), 33 deletions(-) diff --git a/crates/bevy_animation/src/lib.rs b/crates/bevy_animation/src/lib.rs index 0ab68da7c8788..4f8d4c24aba0e 100644 --- a/crates/bevy_animation/src/lib.rs +++ b/crates/bevy_animation/src/lib.rs @@ -6,14 +6,17 @@ use std::ops::Deref; use bevy_app::{App, CoreStage, Plugin}; use bevy_asset::{AddAsset, Assets, Handle}; -use bevy_core::Name; +pub use bevy_core::EntityPath; +use bevy_core::{Name, NameLookup}; use bevy_ecs::{ change_detection::DetectChanges, entity::Entity, prelude::Component, + query::QueryEntityError, reflect::ReflectComponent, schedule::IntoSystemDescriptor, - system::{Query, Res}, + schedule::ParallelSystemDescriptorCoercion, + system::{Query, Res, SystemParam}, }; use bevy_hierarchy::Children; use bevy_math::{Quat, Vec3}; @@ -52,13 +55,6 @@ pub struct VariableCurve { pub keyframes: Keyframes, } -/// Path to an entity, with [`Name`]s. Each entity in a path must have a name. -#[derive(Reflect, FromReflect, Clone, Debug, Hash, PartialEq, Eq, Default)] -pub struct EntityPath { - /// Parts of the path - pub parts: Vec, -} - /// A list of [`VariableCurve`], and the [`EntityPath`] to which they apply. #[derive(Reflect, FromReflect, Clone, TypeUuid, Debug, Default)] #[uuid = "d81b7179-0448-4eb0-89fe-c067222725bf"] @@ -187,9 +183,8 @@ pub fn animation_player( time: Res