72 lines
2.7 KiB
Lua
Raw Normal View History

2025-01-09 13:36:39 +08:00
---@class UGCGameState_C:BP_UGCGameState_C
--Edit Below--
UGCGameSystem.UGCRequire('Script.Common.ue_enum_custom')
UGCGameSystem.UGCRequire('Script.Global.Global')
local UGCGameState = {};
function UGCGameState:ReceiveBeginPlay()
self.IsShowDeadBox = false;
UGCEventSystem.AddListener(EventEnum.PlayerDeathInfo, self.RespawnPlayer, self)
2025-01-14 15:38:12 +08:00
if UGCGameSystem.IsServer() then
else
self:InitBulletFXPool(30)
end
2025-01-09 13:36:39 +08:00
end
function UGCGameState:RespawnPlayer(DeadPlayerKey)
UGCEventSystem.SetTimer(self, function() UGCGameSystem.RespawnPlayer(DeadPlayerKey) end, 4)
end
function UGCGameState:GetPreViewFXActor()
if not UE.IsValid(self.PreViewActor) then
self.PreViewActor = UGCSystemLibrary.GetUniqueInstanceFromPath(UGCGameSystem.GetUGCResourcesFullPath('Asset/Blueprint/SceneActor/BP_PreViewFXActor.BP_PreViewFXActor_C'))
end
return self.PreViewActor
end
function UGCGameState:SpawnParticleAtPos(Pos)
local TempPreViewActor = self:GetPreViewFXActor()
if UE.IsValid(TempPreViewActor) then
2025-02-02 16:26:56 +08:00
local KillParticle = TempPreViewActor:GetNowFXFromFXType(EFXType.Kill)
if UE.IsValid(KillParticle) then
Pos = {
X = Pos.X + TempPreViewActor.KillParticleOffsetTF.Translation.X,
Y = Pos.Y + TempPreViewActor.KillParticleOffsetTF.Translation.Y,
Z = Pos.Z + TempPreViewActor.KillParticleOffsetTF.Translation.Z,
}
local FXScale = {X = TempPreViewActor.KillParticleOffsetTF.Scale3D.X, Y = TempPreViewActor.KillParticleOffsetTF.Scale3D.Y, Z = TempPreViewActor.KillParticleOffsetTF.Scale3D.Z}
2025-02-03 23:08:27 +08:00
local KillParticleComp = GameplayStatics.SpawnEmitterAtLocation(self, KillParticle, Pos, {Roll = 0, Pitch = 0, Yaw = 0}, FXScale, true)
-- 设置颜色
TempPreViewActor:SetParticleCompColor(KillParticleComp, EFXType.Kill)
2025-02-02 16:26:56 +08:00
end
2025-01-09 13:36:39 +08:00
end
end
2025-01-14 15:38:12 +08:00
function UGCGameState:InitBulletFXPool(Count)
self.BulletFXPool = {}
self.BulletFXPoolIndex = 1;
local BulletTailFXClass = UE.LoadClass(UGCGameSystem.GetUGCResourcesFullPath('Asset/FX/BulletFX/BP_BulletTailFX.BP_BulletTailFX_C'))
for i = 1, Count do
local BulletTailFXActor = UGCGameSystem.SpawnActor(self, BulletTailFXClass, VectorHelper.VectorZero(), VectorHelper.RotZero(), VectorHelper.ScaleOne())
self.BulletFXPool[#self.BulletFXPool + 1] = BulletTailFXActor
BulletTailFXActor:StopFly()
end
end
function UGCGameState:GetBulletFXActor()
local Res = self.BulletFXPool[self.BulletFXPoolIndex]
self.BulletFXPoolIndex = (self.BulletFXPoolIndex % #self.BulletFXPool) + 1
return Res
end
2025-01-09 13:36:39 +08:00
-- function UGCGameState:ReceiveTick(DeltaTime)
-- end
-- function UGCGameState:ReceiveEndPlay()
-- end
return UGCGameState;