public void SAVE()
    {
        StreamWriter streamWriter = new StreamWriter("RPTest.txt");
        string       value        = string.Empty;

        foreach (short current in this.m_RPList.Keys)
        {
            for (int i = 0; i < this.m_RPList[current].Count; i++)
            {
                GxRP   gxRP = this.m_RPList[current][i];
                string text = string.Empty;
                for (int j = 0; j < 4; j++)
                {
                    text = text + gxRP.GetLinkedRP(j).ToString() + "/";
                }
                value = string.Concat(new string[]
                {
                    gxRP.GetIndex().ToString(),
                    "/",
                    gxRP.GetMapIndex().ToString(),
                    "/",
                    gxRP.GetPos().x.ToString(),
                    "/",
                    gxRP.GetPos().y.ToString(),
                    "/",
                    gxRP.GetPos().z.ToString(),
                    "/",
                    text
                });
                streamWriter.WriteLine(value);
            }
        }
        streamWriter.WriteLine("<End>");
        streamWriter.Close();
    }
    private bool AutoLinkRPs(short MapIndex, short sRPIndex)
    {
        if (!this.UnLinkAll(MapIndex, sRPIndex))
        {
            return(false);
        }
        GxRP gxRP = this.m_RPList[MapIndex][(int)sRPIndex];
        int  num  = 0;

        this.m_ValidList.Clear();
        this.m_FinalList.Clear();
        this.GetValidRangeRPIndexes(gxRP.GetMapIndex(), gxRP.GetX(), gxRP.GetY(), false);
        if (this.m_ValidList.Count <= 4)
        {
            for (int i = 0; i < this.m_ValidList.Count; i++)
            {
                this.LinkRP(MapIndex, sRPIndex, this.m_ValidList[i]);
            }
            return(true);
        }
        for (int j = 0; j < this.m_ValidList.Count; j++)
        {
            if (sRPIndex != this.m_ValidList[j])
            {
                GxRP rP = this.GetRP(MapIndex, (int)this.m_ValidList[j]);
                if (rP.GetLinkedCount() > 1)
                {
                    short num2 = this.m_ValidList[j];
                    int   num3 = rP.CalcCost(rP.GetX(), rP.GetY());
                    for (int k = 0; k < 4; k++)
                    {
                        if (rP.GetLinkedRP(k) != 0)
                        {
                            if (this.m_ValidList.Contains(rP.GetLinkedRP(k)))
                            {
                                GxRP rP2  = this.GetRP(MapIndex, (int)rP.GetLinkedRP(k));
                                int  num4 = rP2.CalcCost(gxRP.GetX(), gxRP.GetY());
                                if (rP2 != null && num4 <= num3)
                                {
                                    num2 = rP.GetLinkedRP(j);
                                    num3 = num4;
                                }
                            }
                        }
                    }
                    if (!this.m_FinalList.Contains(num2))
                    {
                        this.m_FinalList.AddFirst(num2);
                        num++;
                    }
                    if (num2 != this.m_ValidList[j] && !this.m_FinalList.Contains(this.m_ValidList[j]))
                    {
                        this.m_FinalList.AddLast(this.m_ValidList[j]);
                    }
                }
                else
                {
                    this.m_FinalList.AddFirst(this.m_ValidList[j]);
                    num++;
                }
            }
        }
        if (num > 4)
        {
            Debug.Log("MAX_LINK Over :" + sRPIndex.ToString());
            return(false);
        }
        int num5 = 0;

        foreach (short current in this.m_FinalList)
        {
            if (num5 == 4)
            {
                break;
            }
            this.LinkRP(MapIndex, sRPIndex, current);
            num5++;
        }
        return(true);
    }