Ejemplo n.º 1
0
 // Token: 0x060034D7 RID: 13527 RVA: 0x0015D354 File Offset: 0x0015B754
 private static void updateSelection()
 {
     if ((int)EditorRoads.selected < LevelRoads.materials.Length)
     {
         RoadMaterial roadMaterial = LevelRoads.materials[(int)EditorRoads.selected];
         EditorEnvironmentRoadsUI.selectedBox.text     = roadMaterial.material.mainTexture.name;
         EditorEnvironmentRoadsUI.widthField.state     = roadMaterial.width;
         EditorEnvironmentRoadsUI.heightField.state    = roadMaterial.height;
         EditorEnvironmentRoadsUI.depthField.state     = roadMaterial.depth;
         EditorEnvironmentRoadsUI.offset2Field.state   = roadMaterial.offset;
         EditorEnvironmentRoadsUI.concreteToggle.state = roadMaterial.isConcrete;
     }
 }
Ejemplo n.º 2
0
		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);
		}