Files
test/Assets/PerfectWorld/Scripts/Vfx/CGfxOnTargetMove.cs
T
2026-02-24 18:45:24 +07:00

81 lines
3.3 KiB
C#

using UnityEngine;
namespace BrewMonster
{
/// <summary>
/// Instant-hit movement (no flight). Used for melee/instant skills.
/// Mirrors C++ CGfxOnTargetMove exactly (A3DSkillGfxEvent2.cpp:297-322).
/// 瞬间命中移动(无飞行)。用于近战/瞬发技能。
/// </summary>
public class CGfxOnTargetMove : CGfxMoveBase
{
protected float m_fRadius;
protected Vector3 m_vOffset;
public CGfxOnTargetMove(GfxMoveMode mode) : base(mode)
{
m_HitPos = GfxHitPos.enumHitBottom;
m_fRadius = 0;
}
/// <summary>
/// Set position to target immediately. Cluster offset adds random radius.
/// 立即将位置设置到目标。群集偏移添加随机半径。
/// </summary>
public override void StartMove(Vector3 vHost, Vector3 vTarget)
{
BMLogger.LogError($"[SKILL_GFX_DEBUG] CGfxOnTargetMove.StartMove: Entry - host={vHost}, target={vTarget}, cluster={m_bOneOfCluser}, radius={m_fRadius}");
m_vPos = vTarget;
m_vMoveDir = vTarget - vHost;
m_vMoveDir.y = 0; // C++: zero out Y before normalize
if (Normalize(ref m_vMoveDir) == 0)
{
m_vMoveDir = Vector3.forward; // _unit_z
BMLogger.LogError($"[SKILL_GFX_DEBUG] CGfxOnTargetMove.StartMove: MoveDir was zero, using forward");
}
if (m_bOneOfCluser)
{
float fRandAng = Random.value * Mathf.PI * 2f;
float fRadius = Random.value * m_fRadius;
m_vOffset.x = Mathf.Cos(fRandAng) * fRadius;
m_vOffset.z = Mathf.Sin(fRandAng) * fRadius;
m_vOffset.y = 0;
m_vPos += m_vOffset;
BMLogger.LogError($"[SKILL_GFX_DEBUG] CGfxOnTargetMove.StartMove: Cluster offset applied - offset={m_vOffset}, finalPos={m_vPos}");
}
else
{
m_vOffset = Vector3.zero;
BMLogger.LogError($"[SKILL_GFX_DEBUG] CGfxOnTargetMove.StartMove: No cluster offset, pos={m_vPos}");
}
BMLogger.LogError($"[SKILL_GFX_DEBUG] CGfxOnTargetMove.StartMove: Complete - pos={m_vPos}, dir={m_vMoveDir}");
}
/// <summary>
/// Always returns false — hit is triggered by fly time timeout, NOT by TickMove.
/// 始终返回false — 命中由飞行时间超时触发,而非TickMove。
/// </summary>
public override bool TickMove(uint dwDeltaTime, Vector3 vHostPos, Vector3 vTargetPos)
{
Vector3 oldPos = m_vPos;
m_vPos = vTargetPos + m_vOffset;
BMLogger.LogError($"[SKILL_GFX_DEBUG] CGfxOnTargetMove.TickMove: Updated pos from {oldPos} to {m_vPos} (target={vTargetPos}, offset={m_vOffset}), returning false (hit by timeout)");
return false; // C++ returns false — hit triggered by fly time timeout
}
/// <summary>
/// Override to also read radius from param value.
/// 重写以从参数值中读取半径。
/// </summary>
public override void SetParam(GFX_SKILL_PARAM param)
{
base.SetParam(param);
m_fRadius = param.value.fVal; // C# union access: param.value.fVal
}
}
}