Beispiel #1
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);
         });
     }
 }