From 3c52a10a6d885a1f4a20a4531a8000f915878f0e Mon Sep 17 00:00:00 2001 From: hut Date: Fri, 10 May 2024 10:25:03 +0200 Subject: [PATCH] rename skeleton.rs to load.rs --- src/commands.rs | 8 ++++---- src/effects.rs | 11 +++++++++++ src/hud.rs | 4 ++-- src/{skeleton.rs => load.rs} | 19 +------------------ src/main.rs | 3 +-- src/world.rs | 4 ++-- 6 files changed, 21 insertions(+), 28 deletions(-) rename src/{skeleton.rs => load.rs} (86%) diff --git a/src/commands.rs b/src/commands.rs index 44dc715..ffee5e0 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -15,7 +15,7 @@ use bevy::prelude::*; use bevy_xpbd_3d::prelude::*; use bevy::math::DVec3; use bevy::pbr::{NotShadowCaster, NotShadowReceiver}; -use crate::{actor, camera, chat, hud, nature, shading, skeleton, var, world}; +use crate::{actor, camera, chat, hud, load, nature, shading, var, world}; use regex::Regex; use std::f32::consts::PI; use std::f64::consts::PI as PI64; @@ -611,7 +611,7 @@ fn spawn_entities( transform: Transform::from_scale(scale), ..default() }); - skeleton::load(model.as_str(), &mut actor, &*asset_server); + load::load(model.as_str(), &mut actor, &*asset_server); } // Physics Parameters @@ -788,7 +788,7 @@ fn spawn_entities( NotShadowCaster, NotShadowReceiver, )); - skeleton::load(ar_asset_name, &mut entitycmd, &*asset_server); + load::load(ar_asset_name, &mut entitycmd, &*asset_server); } if state.is_point_of_interest || state.is_moon || state.is_planet { @@ -810,7 +810,7 @@ fn spawn_entities( } else { "marker_satellites" }; - skeleton::load(model, &mut entitycmd, &*asset_server); + load::load(model, &mut entitycmd, &*asset_server); } if state.has_ring { diff --git a/src/effects.rs b/src/effects.rs index 26f99bb..08e96e7 100644 --- a/src/effects.rs +++ b/src/effects.rs @@ -22,6 +22,7 @@ impl Plugin for EffectsPlugin { app.add_systems(Update, spawn_effects); app.add_systems(Update, update_fadein); app.add_systems(Update, update_fadeout); + app.add_systems(Update, play_animations); // Blackout disabled for now //app.add_systems(Update, update_blackout); app.add_event::(); @@ -165,6 +166,16 @@ pub fn update_fadeout( } } +fn play_animations( + mut players: Query<&mut AnimationPlayer, Added>, + asset_server: Res, +) { + for mut player in &mut players { + let animation = asset_server.load("models/suit_v2/suit_v2.glb#Animation0"); + player.play(animation.clone()).repeat(); + } +} + // Blackout disabled for now //pub fn update_blackout( // mut q_effect: Query<&mut BackgroundColor, With>, diff --git a/src/hud.rs b/src/hud.rs index 09e96f3..3485a4a 100644 --- a/src/hud.rs +++ b/src/hud.rs @@ -10,7 +10,7 @@ // // This module manages the heads-up display and augmented reality overlays. -use crate::{actor, audio, camera, chat, nature, skeleton, var}; +use crate::{actor, audio, camera, chat, nature, load, var}; use bevy::pbr::{NotShadowCaster, NotShadowReceiver}; use bevy::prelude::*; use bevy::diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin}; @@ -612,7 +612,7 @@ fn setup( ..default() }, )); - skeleton::load("selectagon", &mut entitycmd, &*asset_server); + load::load("selectagon", &mut entitycmd, &*asset_server); ew_updateoverlays.send(UpdateOverlayVisibility); } diff --git a/src/skeleton.rs b/src/load.rs similarity index 86% rename from src/skeleton.rs rename to src/load.rs index a7347b3..1afd168 100644 --- a/src/skeleton.rs +++ b/src/load.rs @@ -8,18 +8,11 @@ // + + + ███ // + ▀████████████████████████████████████████████████████▀ // -// This module manages model loading and animation. +// This module manages asset loading. 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, play_animations); - } -} - pub fn asset_name_to_path(name: &str) -> &'static str { match name { "suitv2" => "models/suit_v2/suit_v2.glb#Scene0", @@ -71,13 +64,3 @@ pub fn load_scene_by_path( asset_server.load(&path_string) } } - -fn play_animations( - mut players: Query<&mut AnimationPlayer, Added>, - asset_server: Res, -) { - for mut player in &mut players { - let animation = asset_server.load("models/suit_v2/suit_v2.glb#Animation0"); - player.play(animation.clone()).repeat(); - } -} diff --git a/src/main.rs b/src/main.rs index 59092fc..eae243e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,7 @@ mod commands; mod effects; mod hud; mod shading; -mod skeleton; +mod load; mod var; mod world; @@ -132,7 +132,6 @@ impl Plugin for OutFlyPlugin { effects::EffectsPlugin, hud::HudPlugin, shading::ShadingPlugin, - skeleton::SkeletonPlugin, world::WorldPlugin, )); } diff --git a/src/world.rs b/src/world.rs index 9cacffc..f9db8d8 100644 --- a/src/world.rs +++ b/src/world.rs @@ -10,7 +10,7 @@ // // This module populates the world with stars and asteroids. -use crate::{actor, hud, nature, shading, skeleton}; +use crate::{actor, hud, load, nature, shading}; use bevy::prelude::*; use bevy::math::{DVec3, I64Vec3}; use bevy::scene::{InstanceId, SceneInstance}; @@ -322,7 +322,7 @@ fn spawn_despawn_asteroids( }, ..default() }); - skeleton::load(model, &mut entity_commands, &*asset_server); + load::load(model, &mut entity_commands, &*asset_server); db.0.insert(origin, AsteroidData { entity: entity_commands.id(), //viewdistance: 99999999.0,