---@class BP_BuffPickUp_C:AActor ---@field ParticleSystem UParticleSystemComponent ---@field DynamicTextRender UDynamicTextRenderComponent ---@field Sphere USphereComponent ---@field DefaultSceneRoot USceneComponent ---@field CoolingTime float ---@field BuffType TEnumAsByte ---@field PickUpSound UAkAudioEvent --Edit Below-- local BP_BuffPickUp = { bIsActive = true; LastBuffType = 0; }; function BP_BuffPickUp:ReceiveBeginPlay() self.SuperClass.ReceiveBeginPlay(self); if UGCGameSystem.IsServer() then UGCSystemLibrary.BindBeginOverlapFunc(self.Sphere, self.PlayerAddBuff, self) else self:UpdateBuffTemplate() end end function BP_BuffPickUp:SetBuffType(NewBuffType) if table.hasValue(BuffEnum, NewBuffType) then self.BuffType = NewBuffType return true end return false end function BP_BuffPickUp:SetCoolingTime(NewCoolingTime) if NewCoolingTime > 0 then self.CoolingTime = NewCoolingTime else self.CoolingTime = 0 end end function BP_BuffPickUp:OnRep_BuffType() self:UpdateBuffTemplate() end function BP_BuffPickUp:UpdateBuffTemplate() if self.BuffType ~= self.LastBuffType then UGCLogSystem.Log("[BP_BuffPickUp_UpdateBuffTemplate]") self.LastBuffType = self.BuffType local ParticleTemplate = UE.LoadObject(BuffConfig.BuffInfo[self.BuffType].ParticlePath) self.ParticleSystem:SetTemplate(ParticleTemplate) UGCLogSystem.Log("[BP_BuffPickUp_UpdateBuffTemplate] Finish") end end function BP_BuffPickUp:PlayerAddBuff(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult) if self.bIsActive and UE.IsValid(OtherActor) then self:SetIsActive(false) UGCLogSystem.Log("[BP_BuffPickUp_PlayerAddBuff] BuffType:%s, BuffName:%s", tostring(self.BuffType), BuffConfig.BuffInfo[self.BuffType].BuffName) OtherActor:AddBuff(BuffConfig.BuffInfo[self.BuffType].BuffName, nil, 1) UGCSendRPCSystem.ActorRPCNotify(nil, self, "UpdateActiveEffect", self.bIsActive, OtherActor.PlayerKey) self.CoolingHandle = UGCEventSystem.SetTimer(self, function() self:SetIsActive(true) UGCSendRPCSystem.ActorRPCNotify(nil, self, "UpdateActiveEffect", self.bIsActive) self.CoolingHandle = nil end, self.CoolingTime) end end function BP_BuffPickUp:SetIsActive(NewIsActive) if self.bIsActive ~= NewIsActive then self.bIsActive = NewIsActive end end function BP_BuffPickUp:UpdateActiveEffect(NewIsActive, PlayerKey) self.ParticleSystem:SetHiddenInGame(not NewIsActive) if PlayerKey == UGCSystemLibrary.GetLocalPlayerKey() then UGCSoundManagerSystem.PlaySound2D(self.PickUpSound) end end --[[ function BP_BuffPickUp:ReceiveTick(DeltaTime) self.SuperClass.ReceiveTick(self, DeltaTime); end --]] function BP_BuffPickUp:ReceiveEndPlay() if self.CoolingHandle then UGCEventSystem.StopTimer(self.CoolingHandle) self.CoolingHandle = nil end self.SuperClass.ReceiveEndPlay(self); end --[[ function BP_BuffPickUp:GetReplicatedProperties() return end --]] --[[ function BP_BuffPickUp:GetAvailableServerRPCs() return end --]] return BP_BuffPickUp;