local ____lualib = require("lualib_bundle") local __TS__SourceMapTraceBack = ____lualib.__TS__SourceMapTraceBack __TS__SourceMapTraceBack(debug.getinfo(1).short_src, {["5"] = 41,["6"] = 1,["7"] = 1,["8"] = 44,["9"] = 45,["15"] = 9,["16"] = 10,["17"] = 15,["18"] = 16,["19"] = 17,["20"] = 19,["21"] = 20,["22"] = 15,["23"] = 23,["24"] = 24,["26"] = 26,["27"] = 27,["28"] = 29,["29"] = 30,["32"] = 34,["33"] = 9,["34"] = 41,["35"] = 42,["36"] = 48,["37"] = 49,["38"] = 48,["39"] = 52,["40"] = 53,["41"] = 54,["42"] = 55,["43"] = 52}); local ____exports = {} local getId, INSTANCE_ID_VAR_NAME, GlobalVariable local ____MAVariables = require("MAVariables") local MAVariables = ____MAVariables.MAVariables function getId(self, instance) return tostring(instance) end --- Creates an instance of a singleton object. -- This singleton object is stored in a global variable. -- If a new show is loaded, and the singleton is accessed again, -- then the existing singleton is destroyed, and a new instance will be created. function ____exports.getOrCreateShowSingleton(self, globalId, create) local pluginAddonVars = MAVariables(nil, {storageType = "ShowFile", variablesId = globalId}) local function createInstance(self) local instance = create(nil) local objId = getId(nil, instance) pluginAddonVars:setVar(INSTANCE_ID_VAR_NAME, objId) return instance end if GlobalVariable[globalId] == nil then GlobalVariable[globalId] = createInstance(nil) else local instance = GlobalVariable[globalId] if pluginAddonVars:getVar(INSTANCE_ID_VAR_NAME) ~= getId(nil, instance) then instance:destroy() GlobalVariable[globalId] = createInstance(nil) end end return GlobalVariable[globalId] end INSTANCE_ID_VAR_NAME = "_SHOW_SINGLETON_INSTANCE_ID" GlobalVariable = _G function ____exports.isShowSingletonExists(self, globalId) return GlobalVariable[globalId] ~= nil end function ____exports.getShowSingleton(self, globalId) local instance = GlobalVariable[globalId] assert(instance ~= nil, "Could not find Show Singleton globalId = " .. globalId) return instance end return ____exports