호출 방법
addon.Platform:GetUnitCastObservation(unit, kind)
addon을 통해 바로 쓸 수 있으며, 의존성이 필요 없습니다.
하는 일
점검 또는 제한 정책 클라이언트에서 유닛의 시전 또는 정신 집중을 관찰합니다. 없는 것으로 알려진 유닛이나 읽을 수 있는 비활성 결과는 active=false를 반환합니다. 활성 기록에는 name이 있거나, 이름이 비밀이면(유닛은 여전히 시전 중) nameReason이 있으며, 각각 따로 사용할 수 있는 remainingSeconds, durationSeconds, interruptible, spellID 필드가 있고, 선택 필드를 사용할 수 없으면 remainingReason, durationReason, interruptibleReason, spellReason이 있습니다. 존재 관찰이 없거나, 실패하거나, 제한되면 이유와 함께 nil을 반환합니다.
인수
| 이름 | 유형 | 하는 일 |
|---|---|---|
self | RMPlatform | Rotation Master 플랫폼 어댑터 (콜론 호출에서는 암묵적). |
unit | string | 현재 시전이나 정신 집중을 관찰할 유닛 토큰. |
kind | string | 관찰 종류: cast 또는 channel. 기본 차단 가능 여부 튜플 위치가 서로 다릅니다. |
반환값
| 1 | table | nil | active, 그다음 name 또는 nameReason, remainingSeconds, durationSeconds, interruptible, spellID가 있는 새로 읽은 기록입니다. 남은 시간과 지속 시간은 초 단위이며, 남은 시간은 0 아래로 내려가지 않습니다. 사용할 수 없는 선택 필드에는 자체 이유가 있으며, 활성 기록을 무효로 만들지 않습니다. |
|---|---|---|
| 2 | string | nil | 관찰 전체를 사용할 수 없을 때의 사용 불가 또는 조회 검증 이유. |
버전
기본 제공 도우미는 모든 버전에 등록됩니다. 다른 점은 읽는 게임 API이며, API가 없으면 도우미는 대체 동작을 하거나 이유와 함께 nil을 반환합니다.
- 해당 버전에서 사용할 수 없음 (이유는 툴팁에 표시)
- Blizzard의 지원 중단 대체 함수가 켜져 있을 때만
비공개 값 (Retail과 Forever)
Retail과 Forever에서는 게임이 애드온에 비공개 값을 넘깁니다. 이 도우미는 읽는 값을 확인하고(addon.Platform:CanReadValue), 비교할 수 없는 비공개 값 대신 restricted-value 같은 이유와 함께 nil을 반환합니다. nil은 거짓이 아니라 사용할 수 없음으로 취급하세요.
예시
local cast = addon.Platform:GetUnitCastObservation("target", "cast")
if not cast then return nil end
if not cast.active then return false end
if cast.interruptible == nil or cast.remainingSeconds == nil then return nil end
return cast.interruptible and cast.remainingSeconds > 0.5의존성
durationSeconds→Platform.casting.durationSecondsinterruptibility→Platform.casting.interruptibilityremainingSeconds→Platform.casting.remainingSecondsspellIdentity→Platform.casting.spellIdentity
소스
Platform/casting.lua, 82번째 줄. 게임에서는 읽기 전용이며, 복제하면 편집 가능한 사본이 생깁니다.
Platform.casting.GetUnitCastObservation(self, unit, kind)
local policy=self:GetCombatDataPolicy()
if policy~='probe' and policy~='restricted' then return nil,'unsupported-policy' end
if not self:CanReadValue(unit) or not self:CanReadValue(kind) then return nil,'restricted-value' end
if type(unit)~='string' or unit=='' then return nil,'invalid-unit' end
if kind~='cast' and kind~='channel' then return nil,'invalid-cast-query' end
if type(UnitExists)~='function' then return nil,'missing-api' end
local existsOk,exists=pcall(UnitExists,unit)
if not existsOk then return nil,'api-error' end
if not self:CanReadValue(exists) then return nil,'restricted-value' end
if exists==nil then return nil,'unit-data-unavailable' end
if type(exists)~='boolean' then return nil,'invalid-api-result' end
if not exists then return {active=false} end
local fn
if kind=='cast' then fn=UnitCastingInfo else fn=UnitChannelInfo end
if type(fn)~='function' then return nil,'missing-api' end
-- Capture into an owned tuple table without comparing native values. The
-- channel flag is slot7; casting includes castID and uses slot8 instead,
-- so the spell ID is slot9 for a cast and slot8 for a channel.
local ok,tuple=pcall(function() return {fn(unit)} end)
if not ok then return nil,'api-error' end
local name=tuple[1]
local record
if not self:CanReadValue(name) then
-- Retail and Forever make cast fields secret for a unit other than the
-- player or pet unless the spell is flagged never secret
-- (SecretWhenUnitSpellCastRestricted). A secret is a value, never nil:
-- the unit is casting, and only the name is hidden.
record={active=true,nameReason='restricted-value'}
else
if name==nil then return {active=false} end
if type(name)~='string' or name=='' then return nil,'invalid-api-result' end
record={active=true,name=name}
end
record.remainingSeconds,record.remainingReason=remainingSeconds(tuple[5])
record.durationSeconds,record.durationReason=durationSeconds(tuple[4],tuple[5])
record.interruptible,record.interruptibleReason=interruptibility(tuple[kind=='cast' and 8 or 7])
record.spellID,record.spellReason=spellIdentity(tuple[kind=='cast' and 9 or 8])
return record




