From 228380b9f4a6c35248bb3de2ced92a1dd051d735 Mon Sep 17 00:00:00 2001 From: hut Date: Mon, 22 Apr 2024 23:19:42 +0200 Subject: [PATCH] refactoring --- src/skeleton.rs | 124 ++++++++++++++++++++++++++++-------------------- 1 file changed, 72 insertions(+), 52 deletions(-) diff --git a/src/skeleton.rs b/src/skeleton.rs index c8376d2..2d59e0a 100644 --- a/src/skeleton.rs +++ b/src/skeleton.rs @@ -148,6 +148,11 @@ pub enum Limb { LowerLegLeft, } +#[derive(Component)] +pub enum Animation { + HumanFloat, +} + pub fn load( name: &str, entity_commands: &mut EntityCommands, @@ -160,6 +165,7 @@ pub fn load( entity_commands.with_children(|parent| { parent.spawn(( Limb::Base, + Animation::HumanFloat, SceneBundle { scene: load_scene_by_path(human.base.as_str(), asset_server), ..default() @@ -173,6 +179,7 @@ pub fn load( }; let mut parent_limb = parent.spawn(( limb.class, + Animation::HumanFloat, SceneBundle { scene: load_scene_by_path(limb.path.as_str(), asset_server), transform: Transform::from_translation(limb.pos).with_rotation(rot), @@ -192,6 +199,7 @@ pub fn load( }; let mut entity_commands = parent.spawn(( child_limb.class, + Animation::HumanFloat, SceneBundle { scene: load_scene_by_path(child_limb.path.as_str(), asset_server), transform: Transform::from_translation(child_limb.pos).with_rotation(rot), @@ -241,61 +249,73 @@ pub fn _build_body( pub fn animate_skeleton_parts( time: Res