local Base = require("Battle/Logic/AI/Decision/Decision_Base") local Decision_RunToSkillJoyEndPos = class("Decision_RunToSkillJoyEndPos", Base) local IsArrivedStr = "IsArrivedSkillJoyEndPos" --[[ 初始化 --]] function Decision_RunToSkillJoyEndPos:initialize(entity) --类型 self.Type = LuaConst.DecisionType.RunToSkillJoyEndPos --瞬时 self.IsOnce = false end function Decision_RunToSkillJoyEndPos:CanEnter(entity, decisionData, command) local aiBase = entity.components.aiBase if aiBase.CalledSkillJoystickEndPos then local isArrived = aiBase:GetDecisionRecord(decisionData, IsArrivedStr) return isArrived ~= true end return true end --[[ 能否退出 完成条件:到达CalledSkillJoystickEndPos点 --]] function Decision_RunToSkillJoyEndPos:CanExit(entity, decisionData, command) local aiBase = entity.components.aiBase if aiBase.CalledSkillJoystickEndPos then local isArrived = aiBase:GetDecisionRecord(decisionData, IsArrivedStr) return isArrived end return true end --[[ 输出指令 --]] function Decision_RunToSkillJoyEndPos:SetCommand(entity, decisionData, command) local aiBase = entity.components.aiBase if aiBase.CalledSkillJoystickEndPos then local moveComp = entity.components.move if moveComp.LogicPos == aiBase.CalledSkillJoystickEndPos then aiBase:SetDecisionRecord(decisionData, IsArrivedStr, true) return command end command.MoveDir:Reset(aiBase.CalledSkillJoystickEndPos):Sub(moveComp.LogicPos):Normalize() command.RotateDir:Reset(command.MoveDir) command.TargetPos = aiBase.CalledSkillJoystickEndPos:cloneV2() end return command end return Decision_RunToSkillJoyEndPos