import type { EntityId, Component, ComponentType, Vec2, Color } from '../core/types';
import { EventBus } from '../core/EventBus';
export interface Entity {
    readonly id: EntityId;
    name: string;
    tags: Set<string>;
    enabled: boolean;
    parent: EntityId | null;
    children: EntityId[];
}
export interface TransformComponent extends Component {
    type: 'Transform';
    position: Vec2;
    rotation: number;
    scale: Vec2;
    /** Previous position (for interpolation) */
    prevPosition: Vec2;
    prevRotation: number;
}
export interface SpriteComponent extends Component {
    type: 'Sprite';
    /** Asset ID or null for procedural shapes */
    assetId: string | null;
    /** Source rectangle in spritesheet */
    srcRect: {
        x: number;
        y: number;
        w: number;
        h: number;
    } | null;
    width: number;
    height: number;
    anchor: Vec2;
    tint: Color;
    opacity: number;
    flipX: boolean;
    flipY: boolean;
    layer: number;
    visible: boolean;
}
export interface ShapeComponent extends Component {
    type: 'Shape';
    shape: 'rect' | 'circle' | 'polygon' | 'line';
    width: number;
    height: number;
    radius: number;
    points: Vec2[];
    lineStart: Vec2;
    lineEnd: Vec2;
    fillColor: Color;
    strokeColor: Color;
    strokeWidth: number;
    layer: number;
    visible: boolean;
}
export interface Collider2DComponent extends Component {
    type: 'Collider2D';
    shape: 'aabb' | 'circle' | 'polygon';
    width: number;
    height: number;
    radius: number;
    points: Vec2[];
    offset: Vec2;
    isTrigger: boolean;
    layer: number;
    mask: number;
}
export interface RigidBody2DComponent extends Component {
    type: 'RigidBody2D';
    bodyType: 'dynamic' | 'static' | 'kinematic';
    velocity: Vec2;
    acceleration: Vec2;
    angularVelocity: number;
    mass: number;
    drag: number;
    angularDrag: number;
    restitution: number;
    friction: number;
    gravityScale: number;
    fixedRotation: boolean;
}
export interface TextComponent extends Component {
    type: 'Text';
    text: string;
    fontSize: number;
    fontFamily: string;
    color: Color;
    align: 'left' | 'center' | 'right';
    baseline: 'top' | 'middle' | 'bottom';
    layer: number;
    visible: boolean;
}
export interface AnimatorComponent extends Component {
    type: 'Animator';
    currentAnimation: string;
    animations: Record<string, SpriteAnimation>;
    frame: number;
    elapsed: number;
    playing: boolean;
    loop: boolean;
}
export interface SpriteAnimation {
    frames: AnimationFrame[];
    fps: number;
    loop: boolean;
}
export interface AnimationFrame {
    assetId: string;
    srcRect: {
        x: number;
        y: number;
        w: number;
        h: number;
    } | null;
    duration?: number;
}
export interface ScriptComponent extends Component {
    type: 'Script';
    scriptId: string;
    variables: Record<string, unknown>;
}
export interface AudioSourceComponent extends Component {
    type: 'AudioSource';
    soundId: string;
    volume: number;
    loop: boolean;
    spatial: boolean;
    maxDistance: number;
    autoPlay: boolean;
    playing: boolean;
}
export interface ParticleEmitterComponent extends Component {
    type: 'ParticleEmitter';
    emitting: boolean;
    rate: number;
    lifetime: [number, number];
    speed: [number, number];
    angle: [number, number];
    size: [number, number];
    sizeEnd: [number, number];
    color: Color;
    colorEnd: Color;
    gravity: Vec2;
    maxParticles: number;
}
export interface CameraTargetComponent extends Component {
    type: 'CameraTarget';
    priority: number;
    smoothing: number;
    deadzone: Vec2;
    lookahead: Vec2;
}
/** Union of all known component types */
export type BuiltInComponent = TransformComponent | SpriteComponent | ShapeComponent | Collider2DComponent | RigidBody2DComponent | TextComponent | AnimatorComponent | ScriptComponent | AudioSourceComponent | ParticleEmitterComponent | CameraTargetComponent;
export type ComponentMap = {
    Transform: TransformComponent;
    Sprite: SpriteComponent;
    Shape: ShapeComponent;
    Collider2D: Collider2DComponent;
    RigidBody2D: RigidBody2DComponent;
    Text: TextComponent;
    Animator: AnimatorComponent;
    Script: ScriptComponent;
    AudioSource: AudioSourceComponent;
    ParticleEmitter: ParticleEmitterComponent;
    CameraTarget: CameraTargetComponent;
};
export declare function createDefaultComponent<K extends keyof ComponentMap>(type: K, entityId: EntityId): ComponentMap[K];
export declare abstract class System {
    enabled: boolean;
    readonly priority: number;
    constructor(priority?: number);
    /** Called once when added to world. */
    init(_world: World): void;
    /** Called every frame. */
    update(_world: World, _dt: number): void;
    /** Called at fixed timestep (physics). */
    fixedUpdate(_world: World, _fixedDt: number): void;
    /** Called when removed from world. */
    destroy(_world: World): void;
    /** Alias for destroy() — unified cleanup pattern. */
    dispose(world: World): void;
}
export declare class World {
    readonly events: EventBus;
    private _nextId;
    private entities;
    private components;
    private systems;
    private systemsSorted;
    createEntity(name?: string): Entity;
    destroyEntity(id: EntityId): void;
    getEntity(id: EntityId): Entity | undefined;
    /** Get all entities (alive). */
    allEntities(): Entity[];
    /** Find first entity with given tag. */
    findByTag(tag: string): Entity | undefined;
    /** Find all entities with given tag. */
    findAllByTag(tag: string): Entity[];
    /** Find first entity with given name. */
    findByName(name: string): Entity | undefined;
    get entityCount(): number;
    setParent(childId: EntityId, parentId: EntityId | null): void;
    addComponent<K extends keyof ComponentMap>(entityId: EntityId, type: K, overrides?: Partial<ComponentMap[K]>): ComponentMap[K];
    removeComponent(entityId: EntityId, type: ComponentType): void;
    getComponent<K extends keyof ComponentMap>(entityId: EntityId, type: K): ComponentMap[K] | undefined;
    hasComponent(entityId: EntityId, type: ComponentType): boolean;
    /** Query all entities that have ALL specified components. */
    query(...types: ComponentType[]): EntityId[];
    /** Get all components of a type (as a Map). */
    getComponentsOfType<K extends keyof ComponentMap>(type: K): Map<EntityId, ComponentMap[K]>;
    addSystem(system: System): void;
    removeSystem(system: System): void;
    private ensureSorted;
    update(dt: number): void;
    fixedUpdate(fixedDt: number): void;
    /** Clear all entities, components, and systems. */
    clear(): void;
}
