Files
test/Assets/PerfectWorld/Scripts/Vfx/CGfxOnTargetMove.cs
T
2026-05-28 17:55:56 +07:00

91 lines
3.1 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)
{
m_vPos = vTarget;
m_vMoveDir = vTarget - vHost;
m_vMoveDir.y = 0;
if (Normalize(ref m_vMoveDir) == 0)
{
m_vMoveDir = Vector3.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;
}
else
{
m_vOffset = Vector3.zero;
}
#region agent log
#if UNITY_EDITOR || DEVELOPMENT_BUILD
DebugSessionLog.Write("CGfxOnTargetMove.StartMove", "on_target_start", "F",
new DebugSessionPayload
{
spawnX = m_vPos.x,
spawnY = m_vPos.y,
spawnZ = m_vPos.z,
targetX = vTarget.x,
targetY = vTarget.y,
targetZ = vTarget.z,
radius = m_fRadius,
offsetMag = m_vOffset.magnitude,
isCluster = m_bOneOfCluser,
isArea = m_bArea,
frame = Time.frameCount
});
#endif
#endregion
}
/// <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)
{
m_vPos = vTargetPos + m_vOffset;
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
}
}
}