private void lookAtExplosion(Vector3 position) { Vector3 b = new Vector3(1f, 0f, 1f); if (!this._idleIfPresent && Vector3.Distance(Vector3.Scale(position, b), Vector3.Scale(base.transform.position, b)) < 3.5f) { if (LocalPlayer.Sfx) { LocalPlayer.Sfx.PlayBreakWood(base.gameObject); } LOD_Stump componentInParent = base.GetComponentInParent <LOD_Stump>(); LOD_Trees lod_Trees = (!componentInParent) ? base.GetComponentInParent <LOD_Trees>() : componentInParent.transform.parent.GetComponent <LOD_Trees>(); if (lod_Trees) { if (componentInParent && componentInParent.Pool.IsSpawned(base.transform)) { base.transform.parent = componentInParent.Pool.transform; componentInParent.Pool.Despawn(base.transform); } if (!BoltNetwork.isRunning) { this.Finalize(lod_Trees, (!componentInParent) ? base.gameObject : componentInParent.gameObject); } else { RemoveStump removeStump = RemoveStump.Create(GlobalTargets.OnlyServer); removeStump.TargetTree = lod_Trees.GetComponent <BoltEntity>(); if (this._blownUpStump) { removeStump.Position = base.transform.position; removeStump.Rotation = base.transform.rotation; removeStump.CutUpStumpPrefabId = this._blownUpStump.GetComponent <BoltEntity>().prefabId; } removeStump.Send(); this.Finalize((!BoltNetwork.isServer) ? null : lod_Trees, (!componentInParent) ? base.gameObject : componentInParent.gameObject); } } else { TreeHealth componentInParent2 = base.GetComponentInParent <TreeHealth>(); if (componentInParent2 && componentInParent2.LodTree) { if (BoltNetwork.isRunning) { CoopTreeId component = componentInParent2.LodTree.GetComponent <CoopTreeId>(); if (component) { component.Goto_Removed(); } } this.Finalize(componentInParent2.LodTree, componentInParent2.gameObject); } } } }
private void lookAtExplosion(Vector3 position) { Vector3 b = new Vector3(1f, 0f, 1f); if (!this._idleIfPresent && !BoltNetwork.isClient && Vector3.Distance(Vector3.Scale(position, b), Vector3.Scale(base.transform.position, b)) < 3.5f) { LocalPlayer.Sfx.PlayBreakWood(base.gameObject); LOD_Stump componentInParent = base.GetComponentInParent <LOD_Stump>(); if (componentInParent) { LOD_Trees component = componentInParent.transform.parent.GetComponent <LOD_Trees>(); if (component.Pool.IsSpawned(base.transform)) { base.transform.parent = component.Pool.transform; component.Pool.Despawn(base.transform); } if (BoltNetwork.isRunning) { CoopTreeId component2 = component.GetComponent <CoopTreeId>(); if (component2) { component2.Goto_Removed(); } } this.Finalize(component, componentInParent.gameObject); } else { TreeHealth componentInParent2 = base.GetComponentInParent <TreeHealth>(); if (componentInParent2 && componentInParent2.LodTree) { if (BoltNetwork.isRunning) { CoopTreeId component3 = componentInParent2.LodTree.GetComponent <CoopTreeId>(); if (component3) { component3.Goto_Removed(); } } this.Finalize(componentInParent2.LodTree, componentInParent2.gameObject); } } } }
public static void CheckRegrowTrees() { if (PlayerPreferences.TreeRegrowth) { LOD_Trees[] source = UnityEngine.Object.FindObjectsOfType <LOD_Trees>(); List <LOD_Trees> list = (from t in source where !t.enabled && t.CurrentView == null select t).ToList <LOD_Trees>(); if (list != null && list.Count > 0) { TreeLodGrid treeLodGrid = UnityEngine.Object.FindObjectOfType <TreeLodGrid>(); int count = list.Count; int num = count / 10 + 2; float num2 = Mathf.Max((float)count / (float)num, 1f); int num3 = 0; for (float num4 = 0f; num4 < (float)count; num4 += num2) { int index = (int)num4; if (BoltNetwork.isRunning) { CoopTreeId component = list[index].GetComponent <CoopTreeId>(); if (component) { component.RegrowTree(); } list[index].DontSpawn = false; } list[index].enabled = true; list[index].RefreshLODs(); if (treeLodGrid) { treeLodGrid.RegisterTreeRegrowth(list[index].transform.position); } IEnumerator enumerator = list[index].transform.GetEnumerator(); try { while (enumerator.MoveNext()) { object obj = enumerator.Current; Transform transform = (Transform)obj; LOD_Stump component2 = transform.GetComponent <LOD_Stump>(); if (component2) { component2.DespawnCurrent(); component2.CurrentView = null; } UnityEngine.Object.Destroy(transform.gameObject); } } finally { IDisposable disposable; if ((disposable = (enumerator as IDisposable)) != null) { disposable.Dispose(); } } num3++; } if (num3 != 0 && BoltNetwork.isRunning) { CoopTreeGrid.SweepGrid(); } Debug.Log(string.Concat(new object[] { "Tree regrowth: ", num3, "/", count })); } } }