Skip to main content

getTargetMaxThreat 获取目标角色 - 最大仇恨值

getTargetMaxThreat

类型: MethodDeclaration

所属类: TargetManager

定义位置: actor.ts

描述

获取目标角色 - 最大仇恨值

参数 selector: 目标角色选择器

返回值:目标池中符合条件的角色实例

参数

参数名类型描述默认值
selectorActorSelector--

返回值

类型: Actor \| undefined

目标池中符合条件的角色实例

源代码

位置: 第 5263 行

public getTargetMaxThreat(selector: ActorSelector): Actor | undefined {
let target: Actor | undefined
let weight = -1
const inspector = Actor.inspectors[selector]
const owner = this.actor
const targets = this.targets
const threats = this.threats
const length = targets.length
for (let i = 0; i < length; i++) {
const actor = targets[i]
// 检查角色关系,并找出最大仇恨值的目标
if (inspector(owner, actor)) {
const threat = threats[i]
if (threat > weight) {
target = actor
weight = threat
}
}
}
return target
}

文档生成时间:2025/7/7 12:07:06