调用方式
Conditions.spatial.nameplateDistanceCount(value, cache, plates)
记录依赖项 Conditions.spatial.nameplateDistanceCount,然后按该名称调用。带命名空间的调用不会传入 self:请使用冒号调用,或自行传入该对象。
作用
Counts units for DISTANCE_COUNT from a nameplate unit snapshot: units that exist, whose hostility matches value.enemy, and that are definitely within value.distance yards. Compares the count with value.operator and value.value; any unreadable unit or uncertain range makes the whole result unavailable.
参数
| 名称 | 类型 | 作用 |
|---|---|---|
value | table | Condition settings: enemy, distance, operator and value. |
cache | table | nil | Evaluation-pass cache passed to getCached, or nil to read directly. |
plates | table | Snapshot whose keys are nameplate unit tokens. |
返回值
| 1 | boolean | nil | Result of the count comparison, or nil when the count cannot be established. |
|---|---|---|
| 2 | string | nil | Reason for nil, such as unit-snapshot-unavailable, invalid-unit-snapshot, restricted-value or range-uncertain. |
版本
内置辅助函数在每个版本上都会注册。不同的是它们读取的游戏 API;某个 API 缺失时,辅助函数会改用后备方案,或返回 nil 并附上原因。
- 该版本不可用(原因见提示)
- 仅在暴雪的弃用兼容层开启时
| 游戏 API | |||||
|---|---|---|---|---|---|
UnitExists | |||||
UnitIsEnemy |
秘密值(正式服和永久服)
在正式服和永久服上,游戏交给插件的是秘密值。此辅助函数会检查它读取的内容(addon.Platform:CanReadValue),遇到无法比较的秘密值时返回 nil 并附上原因(例如 restricted-value),而不是返回该秘密值。请将 nil 视为不可用,而不是假。
插件如何调用它
- 距离内计数 (evaluate)
if plates~=nil then return nameplateDistanceCount(value,cache,plates) end
依赖项
Functions.cache.getCached→Functions.cache.getCachedFunctions.presentation.compareString→Functions.presentation.compareStringFunctions.presentation.nullable→Functions.presentation.nullableFunctions.presentation.playerize→Functions.presentation.playerizeFunctions.values.compare→Functions.values.compareFunctions.values.isin→Functions.values.isinbooleanRead→Conditions.spatial.booleanReadcombatFilter→Conditions.spatial.combatFilterrangeMember→Conditions.spatial.rangeMember
源码
Conditions/spatial.lua,第 690 行。在游戏中为只读;“复制”会生成一份可编辑的副本。
Conditions.spatial.nameplateDistanceCount(value, cache, plates)
if type(plates)~="table" then return nil,"unit-snapshot-unavailable" end
local count = 0
for unit in pairs(plates) do
if not addon.Platform:CanReadValue(unit) then return nil,"restricted-value" end
if type(unit)~="string" or unit=="" then return nil,"invalid-unit-snapshot" end
local present,issue=booleanRead(cache,UnitExists,unit)
if present==nil then return nil,issue end
if present then
local enemy,problem=booleanRead(cache,UnitIsEnemy,"player",unit)
if enemy==nil then return nil,problem end
if enemy==value.enemy then
local fighting,combatWhy=combatFilter(value,cache,unit)
if fighting==nil then return nil,combatWhy end
if fighting then
local member,why=rangeMember(cache,unit,value.distance)
if member==nil then return nil,why end
if member then count=count+1 end
end
end
end
end
return Functions.values.compare(value.operator, count, value.value)




