private void ExportGroundAndWater() { /* I'll be honest, I tried to make sense of this bit but it went right ** over my head, so I just re-implemented it as it was and fixed it up ** so it took water levels into account, so it's a bit of a mess still. ** Sorry about that. If someone wants to help make it readable then be ** my guest!*/ TerrainManager terrainManager = Singleton <TerrainManager> .instance; int gridSize = 16; int steps = (1920 * 9) / gridSize; //?????????? double[,] waterPoints = new double[steps + 2, steps + 2]; //Why does it add 2? I have no idea double[,] groundPoints = new double[steps + 2, steps + 2]; double[] contourX = new double[steps + 2], contourY = new double[steps + 2], contourZ = new double[] { 1.6 }; for (int y = 0; y < steps + 2; ++y) { for (int x = 0; x < steps + 2; ++x) { if (y == 0 || y == steps + 1 || x == 0 || x == steps + 1) //*shrug* { waterPoints[y, x] = 0.0F; //*more shrug* groundPoints[y, x] = 0.0F; } else { Vector3 position = new Vector3(((y - 1) - (steps / 2)) * gridSize, 0, ((x - 1) - (steps / 2)) * gridSize); //What? float waterLevel = terrainManager.SampleRawHeightSmoothWithWater(position, false, 0f); float groundLevel = terrainManager.SampleRawHeightSmooth(position); float difference = waterLevel - groundLevel; UniqueLogger.AddLog("Levels", Math.Round(waterLevel).ToString() + " - " + Math.Round(groundLevel).ToString(), ""); if (difference < 5.0F) { waterPoints[y, x] = difference; groundPoints[y, x] = groundLevel / 12; //Divided it, as it makes the points more rounded } else { waterPoints[y, x] = (double)difference; groundPoints[y, x] = 0.0F; } } } contourX[y] = y * gridSize; contourY[y] = y * gridSize; //Still no idea... } //UniqueLogger.PrintLog("Levels"); CreateContours(waterPoints, contourX, contourY, contourZ, gridSize, steps, ContourType.Water); CreateContours(groundPoints, contourX, contourY, contourZ, gridSize, steps, ContourType.Ground); }
/// <summary> /// Checks whether the name of the road matches /// the input name. /// </summary> /// <param name="comparisonName">The road name to compare against</param> /// <returns>Whether the name of the road matches the comparison name.</returns> public bool RoadNameMatches(string comparisonName) { string prefixCompare = inGameNamePrefix.ToLower().Replace(" ", ""); string postfixCompare = inGameNamePostfix.ToLower().Replace(" ", ""); string roadNameCompare = prefixCompare + postfixCompare; comparisonName = comparisonName.ToLower().Replace(" ", ""); UniqueLogger.AddLog("Road name matches", inGameNamePrefix + " " + inGameNamePostfix, ""); return(roadNameCompare == comparisonName); }
private OSMWay CreateWay(int index, NetSegment segment, ushort segmentId) { OSMWay returnWay = null; NetSegment.Flags segmentFlags = segment.m_flags; NetManager netManager = Singleton <NetManager> .instance; List <OSMWayND> wayPaths = new List <OSMWayND>(); List <OSMWayTag> wayTags; ushort startNodeId = segment.m_startNode, endNodeId = segment.m_endNode; if (startNodeId != 0 && endNodeId != 0) { Vector3 startNodeDirection = segment.m_startDirection; Vector3 endNodeDirection = segment.m_endDirection; if (segmentFlags.IsFlagSet(NetSegment.Flags.Invert)) { startNodeId = segment.m_endNode; endNodeId = segment.m_startNode; startNodeDirection = segment.m_endDirection; endNodeDirection = segment.m_startDirection; } NetNode startNode = netManager.m_nodes.m_buffer[startNodeId]; NetNode endNode = netManager.m_nodes.m_buffer[endNodeId]; Vector3 startNodePosition = startNode.m_position; Vector3 endNodePosition = endNode.m_position; wayPaths.Add(new OSMWayND { @ref = startNodeId }); if (Vector3.Angle(startNodeDirection, -endNodeDirection) > 3f) { Vector3 midPointA = Vector3.zero, midPointB = Vector3.zero; NetSegment.CalculateMiddlePoints(startNodePosition, startNodeDirection, endNodePosition, endNodeDirection, false, false, out midPointA, out midPointB); Bezier3 bezier = new Bezier3(startNodePosition, midPointA, midPointB, endNodePosition); osmNodes.Add(CreateNode(unindexedNodeOffset++, bezier.Position(0.25f))); osmNodes.Add(CreateNode(unindexedNodeOffset++, bezier.Position(0.5f))); osmNodes.Add(CreateNode(unindexedNodeOffset++, bezier.Position(0.75f))); wayPaths.Add(new OSMWayND { @ref = (uint)unindexedNodeOffset - 3 }); wayPaths.Add(new OSMWayND { @ref = (uint)unindexedNodeOffset - 2 }); wayPaths.Add(new OSMWayND { @ref = (uint)unindexedNodeOffset - 1 }); } wayPaths.Add(new OSMWayND { @ref = endNodeId }); if (Tagger.CreateWayTags(segment, out wayTags)) { if (haveRoadNamerMod) { // If road namer mod is available, then attempt to get the name asscociated with the segment, if any string roadName = RoadNamerManager.Instance().getSegmentName((ushort)(segmentId)); if (roadName != null) { //If a name is available, add a name tag wayTags.Add(new OSMWayTag { k = "name", v = StringUtilities.RemoveTags(roadName) }); } } returnWay = new OSMWay { changeset = 50000000, id = (uint)index, timestamp = DateTime.Now, user = "******", nd = wayPaths.ToArray(), tag = wayTags.ToArray(), version = 1 }; } else { UniqueLogger.AddLog("Road names missing from search", segment.Info.name, ""); } } return(returnWay); }