public void SpawnBridge(ref uint seed, PathList.BridgeObject obj) { if (string.IsNullOrEmpty(obj.Folder)) { return; } Prefab[] prefabArray = Prefab.Load(string.Concat("assets/bundled/prefabs/autospawn/", obj.Folder), null, null, true); if (prefabArray == null || prefabArray.Length == 0) { Debug.LogError(string.Concat("Empty decor folder: ", obj.Folder)); return; } Vector3 startPoint = this.Path.GetStartPoint(); Vector3 endPoint = this.Path.GetEndPoint() - startPoint; float single = endPoint.magnitude; Vector3 vector3 = endPoint / single; float distance = single / obj.Distance; int num = Mathf.RoundToInt(distance); float single1 = 0.5f * (distance - (float)num); Vector3 distance1 = obj.Distance * vector3; Vector3 vector31 = startPoint + ((0.5f + single1) * distance1); Quaternion quaternion = Quaternion.LookRotation(vector3); TerrainHeightMap heightMap = TerrainMeta.HeightMap; TerrainWaterMap waterMap = TerrainMeta.WaterMap; for (int i = 0; i < num; i++) { if (vector31.y > Mathf.Max(heightMap.GetHeight(vector31), waterMap.GetHeight(vector31)) - 1f) { this.SpawnObject(ref seed, prefabArray, vector31, quaternion, null); } vector31 += distance1; } }
public void RefreshTerrainData() { TerrainData terrainDatum = Terrain.activeTerrain.terrainData; TerrainHeightMap component = Terrain.activeTerrain.GetComponent <TerrainHeightMap>(); if (component) { this.heightmap = component.HeightTexture; } TerrainSplatMap terrainSplatMap = Terrain.activeTerrain.GetComponent <TerrainSplatMap>(); if (terrainSplatMap) { this.splatmap0 = terrainSplatMap.SplatTexture0; this.splatmap1 = terrainSplatMap.SplatTexture1; } TerrainAlphaMap terrainAlphaMap = Terrain.activeTerrain.GetComponent <TerrainAlphaMap>(); if (terrainAlphaMap) { this.alphamap = terrainAlphaMap.AlphaTexture; } TerrainBiomeMap terrainBiomeMap = Terrain.activeTerrain.GetComponent <TerrainBiomeMap>(); if (terrainBiomeMap) { this.biomemap = terrainBiomeMap.BiomeTexture; } TerrainTopologyMap terrainTopologyMap = Terrain.activeTerrain.GetComponent <TerrainTopologyMap>(); if (terrainTopologyMap) { this.topologymap = terrainTopologyMap.TopologyTexture; } TerrainWaterMap terrainWaterMap = Terrain.activeTerrain.GetComponent <TerrainWaterMap>(); if (terrainWaterMap) { this.watermap = terrainWaterMap.WaterTexture; } TerrainBlendMap terrainBlendMap = Terrain.activeTerrain.GetComponent <TerrainBlendMap>(); if (terrainBlendMap) { this.blendmap = terrainBlendMap.BlendTexture; } this.size = terrainDatum.size; this.extents = terrainDatum.size * 0.5f; this.offset = (Terrain.activeTerrain.GetPosition() + (terrainDatum.size.XZ3D() * 0.5f)) - base.transform.position; }
public void RefreshTerrainData() { TerrainData terrainData = Terrain.get_activeTerrain().get_terrainData(); TerrainHeightMap component1 = (TerrainHeightMap)((Component)Terrain.get_activeTerrain()).GetComponent <TerrainHeightMap>(); if (Object.op_Implicit((Object)component1)) { this.heightmap = component1.HeightTexture; } TerrainSplatMap component2 = (TerrainSplatMap)((Component)Terrain.get_activeTerrain()).GetComponent <TerrainSplatMap>(); if (Object.op_Implicit((Object)component2)) { this.splatmap0 = component2.SplatTexture0; this.splatmap1 = component2.SplatTexture1; } TerrainAlphaMap component3 = (TerrainAlphaMap)((Component)Terrain.get_activeTerrain()).GetComponent <TerrainAlphaMap>(); if (Object.op_Implicit((Object)component3)) { this.alphamap = component3.AlphaTexture; } TerrainBiomeMap component4 = (TerrainBiomeMap)((Component)Terrain.get_activeTerrain()).GetComponent <TerrainBiomeMap>(); if (Object.op_Implicit((Object)component4)) { this.biomemap = component4.BiomeTexture; } TerrainTopologyMap component5 = (TerrainTopologyMap)((Component)Terrain.get_activeTerrain()).GetComponent <TerrainTopologyMap>(); if (Object.op_Implicit((Object)component5)) { this.topologymap = component5.TopologyTexture; } TerrainWaterMap component6 = (TerrainWaterMap)((Component)Terrain.get_activeTerrain()).GetComponent <TerrainWaterMap>(); if (Object.op_Implicit((Object)component6)) { this.watermap = component6.WaterTexture; } TerrainBlendMap component7 = (TerrainBlendMap)((Component)Terrain.get_activeTerrain()).GetComponent <TerrainBlendMap>(); if (Object.op_Implicit((Object)component7)) { this.blendmap = component7.BlendTexture; } this.size = terrainData.get_size(); this.extents = Vector3.op_Multiply(terrainData.get_size(), 0.5f); this.offset = Vector3.op_Subtraction(Vector3.op_Addition(Terrain.get_activeTerrain().GetPosition(), Vector3.op_Multiply(Vector3Ex.XZ3D(terrainData.get_size()), 0.5f)), ((Component)this).get_transform().get_position()); }
public void Init(UnityEngine.Terrain terrainOverride = null, TerrainConfig configOverride = null) { if (terrainOverride != null) { this.terrain = terrainOverride; } if (configOverride != null) { this.config = configOverride; } TerrainMeta.Terrain = this.terrain; TerrainMeta.Config = this.config; TerrainMeta.Transform = this.terrain.transform; TerrainMeta.Data = this.terrain.terrainData; TerrainMeta.Size = this.terrain.terrainData.size; TerrainMeta.OneOverSize = TerrainMeta.Size.Inverse(); TerrainMeta.Position = this.terrain.GetPosition(); TerrainMeta.Collider = this.terrain.GetComponent <TerrainCollider>(); TerrainMeta.Collision = this.terrain.GetComponent <TerrainCollision>(); TerrainMeta.Physics = this.terrain.GetComponent <TerrainPhysics>(); TerrainMeta.Colors = this.terrain.GetComponent <TerrainColors>(); TerrainMeta.Quality = this.terrain.GetComponent <TerrainQuality>(); TerrainMeta.Path = this.terrain.GetComponent <TerrainPath>(); TerrainMeta.BiomeMap = this.terrain.GetComponent <TerrainBiomeMap>(); TerrainMeta.AlphaMap = this.terrain.GetComponent <TerrainAlphaMap>(); TerrainMeta.BlendMap = this.terrain.GetComponent <TerrainBlendMap>(); TerrainMeta.HeightMap = this.terrain.GetComponent <TerrainHeightMap>(); TerrainMeta.SplatMap = this.terrain.GetComponent <TerrainSplatMap>(); TerrainMeta.TopologyMap = this.terrain.GetComponent <TerrainTopologyMap>(); TerrainMeta.WaterMap = this.terrain.GetComponent <TerrainWaterMap>(); TerrainMeta.DistanceMap = this.terrain.GetComponent <TerrainDistanceMap>(); TerrainMeta.Texturing = this.terrain.GetComponent <TerrainTexturing>(); TerrainMeta.HighestPoint = new Vector3(TerrainMeta.Position.x, TerrainMeta.Position.y + TerrainMeta.Size.y, TerrainMeta.Position.z); TerrainMeta.LowestPoint = new Vector3(TerrainMeta.Position.x, TerrainMeta.Position.y, TerrainMeta.Position.z); TerrainExtension[] components = base.GetComponents <TerrainExtension>(); for (int i = 0; i < (int)components.Length; i++) { components[i].Init(this.terrain, this.config); } uint seed = World.Seed; int num = SeedRandom.Range(ref seed, 0, 4) * 90; int num1 = SeedRandom.Range(ref seed, -45, 46); int num2 = SeedRandom.Sign(ref seed); TerrainMeta.LootAxisAngle = (float)num; TerrainMeta.BiomeAxisAngle = (float)(num + num1 + num2 * 90); }