// Token: 0x0600266F RID: 9839 RVA: 0x000E20AC File Offset: 0x000E04AC public Transform addVertex(int vertexIndex, Vector3 point) { RoadJoint roadJoint = new RoadJoint(point); for (int i = vertexIndex; i < this.joints.Count; i++) { this.paths[i].vertex.name = "Path_" + (i + 1); } if (this.joints.Count == 1) { this.joints[0].setTangent(1, (point - this.joints[0].vertex).normalized * 2.5f); roadJoint.setTangent(0, (this.joints[0].vertex - point).normalized * 2.5f); } else if (this.joints.Count > 1) { if (vertexIndex == 0) { if (this.isLoop) { RoadJoint roadJoint2 = this.joints[this.joints.Count - 1]; RoadJoint roadJoint3 = this.joints[0]; roadJoint.setTangent(1, (roadJoint3.vertex - roadJoint2.vertex).normalized * 2.5f); } else { roadJoint.setTangent(1, (this.joints[0].vertex - point).normalized * 2.5f); } } else if (vertexIndex == this.joints.Count) { if (this.isLoop) { RoadJoint roadJoint4 = this.joints[this.joints.Count - 1]; RoadJoint roadJoint5 = this.joints[0]; roadJoint.setTangent(1, (roadJoint5.vertex - roadJoint4.vertex).normalized * 2.5f); } else { roadJoint.setTangent(0, (this.joints[this.joints.Count - 1].vertex - point).normalized * 2.5f); } } else { RoadJoint roadJoint6 = this.joints[vertexIndex - 1]; RoadJoint roadJoint7 = this.joints[vertexIndex]; roadJoint.setTangent(1, (roadJoint7.vertex - roadJoint6.vertex).normalized * 2.5f); } } this.joints.Insert(vertexIndex, roadJoint); Transform transform = ((GameObject)UnityEngine.Object.Instantiate(Resources.Load("Edit/Path"))).transform; transform.name = "Path_" + vertexIndex; transform.parent = this.line; RoadPath roadPath = new RoadPath(transform); this.paths.Insert(vertexIndex, roadPath); this.updatePoints(); return(roadPath.vertex); }
public static void save() { River river = new River(Level.info.path + "/Environment/Roads.dat", false); river.writeByte(LevelRoads.SAVEDATA_ROADS_VERSION); river.writeByte((byte)LevelRoads.materials.Length); byte b = 0; while ((int)b < LevelRoads.materials.Length) { river.writeSingle(LevelRoads.materials[(int)b].width); river.writeSingle(LevelRoads.materials[(int)b].height); river.writeSingle(LevelRoads.materials[(int)b].depth); river.writeSingle(LevelRoads.materials[(int)b].offset); river.writeBoolean(LevelRoads.materials[(int)b].isConcrete); b += 1; } river.closeRiver(); river = new River(Level.info.path + "/Environment/Paths.dat", false); river.writeByte(LevelRoads.SAVEDATA_PATHS_VERSION); ushort num = 0; ushort num2 = 0; while ((int)num2 < LevelRoads.roads.Count) { if (LevelRoads.roads[(int)num2].joints.Count > 1) { num += 1; } num2 += 1; } river.writeUInt16(num); byte b2 = 0; while ((int)b2 < LevelRoads.roads.Count) { List <RoadJoint> joints = LevelRoads.roads[(int)b2].joints; if (joints.Count > 1) { river.writeUInt16((ushort)joints.Count); river.writeByte(LevelRoads.roads[(int)b2].material); river.writeBoolean(LevelRoads.roads[(int)b2].isLoop); ushort num3 = 0; while ((int)num3 < joints.Count) { RoadJoint roadJoint = joints[(int)num3]; river.writeSingleVector3(roadJoint.vertex); river.writeSingleVector3(roadJoint.getTangent(0)); river.writeSingleVector3(roadJoint.getTangent(1)); river.writeByte((byte)roadJoint.mode); river.writeSingle(roadJoint.offset); river.writeBoolean(roadJoint.ignoreTerrain); num3 += 1; } } b2 += 1; } river.closeRiver(); }
// Token: 0x0600267A RID: 9850 RVA: 0x000E3CAC File Offset: 0x000E20AC public void updatePoints() { for (int i = 0; i < this.joints.Count; i++) { RoadJoint roadJoint = this.joints[i]; if (!roadJoint.ignoreTerrain) { roadJoint.vertex.y = LevelGround.getHeight(roadJoint.vertex); } } for (int j = 0; j < this.joints.Count; j++) { RoadPath roadPath = this.paths[j]; roadPath.vertex.position = this.joints[j].vertex; roadPath.tangents[0].gameObject.SetActive(j > 0 || this.isLoop); roadPath.tangents[1].gameObject.SetActive(j < this.joints.Count - 1 || this.isLoop); roadPath.setTangent(0, this.joints[j].getTangent(0)); roadPath.setTangent(1, this.joints[j].getTangent(1)); } if (this.joints.Count < 2) { this.lineRenderer.numPositions = 0; return; } this.updateSamples(); this.lineRenderer.numPositions = this.samples.Count; for (int k = 0; k < this.samples.Count; k++) { RoadSample roadSample = this.samples[k]; RoadJoint roadJoint2 = this.joints[roadSample.index]; Vector3 position = this.getPosition(roadSample.index, roadSample.time); if (!roadJoint2.ignoreTerrain) { position.y = LevelGround.getHeight(position); } if (roadSample.index < this.joints.Count - 1) { position.y += Mathf.Lerp(roadJoint2.offset, this.joints[roadSample.index + 1].offset, roadSample.time); } else if (this.isLoop) { position.y += Mathf.Lerp(roadJoint2.offset, this.joints[0].offset, roadSample.time); } else { position.y += roadJoint2.offset; } this.lineRenderer.SetPosition(k, position); } }
public static void updateSelection(Road road, RoadJoint joint) { if (road != null && joint != null) { EditorEnvironmentRoadsUI.offsetField.state = joint.offset; EditorEnvironmentRoadsUI.loopToggle.state = road.isLoop; EditorEnvironmentRoadsUI.ignoreTerrainToggle.state = joint.ignoreTerrain; EditorEnvironmentRoadsUI.modeButton.state = (int)joint.mode; } EditorEnvironmentRoadsUI.offsetField.isVisible = (road != null); EditorEnvironmentRoadsUI.loopToggle.isVisible = (road != null); EditorEnvironmentRoadsUI.ignoreTerrainToggle.isVisible = (road != null); EditorEnvironmentRoadsUI.modeButton.isVisible = (road != null); }
public float getLength(int index) { index = Mathf.Clamp(index, 0, this.joints.Count - 1); RoadJoint roadJoint = this.joints[index]; RoadJoint roadJoint2; if (index == this.joints.Count - 1) { roadJoint2 = this.joints[0]; } else { roadJoint2 = this.joints[index + 1]; } return(BezierTool.getLength(roadJoint.vertex, roadJoint.vertex + roadJoint.getTangent(1), roadJoint2.vertex + roadJoint2.getTangent(0), roadJoint2.vertex)); }
// Token: 0x0600266B RID: 9835 RVA: 0x000E1CC0 File Offset: 0x000E00C0 public Vector3 getVelocity(int index, float t) { index = Mathf.Clamp(index, 0, this.joints.Count - 1); t = Mathf.Clamp01(t); RoadJoint roadJoint = this.joints[index]; RoadJoint roadJoint2; if (index == this.joints.Count - 1) { roadJoint2 = this.joints[0]; } else { roadJoint2 = this.joints[index + 1]; } return(BezierTool.getVelocity(roadJoint.vertex, roadJoint.vertex + roadJoint.getTangent(1), roadJoint2.vertex + roadJoint2.getTangent(0), roadJoint2.vertex, t)); }
public Transform addPoint(Transform origin, Vector3 point) { RoadJoint roadJoint = new RoadJoint(point); if (origin == null || origin == this.paths[this.paths.Count - 1].vertex) { if (this.joints.Count > 0) { roadJoint.setTangent(0, (this.joints[this.joints.Count - 1].vertex - point).normalized * 2.5f); } this.joints.Add(roadJoint); Transform transform = ((GameObject)UnityEngine.Object.Instantiate(Resources.Load("Edit/Path"))).transform; transform.name = "Path_" + (this.joints.Count - 1); transform.parent = this.line; RoadPath roadPath = new RoadPath(transform); this.paths.Add(roadPath); this.updatePoints(); return(roadPath.vertex); } if (origin == this.paths[0].vertex) { for (int i = 0; i < this.joints.Count; i++) { this.paths[i].vertex.name = "Path_" + (i + 1); } if (this.joints.Count > 0) { roadJoint.setTangent(1, (this.joints[0].vertex - point).normalized * 2.5f); } this.joints.Insert(0, roadJoint); Transform transform2 = ((GameObject)UnityEngine.Object.Instantiate(Resources.Load("Edit/Path"))).transform; transform2.name = "Path_0"; transform2.parent = this.line; RoadPath roadPath2 = new RoadPath(transform2); this.paths.Insert(0, roadPath2); this.updatePoints(); return(roadPath2.vertex); } return(null); }
// Token: 0x0600266D RID: 9837 RVA: 0x000E1DBC File Offset: 0x000E01BC public float getLengthEstimate(int index) { index = Mathf.Clamp(index, 0, this.joints.Count - 1); RoadJoint roadJoint = this.joints[index]; RoadJoint roadJoint2; if (index == this.joints.Count - 1) { roadJoint2 = this.joints[0]; } else { roadJoint2 = this.joints[index + 1]; } Vector3 tangent = roadJoint.getTangent(1); Vector3 tangent2 = roadJoint2.getTangent(0); if (Vector3.Dot(tangent.normalized, tangent2.normalized) < -0.999f) { return((roadJoint2.vertex - roadJoint.vertex).magnitude); } return(BezierTool.getLengthEstimate(roadJoint.vertex, roadJoint.vertex + tangent, roadJoint2.vertex + tangent2, roadJoint2.vertex)); }
// Token: 0x06002669 RID: 9833 RVA: 0x000E1B74 File Offset: 0x000DFF74 public Vector3 getPosition(int index, float t) { index = Mathf.Clamp(index, 0, this.joints.Count - 1); t = Mathf.Clamp01(t); RoadJoint roadJoint = this.joints[index]; RoadJoint roadJoint2; if (index == this.joints.Count - 1) { roadJoint2 = this.joints[0]; } else { roadJoint2 = this.joints[index + 1]; } Vector3 tangent = roadJoint.getTangent(1); Vector3 tangent2 = roadJoint2.getTangent(0); if (Vector3.Dot(tangent.normalized, tangent2.normalized) < -0.999f) { return(Vector3.Lerp(roadJoint.vertex, roadJoint2.vertex, t)); } return(BezierTool.getPosition(roadJoint.vertex, roadJoint.vertex + tangent, roadJoint2.vertex + tangent2, roadJoint2.vertex, t)); }
public static void load() { LevelRoads._models = new GameObject().transform; LevelRoads.models.name = "Roads"; LevelRoads.models.parent = Level.level; LevelRoads.models.tag = "Logic"; LevelRoads.models.gameObject.layer = LayerMasks.LOGIC; if (ReadWrite.fileExists(Level.info.path + "/Environment/Roads.unity3d", false, false)) { Bundle bundle = Bundles.getBundle(Level.info.path + "/Environment/Roads.unity3d", false); Object[] array = bundle.load(); bundle.unload(); LevelRoads._materials = new RoadMaterial[array.Length]; for (int i = 0; i < LevelRoads.materials.Length; i++) { LevelRoads.materials[i] = new RoadMaterial((Texture2D)array[i]); } } else { LevelRoads._materials = new RoadMaterial[0]; } LevelRoads.roads = new List <Road>(); if (ReadWrite.fileExists(Level.info.path + "/Environment/Roads.dat", false, false)) { River river = new River(Level.info.path + "/Environment/Roads.dat", false); byte b = river.readByte(); if (b > 0) { byte b2 = river.readByte(); for (byte b3 = 0; b3 < b2; b3 += 1) { if ((int)b3 >= LevelRoads.materials.Length) { break; } LevelRoads.materials[(int)b3].width = river.readSingle(); LevelRoads.materials[(int)b3].height = river.readSingle(); LevelRoads.materials[(int)b3].depth = river.readSingle(); if (b > 1) { LevelRoads.materials[(int)b3].offset = river.readSingle(); } LevelRoads.materials[(int)b3].isConcrete = river.readBoolean(); } } river.closeRiver(); } if (ReadWrite.fileExists(Level.info.path + "/Environment/Paths.dat", false, false)) { River river2 = new River(Level.info.path + "/Environment/Paths.dat", false); byte b4 = river2.readByte(); if (b4 > 1) { ushort num = river2.readUInt16(); for (ushort num2 = 0; num2 < num; num2 += 1) { ushort num3 = river2.readUInt16(); byte newMaterial = river2.readByte(); bool newLoop = b4 > 2 && river2.readBoolean(); List <RoadJoint> list = new List <RoadJoint>(); for (ushort num4 = 0; num4 < num3; num4 += 1) { Vector3 vertex = river2.readSingleVector3(); Vector3[] array2 = new Vector3[2]; if (b4 > 2) { array2[0] = river2.readSingleVector3(); array2[1] = river2.readSingleVector3(); } ERoadMode mode; if (b4 > 2) { mode = (ERoadMode)river2.readByte(); } else { mode = ERoadMode.FREE; } float offset; if (b4 > 4) { offset = river2.readSingle(); } else { offset = 0f; } bool ignoreTerrain = b4 > 3 && river2.readBoolean(); RoadJoint item = new RoadJoint(vertex, array2, mode, offset, ignoreTerrain); list.Add(item); } if (b4 < 3) { for (ushort num5 = 0; num5 < num3; num5 += 1) { RoadJoint roadJoint = list[(int)num5]; if (num5 == 0) { roadJoint.setTangent(0, (roadJoint.vertex - list[(int)(num5 + 1)].vertex).normalized * 2.5f); roadJoint.setTangent(1, (list[(int)(num5 + 1)].vertex - roadJoint.vertex).normalized * 2.5f); } else if (num5 == num3 - 1) { roadJoint.setTangent(0, (list[(int)(num5 - 1)].vertex - roadJoint.vertex).normalized * 2.5f); roadJoint.setTangent(1, (roadJoint.vertex - list[(int)(num5 - 1)].vertex).normalized * 2.5f); } else { roadJoint.setTangent(0, (list[(int)(num5 - 1)].vertex - roadJoint.vertex).normalized * 2.5f); roadJoint.setTangent(1, (list[(int)(num5 + 1)].vertex - roadJoint.vertex).normalized * 2.5f); } } } LevelRoads.roads.Add(new Road(newMaterial, newLoop, list)); } } else if (b4 > 0) { byte b5 = river2.readByte(); for (byte b6 = 0; b6 < b5; b6 += 1) { byte b7 = river2.readByte(); byte newMaterial2 = river2.readByte(); List <RoadJoint> list2 = new List <RoadJoint>(); for (byte b8 = 0; b8 < b7; b8 += 1) { Vector3 vertex2 = river2.readSingleVector3(); Vector3[] tangents = new Vector3[2]; ERoadMode mode2 = ERoadMode.FREE; RoadJoint item2 = new RoadJoint(vertex2, tangents, mode2, 0f, false); list2.Add(item2); } for (byte b9 = 0; b9 < b7; b9 += 1) { RoadJoint roadJoint2 = list2[(int)b9]; if (b9 == 0) { roadJoint2.setTangent(0, (roadJoint2.vertex - list2[(int)(b9 + 1)].vertex).normalized * 2.5f); roadJoint2.setTangent(1, (list2[(int)(b9 + 1)].vertex - roadJoint2.vertex).normalized * 2.5f); } else if (b9 == b7 - 1) { roadJoint2.setTangent(0, (list2[(int)(b9 - 1)].vertex - roadJoint2.vertex).normalized * 2.5f); roadJoint2.setTangent(1, (roadJoint2.vertex - list2[(int)(b9 - 1)].vertex).normalized * 2.5f); } else { roadJoint2.setTangent(0, (list2[(int)(b9 - 1)].vertex - roadJoint2.vertex).normalized * 2.5f); roadJoint2.setTangent(1, (list2[(int)(b9 + 1)].vertex - roadJoint2.vertex).normalized * 2.5f); } } LevelRoads.roads.Add(new Road(newMaterial2, false, list2)); } } river2.closeRiver(); } if (LevelGround.terrain != null) { LevelRoads.buildMeshes(); } if (!LevelRoads.isListeningForLandscape) { LevelRoads.isListeningForLandscape = true; if (LevelRoads.< > f__mg$cache0 == null) { LevelRoads.< > f__mg$cache0 = new LandscapeLoadedHandler(LevelRoads.handleLandscapeLoaded); } Landscape.loaded += LevelRoads.< > f__mg$cache0; } }
// Token: 0x06002677 RID: 9847 RVA: 0x000E25D0 File Offset: 0x000E09D0 public void buildMesh() { for (int i = 0; i < this.road.childCount; i++) { UnityEngine.Object.Destroy(this.road.GetChild(i).gameObject); } if (this.joints.Count < 2) { return; } this.updateSamples(); if (!Level.isEditor) { bool flag = false; foreach (LevelTrainAssociation levelTrainAssociation in Level.info.configData.Trains) { if (levelTrainAssociation.RoadIndex == this.roadIndex) { flag = true; break; } } if (flag) { this.updateTrackSamples(); } } Vector3[] array = new Vector3[this.samples.Count * 4 + ((!this.isLoop) ? 8 : 0)]; Vector3[] array2 = new Vector3[this.samples.Count * 4 + ((!this.isLoop) ? 8 : 0)]; Vector2[] array3 = new Vector2[this.samples.Count * 4 + ((!this.isLoop) ? 8 : 0)]; float num = 0f; Vector3 b = Vector3.zero; Vector3 vector = Vector3.zero; Vector3 vector2 = Vector3.zero; Vector3 vector3 = Vector3.zero; Vector3 a = Vector3.zero; Vector2 b2 = Vector2.zero; int j; for (j = 0; j < this.samples.Count; j++) { RoadSample roadSample = this.samples[j]; RoadJoint roadJoint = this.joints[roadSample.index]; vector = this.getPosition(roadSample.index, roadSample.time); if (!roadJoint.ignoreTerrain) { vector.y = LevelGround.getHeight(vector); } vector2 = this.getVelocity(roadSample.index, roadSample.time).normalized; if (roadJoint.ignoreTerrain) { vector3 = Vector3.up; } else { vector3 = LevelGround.getNormal(vector); } a = Vector3.Cross(vector2, vector3); if (!roadJoint.ignoreTerrain) { Vector3 point = vector + a * LevelRoads.materials[(int)this.material].width; float num2 = LevelGround.getHeight(point) - point.y; if (num2 > 0f) { vector.y += num2; } Vector3 point2 = vector - a * LevelRoads.materials[(int)this.material].width; float num3 = LevelGround.getHeight(point2) - point2.y; if (num3 > 0f) { vector.y += num3; } } if (roadSample.index < this.joints.Count - 1) { vector.y += Mathf.Lerp(roadJoint.offset, this.joints[roadSample.index + 1].offset, roadSample.time); } else if (this.isLoop) { vector.y += Mathf.Lerp(roadJoint.offset, this.joints[0].offset, roadSample.time); } else { vector.y += roadJoint.offset; } array[((!this.isLoop) ? 4 : 0) + j * 4] = vector + a * (LevelRoads.materials[(int)this.material].width + LevelRoads.materials[(int)this.material].depth * 2f) - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset; array[((!this.isLoop) ? 4 : 0) + j * 4 + 1] = vector + a * LevelRoads.materials[(int)this.material].width + vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset; array[((!this.isLoop) ? 4 : 0) + j * 4 + 2] = vector - a * LevelRoads.materials[(int)this.material].width + vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset; array[((!this.isLoop) ? 4 : 0) + j * 4 + 3] = vector - a * (LevelRoads.materials[(int)this.material].width + LevelRoads.materials[(int)this.material].depth * 2f) - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset; array2[((!this.isLoop) ? 4 : 0) + j * 4] = vector3; array2[((!this.isLoop) ? 4 : 0) + j * 4 + 1] = vector3; array2[((!this.isLoop) ? 4 : 0) + j * 4 + 2] = vector3; array2[((!this.isLoop) ? 4 : 0) + j * 4 + 3] = vector3; if (j == 0) { b = vector; array3[((!this.isLoop) ? 4 : 0) + j * 4] = Vector2.zero; array3[((!this.isLoop) ? 4 : 0) + j * 4 + 1] = Vector2.zero; array3[((!this.isLoop) ? 4 : 0) + j * 4 + 2] = Vector2.right; array3[((!this.isLoop) ? 4 : 0) + j * 4 + 3] = Vector2.right; } else { num += (vector - b).magnitude; b = vector; b2 = Vector2.up * num / (float)LevelRoads.materials[(int)this.material].material.mainTexture.height * LevelRoads.materials[(int)this.material].height; array3[((!this.isLoop) ? 4 : 0) + j * 4] = Vector2.zero + b2; array3[((!this.isLoop) ? 4 : 0) + j * 4 + 1] = Vector2.zero + b2; array3[((!this.isLoop) ? 4 : 0) + j * 4 + 2] = Vector2.right + b2; array3[((!this.isLoop) ? 4 : 0) + j * 4 + 3] = Vector2.right + b2; } } if (!this.isLoop) { array[4 + j * 4] = vector + a * (LevelRoads.materials[(int)this.material].width + LevelRoads.materials[(int)this.material].depth * 2f) - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset + vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array[4 + j * 4 + 1] = vector + a * LevelRoads.materials[(int)this.material].width - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset + vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array[4 + j * 4 + 2] = vector - a * LevelRoads.materials[(int)this.material].width - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset + vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array[4 + j * 4 + 3] = vector - a * (LevelRoads.materials[(int)this.material].width + LevelRoads.materials[(int)this.material].depth * 2f) - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset + vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array2[4 + j * 4] = vector3; array2[4 + j * 4 + 1] = vector3; array2[4 + j * 4 + 2] = vector3; array2[4 + j * 4 + 3] = vector3; b2 = Vector2.up * num / (float)LevelRoads.materials[(int)this.material].material.mainTexture.height * LevelRoads.materials[(int)this.material].height; array3[4 + j * 4] = Vector2.zero + b2; array3[4 + j * 4 + 1] = Vector2.zero + b2; array3[4 + j * 4 + 2] = Vector2.right + b2; array3[4 + j * 4 + 3] = Vector2.right + b2; j = 0; vector = this.getPosition(this.samples[0].index, this.samples[0].time); if (!this.joints[0].ignoreTerrain) { vector.y = LevelGround.getHeight(vector); } vector2 = this.getVelocity(this.samples[0].index, this.samples[0].time).normalized; if (this.joints[0].ignoreTerrain) { vector3 = LevelGround.getNormal(this.joints[0].vertex); } else { vector3 = LevelGround.getNormal(vector); } a = Vector3.Cross(vector2, vector3); if (!this.joints[0].ignoreTerrain) { Vector3 point3 = vector + a * LevelRoads.materials[(int)this.material].width; float num4 = LevelGround.getHeight(point3) - point3.y; if (num4 > 0f) { vector.y += num4; } Vector3 point4 = vector - a * LevelRoads.materials[(int)this.material].width; float num5 = LevelGround.getHeight(point4) - point4.y; if (num5 > 0f) { vector.y += num5; } } vector.y += this.joints[0].offset; array[j * 4] = vector + a * (LevelRoads.materials[(int)this.material].width + LevelRoads.materials[(int)this.material].depth * 2f) - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset - vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array[j * 4 + 1] = vector + a * LevelRoads.materials[(int)this.material].width - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset - vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array[j * 4 + 2] = vector - a * LevelRoads.materials[(int)this.material].width - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset - vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array[j * 4 + 3] = vector - a * (LevelRoads.materials[(int)this.material].width + LevelRoads.materials[(int)this.material].depth * 2f) - vector3 * LevelRoads.materials[(int)this.material].depth + vector3 * LevelRoads.materials[(int)this.material].offset - vector2 * LevelRoads.materials[(int)this.material].depth * 4f; array2[j * 4] = vector3; array2[j * 4 + 1] = vector3; array2[j * 4 + 2] = vector3; array2[j * 4 + 3] = vector3; array3[j * 4] = Vector2.zero; array3[j * 4 + 1] = Vector2.zero; array3[j * 4 + 2] = Vector2.right; array3[j * 4 + 3] = Vector2.right; } int num6 = 0; for (int k = 0; k < this.samples.Count; k += 20) { int num7 = Mathf.Min(k + 20, this.samples.Count - 1); int num8 = num7 - k + 1; if (!this.isLoop) { if (k == 0) { num8++; } if (num7 == this.samples.Count - 1) { num8++; } } Vector3[] array4 = new Vector3[num8 * 4]; Vector3[] array5 = new Vector3[num8 * 4]; Vector2[] array6 = new Vector2[num8 * 4]; int[] array7 = new int[num8 * 18]; int num9 = k; if (!this.isLoop && k > 0) { num9++; } Array.Copy(array, num9 * 4, array4, 0, array4.Length); Array.Copy(array2, num9 * 4, array5, 0, array4.Length); Array.Copy(array3, num9 * 4, array6, 0, array4.Length); for (int l = 0; l < num8 - 1; l++) { array7[l * 18] = l * 4 + 5; array7[l * 18 + 1] = l * 4 + 1; array7[l * 18 + 2] = l * 4 + 4; array7[l * 18 + 3] = l * 4; array7[l * 18 + 4] = l * 4 + 4; array7[l * 18 + 5] = l * 4 + 1; array7[l * 18 + 6] = l * 4 + 6; array7[l * 18 + 7] = l * 4 + 2; array7[l * 18 + 8] = l * 4 + 5; array7[l * 18 + 9] = l * 4 + 1; array7[l * 18 + 10] = l * 4 + 5; array7[l * 18 + 11] = l * 4 + 2; array7[l * 18 + 12] = l * 4 + 7; array7[l * 18 + 13] = l * 4 + 3; array7[l * 18 + 14] = l * 4 + 6; array7[l * 18 + 15] = l * 4 + 2; array7[l * 18 + 16] = l * 4 + 6; array7[l * 18 + 17] = l * 4 + 3; } Transform transform = new GameObject().transform; transform.name = "Segment_" + num6; transform.parent = this.road; transform.tag = "Environment"; transform.gameObject.layer = LayerMasks.ENVIRONMENT; transform.gameObject.AddComponent <MeshCollider>(); if (!Dedicator.isDedicated) { transform.gameObject.AddComponent <MeshFilter>(); MeshRenderer meshRenderer = transform.gameObject.AddComponent <MeshRenderer>(); meshRenderer.reflectionProbeUsage = ReflectionProbeUsage.Simple; meshRenderer.shadowCastingMode = ShadowCastingMode.Off; } if (LevelRoads.materials[(int)this.material].isConcrete) { transform.GetComponent <Collider>().sharedMaterial = (PhysicMaterial)Resources.Load("Physics/Concrete_Static"); } else { transform.GetComponent <Collider>().sharedMaterial = (PhysicMaterial)Resources.Load("Physics/Gravel_Static"); } Mesh mesh = new Mesh(); mesh.name = "Road_Segment_" + num6; mesh.vertices = array4; mesh.normals = array5; mesh.uv = array6; mesh.triangles = array7; transform.GetComponent <MeshCollider>().sharedMesh = mesh; if (!Dedicator.isDedicated) { transform.GetComponent <MeshFilter>().sharedMesh = mesh; transform.GetComponent <Renderer>().sharedMaterial = LevelRoads.materials[(int)this.material].material; } num6++; } }