load plane mode
reset orientation if no plane head
This commit is contained in:
@@ -4,6 +4,7 @@ use crate::{
|
||||
GameState,
|
||||
head::ActiveHead,
|
||||
heads_database::{HeadControls, HeadsDatabase},
|
||||
player::PlayerBodyMesh,
|
||||
};
|
||||
|
||||
mod collisions;
|
||||
@@ -74,6 +75,7 @@ fn head_change(
|
||||
query: Query<&ActiveHead, Changed<ActiveHead>>,
|
||||
heads_db: Res<HeadsDatabase>,
|
||||
mut selected_controller: ResMut<SelectedController>,
|
||||
mut rig_transform_q: Option<Single<&mut Transform, With<PlayerBodyMesh>>>,
|
||||
) {
|
||||
for head in query.iter() {
|
||||
let stats = heads_db.head_stats(head.0);
|
||||
@@ -83,6 +85,12 @@ fn head_change(
|
||||
};
|
||||
|
||||
if selected_controller.0 != controller {
|
||||
if controller == ControllerSet::ApplyControlsRun {
|
||||
if let Some(mut transform) = rig_transform_q.take() {
|
||||
transform.rotation = Quat::IDENTITY;
|
||||
}
|
||||
}
|
||||
|
||||
selected_controller.0 = controller;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ use crate::abilities::HeadAbility;
|
||||
use bevy::prelude::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Default, Reflect, Serialize, Deserialize)]
|
||||
#[derive(Debug, Default, Reflect, Serialize, Deserialize, PartialEq, Eq)]
|
||||
pub enum HeadControls {
|
||||
#[default]
|
||||
Walk,
|
||||
|
||||
@@ -7,7 +7,7 @@ use crate::{
|
||||
global_observer,
|
||||
head::ActiveHead,
|
||||
heads::HeadChanged,
|
||||
heads_database::HeadsDatabase,
|
||||
heads_database::{HeadControls, HeadsDatabase},
|
||||
hitpoints::Hitpoints,
|
||||
loading_assets::GameAssets,
|
||||
physics_layers::GameLayer,
|
||||
@@ -221,5 +221,15 @@ fn on_update_head(
|
||||
let mesh = asset_server
|
||||
.load(GltfAssetLabel::Scene(0).from_asset(format!("models/heads/{}.glb", head_str)));
|
||||
|
||||
commands.entity(head).despawn_descendants();
|
||||
commands.entity(head).insert(SceneRoot(mesh));
|
||||
|
||||
//TODO: make part of full character mesh later
|
||||
if head_db.head_stats(trigger.0).controls == HeadControls::Plane {
|
||||
let mesh = asset_server.load(GltfAssetLabel::Scene(0).from_asset("models/mig.glb"));
|
||||
|
||||
commands
|
||||
.entity(head)
|
||||
.with_child((Transform::from_xyz(0., -1., 0.), SceneRoot(mesh)));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user