private void OnDestroy() { if (LocalPlayer.Transform == base.transform) { LocalPlayer.Transform = null; LocalPlayer.Ridigbody = null; FMOD_StudioEventEmitter.LocalPlayerTransform = null; LocalPlayer.GameObject = null; LocalPlayer.PlayerBase = null; LocalPlayer.HeadTr = null; LocalPlayer.HipsTr = null; LocalPlayer.Inventory = null; LocalPlayer.ReceipeBook = null; LocalPlayer.SpecialActions = null; LocalPlayer.SpecialItems = null; LocalPlayer.MainCamTr = null; LocalPlayer.MainCam = null; LocalPlayer.InventoryCam = null; LocalPlayer.CamFollowHead = null; LocalPlayer.Animator = null; LocalPlayer.AnimControl = null; LocalPlayer.Create = null; LocalPlayer.Tuts = null; LocalPlayer.Sfx = null; LocalPlayer.Stats = null; LocalPlayer.FpCharacter = null; LocalPlayer.FpHeadBob = null; LocalPlayer.CamRotator = null; LocalPlayer.MainRotator = null; LocalPlayer.ScriptSetup = null; LocalPlayer.TargetFunctions = null; LocalPlayer.HitReactions = null; LocalPlayer.Buoyancy = null; LocalPlayer.WaterViz = null; LocalPlayer.AiInfo = null; LocalPlayer.WaterEngine = null; LocalPlayer.ItemDecayMachine = null; LocalPlayer.AnimatedBook = null; LocalPlayer.PassengerManifest = null; LocalPlayer.GreebleRoot = null; LocalPlayer.MudGreeble = null; LocalPlayer.PlayerDeadCam = null; LocalPlayer.PauseMenuBlur = null; LocalPlayer.PauseMenuBlurPsCam = null; LocalPlayer.HeldItemsData = null; LocalPlayer.Vis = null; } }
private void Awake() { LocalPlayer.Transform = this._transform; LocalPlayer.Ridigbody = this._ridigbody; FMOD_StudioEventEmitter.LocalPlayerTransform = LocalPlayer.Transform; LocalPlayer.GameObject = this._playerGO; LocalPlayer.PlayerBase = this._playerBase; LocalPlayer.HeadTr = this._headTr; LocalPlayer.HipsTr = this._hipsTr; LocalPlayer.Inventory = this._inventory; LocalPlayer.ReceipeBook = this._receipeBook; LocalPlayer.SpecialActions = this._specialActions; LocalPlayer.SpecialItems = this._specialItems; LocalPlayer.MainCamTr = this._mainCamTr; LocalPlayer.MainCam = this._mainCam; LocalPlayer.InventoryCam = this._inventoryCam; LocalPlayer.CamFollowHead = this._camFollowHead; LocalPlayer.Animator = this._animator; LocalPlayer.AnimControl = this._animControl; LocalPlayer.Create = this._create; LocalPlayer.Tuts = this._tuts; LocalPlayer.Sfx = this._sfx; LocalPlayer.Stats = this._stats; LocalPlayer.FpCharacter = this._fpc; LocalPlayer.FpHeadBob = this._fphb; LocalPlayer.CamRotator = this._camRotator; LocalPlayer.MainRotator = this._mainRotator; LocalPlayer.ScriptSetup = this._scriptSetup; LocalPlayer.TargetFunctions = this._targetFunctions; LocalPlayer.HitReactions = this._hitReactions; LocalPlayer.Buoyancy = this._buoyancy; LocalPlayer.WaterViz = this._waterViz; LocalPlayer.AiInfo = this._aiInfo; LocalPlayer.WaterEngine = this._waterEngine; LocalPlayer.ItemDecayMachine = this._itemDecayMachine; LocalPlayer.AnimatedBook = this._animatedBook; LocalPlayer.PassengerManifest = this._passengerManifest; LocalPlayer.GreebleRoot = this._greebleRoot; LocalPlayer.MudGreeble = this._mudGreeble; LocalPlayer.PlayerDeadCam = this._PlayerDeadCam; LocalPlayer.PauseMenuBlur = this._pauseMenuBlur; LocalPlayer.PauseMenuBlurPsCam = this._pauseMenuBlurPsCam; LocalPlayer.HeldItemsData = this._heldItemsData; LocalPlayer.Vis = this._vis; base.StartCoroutine(this.OldSaveCompat()); }
private void Respawn() { Debug.Log("LocalPlayer -> Respawn"); if (LocalPlayer.Stats.Dead) { if (LocalPlayer.IsInEndgame) { GameObject gameObject = GameObject.FindWithTag("EndgameLoader"); if (gameObject) { SceneLoadTrigger component = gameObject.GetComponent <SceneLoadTrigger>(); component.ForceUnload(); } } if (Scene.HudGui) { Scene.HudGui.LoadingCavesInfo.SetActive(false); } EventRegistry.Player.Publish(TfEvent.ExitOverlookArea, null); EventRegistry.Player.Publish(TfEvent.ExitEndgame, null); LocalPlayer.GameObject.SendMessage("NotInACave"); PlayerInventory inventory = LocalPlayer.Inventory; PlayerClothing clothing = LocalPlayer.Clothing; AchievementsManager achievements = LocalPlayer.Achievements; PassengerManifest passengerManifest = LocalPlayer.PassengerManifest; SurvivalBookTodo componentInChildren = LocalPlayer.SpecialItems.GetComponentInChildren <SurvivalBookTodo>(); string name = LocalPlayer.Entity.GetState <IPlayerState>().name; bool value = LocalPlayer.SavedData.ReachedLowSanityThreshold; bool value2 = LocalPlayer.SavedData.ExitedEndgame; LocalPlayer.Inventory.HideAllEquiped(false, false); LocalPlayer.Inventory.enabled = false; if (Scene.SceneTracker.allPlayers.Contains(LocalPlayer.GameObject)) { Scene.SceneTracker.allPlayers.Remove(LocalPlayer.GameObject); } if (Scene.SceneTracker.allPlayerEntities.Contains(LocalPlayer.Entity)) { Scene.SceneTracker.allPlayerEntities.Remove(LocalPlayer.Entity); } BoltNetwork.Detach(LocalPlayer.Entity); GameObject gameObject2 = LocalPlayer.GameObject; BoltEntity entity = LocalPlayer.Entity; gameObject2.name = "player Corpse - " + name; gameObject2.tag = "Untagged"; LocalPlayer.MainCamTr.parent = LocalPlayer.Transform; LocalPlayer.Inventory.CurrentView = PlayerInventory.PlayerViews.Loot; if (LocalPlayer.AnimControl.swimming) { LocalPlayer.Rigidbody.useGravity = true; } for (int i = gameObject2.transform.childCount - 1; i >= 0; i--) { Transform child = gameObject2.transform.GetChild(i); UnityEngine.Object.Destroy(child.gameObject); } Component[] components = gameObject2.GetComponents(typeof(MonoBehaviour)); foreach (Component component2 in components) { if (!(component2 is BoltEntity)) { UnityEngine.Object.DestroyImmediate(component2); } } Transform transform = base.transform; GameObject gameObject3 = UnityEngine.Object.Instantiate <GameObject>(Prefabs.Instance.PlayerPrefab, transform.position, transform.rotation); gameObject3.transform.localEulerAngles = new Vector3(0f, gameObject3.transform.localEulerAngles.y, 0f); gameObject3.name = Prefabs.Instance.PlayerPrefab.name; LocalPlayer.Inventory.SetQuickSelectItemIds(inventory.QuickSelectItemIds); LocalPlayer.Achievements.Clone(achievements); LocalPlayer.SpecialItems.GetComponentInChildren <SurvivalBookTodo>().Clone(componentInChildren); LocalPlayer.SavedData.ReachedLowSanityThreshold.SetValue(value); LocalPlayer.SavedData.ExitedEndgame.SetValue(value2); LocalPlayer.PassengerManifest.Clone(passengerManifest); LocalPlayer.FpCharacter.UnLockView(); LocalPlayer.CamFollowHead.enableMouseControl(false); LocalPlayer.MainCamTr.localEulerAngles = Vector3.zero; LocalPlayer.MainRotator.enabled = true; LocalPlayer.CamRotator.enabled = true; LocalPlayer.Stats.Health = 28f; LocalPlayer.Stats.HealthTarget = 28f; LocalPlayer.Stats.Energy = 100f; LocalPlayer.Stats.Fullness = 0.35f; LocalPlayer.Stats.Thirst = 0.35f; LocalPlayer.Stats.Invoke("CheckArmsStart", 2f); LocalPlayer.Stats.Invoke("PlayWakeMusic", 0.5f); LocalPlayer.Tuts.CloseColdTut(); Scene.RainFollowGO.GetComponent <SmoothTransformConstraint>().target = LocalPlayer.Transform; gameObject3.SetActive(true); CoopUtils.AttachLocalPlayer(gameObject3, name); Scene.SceneTracker.allPlayers.Add(LocalPlayer.GameObject); LocalPlayer.GreebleRoot.SetActive(true); LocalPlayer.Inventory.enabled = true; LocalPlayer.Transform.SendMessage("enableMpRenderers"); LocalPlayer.Transform.SendMessage("playerLoadedFromRespawn"); this._addedItems = false; StealItemTrigger stealItemTrigger = UnityEngine.Object.Instantiate <StealItemTrigger>(Prefabs.Instance.DeadBackpackPrefab, gameObject2.transform.position, gameObject2.transform.rotation); stealItemTrigger._entity = entity; stealItemTrigger.transform.parent = gameObject2.transform; gameObject2.AddComponent <DeathMPTut>(); gameObject2.AddComponent <backpackCleanup>(); ItemStorage itemStorage = gameObject2.AddComponent <ItemStorage>(); itemStorage._acceptedTypes = ~Item.Types.Story; for (int k = inventory._possessedItems.Count - 1; k >= 0; k--) { InventoryItem inventoryItem = inventory._possessedItems[k]; if (!LocalPlayer.Inventory.Owns(inventoryItem._itemId, false)) { if (inventoryItem.MaxAmount == 1) { InventoryItemView inventoryItemView = inventory.InventoryItemViewsCache[inventoryItem._itemId][0]; this.AddItemToStorage(inventoryItem._itemId, inventoryItem._amount, itemStorage, inventoryItemView.Properties); } else if (inventoryItem.MaxAmount > 0 && inventoryItem.MaxAmount < 2147483647) { while (inventory.Owns(inventoryItem._itemId, false)) { InventoryItemView inventoryItemView2 = inventory.InventoryItemViewsCache[inventoryItem._itemId][0]; inventory.SortInventoryViewsByBonus(inventoryItemView2, inventoryItemView2.Properties.ActiveBonus, true); int amount = inventory.AmountOfItemWithBonus(inventoryItem._itemId, inventoryItemView2.Properties.ActiveBonus); inventory.RemoveItem(inventoryItem._itemId, amount, true, false); this.AddItemToStorage(inventoryItem._itemId, amount, itemStorage, inventoryItemView2.Properties); } } else { this.AddItemToStorage(inventoryItem._itemId, inventoryItem._amount, itemStorage, null); } } } for (int l = 0; l < inventory.EquipmentSlots.Length; l++) { InventoryItemView inventoryItemView3 = inventory.EquipmentSlots[l]; if (inventoryItemView3 && inventoryItemView3._itemId > 0) { this.AddItemToStorage(inventoryItemView3._itemId, 1, itemStorage, inventoryItemView3.Properties); } } clothing.DropAll(gameObject2.transform.position, true, true); if (!this._addedItems) { UnityEngine.Object.Destroy(gameObject2); } animalAI[] array2 = UnityEngine.Object.FindObjectsOfType <animalAI>(); foreach (animalAI animalAI in array2) { animalAI.SendMessage("updatePlayerTargets"); } mutantAI[] array4 = UnityEngine.Object.FindObjectsOfType <mutantAI>(); foreach (mutantAI mutantAI in array4) { mutantAI.SendMessage("updatePlayerTargets"); } Fish[] array6 = UnityEngine.Object.FindObjectsOfType <Fish>(); mutantScriptSetup[] array7 = UnityEngine.Object.FindObjectsOfType <mutantScriptSetup>(); foreach (mutantScriptSetup mutantScriptSetup in array7) { mutantScriptSetup.setupPlayer(); mutantScriptSetup.search.refreshCurrentTarget(); } LocalPlayer.Transform.SendMessage("enableMpRenderers"); if (ForestVR.Enabled) { Scene.HudGui.GuiCam.SetActive(true); } Terrain.activeTerrain.GetComponent <Collider>().enabled = true; Scene.Clock.IsNotCave(); } PlayerRespawnMP.Cancel(); if (this._bringUpPauseMenu) { this._bringUpPauseMenu = false; LocalPlayer.Inventory.TogglePauseMenu(); } }