use crate::position::SoundSource;
use crate::types::Position3D;
use serde::{Deserialize, Serialize};
use std::time::Instant;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum GameEngine {
Unity,
Unreal,
Godot,
Custom,
WebEngine,
Console,
PlayStation,
Xbox,
NintendoSwitch,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct GameAudioSource {
pub id: u32,
pub category: AudioCategory,
pub priority: u8,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub enum AudioCategory {
Player,
Npc,
Environment,
Music,
Sfx,
Ui,
Voice,
Ambient,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct AttenuationSettings {
pub min_distance: f32,
pub max_distance: f32,
pub curve: AttenuationCurve,
pub factor: f32,
}
impl Default for AttenuationSettings {
fn default() -> Self {
Self {
min_distance: 1.0,
max_distance: 100.0,
curve: AttenuationCurve::Logarithmic,
factor: 1.0,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum AttenuationCurve {
Linear,
Logarithmic,
Exponential,
Custom,
}
#[derive(Debug, Clone, Default)]
pub struct GamingMetrics {
pub audio_time_ms: f32,
pub active_sources: u32,
pub memory_usage_mb: f32,
pub cpu_usage_percent: f32,
pub gpu_usage_percent: Option<f32>,
pub dropped_frames: u32,
pub fps: f32,
pub latency_ms: f32,
}
#[derive(Debug, Clone)]
pub(super) struct GameAudioSourceData {
pub handle: GameAudioSource,
pub spatial_source: SoundSource,
pub audio_data: Vec<f32>,
pub state: PlaybackState,
pub volume: f32,
pub looping: bool,
pub attenuation: AttenuationSettings,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub(super) enum PlaybackState {
Stopped,
Playing,
Paused,
Finished,
}
#[derive(Debug)]
pub(super) struct FrameTimer {
pub last_frame: Instant,
pub frame_count: u32,
pub fps_accumulator: f32,
pub fps_timer: Instant,
}
impl Default for FrameTimer {
fn default() -> Self {
let now = Instant::now();
Self {
last_frame: now,
frame_count: 0,
fps_accumulator: 0.0,
fps_timer: now,
}
}
}