local Base = require("Battle/Logic/AI/Decision/Decision_Base") local Decision_PatrolOnPath = class("Decision_PatrolOnPath", Base) local private = {} --[[ 初始化 --]] function Decision_PatrolOnPath:initialize(entity) --类型 self.Type = LuaConst.DecisionType.PatrolOnPath --瞬时 self.IsOnce = false end --[[ 进入该Decision --]] function Decision_PatrolOnPath:DecisionIn(entity, decisionData) local patrolComponent = entity.components.patrol if decisionData.StringParam1 ~= "true" then patrolComponent.CurPatrolPathIndex = 1 end patrolComponent.IsPatrolForward = true local path local isBloc if decisionData.IntParam3 == 1 then local characterData = entity.components.base.CurCharacterData if entity:IsMonster() then if characterData.PatrolType == LuaConst.PatrolType.PatrolOnPath then isBloc = 0 path = characterData.PatrolParam else logging.error(LTAG.ERROR, "HYW : 怪物 : ", entity:GetCharacterID(), " 的PatrolType不为2,无法执行PatrolOnPath Decision! decisionData ID : ", decisionData.ID) end elseif entity:GetCharacterType() == LuaConst.CharacterType.NPC then isBloc = characterData.PatrolParam path = characterData.PatrolPath else logging.error(LTAG.ERROR, "HYW : Decision配置错误!目前只有Monster和NPC支持PatrolOnPath! decisionData ID : ", decisionData.ID, " CharacterType : ", entity:GetCharacterType(), " CharacterID : ", entity:GetCharacterID()) end else path = decisionData.IntParam2 end local decisionRecordDic = entity.components.aiBase:GetDecisionRecordDic(decisionData) decisionRecordDic.path = path decisionRecordDic.isBloc = isBloc if decisionData.IntParam4 and decisionData.IntParam4 > 0 then decisionRecordDic.skillIndex = decisionData.IntParam4 end end --[[ 能否退出 --]] function Decision_PatrolOnPath:CanExit(entity, decisionData, command) local decisionRecordDic = entity.components.aiBase:GetDecisionRecordDic(decisionData) if decisionRecordDic.path then local pathType = LevelItemManager.GetPathType(decisionData.IntParam2) if pathType == LuaConst.WalkPathType.Once then local patrolComponent = entity.components.patrol local curPoint = LevelItemManager.GetPathPoint(decisionData.IntParam2, patrolComponent.CurPatrolPathIndex) return curPoint == nil else return false end else return true end end --[[ 输出指令 --]] function Decision_PatrolOnPath:SetCommand(entity, decisionData, command) local decisionRecordDic = entity.components.aiBase:GetDecisionRecordDic(decisionData) if decisionRecordDic.path then local decisionRecordDic = entity.components.aiBase:GetDecisionRecordDic(decisionData) if decisionRecordDic.skillIndex then command.SkillIndex = decisionRecordDic.skillIndex end return self:PatrolOnPath(entity, command, decisionRecordDic.isBloc, decisionRecordDic.path) else return command end end return Decision_PatrolOnPath