local base = require("Battle/Logic/AI/Decision/Decision_Base") local Decision_RunFleeTarget = class("Decision_RunFleeTarget", base) --[[ 初始化 --]] function Decision_RunFleeTarget:initialize(entity) --类型 self.Type = LuaConst.DecisionType.RunFleeTarget --瞬时 self.IsOnce = false end --TODO AI改成Update模式 --[[ 能否退出 完成条件:时间到 --]] function Decision_RunFleeTarget:CanExit(entity, decisionData, command) local comp_Buff = entity.components.buff local comp_AIBase = entity.components.aiBase if not comp_Buff:CheckHasBuffState(LuaConst.SpecialBuffs.CanMove) or not comp_Buff:CheckHasBuffState(LuaConst.SpecialBuffs.CanRotate) then comp_AIBase.CurDecisionStartFrame = LogicUpdateManager._clientHandleFrame return false end local comp_Move = entity.components.move if not comp_Move.TempDir then comp_Move.TempDir = - comp_Move.LogicRotateDir end local passFrame = LogicUpdateManager._clientHandleFrame - comp_AIBase.CurDecisionStartFrame local passTime = passFrame * LuaConst.TimeSpanMs if passTime > decisionData.IntParam1 * 1000 then comp_Move.TempDir = nil return true end return false end function Decision_RunFleeTarget:DecisionIn(entity, decisionData) base.DecisionIn(self, entity, decisionData) entity.components.aiBase:SetIsRouting(true) --设置溃散标记 end --[[ 输出指令 --]] function Decision_RunFleeTarget:SetCommand(entity, decisionData, command) local target = entity.components.target.Target if target then command.MoveDir = entity.components.move.LogicPos - target.components.move.LogicPos command.RotateDir:Reset(command.MoveDir) else if entity.components.move.TempDir then command.MoveDir:Reset(entity.components.move.TempDir) else command.MoveDir:Reset(entity.components.move.LogicRotateDir) end command.RotateDir:Reset(command.MoveDir) end return command end return Decision_RunFleeTarget