local FuncNode_Distance = class("FuncNode_Distance") local RetinueSystem = require"Battle/Logic/Entity/System/RetinueSystem" --[[ 初始化 --]] function FuncNode_Distance:initialize(entity) self.LimitChildCount = 2 self.Type = LuaConst.ConditionFuncType.Distance end function FuncNode_Distance:GetPosByType(posType, entity) if posType == FP.Const.Zero then return entity:GetLogicPos() elseif posType == FP.Const.One then return entity.components.target.Target and entity.components.target.Target:GetLogicPos() elseif posType == FP.Const.Two then logging.error(LTAG.ERROR, "HYW : 暂不支持的类型 @FuncNode_Distance 请联系战斗程序添加 posType : ", posType) elseif posType == FP.Const.Three then logging.error(LTAG.ERROR, "HYW : 暂不支持的类型 @FuncNode_Distance 请联系战斗程序添加 posType : ", posType) elseif posType == FP.Const.Four then logging.error(LTAG.ERROR, "HYW : 暂不支持的类型 @FuncNode_Distance 请联系战斗程序添加 posType : ", posType) elseif posType == FP.Const.Five then logging.error(LTAG.ERROR, "HYW : 暂不支持的类型 @FuncNode_Distance 请联系战斗程序添加 posType : ", posType) elseif posType == FP.Const.Six then return entity.components.target.FollowTarget and entity.components.target.FollowTarget:GetLogicPos() elseif posType == FP.Const.Seven then return entity:GetMasterEntity() and entity:GetMasterEntity():GetLogicPos() elseif posType == FP.Const.Eight then return RetinueSystem.GetRetinueFollowPos(entity) end end --[[ 执行 --]] function FuncNode_Distance:Run(conditionDataNode, entity, missile) local startType = conditionDataNode.FirstNode:Run(entity, missile) local endType = conditionDataNode.SecondNode:Run(entity, missile) --到目标的距离 if startType == FP.Const.Zero and endType == FP.Const.One or startType == FP.Const.One and endType == FP.Const.Zero then return entity.components.target.ToTargetDisSqr end --到群组领袖的距离 if startType == FP.Const.Zero and endType == FP.Const.Four or startType == FP.Const.Four and endType == FP.Const.Zero then return entity.components.group.ToLeaderDisSqr end --到跟随目标的距离 if startType == FP.Const.Zero and endType == FP.Const.Six or startType == FP.Const.Six and endType == FP.Const.Zero then return entity.components.target.ToFollowTargetDisSqr end if startType == FP.Const.Zero and endType == FP.Const.Seven then if entity:GetMasterEntity() then return entity:GetLogicPos():DistanceSqr(entity:GetMasterEntity():GetLogicPos()) end end local startPos = self:GetPosByType(startType, entity) if startPos then local endPos = self:GetPosByType(endType, entity) if endPos then return (endPos - startPos):SqrMagnitude() end end return FP.Const.Zero end return FuncNode_Distance