import { Container } from 'pixi.js';

/** Base scene abstraction used by the game runtime. */
export default class Scene extends Container
{
    public isCreated = false;

    constructor(name: string)
    {
        super();
        this.name = name;
    }

    /** Loads remote assets required by the scene. */
    async load(): Promise<void>
    {
        //@ts-expect-error types
        this.emit('loaded');
    }

    /**
     * Creates display objects once assets are ready.
     * @param _data
     */
    create(_data?: unknown): void
    {
        //@ts-expect-error types
        this.emit('created');
    }

    /**
     * Steps the scene simulation.
     * @param _dt
     */
    update(_dt: number): void {}

    /**
     * Applies layout changes.
     * @param _data
     */
    resize(_data?: unknown): void {}

    /** Signals that the scene becomes active. */
    run(): void
    {
        //@ts-expect-error types
        this.emit('run');
    }

    /** Signals that the scene becomes inactive. */
    stop(): void
    {
        //@ts-expect-error types
        this.emit('stopped');
    }

    /** Suspends updates while keeping state in memory. */
    pause(): void
    {
        //@ts-expect-error types
        this.emit('paused');
    }

    /** Resumes updates after a pause. */
    resume(): void
    {
        //@ts-expect-error types
        this.emit('resume');
    }

    /** Puts the scene to sleep when hidden. */
    sleep(): void
    {
        //@ts-expect-error types
        this.emit('sleep');
    }

    /** Wakes up the scene after being hidden. */
    wake(): void
    {
        //@ts-expect-error types
        this.emit('wake');
    }
}
