78 lines
3.0 KiB
Lua
78 lines
3.0 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);
|
||
|
self.Jumpers = {}
|
||
|
self.SaveTime = 0
|
||
|
if self:HasAuthority() then
|
||
|
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)
|
||
|
sandbox.LogNormalDev(StringFormat_Dev("[BP_Launch:OnBeginOverlap] self=%s", GetObjectFullName_Dev(self)))
|
||
|
|
||
|
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()
|
||
|
sandbox.LogNormalDev("[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()
|
||
|
sandbox.LogNormalDev("[BP_Launch:ReceiveEndPlay]")
|
||
|
if self:HasAuthority() then
|
||
|
self.TriggerBox.OnComponentBeginOverlap:Remove(self.OnBeginOverlap, self)
|
||
|
self.TriggerBox.OnComponentEndOverlap:Remove(self.OnEndOverlap, self)
|
||
|
end
|
||
|
end
|
||
|
return BP_Launch;
|