Add Lissajous and cubic Bezier path types for enemies on special stages (every 3rd level). Path-following enemies spawn with ScriptedPath marker and FollowingPath state, move along parametric curves, and despawn when their path ends off-screen. Key changes: - New flight_paths module with pure path evaluation (Lissajous + Bezier) - ScriptedPath marker component and FollowingPath EnemyState variant - flight_patterns field on StageConfigurations for composable path data - Special stage spawn branch in spawn_enemies() with stagger delays - Path-following movement in move_enemies() with delay gating and despawn - Formation complete early return for special stages - Without<ScriptedPath> filter on attacking_query to prevent double-processing - 13 new unit tests for path evaluation and data contracts Refs: GAL-40
143 lines
3.3 KiB
Rust
143 lines
3.3 KiB
Rust
use bglga::constants::SPECIAL_STAGE_INTERVAL;
|
|
use bglga::resources::is_special_stage;
|
|
use bglga::resources::StageConfigurations;
|
|
|
|
// ── SPECIAL_STAGE_INTERVAL constant ──
|
|
|
|
#[test]
|
|
fn special_stage_interval_is_three() {
|
|
assert_eq!(SPECIAL_STAGE_INTERVAL, 3);
|
|
}
|
|
|
|
// ── is_special_stage function ──
|
|
|
|
#[test]
|
|
fn stage_zero_is_not_special() {
|
|
assert!(!is_special_stage(0));
|
|
}
|
|
|
|
#[test]
|
|
fn stage_1_is_not_special() {
|
|
assert!(!is_special_stage(1));
|
|
}
|
|
|
|
#[test]
|
|
fn stage_2_is_not_special() {
|
|
assert!(!is_special_stage(2));
|
|
}
|
|
|
|
#[test]
|
|
fn stage_3_is_special() {
|
|
assert!(is_special_stage(3));
|
|
}
|
|
|
|
#[test]
|
|
fn stage_4_is_not_special() {
|
|
assert!(!is_special_stage(4));
|
|
}
|
|
|
|
#[test]
|
|
fn stage_5_is_not_special() {
|
|
assert!(!is_special_stage(5));
|
|
}
|
|
|
|
#[test]
|
|
fn stage_6_is_special() {
|
|
assert!(is_special_stage(6));
|
|
}
|
|
|
|
#[test]
|
|
fn stage_9_is_special() {
|
|
assert!(is_special_stage(9));
|
|
}
|
|
|
|
// ── for_stage returns special config for special stages ──
|
|
|
|
#[test]
|
|
fn for_stage_returns_special_config_at_stage_3() {
|
|
let configs = StageConfigurations::default();
|
|
let config = configs.for_stage(3);
|
|
// Special stages have no dive attacks
|
|
assert!(
|
|
config.attack_patterns.is_empty(),
|
|
"Stage 3 (special) should have empty attack_patterns"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn for_stage_returns_special_config_at_stage_6() {
|
|
let configs = StageConfigurations::default();
|
|
let config = configs.for_stage(6);
|
|
assert!(
|
|
config.attack_patterns.is_empty(),
|
|
"Stage 6 (special) should have empty attack_patterns"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn for_stage_returns_normal_config_at_stage_1() {
|
|
let configs = StageConfigurations::default();
|
|
let config = configs.for_stage(1);
|
|
assert!(
|
|
!config.attack_patterns.is_empty(),
|
|
"Stage 1 (normal) should have attack patterns"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn for_stage_returns_normal_config_at_stage_2() {
|
|
let configs = StageConfigurations::default();
|
|
let config = configs.for_stage(2);
|
|
assert!(
|
|
!config.attack_patterns.is_empty(),
|
|
"Stage 2 (normal) should have attack patterns"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn for_stage_returns_normal_config_at_stage_4() {
|
|
let configs = StageConfigurations::default();
|
|
let config = configs.for_stage(4);
|
|
assert!(
|
|
!config.attack_patterns.is_empty(),
|
|
"Stage 4 (normal) should have attack patterns"
|
|
);
|
|
}
|
|
|
|
// ── Special stage config properties ──
|
|
|
|
#[test]
|
|
fn special_stage_has_full_formation() {
|
|
let configs = StageConfigurations::default();
|
|
let config = configs.for_stage(3);
|
|
assert_eq!(
|
|
config.enemy_count, 32,
|
|
"Special stage should have 32 enemies"
|
|
);
|
|
assert_eq!(
|
|
config.formation_layout.positions.len(),
|
|
32,
|
|
"Special stage formation should have 32 positions"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn special_stage_has_max_dive_interval() {
|
|
let configs = StageConfigurations::default();
|
|
let config = configs.for_stage(3);
|
|
assert_eq!(
|
|
config.attack_dive_interval,
|
|
f32::MAX,
|
|
"Special stage should have max dive interval"
|
|
);
|
|
}
|
|
|
|
#[test]
|
|
fn special_stage_has_base_speed() {
|
|
let configs = StageConfigurations::default();
|
|
let config = configs.for_stage(3);
|
|
assert_eq!(
|
|
config.enemy_speed_multiplier, 1.0,
|
|
"Special stage should have 1.0x speed multiplier"
|
|
);
|
|
}
|