CSL_Traffic.CustomTransportLineAI.UpdatePath C# (CSharp) Метод

UpdatePath() приватный Метод

private UpdatePath ( ushort segmentID, NetSegment &data, ItemClass netService, VehicleInfo vehicleType, bool skipQueue ) : bool
segmentID ushort
data NetSegment
netService ItemClass
vehicleType VehicleInfo
skipQueue bool
Результат bool
        public static new bool UpdatePath(ushort segmentID, ref NetSegment data, ItemClass.Service netService, VehicleInfo.VehicleType vehicleType, bool skipQueue)
        {
            if (data.m_path == 0u)
            {
                return StartPathFind(segmentID, ref data, netService, vehicleType, skipQueue);
            }
            if ((data.m_flags & NetSegment.Flags.WaitingPath) == NetSegment.Flags.None)
            {
                return true;
            }
            PathManager instance = Singleton<PathManager>.instance;
            NetManager instance2 = Singleton<NetManager>.instance;
            byte pathFindFlags = instance.m_pathUnits.m_buffer[(int)((UIntPtr)data.m_path)].m_pathFindFlags;
            if ((pathFindFlags & 4) != 0)
            {
                bool flag = false;
                PathUnit.Position pathPos;
                if (instance.m_pathUnits.m_buffer[(int)((UIntPtr)data.m_path)].GetPosition(0, out pathPos))
                {
                    flag = TransportLineAI.CheckNodePosition(data.m_startNode, pathPos);
                }
                if (instance.m_pathUnits.m_buffer[(int)((UIntPtr)data.m_path)].GetLastPosition(out pathPos))
                {
                    TransportLineAI.CheckNodePosition(data.m_endNode, pathPos);
                }
                float length = instance.m_pathUnits.m_buffer[(int)((UIntPtr)data.m_path)].m_length;
                if (length != data.m_averageLength)
                {
                    data.m_averageLength = length;
                    ushort transportLine = instance2.m_nodes.m_buffer[(int)data.m_startNode].m_transportLine;
                    if (transportLine != 0)
                    {
                        Singleton<TransportManager>.instance.UpdateLine(transportLine);
                    }
                }
                if (data.m_lanes != 0u)
                {
                    instance2.m_lanes.m_buffer[(int)((UIntPtr)data.m_lanes)].m_length = data.m_averageLength * ((!flag) ? 1f : 0.75f);
                }
                data.m_flags &= ~NetSegment.Flags.WaitingPath;
                data.m_flags &= ~NetSegment.Flags.PathFailed;
                data.m_flags |= NetSegment.Flags.PathLength;
                CustomTransportLineAI.CheckSegmentProblems(segmentID, ref data);
                return true;
            }
            if ((pathFindFlags & 8) != 0)
            {
                Vector3 position = instance2.m_nodes.m_buffer[(int)data.m_startNode].m_position;
                Vector3 position2 = instance2.m_nodes.m_buffer[(int)data.m_endNode].m_position;
                float num = Vector3.Distance(position, position2);
                if (num != data.m_averageLength)
                {
                    data.m_averageLength = num;
                    ushort transportLine2 = instance2.m_nodes.m_buffer[(int)data.m_startNode].m_transportLine;
                    if (transportLine2 != 0)
                    {
                        Singleton<TransportManager>.instance.UpdateLine(transportLine2);
                    }
                }
                data.m_flags &= ~NetSegment.Flags.WaitingPath;
                data.m_flags |= NetSegment.Flags.PathFailed;
                data.m_flags |= NetSegment.Flags.PathLength;
                CustomTransportLineAI.CheckSegmentProblems(segmentID, ref data);
                return true;
            }
            return false;
        }