Files
Cielonos/Assets/Scripts/MainGame/Base/FunctionalAnimation/Payloads/SpawnVFX.cs

39 lines
1.1 KiB
C#
Raw Normal View History

2025-12-23 19:47:06 -05:00
using System;
2026-06-05 04:21:00 -04:00
using Cielonos.MainGame.Interactions;
2025-12-17 04:19:38 -05:00
using SLSUtilities.FunctionalAnimation;
using UnityEngine;
namespace Cielonos.MainGame.FunctionalAnimation
{
2025-12-23 19:47:06 -05:00
[Serializable]
2025-12-17 04:19:38 -05:00
public class SpawnVFX : FuncAnimPayloadBase
{
public string vfxKey = "VFXKey";
public override void Invoke()
{
2026-04-18 13:57:19 -04:00
if (mute) return;
2026-06-05 04:21:00 -04:00
VFXData vfxData = null;
2026-04-18 13:57:19 -04:00
2026-06-05 04:21:00 -04:00
if (Character != null) // 战斗角色分支
{
vfxData = Character.vfxData;
}
else if (Executor is NpcBase npc) // NPC 分支
{
vfxData = npc.vfxData;
}
if (vfxData != null)
2025-12-17 04:19:38 -05:00
{
2026-06-05 04:21:00 -04:00
//如果非战斗角色Character就是null通过 Executor 来获取 Transform 以正确生成 VFX
VFXObject vfxObject = vfxData.SpawnVFX(vfxKey, Character, Executor.Transform).GetComponent<VFXObject>();
if (vfxObject != null && Character != null)
{
vfxObject.SetCreator(Character);
}
2025-12-17 04:19:38 -05:00
}
}
}
}