head database for aim and ai

This commit is contained in:
2025-04-11 18:35:59 +02:00
parent 806d10e1bd
commit 9df3c00abb
12 changed files with 163 additions and 55 deletions

View File

@@ -4,6 +4,7 @@ mod target_ui;
use crate::{
GameState,
head::ActiveHead,
head_asset::HeadsDatabase,
physics_layers::GameLayer,
player::{Player, PlayerBodyMesh},
tb_entities::EnemySpawn,
@@ -53,15 +54,15 @@ fn add_aim(mut commands: Commands, query: Query<Entity, Added<ActiveHead>>) {
}
}
fn head_change(mut query: Query<(&ActiveHead, &mut AimState), Changed<ActiveHead>>) {
fn head_change(
mut query: Query<(&ActiveHead, &mut AimState), Changed<ActiveHead>>,
heads_db: Res<HeadsDatabase>,
) {
for (head, mut state) in query.iter_mut() {
// info!("head changed: {}", head.0);
// state.max_angle = if head.0 == 0 { PI / 8. } else { PI / 2. }
state.range = match head.0 {
0 => 80.,
3 => 60.,
_ => 40.,
};
let stats = heads_db.head_stats(head.0);
state.range = stats.range;
}
}