UGCProjects/GZJ/Script/SimpleSkill/Selector/SimpleSkillSelector_StraightForward.lua
2025-01-08 22:46:12 +08:00

51 lines
2.2 KiB
Lua
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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;