public void StartSleeping(RestingPlace place = null, bool block_moves = true) { if (!Player.Get().CanSleep()) { return; } this.m_RestingPlace = place; this.SetupSurroundingConstructions(); if (block_moves) { this.m_Player.BlockMoves(); this.m_Player.BlockRotation(); } this.m_StartSleepingTime = Time.time; this.m_StartSleepHour = this.m_Sky.Cycle.Hour; this.m_Progress = 0f; this.m_PrevProgress = 0f; this.m_HourProgress = 0; HUDSleeping.Get().gameObject.SetActive(true); MenuInGameManager.Get().HideMenu(); Item currentItem = this.m_Player.GetCurrentItem(Hand.Right); if (currentItem != null && currentItem.m_Info.IsHeavyObject()) { this.m_Player.DropItem(currentItem); } Player.Get().StartController(PlayerControllerType.Sleep); PlayerAudioModule.Get().PlaySleepSound(); GreenHellGame.Instance.SetSnapshot(AudioMixerSnapshotGame.Sleep, 0.5f); if (Inventory3DManager.Get().IsActive()) { Inventory3DManager.Get().Deactivate(); } }
public void UpdateBuriningDuration() { if (!this.m_Burning) { return; } float num = MainLevel.Instance.m_TODSky.Cycle.GameTimeDelta; if (HUDSleeping.Get().GetState() == HUDSleepingState.Progress) { num = SleepController.Get().m_HoursDelta; } else if (ConsciousnessController.Get().IsUnconscious()) { num = ConsciousnessController.Get().m_HoursDelta; } this.m_BurningDuration += num; }
public override void Check() { float currentTimeMinutes = MainLevel.Instance.GetCurrentTimeMinutes(); if (SleepController.Get().m_LastWakeUpTime <= 0f) { SleepController.Get().m_LastWakeUpTime = currentTimeMinutes; } if (SleepController.Get().m_LastWakeUpTimeLogical <= 0f) { SleepController.Get().m_LastWakeUpTimeLogical = currentTimeMinutes; } if (SleepController.Get().IsActive() && HUDSleeping.Get().GetState() == HUDSleepingState.Progress && this.m_InsomniaLevel == 0f) { SleepController.Get().m_LastWakeUpTimeLogical = MainLevel.Instance.GetCurrentTimeMinutes(); } if (currentTimeMinutes > SleepController.Get().m_LastWakeUpTimeLogical + this.m_NoSleepTmeToActivate) { PlayerDiseasesModule.Get().RequestDisease(ConsumeEffect.Insomnia, 0f, 1); } }
public void UpdateProcessing() { if (!ItemsManager.Get()) { return; } float num = MainLevel.Instance.m_TODSky.Cycle.GameTimeDelta; if (HUDSleeping.Get().GetState() == HUDSleepingState.Progress) { num = SleepController.Get().m_HoursDelta; } else if (ConsciousnessController.Get().IsUnconscious()) { num = ConsciousnessController.Get().m_HoursDelta; } foreach (ItemSlot itemSlot in this.m_ActiveSlots) { Food food = (Food)itemSlot.m_Item; if (this.m_Firecamp) { if (!this.m_Firecamp.m_Burning) { if (food.m_ProcessDuration > 0f) { food.m_ProcessDuration -= num; } else { food.m_ProcessDuration = 0f; } if (!itemSlot.gameObject.activeSelf) { itemSlot.gameObject.SetActive(true); } if (!itemSlot.m_Item.enabled) { itemSlot.m_Item.enabled = true; continue; } continue; } } else if (this.m_Type != FoodProcessor.Type.Dryer && (!this.m_ConnectedFirecamp || !this.m_ConnectedFirecamp.m_Burning)) { if (food.m_ProcessDuration > 0f) { food.m_ProcessDuration -= num; } else { food.m_ProcessDuration = 0f; } if (!itemSlot.gameObject.activeSelf) { itemSlot.gameObject.SetActive(true); } if (!itemSlot.m_Item.enabled) { itemSlot.m_Item.enabled = true; continue; } continue; } if (this.m_Type == FoodProcessor.Type.Dryer) { if (!RainManager.Get().IsRain() || RainManager.Get().IsInRainCutter(base.transform.position)) { food.m_ProcessDuration += num; } else if (food.m_ProcessDuration > 0f) { food.m_ProcessDuration -= num; } else { food.m_ProcessDuration = 0f; } } else { food.m_ProcessDuration += num; } FoodInfo foodInfo = (FoodInfo)itemSlot.m_Item.m_Info; if (food.m_ProcessDuration >= this.GetProcessingTime(foodInfo) || this.m_DebugImmediate) { HUDProcess.Get().UnregisterProcess(itemSlot.m_Item); Item item = ItemsManager.Get().CreateItem(this.GetResultItemID(foodInfo), true, itemSlot.m_Item.transform.position, itemSlot.m_Item.transform.rotation); itemSlot.ReplaceItem(item); if (!this.m_ProcessedSlots.Contains(itemSlot)) { this.m_ProcessedSlots.Add(itemSlot); } this.m_DebugImmediate = false; if (this.m_Type == FoodProcessor.Type.Fire && !foodInfo.m_CanCook) { food.m_Burned = true; break; } break; } } }
private void UpdateSleeping() { if (this.m_Animator.GetBool(this.m_StandUpHash)) { return; } if (HUDSleeping.Get().GetState() != HUDSleepingState.Progress) { this.m_Progress = 0f; this.m_StartSleepingTime = Time.time; this.m_PrevSleepingDateTime = this.m_Sky.Cycle.DateTime; this.m_StartSleepHour = this.m_Sky.Cycle.Hour; return; } this.m_LastProgress = this.m_Progress; bool flag = this.IsAllPlayersSleeping(); if (ReplTools.IsPlayingAlone()) { float num = Time.time - this.m_StartSleepingTime; this.m_Progress = num / (float)this.m_SleepDuration; this.m_Progress = Mathf.Clamp01(this.m_Progress); } else { this.m_Progress += Mathf.Clamp01((float)(this.m_Sky.Cycle.DateTime - this.m_PrevSleepingDateTime).TotalHours * (flag ? 1f : this.m_SleepDurationCoopMul) / (float)this.m_SleepDuration); } this.m_PrevSleepingDateTime = this.m_Sky.Cycle.DateTime; float num2 = this.m_Progress - this.m_PrevProgress; if (ReplTools.IsPlayingAlone() || (ReplTools.AmIMaster() && flag)) { this.m_TODTime.AddHours((float)this.m_SleepDuration * num2, true, false); } this.m_HoursDelta = (float)this.m_SleepDuration * num2; int num3 = (int)((float)this.m_SleepDuration * this.m_Progress); if (num3 > this.m_HourProgress) { this.CheckWorm(); } this.m_HourProgress = num3; float num4 = this.m_Progress - this.m_PrevProgress; foreach (SleepController.ConditionFParam conditionFParam in this.m_FParams) { if (!(conditionFParam.category == "nutrients") || DifficultySettings.ActivePreset.m_NutrientsDepletion != NutrientsDepletion.Off) { PropertyInfo property = this.m_ConditionModule.GetType().GetProperty(conditionFParam.field_name); float num5 = (float)property.GetValue(this.m_ConditionModule, null); float num6 = (conditionFParam.value > 0f) ? (conditionFParam.value * this.m_ParamsMul) : conditionFParam.value; if (PlayerInjuryModule.Get().GetNumWounds() <= 0 || !(conditionFParam.field_name == "m_HP")) { num5 += num6 * num4; } property.SetValue(this.m_ConditionModule, num5, null); } } this.m_ConditionModule.ClampParams(); Insomnia insomnia = (Insomnia)PlayerDiseasesModule.Get().GetDisease(ConsumeEffect.Insomnia); if (insomnia != null) { insomnia.UpdateSleeping(); } if (this.m_Progress >= 1f || Player.Get().IsDead()) { this.WakeUp(false, true); } this.SetupSurroundingConstructions(); this.m_PrevProgress = this.m_Progress; }