2024-04-22 17:42:51 +00:00
|
|
|
// ▄████████▄ + ███ + ▄█████████ ███ +
|
|
|
|
// ███▀ ▀███ + + ███ ███▀ + ███ + +
|
|
|
|
// ███ + ███ ███ ███ █████████ ███ ███ ███ ███
|
|
|
|
// ███ +███ ███ ███ ███ ███▐██████ ███ ███ ███
|
|
|
|
// ███ + ███ ███+ ███ +███ ███ + ███ ███ + ███
|
|
|
|
// ███▄ ▄███ ███▄ ███ ███ + ███ + ███ ███▄ ███
|
|
|
|
// ▀████████▀ + ▀███████ ███▄ ███▄ ▀████ ▀███████
|
|
|
|
// + + + ███
|
|
|
|
// + ▀████████████████████████████████████████████████████▀
|
|
|
|
|
2024-04-22 19:01:27 +00:00
|
|
|
use bevy::ecs::system::EntityCommands;
|
2024-04-22 17:42:51 +00:00
|
|
|
use bevy::prelude::*;
|
2024-04-22 19:01:27 +00:00
|
|
|
|
|
|
|
pub fn asset_name_to_path(name: &str) -> &'static str {
|
|
|
|
match name {
|
|
|
|
"suit" => "models/suit_with_collider.glb#Scene0",
|
|
|
|
"suit_ar_chefhat" => "models/suit_ar_chefhat.glb#Scene0",
|
|
|
|
"asteroid1" => "models/asteroid.glb#Scene0",
|
|
|
|
"asteroid2" => "models/asteroid2.glb#Scene0",
|
|
|
|
"asteroid_lum" => "models/asteroid_lum.glb#Scene0",
|
|
|
|
"moonlet" => "models/moonlet.glb#Scene0",
|
|
|
|
"monolith" => "models/monolith_neon.glb#Scene0",
|
|
|
|
"lightorb" => "models/lightorb.glb#Scene0",
|
|
|
|
"orb_busstop" => "models/orb_busstop.glb#Scene0",
|
|
|
|
"orb_busstop_dim" => "models/orb_busstop_dim.glb#Scene0",
|
|
|
|
"MeteorAceGT" => "models/MeteorAceGT.glb#Scene0",
|
|
|
|
"satellite" => "models/satellite.glb#Scene0",
|
|
|
|
"pizzeria" => "models/pizzeria2.glb#Scene0",
|
|
|
|
"pizzasign" => "models/pizzasign.glb#Scene0",
|
|
|
|
"selectagon" => "models/selectagon.glb#Scene0",
|
|
|
|
"orbitring" => "models/orbitring.glb#Scene0",
|
|
|
|
"clippy" => "models/clippy.glb#Scene0",
|
|
|
|
"clippy_ar" => "models/clippy_ar.glb#Scene0",
|
|
|
|
"whale" => "models/whale.glb#Scene0",
|
|
|
|
"point_of_interest" => "models/point_of_interest.glb#Scene0",
|
|
|
|
_ => "models/error.glb#Scene0",
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-22 19:09:05 +00:00
|
|
|
pub fn skeleton_name_to_skeletondef(name: &str) -> Option<SkeletonDef> {
|
|
|
|
match name {
|
|
|
|
"suitv1" => Some(SkeletonDef {
|
|
|
|
base: "skeleton/suit_v1/base.glb#Scene0".to_string(),
|
|
|
|
}),
|
|
|
|
_ => None,
|
|
|
|
}
|
2024-04-22 19:01:27 +00:00
|
|
|
}
|
2024-04-22 17:42:51 +00:00
|
|
|
|
|
|
|
pub struct SkeletonPlugin;
|
|
|
|
impl Plugin for SkeletonPlugin {
|
|
|
|
fn build(&self, app: &mut App) {
|
2024-04-22 19:01:27 +00:00
|
|
|
app.add_systems(Update, animate_skeleton_parts);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Component)] pub struct SkeletonLimb;
|
2024-04-22 19:09:05 +00:00
|
|
|
pub struct SkeletonDef {
|
|
|
|
pub base: String,
|
|
|
|
}
|
2024-04-22 19:01:27 +00:00
|
|
|
|
|
|
|
//pub fn spawn(
|
|
|
|
// name: &str,
|
|
|
|
// commands: Commands,
|
|
|
|
// asset_server: &AssetServer,
|
|
|
|
//) -> EntityCommands {
|
|
|
|
// let mut entity_commands = commands.spawn_empty();
|
|
|
|
// load(name, &mut entity_commands, asset_server);
|
|
|
|
// return entity_commands;
|
|
|
|
//}
|
|
|
|
|
|
|
|
pub fn load(
|
|
|
|
name: &str,
|
|
|
|
entity_commands: &mut EntityCommands,
|
|
|
|
asset_server: &AssetServer,
|
|
|
|
) {
|
2024-04-22 19:09:05 +00:00
|
|
|
if let Some(skel) = skeleton_name_to_skeletondef(name) {
|
|
|
|
entity_commands.insert(load_scene_by_path(skel.base.as_str(), asset_server));
|
|
|
|
} else {
|
2024-04-22 19:01:27 +00:00
|
|
|
entity_commands.insert(load_scene_by_path(asset_name_to_path(name), asset_server));
|
2024-04-22 17:42:51 +00:00
|
|
|
}
|
2024-04-22 19:01:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//pub fn load_scene(
|
|
|
|
// path: &str,
|
|
|
|
// asset_server: &AssetServer
|
|
|
|
//) -> Handle<Scene> {
|
|
|
|
// load_scene_by_path(asset_name_to_path(path), asset_server)
|
|
|
|
//}
|
|
|
|
|
|
|
|
#[inline]
|
|
|
|
pub fn load_scene_by_path(
|
|
|
|
path: &str,
|
|
|
|
asset_server: &AssetServer
|
|
|
|
) -> Handle<Scene> {
|
|
|
|
let path_string = path.to_string();
|
|
|
|
if let Some(handle) = asset_server.get_handle(&path_string) {
|
|
|
|
handle
|
|
|
|
} else {
|
|
|
|
asset_server.load(&path_string)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn _build_body(
|
|
|
|
_name: String,
|
|
|
|
mut _entity_commands: EntityCommands,
|
|
|
|
) {
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn animate_skeleton_parts(
|
|
|
|
) {
|
2024-04-22 17:42:51 +00:00
|
|
|
}
|