Faction check is now optional

This commit is contained in:
Rendo 2025-11-15 23:06:41 +05:00
commit fba4745162

View file

@ -75,15 +75,17 @@ pub fn observe_collision(
collision: On<Collided>,
mut commands: Commands,
projectile_query: Query<&Projectile>,
mut collision_query: Query<(&mut Damagable, &Factions)>,
mut damagable_query: Query<(&mut Damagable, Option<&Factions>)>,
) {
let Ok(projectile) = projectile_query.get(collision.entity) else {
return;
};
let Ok((mut collided, faction)) = collision_query.get_mut(collision.with) else {
let Ok((mut collided, faction)) = damagable_query.get_mut(collision.with) else {
return;
};
if projectile.faction.can_damage(faction) == false {
if let Some(f) = faction
&& projectile.faction.can_damage(f) == false
{
return;
}