local FuncNode_DistanceToPoint = class("FuncNode_DistanceToPoint") --[[ 初始化 --]] function FuncNode_DistanceToPoint:initialize(entity) self.LimitChildCount = 3 self.Type = LuaConst.ConditionFuncType.DistanceToPoint end --[[ 执行 --]] function FuncNode_DistanceToPoint:Run(conditionDataNode, entity, missile) local startType = conditionDataNode.FirstNode:Run(entity, missile) local targetX = conditionDataNode.SecondNode:Run(entity, missile) local targetZ = conditionDataNode.ThirdNode:Run(entity, missile) local startPos = nil if startType == FP.Const.Zero then --自己作为起点 startPos = entity.components.move.LogicPos:cloneV2() elseif startType == FP.Const.One then --目标作为起点 startPos = entity.components.target.Target.components.move.LogicPos:cloneV2() end local result = FP.Const.Max if startPos then local targetPos = FP.newV2(targetX, targetZ) result = FP.V2.DistanceSqr(startPos,targetPos) FP.releaseV2(targetPos) FP.releaseV2(startPos) else logging.error(LTAG.ERROR, "HYW : FuncNode_DistanceToPoint起点异常,起点类型 : ",startType) end return result end return FuncNode_DistanceToPoint