呼叫方式
Functions.cache.getCached(cache, func, ...)
將它記錄為名為 Functions.cache.getCached 的相依項目(接受自動完成即可完成此步驟),然後以該名稱呼叫。
也接受舊命名空間 utils 下的名稱。
作用
對每個快取與完全相同的參數元組只呼叫一次觀測,包括 nil 結果。傳入評估快取可在一個建議週期內共用觀測;快取為 nil 時直接呼叫。
參數
| 名稱 | 類型 | 作用 |
|---|---|---|
cache | table | nil | 評估快取;為 nil 時略過快取。 |
func | function | string | 要呼叫的函式或全域函式名稱。 |
... | any | 原樣轉送的參數;型別、身分、參數數量與 nil 位置用於區分快取項目。 |
傳回值
| 1 | ... | 所有原始結果,保留 nil 的位置與傳回值數量。 |
|---|
版本
內建輔助函式在每個版本上都會註冊。不同的是它們讀取的遊戲 API;某個 API 不存在時,輔助函式會改用備用方式,或傳回 nil 並附上原因。
它不會直接讀取任何遊戲 API。
插件如何呼叫它
- 任意法術可用 (evaluate)
return Functions.cache.getCached(cache, addon.Platform.IsSpellReady, addon.Platform, spellid, evalStart) - 任意法術充能 (evaluate)
local charges, why = Functions.cache.getCached(cache, addon.Platform.GetSpellCharges, addon.Platform, spellid) - 任意法術冷卻 (evaluate)
local cooldown, why = Functions.cache.getCached(cache, addon.Platform.GetSpellCooldown, addon.Platform, spellid) - 任意法術在射程內 (evaluate)
local exists,presenceReason=Functions.cache.getCached(cache, addon.Platform.GetUnitPresenceObservation, addon.Platform, "target") - 任意法術充能時間 (evaluate)
local charges, why = Functions.cache.getCached(cache, addon.Platform.GetSpellCharges, addon.Platform, spellid) - 戰鬥助手可用 (evaluate)
local available, why = Functions.cache.getCached(cache, addon.Platform.GetAssistedCombatAvailability, addon.Platform) - 戰鬥助手循環法術 (evaluate)
return Functions.cache.getCached(cache, addon.Platform.IsAssistedRotationSpell, addon.Platform, spellid) - 戰鬥助手建議 (evaluate)
local suggestion, reason = Functions.cache.getCached(cache, addon.Platform.GetAssistedSuggestion, addon.Platform)
以及另外 82 處: 可攻擊 (evaluate), 施法中 (evaluate), 施法進度 (evaluate), 施法剩餘時間 (evaluate), 施放特定法術 (evaluate), 施法可中斷 (evaluate), 引導中 (evaluate), 引導進度 (evaluate), 引導剩餘時間 (evaluate), 引導特定法術 (evaluate), 引導可中斷 (evaluate), 職業 (evaluate), 單位分類 (evaluate), 戰鬥中 (evaluate), 已死亡或處於鬼魂狀態 (evaluate), 距離 (evaluate), 距離內計數 (evaluate), 日月蝕 (evaluate), 擴充角色屬性 (evaluate), 擴充角色屬性百分比 (evaluate), 首領戰 (evaluate), 敵對 (evaluate), 變形形態 (evaluate), 是友方 (evaluate), 雕紋 (evaluate), 在隊伍中 (evaluate), 隊伍計數 (evaluate), 生命力 (evaluate), 生命力百分比 (evaluate), 英雄天賦樹 (evaluate), 可控制 (evaluate), 副本 (evaluate), 是同一單位 (evaluate), 傳奇+鑰石等級 (evaluate), 失去控制封鎖 (evaluate), 失去控制類型 (evaluate), 法力 (evaluate), 法力百分比 (evaluate), 團隊標記 (evaluate), 團隊標記數量 (evaluate), 移動中 (evaluate), 戶外 (evaluate), 擁有寵物 (evaluate), 寵物法術生效中或待生效 (evaluate), 寵物法術可用 (evaluate), 寵物法術充能 (evaluate), 寵物法術冷卻 (evaluate), 寵物法術施放歷史 (evaluate), 寵物法術施放歷史時間 (evaluate), 寵物法術在射程內 (evaluate), 寵物法術充能時間 (evaluate), 寵物快樂值 (evaluate), 擁有指定名稱的寵物 (evaluate), 玩家狀態 (evaluate), 點數 (evaluate), 能量 (evaluate), 能量百分比 (evaluate), 主要天賦樹 (evaluate), PvP 標記 (evaluate), 團隊職務 (evaluate), 職責 (evaluate), 符文 (evaluate), 符文冷卻 (evaluate), 法術生效中或待生效 (evaluate), 法術自動重複中 (evaluate), 法術可用 (evaluate), 法術充能 (evaluate), 法術冷卻 (evaluate), 法術觸發高亮 (evaluate), 法術在射程內 (evaluate), 法術充能時間 (evaluate), Stagger (evaluate), 角色屬性 (evaluate), 潛行 (evaluate), 武器攻擊間隔剩餘時間 (evaluate), 天賦 (evaluate), 天賦樹點數 (evaluate), 威脅值 (evaluate), 單位存在 (evaluate), 區域 PvP (evaluate), Conditions.spatial.rangeMember, Conditions.weapon.swingSpeed
相依項目
getCachedInternal→utils.getCachedInternal
原始碼
Functions/cache.lua,第 164 行。在遊戲中為唯讀;「複製」會產生一份可編輯的複本。
Functions.cache.getCached(cache, func, ...)
return getCachedInternal(cache, true, func, ...)