少年修仙传客户端代码仓库
hch
2025-06-12 a9fdd65579003ef3c95e64d96cc97b1d19b528ba
Fight/GameActor/GActor.cs
@@ -408,19 +408,16 @@
         && MathUtility.DistanceSqrtXZ(DestPos, destPos) < 0.01f
         && !force)
        {
            Debug.LogFormat("3333333 想要切换至目标npc: {0}", destPos);
            Run();
            return;
        }
        DestPos = destPos;
        Debug.LogFormat("44444444444 想要切换至目标npc: {0}", destPos);
        Vector3 _validPos = Pos;
        if (TryGetValidPos(destPos, ref _validPos))
        {
            DestPos = _validPos;
            m_SearchType = E_SearchType.Static;
            Debug.LogFormat("55555555 想要切换至目标npc: {0}", DestPos);
            MoveTo(_validPos, keepDist);
        }
    }
@@ -490,25 +487,35 @@
    {
        Vector3 _curPos = Pos;
        _curPos.y = 0;
        Debug.LogFormat("6666666 想要切换至目标npc: {0}  {1}", position, m_Path);
        if (NavMesh.CalculatePath(_curPos, position, NavMesh.AllAreas, m_Path))
        try
        {
            m_CornerIndex = 0;
            m_KeepDist = keepDist;
            PathFindStatus = E_PathFindStatus.Moving;
            if (OnPathFindStart != null)
            if (NavMesh.CalculatePath(_curPos, position, NavMesh.AllAreas, m_Path))
            {
                OnPathFindStart();
                m_CornerIndex = 0;
                m_KeepDist = keepDist;
                PathFindStatus = E_PathFindStatus.Moving;
                if (OnPathFindStart != null)
                {
                    OnPathFindStart();
                }
                Run();
                State = E_ActorState.AutoRun;
                Debug.LogFormat("77777777 想要切换至目标npc: {0}", position);
                // if (this is GActorNpcFight
                //  && (ServerInstID == 133 || ServerInstID == 134 || ServerInstID == 112))
                // {
                //     Debug.LogFormat("{0} 开始寻路至点: {1}", ServerInstID, position);
                // }
            }
            Run();
            State = E_ActorState.AutoRun;
            // if (this is GActorNpcFight
            //  && (ServerInstID == 133 || ServerInstID == 134 || ServerInstID == 112))
            // {
            //     Debug.LogFormat("{0} 开始寻路至点: {1}", ServerInstID, position);
            // }
        }
        catch (System.Exception e)
        {
            Debug.LogError("NavMeshPath error: " + e.Message);
            return;
        }
    }
    public static bool TryGetValidPos(Vector3 position, ref Vector3 validPosition)