public void SetRoute(ushort segmentId, string routePrefix, string route, string oldRouteStr = null) { RouteContainer routeContainer = null; if (!String.IsNullOrEmpty(route)) { if (m_routeDict.ContainsKey(segmentId)) { routeContainer = m_routeDict[segmentId]; routeContainer.m_routePrefix = routePrefix; routeContainer.m_route = route; } else { routeContainer = new RouteContainer(segmentId, routePrefix, route); } m_routeDict[segmentId] = routeContainer; if (routeContainer.m_shieldObject == null) { routeContainer.m_shieldObject = new GameObject(segmentId + "shield"); routeContainer.m_shieldObject.AddComponent <MeshRenderer>(); routeContainer.m_shieldMesh = routeContainer.m_shieldObject.AddComponent <MeshFilter>(); GameObject numTextObject = new GameObject(segmentId + "text"); numTextObject.transform.parent = routeContainer.m_shieldObject.transform; numTextObject.AddComponent <MeshRenderer>(); numTextObject.GetComponent <MeshRenderer>().sortingOrder = 1001; routeContainer.m_numMesh = numTextObject.AddComponent <TextMesh>(); } string routeStr = routePrefix + '/' + route; if (!m_usedRoutes.ContainsKey(routeStr)) { m_usedRoutes[routeStr] = 0; } m_usedRoutes[routeStr] += 1; if (oldRouteStr != null) { DecrementRoadRouteCounter(oldRouteStr); } } else { GameObject.Destroy(m_routeDict[segmentId].m_shieldObject); m_routeDict.Remove(segmentId); } if (oldRouteStr != null) { DecrementRoadRouteCounter(oldRouteStr); } EventBusManager.Instance().Publish("forceupdateroutes", null); }
public string GetRouteStr(ushort segmentId) { if (RouteExists(segmentId)) { RouteContainer container = m_routeDict[segmentId]; return(container.m_route); } else { return(null); } }