public static void CreateWindSFX(Transform root) { Collider[] allComponentsInChildren = root.GetAllComponentsInChildren <Collider>(); if (allComponentsInChildren.Length > 0) { Bounds bounds = allComponentsInChildren[0].bounds; for (int i = 1; i < allComponentsInChildren.Length; i++) { bounds.Encapsulate(allComponentsInChildren[i].bounds); } float num = Terrain.activeTerrain.SampleHeight(bounds.center); float y = Terrain.activeTerrain.transform.position.y; float num2 = bounds.max.y - (num + y); if (num2 >= 2f) { FMOD_StudioEventEmitter.CreateAmbientEmitter(root, bounds.center, "event:/ambient/wind/wind_moan_structures"); } } }
protected virtual void CreateStructure(bool isRepair = false) { if (isRepair) { this.Clear(); base.StartCoroutine(this.DelayedAwake(true)); } int num = LayerMask.NameToLayer("Prop"); this._wallRoot = this.SpawnStructure(); this._wallRoot.parent = base.transform; if (this._wasBuilt) { this._gridToken = InsideCheck.AddWallChunk(this._p1, this._p2, 4.75f * this._logWidth + 1f); if (this._lods) { UnityEngine.Object.Destroy(this._lods.gameObject); } this._lods = new GameObject("lods").AddComponent <WallChunkLods>(); this._lods.transform.parent = base.transform; this._lods.DefineChunk(this._p1, this._p2, 4.44f * this._logWidth, this._wallRoot, this.Addition); if (!this._wallCollision) { GameObject gameObject = new GameObject("collision"); gameObject.transform.parent = this._wallRoot.parent; gameObject.transform.position = this._wallRoot.position; gameObject.transform.rotation = this._wallRoot.rotation; gameObject.tag = "structure"; this._wallCollision = gameObject.transform; GameObject gameObject2 = this._wallRoot.gameObject; int layer = num; gameObject.layer = layer; gameObject2.layer = layer; float num3; float num4; Vector3 size; Vector3 vector; if (this.UseHorizontalLogs) { float num2 = Vector3.Distance(this._p1, this._p2) / this._logLength; num3 = 7.4f * num2; num4 = 6.75f * (0.31f + (num2 - 1f) / 2f); size = new Vector3(1.75f, 0.9f * this._height * this._logWidth, num3 * 1f); vector = Vector3.Lerp(this._p1, this._p2, 0.5f); vector = this._wallRoot.InverseTransformPoint(vector); vector.y = size.y / 2f - this._logWidth / 2f; } else { num3 = this._logWidth * (float)(this._wallRoot.childCount - 1) + 1.5f; num4 = 0f; vector = Vector3.zero; IEnumerator enumerator = this._wallRoot.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Transform transform = (Transform)obj; vector += transform.position; } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } size = new Vector3(1.75f, 0.92f * this._height * this._logWidth, num3); vector /= (float)this._wallRoot.childCount; vector = this._wallRoot.InverseTransformPoint(vector); vector.y = size.y / 2f - this._logWidth / 2f; } getStructureStrength getStructureStrength = gameObject.AddComponent <getStructureStrength>(); getStructureStrength._strength = getStructureStrength.strength.strong; BoxCollider boxCollider = gameObject.AddComponent <BoxCollider>(); boxCollider.center = vector; boxCollider.size = size; boxCollider.isTrigger = true; BuildingHealth component = base.GetComponent <BuildingHealth>(); if (component) { component._renderersRoot = this._wallRoot.gameObject; } WallChunkArchitect.Additions addition = this._addition; if (addition != WallChunkArchitect.Additions.Wall) { BoxCollider boxCollider2 = null; if (this._height > 4f) { vector.y += this._logWidth * 2f; size.y = 1f * this._logWidth; boxCollider2 = gameObject.AddComponent <BoxCollider>(); boxCollider2.center = vector; boxCollider2.size = size; } FMOD_StudioEventEmitter.CreateAmbientEmitter(gameObject.transform, gameObject.transform.TransformPoint(vector), "event:/ambient/wind/wind_moan_structures"); size.y = Mathf.Clamp(this._height, 0f, 4f) * this._logWidth; size.z = num4; vector.y = size.y / 2f - this._logWidth / 2f; vector.z = num3 - num4 / 2f; BoxCollider boxCollider3 = gameObject.AddComponent <BoxCollider>(); boxCollider3.center = vector; boxCollider3.size = size; vector.z = num4 / 2f; BoxCollider boxCollider4 = gameObject.AddComponent <BoxCollider>(); boxCollider4.center = vector; boxCollider4.size = size; if (this._addition == WallChunkArchitect.Additions.Window) { size.y = this._logWidth * 1.9f; size.z = num3 - num4 * 2f; vector.z += num4 / 2f + size.z / 2f; vector.y = size.y / 2f - this._logWidth / 2f; BoxCollider boxCollider5 = gameObject.AddComponent <BoxCollider>(); boxCollider5.center = vector; boxCollider5.size = size; GameObject gameObject3 = new GameObject("PerchTarget"); SphereCollider sphereCollider = gameObject3.AddComponent <SphereCollider>(); sphereCollider.isTrigger = true; sphereCollider.radius = 0.145f; gameObject3.transform.parent = this._wallRoot; vector.y += size.y / 2f; gameObject3.transform.localPosition = vector; if (BoltNetwork.isRunning) { if (boxCollider2) { component.SetMpRandomDistortColliders(new Collider[] { boxCollider2, boxCollider4, boxCollider3, boxCollider5 }); } else { component.SetMpRandomDistortColliders(new Collider[] { boxCollider4, boxCollider3, boxCollider5 }); } } } else if (BoltNetwork.isRunning) { component.SetMpRandomDistortColliders(new Collider[] { boxCollider2, boxCollider4, boxCollider3 }); } } else { BoxCollider boxCollider6 = gameObject.AddComponent <BoxCollider>(); boxCollider6.center = vector; boxCollider6.size = size; if (BoltNetwork.isRunning) { component.SetMpRandomDistortColliders(new Collider[] { boxCollider6 }); } } gridObjectBlocker gridObjectBlocker = gameObject.AddComponent <gridObjectBlocker>(); gridObjectBlocker.ignoreOnDisable = true; addToBuilt addToBuilt = gameObject.AddComponent <addToBuilt>(); addToBuilt.addToStructures = true; BuildingHealthHitRelay buildingHealthHitRelay = gameObject.AddComponent <BuildingHealthHitRelay>(); } if (this.Addition >= WallChunkArchitect.Additions.Door1 && this._addition <= WallChunkArchitect.Additions.LockedDoor2 && !isRepair) { Vector3 position = Vector3.Lerp(this._p1, this._p2, 0.5f); position.y -= this._logWidth / 2f; Vector3 worldPosition = (this._addition != WallChunkArchitect.Additions.Door1 && this._addition != WallChunkArchitect.Additions.LockedDoor1) ? this._p1 : this._p2; worldPosition.y = position.y; Transform transform2 = UnityEngine.Object.Instantiate <Transform>(Prefabs.Instance.DoorPrefab, position, this._wallRoot.rotation); transform2.LookAt(worldPosition); transform2.parent = base.transform; } } }