import type { LocalizedString, Position } from './shared-types';
import { dataSets, loadModels } from './loadModels';

export interface Region {
  readonly region_id: number;
  readonly center: Position;
  readonly description_id: number;
  readonly faction_id: number;
  readonly max: Position;
  readonly min: Position;
  readonly name_id: number;
  readonly wormhole_class_id?: number;
  readonly nebula_id?: number;
  readonly universe_id: string;
  readonly description: LocalizedString;
  readonly name: LocalizedString;
}

export function getRegion(region_id: number) {
  if (!dataSets.loaded) loadModels();
  const data = dataSets.regions[String(region_id)];
  if (!data) throw new Error(`Region ID ${region_id} not found in reference data`);
  return data;
}
