2025-02-03 23:08:27 +08:00

155 lines
4.2 KiB
Lua

---@class BP_PreViewFXActor_C:AActor
---@field DynamicTextRender UDynamicTextRenderComponent
---@field DefaultSceneRoot USceneComponent
---@field DefaultFX TMap:TEnumAsByte<EFXType>,UParticleSystem
---@field KillParticleOffsetTF FTransform
--Edit Below--
local BP_PreViewFXActor = {
FXTable = {};
FXIDList = {};
OverrideColor = {};
NowFXIndex = {};
}
function BP_PreViewFXActor:ReceiveBeginPlay()
BP_PreViewFXActor.SuperClass.ReceiveBeginPlay(self)
if UGCGameSystem.IsServer() then
else
--self.DefaultFX = {
-- [EFXType.Muzzle] = self.MuzzleParticle;
-- [EFXType.Kill] = self.KillParticle;
-- [EFXType.Bullet] = self.BulletParticle;
-- [EFXType.MuzzleTailed] = self.TailedMuzzle;
-- [EFXType.Hit] = self.HitParticle;
--}
self:InitFXTable()
end
end
--[[
FFXData
ID int32
FXType EFXType
Rarity int32
Name FString
Desc FString
Particle UParticleSystem
ColorValue float[]
BaseColor FLinearColor
]]
function BP_PreViewFXActor:InitFXTable()
for i, v in pairs(EFXType) do
self.FXIDList[v] = {}
self.NowFXIndex[v] = 0
end
local ReadFXTable = UGCSystemLibrary.GetDataTableFromPath(UGCGameSystem.GetUGCResourcesFullPath('Asset/FX/A_Table/Table_FXData.Table_FXData'))
self.FXTable = table.DeepCopy(ReadFXTable)
for i, v in pairs(self.FXTable) do
UGCLogSystem.Log("[BP_PreViewFXActor_LoadFXTable] Key:%s", tostring(i))
table.insert(self.FXIDList[v.FXType], v.ID)
end
for i, v in pairs(self.FXIDList) do
table.sort(self.FXIDList[i])
end
end
function BP_PreViewFXActor:GetParticleColor(FXType)
return self.OverrideColor[FXType]
end
function BP_PreViewFXActor:GetParticleDefaultColor(FXType)
local FXIndex = self:GetNowFXIndex(FXType)
local FXID = self.FXIDList[FXType][FXIndex]
if FXID then
return self.FXTable[FXID].BaseColor
end
return nil
end
function BP_PreViewFXActor:GetColorValue(FXType)
local FXIndex = self:GetNowFXIndex(FXType)
local FXID = self.FXIDList[FXType][FXIndex]
if FXID then
return self.FXTable[FXID].ColorValue
end
return {}
end
--- 覆盖对应特效的颜色
---@param FXType EFXType
---@param NewColor FLinearColor 为nil则重置为默认颜色
function BP_PreViewFXActor:SetOverrideColor(FXType, NewColor)
---@field SetColorParameter:fun(ParameterName:FName,param:FLinearColor)
---@field SetVectorParameter:fun(ParameterName:FName,param:FVector)
self.OverrideColor[FXType] = NewColor
UGCEventSystem.SendEvent(EventEnum.OverrideFXColor, FXType, self.OverrideColor[FXType])
end
function BP_PreViewFXActor:GetNowFXIndex(FXType)
return self.NowFXIndex[FXType]
end
function BP_PreViewFXActor:GetNowFXFromFXType(FXType)
local FXIndex = self:GetNowFXIndex(FXType)
local FXID = self.FXIDList[FXType][FXIndex]
if FXID then
return self.FXTable[FXID].Particle
else
return self.DefaultFX[FXType]
end
end
function BP_PreViewFXActor:SetNextFX(FXType)
if #self.FXIDList[FXType] > 0 then
self.NowFXIndex[FXType] = (self.NowFXIndex[FXType] % #self.FXIDList[FXType]) + 1
UGCEventSystem.SendEvent(EventEnum.ChangeFX, FXType)
end
end
function BP_PreViewFXActor:SetParticleCompColor(ParticleComp, FXType)
if UE.IsValid(ParticleComp) then
local ColorValue = self:GetColorValue(FXType)
local Color = self:GetParticleColor(FXType)
if Color == nil then
Color = self:GetParticleDefaultColor(FXType)
end
for i, v in pairs(ColorValue) do
local TempColor = table.DeepCopy(UE.ToTable(Color))
local ColorVector = KismetMathLibrary.Conv_LinearColorToVector(TempColor)
ColorVector = VectorHelper.MulNumber(ColorVector, v)
ParticleComp:SetVectorParameter("Color" .. i, ColorVector)
end
end
end
--[[
function BP_PreViewFXActor:ReceiveTick(DeltaTime)
BP_PreViewFXActor.SuperClass.ReceiveTick(self, DeltaTime)
end
--]]
--[[
function BP_PreViewFXActor:ReceiveEndPlay()
BP_PreViewFXActor.SuperClass.ReceiveEndPlay(self)
end
--]]
--[[
function BP_PreViewFXActor:GetReplicatedProperties()
return
end
--]]
--[[
function BP_PreViewFXActor:GetAvailableServerRPCs()
return
end
--]]
return BP_PreViewFXActor