51 lines
2.2 KiB
Lua
51 lines
2.2 KiB
Lua
|
local SimpleSkillSelector = require("Script.SimpleSkill.Selector.SimpleSkillSelector")
|
|||
|
local SimpleSkillSelector_Straightforward = LuaClass("SimpleSkillSelector_Straightforward", SimpleSkillSelector)
|
|||
|
|
|||
|
function SimpleSkillSelector_Straightforward:ctor()
|
|||
|
SimpleSkillSelector_Straightforward.super.ctor(self)
|
|||
|
end
|
|||
|
|
|||
|
function SimpleSkillSelector_Straightforward:InitSelectorFromData(SelectorData, CasterPawn)
|
|||
|
SimpleSkillSelector.InitSelectorFromData(self, SelectorData, CasterPawn)
|
|||
|
self.ForwardOffset = self.ForwardOffset > 0.001 and self.ForwardOffset or 1 --此时ForwardOffset为碰撞盒前向偏移的系数,必须为1以上
|
|||
|
end
|
|||
|
|
|||
|
--- 子类实现
|
|||
|
function SimpleSkillSelector_Straightforward:ActivateSelector()
|
|||
|
SimpleSkillSelector.ActivateSelector(self)
|
|||
|
|
|||
|
|
|||
|
|
|||
|
self:GetPawnsInRectangle()
|
|||
|
end
|
|||
|
|
|||
|
function SimpleSkillSelector_Straightforward:GetPawnsInRectangle()
|
|||
|
local Length = self.Param_Vector.X
|
|||
|
local Width = self.Param_Vector.Y
|
|||
|
local Height = self.Param_Vector.Z
|
|||
|
|
|||
|
local Forward = self.CasterPawn:GetActorForwardVector()
|
|||
|
local BoxLoc = VectorHelper.Add(self.CasterPawn:K2_GetActorLocation(), VectorHelper.MulNumber(KismetMathLibrary.Normal(Forward), Length / 2 * self.ForwardOffset))
|
|||
|
|
|||
|
local CasterRotation = self.CasterPawn:K2_GetActorRotation()
|
|||
|
local BoxRotation = {Yaw = CasterRotation.Yaw, Pitch = CasterRotation.Pitch, Roll = CasterRotation.Roll}
|
|||
|
local BoxExtent = {X = Length/2, Y = Width/2, Z = Height/2}
|
|||
|
|
|||
|
local ObjectTypes = {}
|
|||
|
local ActorClassFilter = UE.LoadClass(BPClassPath.MonsterBase)
|
|||
|
local ActorsToIgnore = self:GetIgnoredActors()
|
|||
|
local RetVal, OutActors = KismetSystemLibrary.BoxOverlapActors(self.CasterPawn, BoxLoc, BoxRotation, BoxExtent, ObjectTypes, ActorClassFilter, ActorsToIgnore)
|
|||
|
|
|||
|
if GlobalConfigs.OpenDebug then
|
|||
|
UnrealNetwork.CallUnrealRPC_Multicast(self.CasterPawn , "DrawDebugBox" , VectorHelper.ToLuaTable(BoxLoc), BoxExtent, {1,0,0,1}, BoxRotation)
|
|||
|
end
|
|||
|
|
|||
|
if RetVal then
|
|||
|
local RetLimitNum = self.LimitNum > 0 and (self.LimitNum > #OutActors and #OutActors or self.LimitNum) or #OutActors
|
|||
|
for i = 1, RetLimitNum, 1 do
|
|||
|
table.insert(self.TargetPawns, OutActors[i])
|
|||
|
end
|
|||
|
end
|
|||
|
end
|
|||
|
|
|||
|
return SimpleSkillSelector_Straightforward;
|