diff --git a/src/skeleton.rs b/src/skeleton.rs index 179093f..fe14531 100644 --- a/src/skeleton.rs +++ b/src/skeleton.rs @@ -11,6 +11,13 @@ use bevy::ecs::system::EntityCommands; use bevy::prelude::*; +pub struct SkeletonPlugin; +impl Plugin for SkeletonPlugin { + fn build(&self, app: &mut App) { + app.add_systems(Update, animate_skeleton_parts); + } +} + pub fn asset_name_to_path(name: &str) -> &'static str { match name { "suit" => "models/suit_with_collider.glb#Scene0", @@ -105,14 +112,8 @@ pub fn skeleton_name_to_skeletondef(name: &str) -> Option { } } -pub struct SkeletonPlugin; -impl Plugin for SkeletonPlugin { - fn build(&self, app: &mut App) { - app.add_systems(Update, animate_skeleton_parts); - } -} - #[derive(Component)] pub struct SkeletonLimb; +#[derive(Component)] pub struct MirroredLimb; pub enum SkeletonDef { Human(HumanDef) } @@ -178,6 +179,9 @@ pub fn load( ..default() } )); + if limb.mirror { + parent_limb.insert(MirroredLimb); + } if !limb.children.is_empty() { parent_limb.with_children(|parent| { for child_limb in limb.children { @@ -186,7 +190,7 @@ pub fn load( } else { Quat::IDENTITY }; - parent.spawn(( + let mut entity_commands = parent.spawn(( child_limb.class, SceneBundle { scene: load_scene_by_path(child_limb.path.as_str(), asset_server), @@ -194,6 +198,9 @@ pub fn load( ..default() } )); + if child_limb.mirror { + entity_commands.insert(MirroredLimb); + } } }); } @@ -233,5 +240,62 @@ pub fn _build_body( } pub fn animate_skeleton_parts( + time: Res