예제 #1
0
 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
             }));
         }
     }
 }
예제 #2
0
 public override void Attached()
 {
     base.state.Transform.SetTransforms(base.transform);
     if (base.entity.isOwner)
     {
         base.state.PlayerVariation     = LocalPlayer.Stats.PlayerVariation;
         base.state.PlayerVariationHair = LocalPlayer.Stats.PlayerVariationHair;
         base.Invoke("InitClothingMpSync", 0.1f);
         base.Invoke("RefreshPlayerMaterials", 0.1f);
         this.FindHands();
         if (base.entity.isOwner && BoltNetwork.isClient && Scene.TriggerCutScene.clientPlayerOnPlaneGo != null)
         {
             Scene.TriggerCutScene.clientPlayerOnPlaneGo.SendMessage("PlayerVariationSetupClean", base.state.PlayerVariation, SendMessageOptions.DontRequireReceiver);
             Scene.TriggerCutScene.clientCutScenePlayerGo.SendMessage("PlayerVariationSetup", base.state.PlayerVariation, SendMessageOptions.DontRequireReceiver);
         }
     }
     else
     {
         base.state.AddCallback("PlayerVariation", new PropertyCallbackSimple(this.PlayerVariationSetup));
         base.state.AddCallback("PlayerVariationHair", new PropertyCallbackSimple(this.PlayerVariationSetup));
         base.state.AddCallback("PlayerClothingIds[]", new PropertyCallbackSimple(this.PlayerVariationSetup));
         base.state.AddCallback("Bloody", new PropertyCallbackSimple(this.RefreshPlayerMaterials));
         base.state.AddCallback("Muddy", new PropertyCallbackSimple(this.RefreshPlayerMaterials));
         base.state.AddCallback("RedPaint", new PropertyCallbackSimple(this.RefreshPlayerMaterials));
         base.state.AddCallback("Cold", new PropertyCallbackSimple(this.RefreshPlayerMaterials));
         this.PlayerVariationSetup();
         this.RefreshPlayerMaterials();
         if (BoltNetwork.isServer && CoopTreeGrid.TodoPlayerSweeps.Contains(base.entity.source))
         {
             CoopTreeGrid.TodoPlayerSweeps.Remove(base.entity.source);
             CoopTreeGrid.SweepGrid();
         }
         Transform   playerTr = base.transform;
         PlayerName  pn       = base.GetComponentInChildren <PlayerName>();
         targetStats ts       = base.GetComponent <targetStats>();
         base.state.AddCallback("name", delegate
         {
             pn.Init(this.state.name);
         });
         this.plasticTorch = base.GetComponentsInChildren <BatteryBasedLight>(true).FirstOrDefault <BatteryBasedLight>();
         if (BoltNetwork.isClient && Scene.SceneTracker)
         {
             if (!Scene.SceneTracker.allPlayers.Contains(base.gameObject))
             {
                 Scene.SceneTracker.allPlayers.Add(base.entity.gameObject);
             }
             if (!Scene.SceneTracker.allPlayerEntities.Contains(base.entity))
             {
                 Scene.SceneTracker.allPlayerEntities.Add(base.entity);
             }
             if (!Scene.SceneTracker.allClients.Contains(base.gameObject))
             {
                 Scene.SceneTracker.allClients.Add(base.entity.gameObject);
             }
         }
         base.state.AddCallback("CurrentView", delegate
         {
             if (this.state.CurrentView == 7 != this.RespawnDeadTrigger.activeSelf)
             {
                 if (!ts || !ts.inWater)
                 {
                     this.RespawnDeadTrigger.SetActive(!this.RespawnDeadTrigger.activeSelf);
                 }
             }
             pn.OnCurrentViewChanged();
             if (this.state.CurrentView == 8)
             {
                 if (Scene.SceneTracker.allPlayers.Contains(this.gameObject))
                 {
                     Scene.SceneTracker.allPlayers.Remove(this.gameObject);
                 }
                 if (Scene.SceneTracker.allPlayerEntities.Contains(this.entity))
                 {
                     Scene.SceneTracker.allPlayerEntities.Remove(this.entity);
                 }
                 for (int i = playerTr.childCount - 1; i >= 0; i--)
                 {
                     Transform child = playerTr.GetChild(i);
                     if (!child.GetComponent <Animator>())
                     {
                         UnityEngine.Object.Destroy(child.gameObject);
                     }
                     else
                     {
                         for (int j = child.childCount - 1; j >= 0; j--)
                         {
                             UnityEngine.Object.Destroy(child.GetChild(j).gameObject);
                         }
                         Component[] components = child.GetComponents(typeof(MonoBehaviour));
                         foreach (Component component in components)
                         {
                             if (!(component is Animator))
                             {
                                 UnityEngine.Object.DestroyImmediate(component);
                             }
                         }
                     }
                 }
                 Component[] components2 = this.GetComponents(typeof(MonoBehaviour));
                 foreach (Component component2 in components2)
                 {
                     if (!(component2 is BoltEntity))
                     {
                         UnityEngine.Object.DestroyImmediate(component2);
                     }
                 }
                 StealItemTrigger stealItemTrigger        = UnityEngine.Object.Instantiate <StealItemTrigger>(Prefabs.Instance.DeadBackpackPrefab);
                 stealItemTrigger._entity                 = this.entity;
                 stealItemTrigger.transform.parent        = playerTr;
                 stealItemTrigger.transform.localPosition = Vector3.zero;
             }
         });
         base.state.AddCallback("BatteryTorchEnabled", delegate
         {
             this.plasticTorch.SetEnabled(this.state.BatteryTorchEnabled);
         });
         base.state.AddCallback("BatteryTorchColor", delegate
         {
             this.plasticTorch.SetColor(this.state.BatteryTorchColor);
         });
         base.state.AddCallback("BatteryTorchIntensity", delegate
         {
             this.plasticTorch.SetIntensity(this.state.BatteryTorchIntensity);
         });
     }
 }