public static void bakeRoads() { for (int i = 0; i < LevelRoads.roads.Count; i++) { LevelRoads.roads[i].updatePoints(); } LevelRoads.buildMeshes(); }
private static void handleLandscapeLoaded() { if (Level.isEditor) { LevelRoads.bakeRoads(); } else { LevelRoads.buildMeshes(); } }
// Token: 0x06002671 RID: 9841 RVA: 0x000E247C File Offset: 0x000E087C public void removeVertex(int vertexIndex) { if (this.joints.Count < 2) { LevelRoads.removeRoad(this); return; } for (int i = vertexIndex + 1; i < this.paths.Count; i++) { this.paths[i].vertex.name = "Path_" + (i - 1); } this.paths[vertexIndex].remove(); this.paths.RemoveAt(vertexIndex); this.joints.RemoveAt(vertexIndex); this.updatePoints(); }
// Token: 0x060034D6 RID: 13526 RVA: 0x0015D288 File Offset: 0x0015B688 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.roadIndexBox.text = LevelRoads.getRoadIndex(road).ToString(); } EditorEnvironmentRoadsUI.offsetField.isVisible = (road != null); EditorEnvironmentRoadsUI.loopToggle.isVisible = (road != null); EditorEnvironmentRoadsUI.ignoreTerrainToggle.isVisible = (road != null); EditorEnvironmentRoadsUI.modeButton.isVisible = (road != null); EditorEnvironmentRoadsUI.roadIndexBox.isVisible = (road != null); }
public static void save() { LevelObjects.save(); LevelLighting.save(); LevelGround.save(); LevelRoads.save(); if (!Level.isVR) { LevelNavigation.save(); LevelNodes.save(); LevelItems.save(); LevelPlayers.save(); LevelZombies.save(); LevelVehicles.save(); LevelAnimals.save(); LevelVisibility.save(); } Editor.save(); }
// Token: 0x06001F04 RID: 7940 RVA: 0x000AB768 File Offset: 0x000A9B68 private static void select(Transform target) { if (EditorRoads.road != null) { if (EditorRoads.tangentIndex > -1) { EditorRoads.path.unhighlightTangent(EditorRoads.tangentIndex); } else if (EditorRoads.vertexIndex > -1) { EditorRoads.path.unhighlightVertex(); } } if (EditorRoads.selection == target || target == null) { EditorRoads.deselect(); } else { EditorRoads.selection = target; EditorRoads._road = LevelRoads.getRoad(EditorRoads.selection, out EditorRoads.vertexIndex, out EditorRoads.tangentIndex); if (EditorRoads.road != null) { EditorRoads._path = EditorRoads.road.paths[EditorRoads.vertexIndex]; EditorRoads._joint = EditorRoads.road.joints[EditorRoads.vertexIndex]; if (EditorRoads.tangentIndex > -1) { EditorRoads.path.highlightTangent(EditorRoads.tangentIndex); } else if (EditorRoads.vertexIndex > -1) { EditorRoads.path.highlightVertex(); } } else { EditorRoads._path = null; EditorRoads._joint = null; } } EditorEnvironmentRoadsUI.updateSelection(EditorRoads.road, EditorRoads.joint); }
public void removePoint(Transform select) { if (this.joints.Count < 2) { LevelRoads.removeRoad(this); return; } for (int i = 0; i < this.paths.Count; i++) { if (this.paths[i].vertex == select) { for (int j = i + 1; j < this.paths.Count; j++) { this.paths[j].vertex.name = "Path_" + (j - 1); } UnityEngine.Object.Destroy(select.gameObject); this.joints.RemoveAt(i); this.paths.RemoveAt(i); this.updatePoints(); return; } } }
public static void chartify() { Bundle bundle = Bundles.getBundle(Level.info.path + "/Charts.unity3d", false); if (bundle == null) { return; } Texture2D texture2D = (Texture2D)bundle.load("Height_Strip"); Texture2D texture2D2 = (Texture2D)bundle.load("Layer_Strip"); bundle.unload(); if (texture2D == null || texture2D2 == null) { return; } Texture2D texture2D3 = new Texture2D((int)Level.size, (int)Level.size); texture2D3.name = "Chartify"; texture2D3.hideFlags = 61; texture2D3.filterMode = 2; float num = Mathf.Clamp01(WaterSystem.worldSeaLevel / Level.TERRAIN); float num2 = 1f; for (byte b = 0; b < Regions.WORLD_SIZE; b += 1) { for (byte b2 = 0; b2 < Regions.WORLD_SIZE; b2 += 1) { if (!LevelObjects.regions[(int)b, (int)b2]) { List<LevelObject> list = LevelObjects.objects[(int)b, (int)b2]; for (int i = 0; i < list.Count; i++) { list[i].enableCollision(); list[i].enableVisual(); } } if (!LevelGround.regions[(int)b, (int)b2]) { List<ResourceSpawnpoint> list2 = LevelGround.trees[(int)b, (int)b2]; for (int j = 0; j < list2.Count; j++) { list2[j].enable(); } } } } GameObject gameObject = new GameObject(); gameObject.layer = LayerMasks.GROUND; for (int k = 0; k < texture2D3.width; k++) { for (int l = 0; l < texture2D3.height; l++) { Vector3 vector; vector..ctor((float)(-(float)Level.size) / 2f + (float)Level.border + (float)k / (float)texture2D3.width * ((float)Level.size - (float)Level.border * 2f), Level.HEIGHT, (float)(-(float)Level.size) / 2f + (float)Level.border + (float)l / (float)texture2D3.height * ((float)Level.size - (float)Level.border * 2f)); EObjectChart eobjectChart; RaycastHit raycastHit; Level.findChartHit(vector, out eobjectChart, out raycastHit); Transform transform = raycastHit.transform; Vector3 point = raycastHit.point; if (transform == null) { transform = gameObject.transform; point = vector; point.y = LevelGround.getHeight(vector); } int num3 = transform.gameObject.layer; if (eobjectChart == EObjectChart.GROUND) { num3 = LayerMasks.GROUND; } else if (eobjectChart == EObjectChart.HIGHWAY) { num3 = 0; } else if (eobjectChart == EObjectChart.ROAD) { num3 = 1; } else if (eobjectChart == EObjectChart.STREET) { num3 = 2; } else if (eobjectChart == EObjectChart.PATH) { num3 = 3; } else if (eobjectChart == EObjectChart.LARGE) { num3 = LayerMasks.LARGE; } else if (eobjectChart == EObjectChart.MEDIUM) { num3 = LayerMasks.MEDIUM; } else if (eobjectChart == EObjectChart.CLIFF) { num3 = 4; } if (num3 == LayerMasks.ENVIRONMENT) { RoadMaterial roadMaterial = LevelRoads.getRoadMaterial(transform); if (roadMaterial != null) { if (!roadMaterial.isConcrete) { num3 = 3; } else if (roadMaterial.width > 8f) { num3 = 0; } else { num3 = 1; } } } Color pixel; if (eobjectChart == EObjectChart.WATER) { pixel = texture2D.GetPixel(0, 0); } else if (num3 == LayerMasks.GROUND) { if (WaterUtility.isPointUnderwater(point)) { pixel = texture2D.GetPixel(0, 0); } else { float num4 = point.y / Level.TERRAIN; num4 = (num4 - num) / (num2 - num); num4 = Mathf.Clamp01(num4); pixel = texture2D.GetPixel((int)(num4 * (float)(texture2D.width - 1)) + 1, 0); } } else { pixel = texture2D2.GetPixel(num3, 0); } texture2D3.SetPixel(k, l, pixel); } } texture2D3.Apply(); for (byte b3 = 0; b3 < Regions.WORLD_SIZE; b3 += 1) { for (byte b4 = 0; b4 < Regions.WORLD_SIZE; b4 += 1) { if (!LevelObjects.regions[(int)b3, (int)b4]) { List<LevelObject> list3 = LevelObjects.objects[(int)b3, (int)b4]; for (int m = 0; m < list3.Count; m++) { list3[m].disableCollision(); list3[m].disableVisual(); } } if (!LevelGround.regions[(int)b3, (int)b4]) { List<ResourceSpawnpoint> list4 = LevelGround.trees[(int)b3, (int)b4]; for (int n = 0; n < list4.Count; n++) { list4[n].disable(); } } } } byte[] bytes = texture2D3.EncodeToPNG(); ReadWrite.writeBytes(Level.info.path + "/Chart.png", false, false, bytes); Object.DestroyImmediate(texture2D3); }
public IEnumerator init(int id) { if (!Level.isVR) { LevelNavigation.load(); } LoadingUI.updateProgress(1f / Level.STEPS); yield return null; LevelObjects.load(); LoadingUI.updateProgress(2f / Level.STEPS); yield return null; LevelLighting.load(Level.size); LoadingUI.updateProgress(3f / Level.STEPS); yield return null; LevelGround.load(Level.size); LoadingUI.updateProgress(4f / Level.STEPS); yield return null; LevelRoads.load(); LoadingUI.updateProgress(5f / Level.STEPS); yield return null; if (!Level.isVR) { LevelNodes.load(); LoadingUI.updateProgress(6f / Level.STEPS); yield return null; LevelItems.load(); LoadingUI.updateProgress(7f / Level.STEPS); yield return null; } LevelPlayers.load(); LoadingUI.updateProgress(8f / Level.STEPS); yield return null; if (!Level.isVR) { LevelZombies.load(); LoadingUI.updateProgress(9f / Level.STEPS); yield return null; LevelVehicles.load(); LoadingUI.updateProgress(10f / Level.STEPS); yield return null; LevelAnimals.load(); LoadingUI.updateProgress(11f / Level.STEPS); yield return null; } LevelVisibility.load(); LoadingUI.updateProgress(12f / Level.STEPS); yield return null; if (Level.loadingSteps != null) { Level.loadingSteps(); } yield return null; LevelBarricades.load(); yield return null; LevelStructures.load(); Level._hash = Hash.combine(new byte[][] { Level.getLevelHash(Level.info.path), LevelGround.hash, LevelLighting.hash, LevelObjects.hash }); Physics.gravity = new Vector3(0f, Level.info.configData.Gravity, 0f); yield return null; Resources.UnloadUnusedAssets(); GC.Collect(); yield return null; Level._editing = new GameObject().transform; Level.editing.name = "Editing"; Level.editing.parent = Level.level; if (Level.isEditor) { Level.mapper = ((GameObject)Object.Instantiate(Resources.Load("Edit/Mapper"))).transform; Level.mapper.name = "Mapper"; Level.mapper.parent = Level.editing; Level.mapper.position = new Vector3(0f, 1028f, 0f); Level.mapper.rotation = Quaternion.Euler(90f, 0f, 0f); Level.mapper.GetComponent<Camera>().orthographicSize = (float)(Level.size / 2 - Level.border); if (Level.isDevkit) { GameObject gameObject = Object.Instantiate<GameObject>(Resources.Load<GameObject>("Edit2/Editor")); if (gameObject != null) { gameObject.name = "Editor"; gameObject.transform.parent = Level.editing; } } else { Transform transform = ((GameObject)Object.Instantiate(Resources.Load((!Level.isVR) ? "Edit/Editor" : "Edit/VR"))).transform; transform.name = "Editor"; transform.parent = Level.editing; transform.tag = "Logic"; transform.gameObject.layer = LayerMasks.LOGIC; } } yield return null; if (Level.onPrePreLevelLoaded != null) { Level.onPrePreLevelLoaded(id); } yield return null; if (Level.onPreLevelLoaded != null) { Level.onPreLevelLoaded(id); } yield return null; if (Level.onLevelLoaded != null) { Level.onLevelLoaded(id); } yield return null; if (Level.onPostLevelLoaded != null) { Level.onPostLevelLoaded(id); } yield return null; if (!Level.isEditor && Level.info != null && Level.info.hasTriggers) { Transform transform2 = null; string text = Level.info.name.ToLower(); if (text != null) { if (!(text == "germany")) { if (!(text == "pei")) { if (!(text == "russia")) { if (text == "tutorial") { transform2 = ((GameObject)Object.Instantiate(Resources.Load("Level/Triggers_Tutorial"))).transform; } } else { transform2 = ((GameObject)Object.Instantiate(Resources.Load("Level/Triggers_Russia"))).transform; } } else { transform2 = ((GameObject)Object.Instantiate(Resources.Load("Level/Triggers_PEI"))).transform; } } else { transform2 = ((GameObject)Object.Instantiate(Resources.Load("Level/Triggers_Germany"))).transform; } } if (transform2 != null) { transform2.position = Vector3.zero; transform2.rotation = Quaternion.identity; transform2.name = "Triggers"; transform2.parent = Level.clips; } } yield return null; Level._isLoaded = true; Level.isLoadingContent = false; yield break; }
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; } }
public static void buildRoadsCommand() { LevelRoads.bakeRoads(); }
// Token: 0x06001F06 RID: 7942 RVA: 0x000AB8B0 File Offset: 0x000A9CB0 private void Update() { if (!EditorRoads.isPaving) { return; } if (!EditorInteract.isFlying && GUIUtility.hotControl == 0) { if (EditorInteract.worldHit.transform != null) { EditorRoads.highlighter.position = EditorInteract.worldHit.point; } if ((Input.GetKeyDown(KeyCode.Delete) || Input.GetKeyDown(KeyCode.Backspace)) && EditorRoads.selection != null && EditorRoads.road != null) { if (Input.GetKey(ControlsSettings.other)) { LevelRoads.removeRoad(EditorRoads.road); } else { EditorRoads.road.removeVertex(EditorRoads.vertexIndex); } EditorRoads.deselect(); } if (Input.GetKeyDown(ControlsSettings.tool_2) && EditorInteract.worldHit.transform != null) { Vector3 point = EditorInteract.worldHit.point; if (EditorRoads.road != null) { if (EditorRoads.tangentIndex > -1) { EditorRoads.road.moveTangent(EditorRoads.vertexIndex, EditorRoads.tangentIndex, point - EditorRoads.joint.vertex); } else if (EditorRoads.vertexIndex > -1) { EditorRoads.road.moveVertex(EditorRoads.vertexIndex, point); } } } if (Input.GetKeyDown(ControlsSettings.primary)) { if (EditorInteract.logicHit.transform != null) { if (EditorInteract.logicHit.transform.name.IndexOf("Path") != -1 || EditorInteract.logicHit.transform.name.IndexOf("Tangent") != -1) { EditorRoads.select(EditorInteract.logicHit.transform); } } else if (EditorInteract.worldHit.transform != null) { Vector3 point2 = EditorInteract.worldHit.point; if (EditorRoads.road != null) { if (EditorRoads.tangentIndex > -1) { EditorRoads.select(EditorRoads.road.addVertex(EditorRoads.vertexIndex + EditorRoads.tangentIndex, point2)); } else { float num = Vector3.Dot(point2 - EditorRoads.joint.vertex, EditorRoads.joint.getTangent(0)); float num2 = Vector3.Dot(point2 - EditorRoads.joint.vertex, EditorRoads.joint.getTangent(1)); if (num > num2) { EditorRoads.select(EditorRoads.road.addVertex(EditorRoads.vertexIndex, point2)); } else { EditorRoads.select(EditorRoads.road.addVertex(EditorRoads.vertexIndex + 1, point2)); } } } else { EditorRoads.select(LevelRoads.addRoad(point2)); } } } } }
// Token: 0x060034DE RID: 13534 RVA: 0x0015D47B File Offset: 0x0015B87B private static void onClickedBakeRoadsButton(SleekButton button) { LevelRoads.bakeRoads(); }