// types.ts
export interface Vector {
  x: number
  y: number
}

export interface Bullet {
  position: Vector
  velocity: Vector
  createdAt: number
  active: boolean
}

export interface Particle {
  position: Vector
  velocity: Vector
  color: string
  life: number
  maxLife: number
  active: boolean
}

export interface Enemy {
  element: HTMLElement
  bounds: DOMRect
  gridX: number
  gridY: number
}

export interface GameState {
  player: {
    position: Vector
    velocity: Vector
    direction: number
    thrust: boolean
  }
  bullets: Bullet[]
  particles: Particle[]
  enemies: Enemy[]
  totalEnemies: number
  score: number
  level: number
  keys: Set<string>
  lastFired: number
  isRunning: boolean
}

export interface GameConfig {
  canvas: {
    width: number
    height: number
  }
  player: {
    acceleration: number
    maxSpeed: number
    rotationSpeed: number
    size: number
    thrustParticles: boolean
  }
  bullets: {
    speed: number
    lifetime: number
    fireRate: number
    maxCount: number
    size: number
  }
  particles: {
    speed: number
    lifetime: number
    count: number
    colors: string[]
  }
  enemies: {
    updateInterval: number
    ignoredTags: Set<string>
    hiddenTags: Set<string>
  }
  grid: {
    cellSize: number
    cols: number
    rows: number
  }
  fps: number
}

export interface GridCell {
  enemies: Enemy[]
}

export interface SpatialGrid {
  cells: GridCell[][]
  cellSize: number
  cols: number
  rows: number
}

export interface PooledObject {
  active: boolean
}

export interface ObjectPool<T extends PooledObject> {
  objects: T[]
  maxSize: number
  createFn: () => T
  resetFn: (obj: T) => void
}
