different head different range
This commit is contained in:
@@ -3,8 +3,9 @@ mod target_ui;
|
||||
|
||||
use crate::{
|
||||
GameState,
|
||||
head::ActiveHead,
|
||||
physics_layers::GameLayer,
|
||||
player::{Player, PlayerRig},
|
||||
player::{Player, PlayerBodyMesh},
|
||||
tb_entities::EnemySpawn,
|
||||
};
|
||||
use avian3d::prelude::*;
|
||||
@@ -41,28 +42,33 @@ pub fn plugin(app: &mut App) {
|
||||
|
||||
app.add_systems(
|
||||
Update,
|
||||
(update_player_aim, update_npc_aim).run_if(in_state(GameState::Playing)),
|
||||
(update_player_aim, update_npc_aim, head_change).run_if(in_state(GameState::Playing)),
|
||||
);
|
||||
app.add_systems(Update, add_aim.run_if(in_state(GameState::Playing)));
|
||||
app.add_systems(Update, add_aim);
|
||||
}
|
||||
|
||||
fn add_aim(
|
||||
mut commands: Commands,
|
||||
query: Query<Entity, Added<Player>>,
|
||||
query2: Query<Entity, Added<EnemySpawn>>,
|
||||
) {
|
||||
fn add_aim(mut commands: Commands, query: Query<Entity, Added<ActiveHead>>) {
|
||||
for e in query.iter() {
|
||||
commands.entity(e).insert(AimState::default());
|
||||
}
|
||||
for e in query2.iter() {
|
||||
commands.entity(e).insert(AimState::default());
|
||||
}
|
||||
|
||||
fn head_change(mut query: Query<(&ActiveHead, &mut AimState), Changed<ActiveHead>>) {
|
||||
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.,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn update_player_aim(
|
||||
mut commands: Commands,
|
||||
potential_targets: Query<(Entity, &Transform), With<EnemySpawn>>,
|
||||
player_rot: Query<(&Transform, &GlobalTransform), With<PlayerRig>>,
|
||||
player_rot: Query<(&Transform, &GlobalTransform), With<PlayerBodyMesh>>,
|
||||
mut player_aim: Query<(&AimState, &mut AimTarget), With<Player>>,
|
||||
spatial_query: SpatialQuery,
|
||||
) {
|
||||
|
||||
Reference in New Issue
Block a user