public void OnInsomniaHealButton() { Insomnia insomnia = (Insomnia)PlayerDiseasesModule.Get().GetDisease(ConsumeEffect.Insomnia); if (insomnia != null) { insomnia.m_InsomniaLevel = 0f; SleepController.Get().m_LastWakeUpTimeLogical = MainLevel.Instance.GetCurrentTimeMinutes(); } }
public void OnInsomniaButton() { Insomnia insomnia = (Insomnia)PlayerDiseasesModule.Get().GetDisease(ConsumeEffect.Insomnia); if (insomnia != null) { if (insomnia.m_InsomniaLevel <= 0f) { SleepController.Get().m_LastWakeUpTimeLogical -= insomnia.m_NoSleepTmeToActivate; return; } SleepController.Get().m_LastWakeUpTimeLogical -= insomnia.m_NoSleepTimeToIncreaseLevel; } }
public void OnInsomniaDecreaseButton() { Insomnia insomnia = (Insomnia)PlayerDiseasesModule.Get().GetDisease(ConsumeEffect.Insomnia); if (insomnia != null) { if (insomnia.m_InsomniaLevel < 1f) { this.OnInsomniaHealButton(); return; } SleepController.Get().m_LastWakeUpTimeLogical += insomnia.m_NoSleepTimeToIncreaseLevel; SleepController.Get().m_LastWakeUpTimeLogical = System.Math.Min(MainLevel.Instance.GetCurrentTimeMinutes(), SleepController.Get().m_LastWakeUpTimeLogical); } }
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; }