{"version":3,"sources":["../../src/decorators/TickerDecorator.ts"],"names":[],"mappings":";AAOO,IAAM,oBAAiE,GAAC;AAQhE,SAAR,gBAAiC,IAAqB,EAAA;AACzD,EAAA,OAAO,SAAU,MAAgC,EAAA;AAC7C,IAAA,IAAI,CAAC,IAAM,EAAA;AACP,MAAA,IAAA,GAAO,MAAO,CAAA,IAAA,CAAA;AAAA,KAClB;AACA,IAAI,IAAA,iBAAA,CAAkB,IAAI,CAAG,EAAA;AACzB,MAAQ,OAAA,CAAA,IAAA,CAAK,CAAoB,iBAAA,EAAA,IAAI,CAAyC,uCAAA,CAAA,CAAA,CAAA;AAAA,KAClF;AACA,IAAA,MAAA,CAAO,UAAU,EAAK,GAAA,IAAA,CAAA;AACtB,IAAA,iBAAA,CAAkB,IAAI,CAAI,GAAA,MAAA,CAAA;AAAA,GAC9B,CAAA;AACJ,CAAA;AAUO,SAAS,oBAAmD,CAAA,QAAA,EAAwB,IAAa,EAAA,QAAA,EAAmB,QAA2D,EAAA;AAClL,EAAI,IAAA;AACA,IAAI,IAAA,MAAA,GAAS,kBAAkB,QAAQ,CAAA,CAAA;AACvC,IAAA,IAAI,CAAC,MAAQ,EAAA;AACT,MAAQ,OAAA,CAAA,KAAA,CAAM,CAAoB,iBAAA,EAAA,QAAQ,CAAY,UAAA,CAAA,CAAA,CAAA;AACtD,MAAA,OAAA;AAAA,KACJ;AACA,IAAA,OAAO,IAAI,MAAA,CAAO,IAAM,EAAA,QAAA,EAAU,QAAQ,CAAA,CAAA;AAAA,WAEvC,CAAG,EAAA;AACN,IAAA,OAAA,CAAQ,KAAM,CAAA,CAAA,qCAAA,EAAwC,QAAQ,CAAA,CAAA,EAAI,CAAC,CAAA,CAAA;AACnE,IAAA,OAAA;AAAA,GACJ;AACJ","file":"TickerDecorator.mjs","sourcesContent":["import { UPDATE_PRIORITY } from \"pixi.js\"\nimport TickerBase, { TickerArgsType } from \"../classes/ticker/TickerBase\"\nimport { TickerIdType } from \"../types/TickerIdType\"\n\n/**\n * A dictionary that contains all tickers registered and avvailable to be used.\n */\nexport const registeredTickers: { [name: TickerIdType]: typeof TickerBase } = {}\n/**\n * Is a decorator that register a ticker in the game.\n * Is a required decorator for use the ticker in the game.\n * Thanks to this decoration the game has the possibility of updating the tickers to the latest modification and saving the game.\n * @param name is th identifier of the label, by default is the name of the class\n * @returns \n */\nexport default function tickerDecorator(name?: TickerIdType) {\n    return function (target: typeof TickerBase<any>) {\n        if (!name) {\n            name = target.name\n        }\n        if (registeredTickers[name]) {\n            console.info(`[Pixi'VN] Ticker ${name} already exists, it will be overwritten`)\n        }\n        target.prototype.id = name\n        registeredTickers[name] = target\n    }\n}\n\n/**\n * Get a ticker instance by the id.\n * @param tickerId The id of the ticker.\n * @param args The arguments that you want to pass to the ticker.\n * @param duration The duration of the ticker. If is undefined, the ticker will be called every frame.\n * @param priority The priority of the ticker. If is undefined, the priority will be UPDATE_PRIORITY.NORMAL.\n * @returns The instance of the ticker\n */\nexport function geTickerInstanceById<TArgs extends TickerArgsType>(tickerId: TickerIdType, args: TArgs, duration?: number, priority?: UPDATE_PRIORITY): TickerBase<TArgs> | undefined {\n    try {\n        let ticker = registeredTickers[tickerId]\n        if (!ticker) {\n            console.error(`[Pixi'VN] Ticker ${tickerId} not found`)\n            return\n        }\n        return new ticker(args, duration, priority)\n    }\n    catch (e) {\n        console.error(`[Pixi'VN] Error while getting Ticker ${tickerId}`, e)\n        return\n    }\n}\n"]}