2025-01-04 23:00:19 +08:00

82 lines
3.1 KiB
Lua

---@class BP_Launch_C:BP_PlaceItemBase_C
---@field TriggerBox UStaticMeshComponent
---@field P_bounce UParticleSystemComponent
---@field TriggerBoxOld UBoxComponent
---@field Cube UStaticMeshComponent
---@field Scene USceneComponent
---@field ZSpeed FVector
---@field CDTime float
---@field IsAddBuff bool
---@field IsActivate bool
---@field DisableFaillingTime int32
---@field BouncingSound UAkEventObject
--Edit Below--
---@type Launch_C
local BP_Launch = {}
function BP_Launch:ReceiveBeginPlay()
self.SuperClass.ReceiveBeginPlay(self);
UGCLogSystem.Log("[BP_Launch_ReceiveBeginPlay]")
self.Jumpers = {}
self.SaveTime = 0
if self:HasAuthority() then
UGCLogSystem.Log("[BP_Launch_ReceiveBeginPlay] 2")
UGCSystemLibrary.BindBeginOverlapFunc(self.TriggerBox, self.OnBeginOverlap, self)
-- UGCSystemLibrary.BindEndOverlapFunc(self.TriggerBox, self.OnEndOverlap, self)
--self.TriggerBox.OnComponentBeginOverlap:Add(self.OnBeginOverlap, self)
--self.TriggerBox.OnComponentEndOverlap:Add(self.OnEndOverlap, self)
end
end
function BP_Launch:OnBeginOverlap(OverlappedComp, Other, OtherComp, OtherBodyIndex, bFromSweep, SweepResult)
UGCLogSystem.Log("[BP_Launch_OnBeginOverlap]")
local GameState = GameplayStatics.GetGameState(self)
local CurrentServerWorldTimeSeconds = GameState:GetServerWorldTimeSeconds()
local AddSpeed = 0
local Character = Other.PlayerState:GetPlayerCharacter()
if(self.IsActivate) then
if(Character.CanJump) then
table.insert(self.Jumpers, Other)
end
if(CurrentServerWorldTimeSeconds - self.SaveTime >= self.CDTime) then
self.SaveTime = CurrentServerWorldTimeSeconds
for i = 1, #self.Jumpers, 1 do
local PlayerCharacter = self.Jumpers[i].PlayerState:GetPlayerCharacter()
if(self.IsAddBuff) then
PlayerCharacter:DisableFallingDamageForPerioud(self.DisableFaillingTime)
end
--考虑角色跳起来的情况
if PlayerCharacter.CharacterMovement.Velocity.Z < 0 then
AddSpeed = Vector.New(0, 0, self.ZSpeed.Z - PlayerCharacter.CharacterMovement.Velocity.Z)
self.Jumpers[i].CharacterMovement:AddImpulse(AddSpeed, true)
elseif PlayerCharacter.CharacterMovement.Velocity.Z == 0 then
self.Jumpers[i].CharacterMovement:AddImpulse(self.ZSpeed, true)
end
UnrealNetwork.CallUnrealRPC_Multicast(self, "PlayDisappear")
end
end
table.remove(self.Jumpers)
end
end
function BP_Launch:PlayDisappear()
UGCLogSystem.Log("[BP_Launch_PlayDisappear]")
local MyLocation = self.TriggerBox:K2_GetComponentLocation()
self.P_bounce:SetActive(true, true)
UGCSoundManagerSystem.PlaySoundAtLocation(self.BouncingSound, MyLocation)
end
function BP_Launch:ReceiveEndPlay()
UGCLogSystem.Log("[BP_Launch_ReceiveEndPlay]")
if self:HasAuthority() then
self.TriggerBox.OnComponentBeginOverlap:Remove(self.OnBeginOverlap, self)
end
end
return BP_Launch;