public void TierDestroyed_Actual(FoundationChunkTier tier) { if (!PlayerPreferences.NoDestruction) { try { if (!this._collapsing) { int num = tier._segmentNum + this._foundation.Edges.Take(tier._edgeNum).Sum((FoundationArchitect.Edge e) => e._segments.Length); this._chunks[num]._tiers[tier._tierNum]._hp = -42f; Transform exists = this._foundation.FoundationRoot.transform.Find("Edge" + tier._edgeNum); if (exists) { Renderer[] componentsInChildren = tier.GetComponentsInChildren <Renderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { Transform transform = componentsInChildren[i].transform; GameObject gameObject = transform.gameObject; transform.parent = null; gameObject.layer = 31; CapsuleCollider capsuleCollider = gameObject.AddComponent <CapsuleCollider>(); capsuleCollider.radius = 0.5f; capsuleCollider.height = 4.5f; capsuleCollider.direction = 2; Rigidbody rigidbody = gameObject.AddComponent <Rigidbody>(); if (rigidbody) { rigidbody.AddForce((transform.position - tier.transform.position).normalized * 2.5f, ForceMode.Impulse); rigidbody.AddRelativeTorque(Vector3.up * 2f, ForceMode.Impulse); } destroyAfter destroyAfter = gameObject.AddComponent <destroyAfter>(); destroyAfter.destroyTime = 1.75f; this._collapsedLogs++; } } Collider component = tier.GetComponent <Collider>(); if (component && !component.isTrigger) { UnityEngine.Object.Destroy(component); } if (BoltNetwork.isServer) { this.PublishDestroyedTierData(this.LightWeightExport()); } this.IntegrityCheck(num, tier._tierNum); if (!this._collapsing) { this.CheckSpawnRepairTrigger(); } } } catch (Exception exception) { Debug.LogException(exception); } } }
public void LocalizedTierHit(LocalizedHitData data, FoundationChunkTier tier) { if (!PlayerPreferences.NoDestruction && !BoltNetwork.isClient) { this._lastHit = Time.realtimeSinceStartup; FoundationArchitect.Edge edge = this._foundation.Edges[tier._edgeNum]; int num = this._foundation.Edges.Take(tier._edgeNum).Sum((FoundationArchitect.Edge e) => e._segments.Length); int num2 = tier._segmentNum + num; this._chunks[num2]._tiers[tier._tierNum]._hp -= data._damage; float hp = this._chunks[num2]._tiers[tier._tierNum]._hp; if (hp <= 0f) { if (tier.transform.parent) { tier.transform.parent = null; Renderer[] componentsInChildren = tier.GetComponentsInChildren <Renderer>(); for (int i = 0; i < componentsInChildren.Length; i++) { Transform transform = componentsInChildren[i].transform; GameObject gameObject = transform.gameObject; transform.parent = null; gameObject.layer = 31; CapsuleCollider capsuleCollider = gameObject.AddComponent <CapsuleCollider>(); capsuleCollider.radius = 0.5f; capsuleCollider.height = 4.5f; capsuleCollider.direction = 0; Rigidbody rigidbody = gameObject.AddComponent <Rigidbody>(); if (rigidbody) { rigidbody.AddForce((transform.position - data._position).normalized * 2f, ForceMode.Impulse); rigidbody.AddRelativeTorque(Vector3.up * 2f, ForceMode.Impulse); } destroyAfter destroyAfter = gameObject.AddComponent <destroyAfter>(); destroyAfter.destroyTime = 1.75f; this._collapsedLogs++; } if (LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayStructureBreak(base.gameObject, 0.2f); } UnityEngine.Object.Destroy(tier.gameObject); if (BoltNetwork.isServer) { this.PublishDestroyedTierData(this.LightWeightExport()); } this.IntegrityCheck(num2, tier._tierNum); } } else { if (BoltNetwork.isServer && base.entity && base.entity.isAttached) { this.CalcTotalRepairMaterial(); } this.Distort(data); } if (!this._collapsing) { this.CheckSpawnRepairTrigger(); } Prefabs.Instance.SpawnHitPS(HitParticles.Wood, data._position, Quaternion.LookRotation(tier.transform.right)); } }