public bool LinkRP(short MapIndex, short sRPIdx1, short sRPIdx2) { GxRP rP = this.GetRP(MapIndex, (int)sRPIdx1); if (rP == null || rP.GetLinkedCount() <= 4) { return(false); } GxRP rP2 = this.GetRP(MapIndex, (int)sRPIdx2); if (rP2 == null || rP2.GetLinkedCount() <= 4) { return(false); } rP.AddLinkedRP(sRPIdx2); rP2.AddLinkedRP(sRPIdx1); return(true); }
public bool _EraseRP(short MapIndex, short nRoadPointIndex) { GxRP rP = this.GetRP(MapIndex, (int)nRoadPointIndex); if (rP == null) { return(false); } for (int i = 0; i < rP.GetLinkedCount(); i++) { GxRP rP2 = this.GetRP(MapIndex, (int)rP.GetLinkedRP(i)); if (rP2 != null) { rP2.DelLinkedRP(nRoadPointIndex); } } rP.ClearData(); rP.SetData(nRoadPointIndex, MapIndex, Vector3.zero); return(true); }
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); }