zuma-like/src/states/linear/components_track.rs

57 lines
1.5 KiB
Rust
Raw Normal View History

2026-04-15 23:02:14 +03:00
use bevy::prelude::*;
#[derive(Resource)]
pub struct Track {
2026-04-15 23:02:14 +03:00
pub start_point: Vec2,
pub start_direction: Vec2, // будет нормализовано при построении
pub segments: Vec<PathSegment>,
}
#[derive(Debug)]
pub enum SegementType{
Line,
Turn,
}
2026-04-15 23:02:14 +03:00
// линия всегда строится от точки старта по направлению
// направление изменяется сегментами поворота
// left при истине - поворот против часовой стрелки, ложь - по часовой
#[derive(Clone, Copy)]
pub enum PathSegment {
2026-04-15 23:02:14 +03:00
Line { length: f32 },
Turn { radius: f32, left: bool },
// TODO заменить перечисление на структуру с полем типа SegementType, чтоб был единый источник типа
}
#[derive(Resource)]
pub struct PrecalculatedTrack{
pub segments: Vec<PTSegment>,
pub min_spawn_gap: f32, //нормализован
pub total_length: f32,
pub speed_norm: f32,
}
#[derive(Debug)]
pub struct PTSegment {
pub t_start: f32,
pub t_end: f32,
pub segment_type: SegementType,
pub start_pos: Vec2,
pub direction: Vec2,
pub center: Vec2,
pub radius: f32,
pub start_angle: f32,
pub sweep_sign: f32,
pub length: f32,
}
#[derive(Debug, Clone, Copy)]
pub struct ArcCalculation {
pub normal: Vec2,
pub center: Vec2,
pub start_angle: f32,
pub sweep_sign: f32,
pub end_pos: Vec2,
2026-04-15 23:02:14 +03:00
}