--[[ Generated with https://github.com/TypeScriptToLua/TypeScriptToLua ]] -- Lua Library inline imports local function __TS__Number(value) local valueType = type(value) if valueType == "number" then return value elseif valueType == "string" then local numberValue = tonumber(value) if numberValue then return numberValue end if value == "Infinity" then return math.huge end if value == "-Infinity" then return -math.huge end local stringWithoutSpaces = string.gsub(value, "%s", "") if stringWithoutSpaces == "" then return 0 end return 0 / 0 elseif valueType == "boolean" then return value and 1 or 0 else return 0 / 0 end end -- End of Lua Library inline imports local ____exports = {} local _, _Mekanome = ... local Mekanome = _Mekanome local isMoving = false local isCasting = false local isChanneling = false local isAlive = true local isMounted = false local Player = nil local Target = nil local Mouseover = nil local sqw = C_CVar.GetCVar("SpellQueueWindow") local spellQueueWindow = sqw ~= nil and __TS__Number(sqw) or 0 --- Refresh the players state local function Refresh() local MobUtils = Mekanome.MobUtils local MobManager = Mekanome.MobManager local player = MobManager.GetMob({token = "player"}) local target = MobManager.GetMob({token = "target"}) local mouseover = MobManager.GetMob({token = "mouseover"}) if player == nil then error( Mekanome.Error("Unable to refresh player state as player object doesnt exist."), 0 ) end Player = player Target = target Mouseover = mouseover isMoving = MobUtils.GetIsMoving(player) isMounted = MobUtils.IsMounted(player) isAlive = MobUtils.IsAlive(player) local castEnd = MobUtils.GetCastEndTime(player) local channelEnd = MobUtils.GetChannelEndTime(player) if castEnd then local timeUntilEnd = castEnd - GetTime() isCasting = timeUntilEnd > spellQueueWindow / 1000 else isCasting = false end if channelEnd then local timeUntilEnd = channelEnd - GetTime() isChanneling = timeUntilEnd > spellQueueWindow / 1000 else isChanneling = false end end --- Get the players state local function GetPlayerState() if Player == nil then error( Mekanome.Error("Unable to get player state as player object doesnt exist."), 0 ) end return { Player = Player, Target = Target, Mouseover = Mouseover, spellQueueWindow = spellQueueWindow, isAlive = isAlive, isMounted = isMounted, isMoving = isMoving, isCasting = isCasting, isChanneling = isChanneling } end local function Init() Mekanome.EventManager.RegisterEventHandler( "CVAR_UPDATE", function(____, ____bindingPattern0) local eventName eventName = ____bindingPattern0[1] if eventName == "SpellQueueWindow" then local newSQW = C_CVar.GetCVar("SpellQueueWindow") if newSQW ~= nil then spellQueueWindow = __TS__Number(newSQW) end end end, "tm_cvar_update" ) end local _PlayerStateManager = {Refresh = Refresh, GetPlayerState = GetPlayerState, Init = Init} Mekanome.PlayerStateManager = _PlayerStateManager ____exports.default = {} return ____exports