コード例 #1
0
ファイル: PhysicsTool.cs プロジェクト: sky-xk-nge/Unturned
        public static EPhysicsMaterial checkMaterial(Vector3 point)
        {
            if (LevelGround.terrain == null)
            {
                AssetReference <LandscapeMaterialAsset> reference;
                if (Landscape.getSplatmapMaterial(point, out reference))
                {
                    LandscapeMaterialAsset landscapeMaterialAsset = Assets.find <LandscapeMaterialAsset>(reference);
                    if (landscapeMaterialAsset != null)
                    {
                        return(landscapeMaterialAsset.physicsMaterial);
                    }
                }
                return(EPhysicsMaterial.NONE);
            }
            GroundMaterial material = LevelGround.getMaterial(point);

            if (material.isGrassy_0 || material.isGrassy_1 || material.isFlowery_0 || material.isFlowery_1)
            {
                return(EPhysicsMaterial.FOLIAGE_STATIC);
            }
            if (material.isRocky)
            {
                return(EPhysicsMaterial.GRAVEL_STATIC);
            }
            if (material.isRoad)
            {
                return(EPhysicsMaterial.CONCRETE_STATIC);
            }
            if (material.isSnowy)
            {
                return(EPhysicsMaterial.SNOW_STATIC);
            }
            return(EPhysicsMaterial.CONCRETE_STATIC);
        }
コード例 #2
0
        static bool tick_Prefix(Animal __instance)
        {
            var pet = PetsPlugin.Instance.PetsService.GetPet(__instance);

            if (pet == null)
            {
                return(true);
            }

            Vector3 playerPos = pet.Player.transform.position;

            Vector3 spawnPos = playerPos + ((pet.Player.transform.right + pet.Player.transform.forward) * PetsPlugin.Instance.Configuration.Instance.MinDistance);

            spawnPos.y = LevelGround.getHeight(spawnPos);

            float delta = Time.time - (float)ReflectionUtil.getValue("lastTick", __instance);

            ReflectionUtil.setValue("lastTick", Time.time, __instance);

            ReflectionUtil.setValue("target", spawnPos, __instance);
            ReflectionUtil.setValue("_isFleeing", true, __instance);
            ReflectionUtil.setValue("player", null, __instance);
            ReflectionUtil.setValue("isAttacking", false, __instance);
            ReflectionUtil.setValue("_isFleeing", true, pet.Animal);
            ReflectionUtil.setValue("isWandering", false, pet.Animal);
            ReflectionUtil.setValue("isHunting", false, pet.Animal);
            ReflectionUtil.callMethod("move", __instance, delta);
            return(false);
        }
コード例 #3
0
 private void Update()
 {
     if (!EditorTerrainMaterials.isPainting)
     {
         return;
     }
     if (!EditorInteract.isFlying && GUIUtility.hotControl == 0)
     {
         if (Input.GetKeyDown(122) && !LevelGround.previewHQ && Input.GetKey(306))
         {
             if (EditorTerrainMaterials.map2)
             {
                 LevelGround.undoMaterial2();
             }
             else
             {
                 LevelGround.undoMaterial();
             }
         }
         if (Input.GetKeyDown(120) && !LevelGround.previewHQ && Input.GetKey(306))
         {
             if (EditorTerrainMaterials.map2)
             {
                 LevelGround.redoMaterial2();
             }
             else
             {
                 LevelGround.redoMaterial();
             }
         }
         if (EditorInteract.groundHit.transform != null)
         {
             EditorTerrainMaterials.brush.position = EditorInteract.groundHit.point;
         }
         if (Input.GetKeyUp(ControlsSettings.primary) && !LevelGround.previewHQ && EditorTerrainMaterials.wasPainting)
         {
             if (EditorTerrainMaterials.map2)
             {
                 LevelGround.registerMaterial2();
             }
             else
             {
                 LevelGround.registerMaterial();
             }
         }
         if (Input.GetKey(ControlsSettings.primary) && !LevelGround.previewHQ && EditorInteract.groundHit.transform != null)
         {
             LevelGround.paint(EditorInteract.groundHit.point, (int)EditorTerrainMaterials.brushSize, EditorTerrainMaterials.brushNoise, (int)EditorTerrainMaterials.selected, EditorTerrainMaterials.map2);
             EditorTerrainMaterials.wasPainting = true;
         }
         else
         {
             EditorTerrainMaterials.wasPainting = false;
         }
     }
 }
コード例 #4
0
ファイル: Animal.cs プロジェクト: sky-xk-nge/Unturned
        private bool checkTargetValid(Vector3 point)
        {
            if (!Level.checkSafeIncludingClipVolumes(point))
            {
                return(false);
            }
            float height = LevelGround.getHeight(point);

            return(!WaterUtility.isPointUnderwater(new Vector3(point.x, height - 1f, point.z)));
        }
コード例 #5
0
 // Token: 0x06002666 RID: 9830 RVA: 0x000E1A3C File Offset: 0x000DFE3C
 public void getTrackPosition(float t, out int index, out Vector3 position, out Vector3 normal)
 {
     position = this.getPosition(t, out index);
     normal   = Vector3.up;
     if (!this.joints[index].ignoreTerrain)
     {
         position.y = LevelGround.getHeight(position);
         normal     = LevelGround.getNormal(position);
     }
     position += normal * (LevelRoads.materials[(int)this.material].depth + LevelRoads.materials[(int)this.material].offset);
 }
コード例 #6
0
 public static bool IsPlayerInCave(this TeleportationPlugin plugin, UnturnedPlayer player)
 {
     if (!plugin.Configuration.Instance.AllowCave)
     {
         if (LevelGround.checkSafe(player.Position) != player.Position)
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #7
0
 // 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);
     }
 }
コード例 #8
0
        private Transform spawnStructure(StructureRegion region, ushort id, Vector3 point, byte angle_x, byte angle_y, byte angle_z, byte hp, ulong owner, ulong group, uint instanceID)
        {
            if (id == 0)
            {
                return(null);
            }
            ItemStructureAsset itemStructureAsset;

            try
            {
                itemStructureAsset = (ItemStructureAsset)Assets.find(EAssetType.ITEM, id);
            }
            catch
            {
                itemStructureAsset = null;
            }
            if (itemStructureAsset != null)
            {
                Transform structure = StructureTool.getStructure(id, hp, owner, group, itemStructureAsset);
                structure.parent   = LevelStructures.models;
                structure.position = point;
                structure.rotation = Quaternion.Euler((float)(angle_x * 2), (float)(angle_y * 2), (float)(angle_z * 2));
                if (!Dedicator.isDedicated && (itemStructureAsset.construct == EConstruct.FLOOR || itemStructureAsset.construct == EConstruct.FLOOR_POLY))
                {
                    LevelGround.bewilder(point);
                }
                region.drops.Add(new StructureDrop(structure, instanceID));
                StructureManager.structureColliders.Clear();
                structure.GetComponentsInChildren <Collider>(StructureManager.structureColliders);
                for (int i = 0; i < StructureManager.structureColliders.Count; i++)
                {
                    if (StructureManager.structureColliders[i] is MeshCollider)
                    {
                        StructureManager.structureColliders[i].enabled = false;
                    }
                    if (StructureManager.structureColliders[i] is MeshCollider)
                    {
                        StructureManager.structureColliders[i].enabled = true;
                    }
                }
                return(structure);
            }
            if (!Provider.isServer)
            {
                Provider.connectionFailureInfo = ESteamConnectionFailureInfo.STRUCTURE;
                Provider.disconnect();
            }
            return(null);
        }
コード例 #9
0
ファイル: LandscapeTile.cs プロジェクト: sky-xk-nge/Unturned
 public void convertLegacyHeightmap()
 {
     for (int i = 0; i < Landscape.HEIGHTMAP_RESOLUTION; i++)
     {
         for (int j = 0; j < Landscape.HEIGHTMAP_RESOLUTION; j++)
         {
             HeightmapCoord heightmapCoord = new HeightmapCoord(i, j);
             Vector3        worldPosition  = Landscape.getWorldPosition(this.coord, heightmapCoord, this.sourceHeightmap[i, j]);
             float          num            = LevelGround.getConversionHeight(worldPosition);
             num /= Landscape.TILE_HEIGHT;
             num += 0.5f;
             this.sourceHeightmap[i, j] = num;
         }
     }
     this.data.SetHeights(0, 0, this.sourceHeightmap);
 }
コード例 #10
0
ファイル: LandscapeTile.cs プロジェクト: sky-xk-nge/Unturned
 public void convertLegacySplatmap()
 {
     for (int i = 0; i < Landscape.SPLATMAP_RESOLUTION; i++)
     {
         for (int j = 0; j < Landscape.SPLATMAP_RESOLUTION; j++)
         {
             SplatmapCoord splatmapCoord = new SplatmapCoord(i, j);
             Vector3       worldPosition = Landscape.getWorldPosition(this.coord, splatmapCoord);
             for (int k = 0; k < Landscape.SPLATMAP_LAYERS; k++)
             {
                 float conversionWeight = LevelGround.getConversionWeight(worldPosition, k, true);
                 this.sourceSplatmap[i, j, k] = conversionWeight;
             }
         }
     }
     this.data.SetAlphamaps(0, 0, this.sourceSplatmap);
 }
コード例 #11
0
ファイル: Level.cs プロジェクト: sky-xk-nge/Unturned
		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();
		}
コード例 #12
0
        protected override void addFoliage(Vector3 position, Quaternion rotation, Vector3 scale, bool clearWhenBaked)
        {
            ResourceAsset resourceAsset = Assets.find <ResourceAsset>(this.resource);

            if (resourceAsset == null)
            {
                return;
            }
            byte b = 0;

            while ((int)b < LevelGround.resources.Length)
            {
                GroundResource groundResource = LevelGround.resources[(int)b];
                if (groundResource.id == resourceAsset.id)
                {
                    break;
                }
                b += 1;
            }
            LevelGround.addSpawn(position, b, clearWhenBaked);
        }
コード例 #13
0
 // Token: 0x060035D5 RID: 13781 RVA: 0x0016AC0F File Offset: 0x0016900F
 private static void onClickedBakeSkyboxResourcesButton(SleekButton button)
 {
     LevelGround.bakeSkyboxResources();
 }
コード例 #14
0
ファイル: Level.cs プロジェクト: sky-xk-nge/Unturned
		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);
		}
コード例 #15
0
ファイル: Level.cs プロジェクト: sky-xk-nge/Unturned
		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;
		}
コード例 #16
0
 private static void onClickedBakeLocalMaterialsButton(SleekButton button)
 {
     LevelGround.bakeMaterials(false);
 }
コード例 #17
0
 private static void onClickedBakeGlobalMaterialsButton(SleekButton button)
 {
     LevelGround.bakeMaterials(true);
 }
コード例 #18
0
ファイル: EditorSpawns.cs プロジェクト: sky-xk-nge/Unturned
 private void Update()
 {
     if (!EditorSpawns.isSpawning)
     {
         return;
     }
     if (!EditorInteract.isFlying && GUIUtility.hotControl == 0)
     {
         if (Input.GetKeyDown(ControlsSettings.tool_0))
         {
             if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_RESOURCE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_RESOURCE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ITEM)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_ITEM;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_PLAYER)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_PLAYER;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ZOMBIE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_ZOMBIE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_VEHICLE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_VEHICLE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ANIMAL)
             {
                 EditorSpawns.spawnMode = ESpawnMode.ADD_ANIMAL;
             }
         }
         if (Input.GetKeyDown(ControlsSettings.tool_1))
         {
             if (EditorSpawns.spawnMode == ESpawnMode.ADD_RESOURCE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_RESOURCE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ITEM)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_ITEM;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_PLAYER)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_PLAYER;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ZOMBIE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_ZOMBIE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_VEHICLE)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_VEHICLE;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ANIMAL)
             {
                 EditorSpawns.spawnMode = ESpawnMode.REMOVE_ANIMAL;
             }
         }
         if (EditorInteract.worldHit.transform != null)
         {
             if (EditorSpawns.spawnMode == ESpawnMode.ADD_ITEM)
             {
                 EditorSpawns.itemSpawn.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_PLAYER)
             {
                 EditorSpawns.playerSpawn.position    = EditorInteract.worldHit.point;
                 EditorSpawns.playerSpawnAlt.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ZOMBIE)
             {
                 EditorSpawns.zombieSpawn.position = EditorInteract.worldHit.point + Vector3.up;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_VEHICLE)
             {
                 EditorSpawns.vehicleSpawn.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ANIMAL)
             {
                 EditorSpawns.animalSpawn.position = EditorInteract.worldHit.point;
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_RESOURCE || EditorSpawns.spawnMode == ESpawnMode.REMOVE_ITEM || EditorSpawns.spawnMode == ESpawnMode.REMOVE_PLAYER || EditorSpawns.spawnMode == ESpawnMode.REMOVE_ZOMBIE || EditorSpawns.spawnMode == ESpawnMode.REMOVE_VEHICLE || EditorSpawns.spawnMode == ESpawnMode.REMOVE_ANIMAL)
             {
                 EditorSpawns.remove.position = EditorInteract.worldHit.point;
             }
         }
         if (Input.GetKeyDown(ControlsSettings.primary) && EditorInteract.worldHit.transform != null)
         {
             Vector3 point = EditorInteract.worldHit.point;
             if (EditorSpawns.spawnMode == ESpawnMode.ADD_RESOURCE)
             {
                 if ((int)EditorSpawns.selectedResource < LevelGround.resources.Length)
                 {
                     LevelGround.addSpawn(point, EditorSpawns.selectedResource, false);
                 }
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_RESOURCE)
             {
                 LevelGround.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ITEM)
             {
                 if ((int)EditorSpawns.selectedItem < LevelItems.tables.Count)
                 {
                     LevelItems.addSpawn(point);
                 }
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ITEM)
             {
                 LevelItems.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_PLAYER)
             {
                 LevelPlayers.addSpawn(point, EditorSpawns.rotation, EditorSpawns.selectedAlt);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_PLAYER)
             {
                 LevelPlayers.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ZOMBIE)
             {
                 if ((int)EditorSpawns.selectedZombie < LevelZombies.tables.Count)
                 {
                     LevelZombies.addSpawn(point);
                 }
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ZOMBIE)
             {
                 LevelZombies.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_VEHICLE)
             {
                 LevelVehicles.addSpawn(point, EditorSpawns.rotation);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_VEHICLE)
             {
                 LevelVehicles.removeSpawn(point, (float)EditorSpawns.radius);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.ADD_ANIMAL)
             {
                 LevelAnimals.addSpawn(point);
             }
             else if (EditorSpawns.spawnMode == ESpawnMode.REMOVE_ANIMAL)
             {
                 LevelAnimals.removeSpawn(point, (float)EditorSpawns.radius);
             }
         }
     }
 }
コード例 #19
0
        // 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++;
            }
        }
コード例 #20
0
 // Token: 0x0600359C RID: 13724 RVA: 0x00168002 File Offset: 0x00166402
 private static void onClickedBakeDetailsButton(SleekButton button)
 {
     LevelGround.bakeDetails();
 }
コード例 #21
0
 private void Update()
 {
     if (!EditorTerrainHeight.isTerraforming)
     {
         return;
     }
     if (!EditorInteract.isFlying && GUIUtility.hotControl == 0)
     {
         if (Input.GetKeyDown(ControlsSettings.tool_0))
         {
             if (EditorTerrainHeight.brushMode == EPaintMode.ADJUST_UP)
             {
                 EditorTerrainHeight.brushMode = EPaintMode.ADJUST_DOWN;
             }
             else
             {
                 EditorTerrainHeight.brushMode = EPaintMode.ADJUST_UP;
             }
         }
         if (Input.GetKeyDown(ControlsSettings.tool_1))
         {
             EditorTerrainHeight.brushMode = EPaintMode.SMOOTH;
         }
         if (Input.GetKeyDown(ControlsSettings.tool_2))
         {
             EditorTerrainHeight.brushMode = EPaintMode.FLATTEN;
         }
         if (Input.GetKeyDown(122) && Input.GetKey(306))
         {
             if (EditorTerrainHeight.map2)
             {
                 LevelGround.undoHeight2();
             }
             else
             {
                 LevelGround.undoHeight();
             }
         }
         if (Input.GetKeyDown(120) && Input.GetKey(306))
         {
             if (EditorTerrainHeight.map2)
             {
                 LevelGround.redoHeight2();
             }
             else
             {
                 LevelGround.redoHeight();
             }
         }
         if (EditorInteract.groundHit.transform != null)
         {
             if (EditorTerrainHeight.brushMode == EPaintMode.FLATTEN)
             {
                 EditorTerrainHeight.brush.position = new Vector3(EditorInteract.groundHit.point.x, EditorTerrainHeight.brushHeight * Level.TERRAIN, EditorInteract.groundHit.point.z);
             }
             else
             {
                 EditorTerrainHeight.brush.position = EditorInteract.groundHit.point;
             }
         }
         if (Input.GetKeyUp(ControlsSettings.primary) && EditorTerrainHeight.wasTerraforming)
         {
             if (EditorTerrainHeight.map2)
             {
                 LevelGround.registerHeight2();
             }
             else
             {
                 LevelGround.registerHeight();
             }
         }
         if (Input.GetKey(ControlsSettings.primary) && EditorInteract.groundHit.transform != null)
         {
             if (EditorTerrainHeight.brushMode == EPaintMode.ADJUST_UP)
             {
                 LevelGround.adjust(EditorInteract.groundHit.point, (int)EditorTerrainHeight.brushSize, EditorTerrainHeight.brushStrength, EditorTerrainHeight.brushNoise, EditorTerrainHeight.map2);
             }
             else if (EditorTerrainHeight.brushMode == EPaintMode.ADJUST_DOWN)
             {
                 LevelGround.adjust(EditorInteract.groundHit.point, (int)EditorTerrainHeight.brushSize, -EditorTerrainHeight.brushStrength, EditorTerrainHeight.brushNoise, EditorTerrainHeight.map2);
             }
             else if (EditorTerrainHeight.brushMode == EPaintMode.SMOOTH)
             {
                 LevelGround.smooth(EditorInteract.groundHit.point, (int)EditorTerrainHeight.brushSize, EditorTerrainHeight.brushStrength, EditorTerrainHeight.brushNoise, EditorTerrainHeight.map2);
             }
             else if (EditorTerrainHeight.brushMode == EPaintMode.FLATTEN)
             {
                 LevelGround.flatten(EditorInteract.groundHit.point, (int)EditorTerrainHeight.brushSize, EditorTerrainHeight.brushHeight, EditorTerrainHeight.brushStrength, EditorTerrainHeight.brushNoise, EditorTerrainHeight.map2);
             }
             EditorTerrainHeight.wasTerraforming = true;
         }
         else
         {
             EditorTerrainHeight.wasTerraforming = false;
         }
         if (Input.GetKeyDown(ControlsSettings.tool_2) && EditorInteract.groundHit.transform != null)
         {
             EditorTerrainHeight.brushHeight = EditorInteract.groundHit.point.y / Level.TERRAIN;
             if (EditorTerrainHeight.brushHeight < 0f)
             {
                 EditorTerrainHeight.brushHeight = 0f;
             }
             else if (EditorTerrainHeight.brushHeight > 1f)
             {
                 EditorTerrainHeight.brushHeight = 1f;
             }
             EditorTerrainHeightUI.heightValue.state = EditorTerrainHeight.brushHeight;
         }
     }
 }