{"version":3,"sources":["../../../src/classes/ticker/TickerBase.ts"],"names":[],"mappings":";AA6CA,IAAqB,aAArB,MAAwF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAMpF,WAAA,CAAY,IAAa,EAAA,QAAA,EAAmB,QAA4B,EAAA;AASxE;AAAA;AAAA;AAAA,IAAmB,IAAA,CAAA,EAAA,GAAA,mBAAA,CAAA;AARf,IAAA,IAAA,CAAK,IAAO,GAAA,IAAA,CAAA;AACZ,IAAA,IAAA,CAAK,QAAW,GAAA,QAAA,CAAA;AAChB,IAAA,IAAA,CAAK,QAAW,GAAA,QAAA,CAAA;AAChB,IAAK,IAAA,CAAA,EAAA,GAAK,IAAK,CAAA,WAAA,CAAY,SAAU,CAAA,EAAA,CAAA;AAAA,GACzC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,EAAG,CAAA,OAAA,EAAiB,KAAc,EAAA,KAAA,EAA0B,SAAyB,EAAA;AAAE,IAAM,MAAA,IAAI,MAAM,yDAAyD,CAAA,CAAA;AAAA,GAAE;AACtK","file":"TickerBase.mjs","sourcesContent":["import { Ticker, UPDATE_PRIORITY } from \"pixi.js\"\nimport { tickerDecorator } from \"../../decorators\"\nimport { geTickerInstanceById } from \"../../decorators/TickerDecorator\"\nimport ITicker from \"../../interface/ITicker\"\nimport { GameWindowManager } from \"../../managers\"\nimport { StorageElementType } from \"../../types/StorageElementType\"\nimport { TickerIdType } from \"../../types/TickerIdType\"\n\nexport type TickerArgsType = { [id: string]: StorageElementType } | {\n    tagToRemoveAfter?: string[] | string,\n    [id: string]: StorageElementType\n}[]\n\n/**\n * A class is used to create a ticker element to add into a Pixi Application.\n * You can use GameWindowManager.addTicker() to add this element into the application.\n * This class should be extended and the fn method should be overridden.\n * You must use the {@link tickerDecorator} to register the ticker in the game.\n * In Ren'Py is a transform.\n * @example\n * ```typescript\n * \\@tickerDecorator() // this is equivalent to tickerDecorator(\"RotateTicker\")\n * export class RotateTicker extends TickerBase<{ speed?: number }> {\n *     override fn(\n *         t: Ticker, // the ticker that is calling this method\n *         args: { // the arguments that you passed when you added the ticker\n *             speed?: number,\n *         },\n *         tags: string[], // the tags of the canvas elements that are connected to this ticker\n *         tickerId: string, // the id of the ticker. You can use this to get the ticker from the GameWindowManager.currentTickers\n *     ): void {\n *         let speed = args.speed === undefined ? 0.1 : args.speed\n *         tags.forEach((tag) => {\n *                 let element = GameWindowManager.getCanvasElement(tag)\n *                 if (element && element instanceof Container) {\n *                     if (clockwise)\n *                         element.rotation += speed * t.deltaTime\n *                     else\n *                         element.rotation -= speed * t.deltaTime\n *                 }\n *             })\n *     }\n * }\n * ```\n */\nexport default class TickerBase<TArgs extends TickerArgsType> implements ITicker<TArgs> {\n    /**\n     * @param args The arguments that you want to pass to the ticker.\n     * @param duration The duration of the ticker in seconds. If is undefined, the step will end only when the animation is finished (if the animation doesn't have a goal to reach then it won't finish). @default undefined\n     * @param priority The priority of the ticker. @default UPDATE_PRIORITY.NORMAL\n     */\n    constructor(args: TArgs, duration?: number, priority?: UPDATE_PRIORITY) {\n        this.args = args\n        this.duration = duration\n        this.priority = priority\n        this.id = this.constructor.prototype.id\n    }\n    /**\n     * Get the id of the ticker. This variable is used in the system to get the ticker by id, {@link geTickerInstanceById}\n     */\n    id: TickerIdType = 'ticker_id_not_set'\n    args: TArgs\n    duration?: number\n    priority?: UPDATE_PRIORITY\n    /**\n     * The method that will be called every frame.\n     * This method should be overridden and you can use GameWindowManager.addCanvasElement() to get the canvas element of the canvas, and edit them.\n     * @param _ticker The ticker that is calling this method\n     * @param _args The arguments that you passed when you added the ticker\n     * @param _tags The tags of the canvas elements that are connected to this ticker\n     * @param _tickerId The id of the ticker. You can use this to get the ticker from the {@link GameWindowManager.currentTickers}\n     */\n    fn(_ticker: Ticker, _args: TArgs, _tags: string | string[], _tickerId: string): void { throw new Error(\"[Pixi'VN] The method TickerBase.fn() must be overridden\") }\n}\n"]}