---@class BP_DisappearFloor_C:AActor ---@field PuParticle UParticleSystemComponent ---@field TriggerBox UStaticMeshComponent ---@field WillHideParticle UParticleSystemComponent ---@field Floor UStaticMeshComponent ---@field Scene USceneComponent ---@field IsActivate bool ---@field DefaultColor FLinearColor ---@field TargetColor FLinearColor ---@field DelayHideTime float ---@field ResetFloorTime float ---@field BouncingSound UAkAudioEvent --Edit Below-- ---@type Launch_C local BP_DisappearFloor = { IsLockActivate = false; FloorID = -1; }; function BP_DisappearFloor:ReceiveBeginPlay() BP_DisappearFloor.SuperClass.ReceiveBeginPlay(self) if self:HasAuthority() then UGCSystemLibrary.BindBeginOverlapFunc(self.TriggerBox, self.OnBeginOverlap, self) else self.FloorMaterialInterface = self.Floor:GetMaterial(0) self.DynamicMat = KismetMaterialLibrary.CreateDynamicMaterialInstance(self, self.FloorMaterialInterface); self.Floor:SetMaterial(0, self.DynamicMat) self.DynamicMat:SetVectorParameterValue("Color_Modifier", self.DefaultColor) self.WillHideParticle:SetFloatParameter("ParticleLifeTime", 2) end end function BP_DisappearFloor:SetID(NewID) self.FloorID = NewID end function BP_DisappearFloor:SetIsActivate(InIsActivate, LockOrUnLock) if LockOrUnLock then if InIsActivate then self.IsLockActivate = false else self.IsLockActivate = true end self.IsActivate = InIsActivate end if not self.IsLockActivate then self.IsActivate = InIsActivate end end function BP_DisappearFloor:OnBeginOverlap(OverlappedComponent, OtherActor, OtherComp, OtherBodyIndex, bFromSweep, SweepResult) if self.IsActivate then self:HideFloor(true) if self.ResetFloorHandle == nil then self:SetIsActivate(false) if self.ResetFloorTime > 0 then self.ResetFloorHandle = UGCEventSystem.SetTimer(self, self.ResetFloor, self.ResetFloorTime) end end if OtherActor.PlayerKey then UGCEventSystem.SendEvent(EventEnum.PlayerStepThroughFloor, OtherActor.PlayerKey) end end end function BP_DisappearFloor:ReceiveEndPlay() if self:HasAuthority() then self.TriggerBox.OnComponentBeginOverlap:Remove(self.OnBeginOverlap, self) if self.ResetFloorHandle then UGCEventSystem.StopTimer(self.ResetFloorHandle) self.ResetFloorHandle = nil end end end -- 设置延迟关闭地板碰撞及隐藏地板的时间 function BP_DisappearFloor:SetDelayHideTime(InDelayHideTime) self.DelayHideTime = InDelayHideTime end -- 设置重置地板的时间 function BP_DisappearFloor:SetResetFloorTime(NewTime) self.ResetFloorTime = NewTime end function BP_DisappearFloor:HideFloor(IsLaunch) UGCEventSystem.SetTimer(self, function() self:SetFloorCollisionIsEnable(false) if not UGCGameSystem.IsServer() then self:HideFloorEffect() end end, self.DelayHideTime) if UGCGameSystem.IsServer() then UGCSendRPCSystem.ActorRPCNotify(nil, self, "HideFloor", IsLaunch) else UGCSoundManagerSystem.PlaySoundAtLocation(self.BouncingSound, self:K2_GetActorLocation()) self.WillHideParticle:SetActive(true, true) self:UpdateColor(false) end end function BP_DisappearFloor:HideFloorEffect() self.Floor:SetHiddenInGame(true) self.PuParticle:SetActive(true, true) SoundSystem.PlaySound(SoundSystem.ESound.Pu, self:K2_GetActorLocation(), self:K2_GetActorRotation()) end function BP_DisappearFloor:ResetFloor() self:SetFloorCollisionIsEnable(true) if UGCGameSystem.IsServer() then self.ResetFloorHandle = nil self:SetIsActivate(true) UGCSendRPCSystem.ActorRPCNotify(nil, self, "ResetFloor") else self.Floor:SetHiddenInGame(false) self:UpdateColor(true) end end function BP_DisappearFloor:SetFloorCollisionIsEnable(bEnable) local BlockType = (bEnable and ECollisionEnabled.QueryAndPhysics or ECollisionEnabled.NoCollision) self.Floor:SetCollisionEnabled(BlockType) end function BP_DisappearFloor:UpdateColor(IsDefault) local FloorTargetColor = IsDefault and self.DefaultColor or self.TargetColor self.DynamicMat:SetVectorParameterValue("Color_Modifier", FloorTargetColor) end return BP_DisappearFloor;