local Base = require("Battle/Logic/AI/Decision/Decision_Base") local Decision_RunToPoint = class("Decision_RunToPoint", Base) local temp_v2 = FP.newV2(0,0) --[[ 初始化 --]] function Decision_RunToPoint:initialize(entity) --类型 self.Type = LuaConst.DecisionType.RunToPoint --瞬时 self.IsOnce = false end --[[ 进入该Decision --]] function Decision_RunToPoint:DecisionIn(entity, decisionData) local pos = FP.newV2(decisionData.IntParam1 / 10,decisionData.IntParam2 / 10) if not string.isNilOrEmpty(decisionData.StringParam1) then local minStr,maxStr = string.match(decisionData.StringParam1, "xRange%((%S*),(%S*)%)") local randomVal = LogicRandom.GetRangeValue(entity, tonumber(minStr), tonumber(maxStr) ,7022) FP.V2.Normalize(temp_v2:Reset(pos):Sub(entity:GetLogicPos())) -- 计算forward向量 local rightDir = FP.V2.GetRightByForward(temp_v2)-- 向右的向量 rightDir:Mul(randomVal) pos:Add(rightDir) FP.releaseV2(rightDir) end SystemManager.FindPath(entity, pos, true) end function Decision_RunToPoint:DecisionOut(entity, decisionData) if decisionData.IntParam3 > 0 then entity.components.patrol.ExitPatrolPoint:Reset(decisionData.IntParam1 / 10,decisionData.IntParam2 / 10) end end --[[ 能否退出 退出条件:移动到固定目标点 --]] function Decision_RunToPoint:CanExit(entity, decisionData, command) local pathComponent = entity.components.path local curPathPos = pathComponent.Path[pathComponent.CurPathPosIndex] return not curPathPos end --[[ 输出指令 --]] function Decision_RunToPoint:SetCommand(entity, decisionData, command) return self:RunToPathPoint(entity, command,decisionData) end return Decision_RunToPoint