// Token: 0x0600264E RID: 9806 RVA: 0x000E135D File Offset: 0x000DF75D public RoadJoint(Vector3 vertex, Vector3[] tangents, ERoadMode mode, float offset, bool ignoreTerrain) { this.vertex = vertex; this.tangents = tangents; this.mode = mode; this.offset = offset; this.ignoreTerrain = ignoreTerrain; }
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; } }