local base = require("Battle/Logic/AI/Decision/Decision_Base") local Decision_Idle = class("Decision_Idle", base) local Const_DecisionIdle_Time = "LockIdleTime" --[[ 初始化 --]] function Decision_Idle:initialize(entity) --类型 self.Type = LuaConst.DecisionType.Idle --瞬时 self.IsOnce = false end function Decision_Idle:DecisionIn(entity, decisionData) if decisionData.IntParam2 > 0 then local aiBaseComponent = entity.components.aiBase aiBaseComponent:SetDecisionRecord(decisionData,Const_DecisionIdle_Time,LogicUpdateManager._clientHandleFrame) end end function Decision_Idle:SetCommand(entity, decisionData, command) if decisionData.IntParam1 == 0 then local comp_Target = entity.components.target if comp_Target and comp_Target.Target then command.RotateDir:Reset(comp_Target.ToTargetDir) end end return command end --[[ 能否退出 --]] function Decision_Idle:CanExit(entity, decisionData, command) if decisionData.IntParam2 == 0 then return true elseif decisionData.IntParam2 < 0 then return false end local aiBaseComponent = entity.components.aiBase local lastInTimeFrame = aiBaseComponent:GetDecisionRecord(decisionData,Const_DecisionIdle_Time) if lastInTimeFrame == nil then return false end if (LogicUpdateManager._clientHandleFrame - lastInTimeFrame) >= decisionData.IntParam2 * LuaConst.LogicFrameRate then return true end return false end return Decision_Idle