Add more gfx and hook logic for gfx(KK only)

This commit is contained in:
Tran Hai Nam
2026-05-13 17:27:47 +07:00
parent d5ba997382
commit 1fe7df6c24
72 changed files with 602106 additions and 17 deletions
+38 -4
View File
@@ -84,6 +84,8 @@ public class GFX_BINDING : FX_BINDING_BASE
public bool isStartPlaying = false;
private ParticleSystem _ps;
bool _destroyScheduled;
/// <summary>Prefab baseline local rotation (before event euler). Keeps correct orientation after reparent to hook. / 预制体基准本地旋转(事件欧拉之前),重挂到挂点后仍保持正确朝向</summary>
Quaternion _prefabLocalRot = Quaternion.identity;
public GFX_BINDING(A3DCombActDynData pDynData) : base(pDynData)
{
@@ -150,10 +152,38 @@ public class GFX_BINDING : FX_BINDING_BASE
return false;
return _ps == null || !_ps.isPlaying;
}
public override void Render() {
m_pGfx.SetActive(true);
m_pGfx.transform.localPosition = Vector3.zero;
public override void Render() {
if (m_pGfx == null)
return;
CECModel host = GetDynData()?.GetHostModel();
if (m_pInfo is FX_BASE_INFO fx && host != null)
{
Transform hookT = null;
if (!string.IsNullOrEmpty(fx.m_strHookName))
{
hookT = host.GetHook(fx.m_strHookName, true);
Debug.Log("GFX_BINDING Render: " + fx.m_strHookName + " " + hookT.name);
#if UNITY_EDITOR
if (hookT == null)
BMLogger.LogWarning($"[GFX_BINDING.Render] Hook '{fx.m_strHookName}' not found; GFX stays on character root.");
#endif
}
if (hookT != null)
m_pGfx.transform.SetParent(hookT, false);
m_pGfx.transform.localPosition = EC_Utility.ToVector3(fx.m_vOffset);
m_pGfx.transform.localRotation = _prefabLocalRot * Quaternion.Euler(fx.m_fPitch, fx.m_fYaw, fx.m_fRot);
}
else
{
m_pGfx.transform.localPosition = Vector3.zero;
m_pGfx.transform.localRotation = _prefabLocalRot;
}
m_pGfx.transform.localScale = Vector3.one;
m_pGfx.SetActive(true);
_ps = m_pGfx.GetComponent<ParticleSystem>();
if (_ps != null)
_ps.Play();
@@ -172,6 +202,7 @@ public class GFX_BINDING : FX_BINDING_BASE
}
public void SetGfx(GameObject gfx, Quaternion prefabRotation) {
m_pGfx = gfx;
_prefabLocalRot = prefabRotation;
m_pGfx.transform.localRotation = prefabRotation;
}
@@ -220,6 +251,9 @@ public class A3DCombActDynData
/// <summary>Elapsed time (ms) along the combined action timeline; drives FX event triggers. / 组合动作时间轴已播放毫秒数,用于触发特效事件</summary>
public int GetComActElapsedMs() { return m_dwTimeSpan; }
/// <summary>Host <see cref="CECModel"/> for hook lookup and FX attach. / 用于挂点查询与特效挂接的宿主模型</summary>
public CECModel GetHostModel() => m_pECModel;
public List<string> m_ActionNames = new List<string>();
public List<string> m_SFXNames = new List<string>();
@@ -353,7 +387,7 @@ public class A3DCombActDynData
else if (prefab == null)
{
Debug.LogWarning("Missing gfx prefab, using placeholder: " + path);
string path2 = "gfx/人物/技能/妖精/宠物召唤吟唱.gfx";
string path2 = "gfx/NullDefault";
GameObject prefab2 = await AddressableManager.Instance.LoadPrefabAsync(path2);
var gfx = GameObject.Instantiate(prefab2, m_pECModel.transform);
gfx.SetActive(false);