local Base = require("Battle/Logic/AI/Decision/Decision_Base") local Decision_Convey = class("Decision_Convey", Base) --[[ 初始化 --]] function Decision_Convey:initialize(entity) --类型 self.Type = LuaConst.DecisionType.Convey --瞬时 self.IsOnce = true end --[[ 输出指令 --]] function Decision_Convey:SetCommand(entity, decisionData, command) command.DecisionID = decisionData.ID return command end local ETargetType = { TARGET = 0, FOLLOW_TARGET = 1, POS = 2, } --[[ 执行 --]] function Decision_Convey:Handle(entity, decisionData, stateType, animName) local targetType = decisionData.IntParam1 local pos = FP.newV2(decisionData.IntParam2 / 10,decisionData.IntParam3 / 10) local forward = nil if targetType == ETargetType.TARGET then if entity.components.target.Target then pos:Add(entity.components.target.Target.components.move.LogicPos) forward = entity.components.target.Target.components.move.LogicRotateDir else pos = nil end elseif targetType == ETargetType.FOLLOW_TARGET then if entity.components.target.FollowTarget then pos:Add(entity.components.target.FollowTarget.components.move.LogicPos) forward = entity.components.target.FollowTarget.components.move.LogicRotateDir else pos = nil end elseif targetType == ETargetType.POS then if decisionData.IntParam4 == 0 then forward = FP.Const.Vector2_Forward else local rad = (90 - decisionData.IntParam4) * FP.Const.Deg2Rad --策划要求decisionData.IntParam4跟GameObject的Y值一致, 所以这里得用 90-decisionData.IntParam4 forward = FP.newV2(FP.Math.Cos(rad), FP.Math.Sin(rad)) end end if pos then SystemManager.OnConvey(entity, pos, forward, true) end return LuaConst.StateType.None, nil end return Decision_Convey