rename skeleton.rs to load.rs

This commit is contained in:
yuni 2024-05-10 10:25:03 +02:00
parent 10acb83b83
commit 3c52a10a6d
6 changed files with 21 additions and 28 deletions

View file

@ -15,7 +15,7 @@ use bevy::prelude::*;
use bevy_xpbd_3d::prelude::*; use bevy_xpbd_3d::prelude::*;
use bevy::math::DVec3; use bevy::math::DVec3;
use bevy::pbr::{NotShadowCaster, NotShadowReceiver}; 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 regex::Regex;
use std::f32::consts::PI; use std::f32::consts::PI;
use std::f64::consts::PI as PI64; use std::f64::consts::PI as PI64;
@ -611,7 +611,7 @@ fn spawn_entities(
transform: Transform::from_scale(scale), transform: Transform::from_scale(scale),
..default() ..default()
}); });
skeleton::load(model.as_str(), &mut actor, &*asset_server); load::load(model.as_str(), &mut actor, &*asset_server);
} }
// Physics Parameters // Physics Parameters
@ -788,7 +788,7 @@ fn spawn_entities(
NotShadowCaster, NotShadowCaster,
NotShadowReceiver, 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 { if state.is_point_of_interest || state.is_moon || state.is_planet {
@ -810,7 +810,7 @@ fn spawn_entities(
} else { } else {
"marker_satellites" "marker_satellites"
}; };
skeleton::load(model, &mut entitycmd, &*asset_server); load::load(model, &mut entitycmd, &*asset_server);
} }
if state.has_ring { if state.has_ring {

View file

@ -22,6 +22,7 @@ impl Plugin for EffectsPlugin {
app.add_systems(Update, spawn_effects); app.add_systems(Update, spawn_effects);
app.add_systems(Update, update_fadein); app.add_systems(Update, update_fadein);
app.add_systems(Update, update_fadeout); app.add_systems(Update, update_fadeout);
app.add_systems(Update, play_animations);
// Blackout disabled for now // Blackout disabled for now
//app.add_systems(Update, update_blackout); //app.add_systems(Update, update_blackout);
app.add_event::<SpawnEffectEvent>(); app.add_event::<SpawnEffectEvent>();
@ -165,6 +166,16 @@ pub fn update_fadeout(
} }
} }
fn play_animations(
mut players: Query<&mut AnimationPlayer, Added<AnimationPlayer>>,
asset_server: Res<AssetServer>,
) {
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 // Blackout disabled for now
//pub fn update_blackout( //pub fn update_blackout(
// mut q_effect: Query<&mut BackgroundColor, With<BlackOutOverlay>>, // mut q_effect: Query<&mut BackgroundColor, With<BlackOutOverlay>>,

View file

@ -10,7 +10,7 @@
// //
// This module manages the heads-up display and augmented reality overlays. // 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::pbr::{NotShadowCaster, NotShadowReceiver};
use bevy::prelude::*; use bevy::prelude::*;
use bevy::diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin}; use bevy::diagnostic::{DiagnosticsStore, FrameTimeDiagnosticsPlugin};
@ -612,7 +612,7 @@ fn setup(
..default() ..default()
}, },
)); ));
skeleton::load("selectagon", &mut entitycmd, &*asset_server); load::load("selectagon", &mut entitycmd, &*asset_server);
ew_updateoverlays.send(UpdateOverlayVisibility); ew_updateoverlays.send(UpdateOverlayVisibility);
} }

View file

@ -8,18 +8,11 @@
// + + + ███ // + + + ███
// + ▀████████████████████████████████████████████████████▀ // + ▀████████████████████████████████████████████████████▀
// //
// This module manages model loading and animation. // This module manages asset loading.
use bevy::ecs::system::EntityCommands; use bevy::ecs::system::EntityCommands;
use bevy::prelude::*; 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 { pub fn asset_name_to_path(name: &str) -> &'static str {
match name { match name {
"suitv2" => "models/suit_v2/suit_v2.glb#Scene0", "suitv2" => "models/suit_v2/suit_v2.glb#Scene0",
@ -71,13 +64,3 @@ pub fn load_scene_by_path(
asset_server.load(&path_string) asset_server.load(&path_string)
} }
} }
fn play_animations(
mut players: Query<&mut AnimationPlayer, Added<AnimationPlayer>>,
asset_server: Res<AssetServer>,
) {
for mut player in &mut players {
let animation = asset_server.load("models/suit_v2/suit_v2.glb#Animation0");
player.play(animation.clone()).repeat();
}
}

View file

@ -19,7 +19,7 @@ mod commands;
mod effects; mod effects;
mod hud; mod hud;
mod shading; mod shading;
mod skeleton; mod load;
mod var; mod var;
mod world; mod world;
@ -132,7 +132,6 @@ impl Plugin for OutFlyPlugin {
effects::EffectsPlugin, effects::EffectsPlugin,
hud::HudPlugin, hud::HudPlugin,
shading::ShadingPlugin, shading::ShadingPlugin,
skeleton::SkeletonPlugin,
world::WorldPlugin, world::WorldPlugin,
)); ));
} }

View file

@ -10,7 +10,7 @@
// //
// This module populates the world with stars and asteroids. // 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::prelude::*;
use bevy::math::{DVec3, I64Vec3}; use bevy::math::{DVec3, I64Vec3};
use bevy::scene::{InstanceId, SceneInstance}; use bevy::scene::{InstanceId, SceneInstance};
@ -322,7 +322,7 @@ fn spawn_despawn_asteroids(
}, },
..default() ..default()
}); });
skeleton::load(model, &mut entity_commands, &*asset_server); load::load(model, &mut entity_commands, &*asset_server);
db.0.insert(origin, AsteroidData { db.0.insert(origin, AsteroidData {
entity: entity_commands.id(), entity: entity_commands.id(),
//viewdistance: 99999999.0, //viewdistance: 99999999.0,