local Base = require("Battle/Logic/AI/Decision/Decision_Base") local Decision_WanderToTarget = class("Decision_WanderToTarget", Base) --[[ 初始化 --]] function Decision_WanderToTarget:initialize(entity) --类型 self.Type = LuaConst.DecisionType.WanderToTarget --瞬时 self.IsOnce = false end --[[ 能否退出 退出条件:一定距离之内 --]] function Decision_WanderToTarget:CanExit(entity, decisionData, command) local targetComponent = entity.components.target if targetComponent.Target then return targetComponent.ToTargetDisSqr <= decisionData.IntParam1 * decisionData.IntParam1 else return true end end --[[ 输出指令 --]] function Decision_WanderToTarget:SetCommand(entity, decisionData, command) command.DecisionID = decisionData.ID --始终朝向目标 local target = entity.components.target.target if target then local dir = target.components.move.LogicPos - entity.components.move.LogicPos command.RotateDir:Reset(dir) FP.releaseV2(dir) end return command end --[[ 执行 --]] function Decision_WanderToTarget:Handle(entity, decisionData, stateType, animName) local animComponent = entity.components.anim animName = "walk_front_loop" if animComponent.CurAnimID ~= animName or animComponent.IsCurAnimOver then return LuaConst.StateType.Wander, animName end return LuaConst.StateType.None, nil end return Decision_WanderToTarget