参考 › 函数参考 › Functions

Functions.cache.getCached

公共

调用方式

Functions.cache.getCached(cache, func, ...)

将其记录为名为 Functions.cache.getCached 的依赖项(接受自动补全即可完成),然后按该名称调用。

也接受以前的命名空间 utils 下的名称。

作用

对每个缓存和完全相同的参数元组只调用一次观测,包括 nil 结果。传入评估缓存可在一个推荐周期内共享观测;缓存为 nil 时直接调用。

参数

名称类型作用
cachetable | nil评估缓存;为 nil 时绕过缓存。
funcfunction | 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

依赖项

源码

Functions/cache.lua,第 164 行。在游戏中为只读;“复制”会生成一份可编辑的副本。

Functions.cache.getCached(cache, func, ...)
    return getCachedInternal(cache, true, func, ...)

返回函数参考