private void OnEat(ConsumableInfo info) { if (info.m_ConsumeEffect != ConsumeEffect.None && UnityEngine.Random.Range(0f, 1f) <= info.m_ConsumeEffectChance && info.m_ConsumeEffectLevel >= 0) { PlayerDiseasesModule.Get().RequestDisease(info.m_ConsumeEffect, info.m_ConsumeEffectDelay, info.m_ConsumeEffectLevel); } PlayerDiseasesModule.Get().OnEat(info); PlayerInjuryModule.Get().OnEat(info); if (info.m_Disgusting) { PlayerAudioModule.Get().PlayEatingDisgustingSound(1f, false); } else { PlayerAudioModule.Get().PlayEatingSound(1f, false); } EventsManager.OnEvent(Enums.Event.Eat, 1, (int)info.m_ID); PlayerSanityModule.Get().OnEat(info.m_SanityChange); Localization localization = GreenHellGame.Instance.GetLocalization(); HUDMessages hudmessages = (HUDMessages)HUDManager.Get().GetHUD(typeof(HUDMessages)); string text = string.Empty; if (info.m_ConsumeEffect == ConsumeEffect.FoodPoisoning) { text = info.m_ConsumeEffectLevel.ToString("F0") + " " + localization.Get("HUD_FoodPoisoning"); hudmessages.AddMessage(text, null, HUDMessageIcon.FoodPoisoning, string.Empty); } if (info.m_AddEnergy > 0f) { text = info.m_AddEnergy.ToString("F0") + " " + localization.Get("HUD_Energy"); hudmessages.AddMessage(text, null, HUDMessageIcon.Energy, string.Empty); } if (info.m_Water > 0f) { text = info.m_Water.ToString("F0") + " " + localization.Get("HUD_Hydration"); hudmessages.AddMessage(text, null, HUDMessageIcon.Hydration, string.Empty); } if (info.m_Fat > 0f) { text = info.m_Fat.ToString("F0") + " " + localization.Get("HUD_Nutrition_Fat"); hudmessages.AddMessage(text, null, HUDMessageIcon.Fat, string.Empty); } if (info.m_Proteins > 0f) { text = info.m_Proteins.ToString("F0") + " " + localization.Get("HUD_Nutrition_Protein"); hudmessages.AddMessage(text, null, HUDMessageIcon.Proteins, string.Empty); } if (info.m_Carbohydrates > 0f) { text = info.m_Carbohydrates.ToString("F0") + " " + localization.Get("HUD_Nutrition_Carbo"); hudmessages.AddMessage(text, null, HUDMessageIcon.Carbo, string.Empty); } text = localization.Get(TriggerAction.GetTextPerfect(TriggerAction.TYPE.Eat)) + ": " + info.GetNameToDisplayLocalized(); hudmessages.AddMessage(text, null, HUDMessageIcon.Item, info.m_IconName); ItemsManager.Get().OnEat(info); if (info.m_ID == ItemID.coca_leafs) { PlayerCocaineModule.Get().OnEatCocaine(); } }
private void UpdateState() { Stalker.State state = this.m_State; if (state != Stalker.State.MoveAround) { if (state != Stalker.State.RunAway) { if (state != Stalker.State.Attack) { } } else { float num = Vector3.Distance(Player.Get().transform.position, base.transform.position); if (num > StalkerManager.Get().m_MoveAwayRange&& !this.m_PlayerApproaching) { this.m_State = Stalker.State.MoveAround; } } } else if (StalkerManager.Get().CanAttack()) { this.m_State = Stalker.State.Attack; StalkerManager.Get().OnStalkerStartAttack(); } else { float num2 = Vector3.Distance(Player.Get().transform.position, base.transform.position); if (num2 < StalkerManager.Get().m_MoveAroundMinRange) { this.m_State = Stalker.State.RunAway; } PlayerSanityModule.Get().OnWhispersEvent(PlayerSanityModule.WhisperType.Stalker); } }
private void InitSliders() { PlayerConditionModule playerConditionModule = PlayerConditionModule.Get(); this.m_Proteins.minValue = 0f; this.m_Proteins.maxValue = playerConditionModule.GetMaxNutritionProtein(); this.m_Proteins.value = playerConditionModule.GetNutritionProtein(); this.m_Fat.minValue = 0f; this.m_Fat.maxValue = playerConditionModule.GetMaxNutritionFat(); this.m_Fat.value = playerConditionModule.GetNutritionFat(); this.m_Carbo.minValue = 0f; this.m_Carbo.maxValue = playerConditionModule.GetMaxNutritionCarbo(); this.m_Carbo.value = playerConditionModule.GetNutritionCarbo(); this.m_Hydration.minValue = 0f; this.m_Hydration.maxValue = playerConditionModule.GetMaxHydration(); this.m_Hydration.value = playerConditionModule.GetHydration(); this.m_HP.minValue = 1f; this.m_HP.maxValue = playerConditionModule.GetMaxHP(); this.m_HP.value = playerConditionModule.GetHP(); this.m_Energy.minValue = 1f; this.m_Energy.maxValue = playerConditionModule.GetMaxEnergy(); this.m_Energy.value = playerConditionModule.GetEnergy(); this.m_Sanity.minValue = 0f; this.m_Sanity.maxValue = 100f; this.m_Sanity.value = (float)PlayerSanityModule.Get().m_Sanity; this.m_Dirtiness.minValue = 0f; this.m_Dirtiness.maxValue = PlayerConditionModule.Get().m_MaxDirtiness; this.m_Dirtiness.value = PlayerConditionModule.Get().m_Dirtiness; }
private BSItemData GetObjectToAttach(ref string group, List <string> item_id_names) { group = string.Empty; if (PlayerSanityModule.Get().m_ItemHallucinationsEnabled&& this.m_ObjectsInArea["Sanity"].Count < PlayerSanityModule.Get().GetWantedItemsHallucinationsCount() && this.m_AttachmentData.ContainsKey("Sanity")) { group = "Sanity"; BSItemData randomObject = this.GetRandomObject(this.m_AttachmentData[group], ItemID.None); if (randomObject != null && item_id_names.Contains(randomObject.m_ItemID.ToString())) { return(randomObject); } } foreach (string text in this.m_AttachmentData.Keys) { if (!(text == "Sanity")) { for (int i = 0; i < item_id_names.Count; i++) { BSItemData randomObject2 = this.GetRandomObject(this.m_AttachmentData[text], (ItemID)Enum.Parse(typeof(ItemID), item_id_names[i])); if (randomObject2 != null) { group = text; return(randomObject2); } } } } return(null); }
public override void Update() { base.Update(); float currentTimeMinutes = MainLevel.Instance.GetCurrentTimeMinutes(); if (currentTimeMinutes < SleepController.Get().m_LastWakeUpTimeLogical + this.m_NoSleepTmeToActivate) { this.m_Level = 0; this.m_InsomniaLevel = 0f; this.Deactivate(); return; } this.m_InsomniaLevel = (currentTimeMinutes - (SleepController.Get().m_LastWakeUpTimeLogical + this.m_NoSleepTmeToActivate)) / this.m_NoSleepTimeToIncreaseLevel; if (this.m_InsomniaLevel >= 5.9999f) { SleepController.Get().m_LastWakeUpTimeLogical = MainLevel.Instance.GetCurrentTimeMinutes(); SleepController.Get().m_LastWakeUpTimeLogical -= this.m_NoSleepTmeToActivate; SleepController.Get().m_LastWakeUpTimeLogical -= this.m_NoSleepTimeToIncreaseLevel * 5.9999f; } if (this.m_InsomniaLevel <= -0.0001f) { SleepController.Get().m_LastWakeUpTimeLogical = MainLevel.Instance.GetCurrentTimeMinutes(); } this.m_InsomniaLevel = Mathf.Clamp(this.m_InsomniaLevel, -0.0001f, 5.9999f); this.m_Level = (int)Mathf.Ceil(this.m_InsomniaLevel); this.m_Level = Mathf.Clamp(this.m_Level, 1, 6); if (MainLevel.s_GameTime - this.m_LastSanityDecreaseTime >= this.m_SanityDecreaseInterval && (!SleepController.Get().IsActive() || SleepController.Get().IsWakingUp())) { PlayerSanityModule.Get().OnEvent(PlayerSanityModule.SanityEventType.Insomnia, this.m_SanityDecreaseVal * this.m_Level); this.m_LastSanityDecreaseTime = MainLevel.s_GameTime; } }
public void OnSetAllFullButton() { PlayerConditionModule.Get().m_MaxHP = 100f; PlayerConditionModule.Get().ResetParams(); PlayerSanityModule.Get().m_Sanity = 100; this.InitSliders(); }
private void UpdateState() { switch (this.m_State) { case Stalker.State.MoveAround: if (StalkerManager.Get().CanAttack()) { this.m_State = Stalker.State.Attack; StalkerManager.Get().OnStalkerStartAttack(); return; } if (Vector3.Distance(Player.Get().transform.position, base.transform.position) < StalkerManager.Get().m_MoveAroundMinRange) { this.m_State = Stalker.State.RunAway; } PlayerSanityModule.Get().OnWhispersEvent(PlayerSanityModule.WhisperType.Stalker); return; case Stalker.State.RunAway: if (Vector3.Distance(Player.Get().transform.position, base.transform.position) > StalkerManager.Get().m_MoveAwayRange&& !this.m_PlayerApproaching) { this.m_State = Stalker.State.MoveAround; } break; case Stalker.State.Attack: break; default: return; } }
public void WakeUp(bool force_update = false, bool unblock_moves = true) { if (force_update) { this.m_TODTime.AddHours((float)this.m_SleepDuration, true); this.CheckWorm(); this.SetupSurroundingConstructions(); } if (unblock_moves) { this.m_Player.UnblockMoves(); this.m_Player.UnblockRotation(); } this.m_StartSleepingTime = 0f; this.m_ParamsMul = 1f; this.UpdateLastWakeUpTime(); if (this.m_RestingPlace != null) { EventsManager.OnEvent(Enums.Event.Sleep, 1, this.m_SleepDuration, 1); PlayerSanityModule.Get().OnEvent(PlayerSanityModule.SanityEventType.BedSleep, 1); } else { EventsManager.OnEvent(Enums.Event.Sleep, 1, this.m_SleepDuration, 0); PlayerSanityModule.Get().OnEvent(PlayerSanityModule.SanityEventType.GroundSleep, 1); PlayerInjuryModule.Get().SleptOnGround(); } GreenHellGame.Instance.SetSnapshot(AudioMixerSnapshotGame.Default, 0.5f); this.m_Animator.SetBool(this.m_StandUpHash, true); this.Stop(); }
private BSItemData GetObjectToAttach(ref string group, List <string> item_id_names) { group = string.Empty; if (PlayerSanityModule.Get().m_ItemHallucinationsEnabled&& this.m_ObjectsInArea["Sanity"].Count < PlayerSanityModule.Get().GetWantedItemsHallucinationsCount() && this.m_AttachmentData.ContainsKey("Sanity")) { group = "Sanity"; BSItemData randomObject = this.GetRandomObject(this.m_AttachmentData[group]); if (randomObject != null && item_id_names.Contains(randomObject.m_ItemID.ToString())) { return(randomObject); } } foreach (string text in this.m_Groups.Keys) { if (!(text == "Sanity")) { if (this.m_ObjectsInArea[text].Count < this.m_Groups[text]) { group = text; BSItemData randomObject2 = this.GetRandomObject(this.m_AttachmentData[group]); if (randomObject2 != null && item_id_names.Contains(randomObject2.m_ItemID.ToString())) { return(randomObject2); } } } } return(null); }
private void OnEnterAttackState() { foreach (HumanAI humanAI in this.m_Members) { humanAI.SetState(HumanAI.State.Attack); } PlayerSanityModule.Get().OnWhispersEvent(PlayerSanityModule.WhisperType.AISight); }
public bool CanAttack() { float b = (float)PlayerSanityModule.Get().m_Sanity; float b2 = (float)PlayerSanityModule.Get().m_StalkerAttackSanityLevel; float proportionalClamp = CJTools.Math.GetProportionalClamp(this.m_AttackIntervalMin, this.m_AttackIntervalMax, b, b2, 1f); return(Time.time - this.m_LastAttackTime >= proportionalClamp); }
public float GetBatteryLevel() { if (PlayerSanityModule.Get().IsWhispersLevel()) { return(0f); } return(this.m_BatteryLevel); }
protected override void OnDeactivate() { base.OnDeactivate(); if (this.m_Hallucination) { PlayerSanityModule.Get().OnDeactivateHallucination(); } UnityEngine.Object.Destroy(base.gameObject); }
public override bool OnDrink(bool planned) { if (planned) { PlayerSanityModule.Get().OnEvent(PlayerSanityModule.SanityEventType.PlannedAction, 1); return(true); } return(false); }
private void UpdateSanityPP() { float proportionalClamp = CJTools.Math.GetProportionalClamp(0f, 1f, (float)PlayerSanityModule.Get().m_Sanity / 100f, 1f, 0f); float weight = PostProcessManager.Get().GetWeight(PostProcessManager.Effect.Sanity); if (weight != proportionalClamp) { PostProcessManager.Get().SetWeight(PostProcessManager.Effect.Sanity, weight + (proportionalClamp - weight) * Time.deltaTime * 2f); } }
public override void OnTake() { base.OnTake(); if (((ConsumableInfo)this.m_Info).m_Disgusting) { PlayerSanityModule.Get().OnWhispersEvent(PlayerSanityModule.WhisperType.TakeItemBad); return; } PlayerSanityModule.Get().OnWhispersEvent(PlayerSanityModule.WhisperType.TakeItemGood); }
public void Disappear(bool play_disappear_chatter = false) { if (this.m_HallucinationDisappearing) { return; } this.m_HallucinationDisappearing = true; UnityEngine.Object.Instantiate <GameObject>(this.IsAI() ? CJObject.s_DisappearAIFXPrefab : CJObject.s_DisappearItemFXPrefab, base.transform.position, base.transform.rotation).GetComponent <DisappearEffect>().Initialize(base.transform); PlayerSanityModule.Get().OnObjectDisappear(this, play_disappear_chatter); }
private void UpdateSanityPP() { float num = CJTools.Math.GetProportionalClamp(0f, 1f, (float)PlayerSanityModule.Get().m_Sanity / 100f, 1f, 0f); num = (Player.Get().m_DreamPPActive ? 0f : num); float weight = PostProcessManager.Get().GetWeight(PostProcessManager.Effect.Sanity); if (weight != num) { PostProcessManager.Get().SetWeight(PostProcessManager.Effect.Sanity, weight + (num - weight) * Time.deltaTime * 2f); } }
private void UpdateGamePP() { float num = (!Player.Get().GetComponent <NotepadController>().IsActive()) ? 1f : 0f; num = (((float)PlayerSanityModule.Get().m_Sanity >= 10f) ? num : 0f); float weight = PostProcessManager.Get().GetWeight(PostProcessManager.Effect.Game); if (weight != num) { PostProcessManager.Get().SetWeight(PostProcessManager.Effect.Game, weight + (num - weight) * Time.deltaTime * 2f); } }
private void Setup() { this.m_ToggleLimbs.Clear(); this.m_ToggleLimbsState.Clear(); this.m_ToggleLimbs.Add(this.m_ToggleLH); this.m_ToggleLimbsState.Add(this.m_ToggleLH.isOn); this.m_ToggleLimbs.Add(this.m_ToggleRH); this.m_ToggleLimbsState.Add(this.m_ToggleRH.isOn); this.m_ToggleLimbs.Add(this.m_ToggleLL); this.m_ToggleLimbsState.Add(this.m_ToggleLL.isOn); this.m_ToggleLimbs.Add(this.m_ToggleRL); this.m_ToggleLimbsState.Add(this.m_ToggleRL.isOn); this.m_WoundTypeList.Clear(); for (int i = 0; i < Enum.GetValues(typeof(InjuryType)).Length; i++) { this.m_WoundTypeList.AddElement(Enum.GetValues(typeof(InjuryType)).GetValue(i).ToString(), -1); } this.m_WoundTypeList.SetFocus(true); this.m_WoundParameters.Clear(); for (int j = 0; j < 10; j++) { Transform transform = base.gameObject.transform.FindDeepChild("Wound" + j.ToString()); if (transform != null) { Text component = transform.gameObject.GetComponent <Text>(); this.m_WoundParameters.Add(component); } } PlayerConditionModule playerConditionModule = PlayerConditionModule.Get(); this.m_Proteins.minValue = 0f; this.m_Proteins.maxValue = playerConditionModule.GetMaxNutritionProtein(); this.m_Proteins.value = playerConditionModule.GetNutritionProtein(); this.m_Fat.minValue = 0f; this.m_Fat.maxValue = playerConditionModule.GetMaxNutritionFat(); this.m_Fat.value = playerConditionModule.GetNutritionFat(); this.m_Carbo.minValue = 0f; this.m_Carbo.maxValue = playerConditionModule.GetMaxNutritionCarbo(); this.m_Carbo.value = playerConditionModule.GetNutritionCarbo(); this.m_Hydration.minValue = 0f; this.m_Hydration.maxValue = playerConditionModule.GetMaxHydration(); this.m_Hydration.value = playerConditionModule.GetHydration(); this.m_HP.minValue = 0f; this.m_HP.maxValue = playerConditionModule.GetMaxHP(); this.m_HP.value = playerConditionModule.GetHP(); this.m_Energy.minValue = 0f; this.m_Energy.maxValue = playerConditionModule.GetMaxEnergy(); this.m_Energy.value = playerConditionModule.GetEnergy(); this.m_Sanity.minValue = 0f; this.m_Sanity.maxValue = 100f; this.m_Sanity.value = (float)PlayerSanityModule.Get().m_Sanity; }
private void SetupDialogs() { this.ClearDatas(); foreach (string text in DialogsManager.Get().m_ScenarioDialogs.Keys) { List <Dialog> list = DialogsManager.Get().m_ScenarioDialogs[text]; if (list.Count != 0) { HUDSelectDialogElemData hudselectDialogElemData; if (text == "ALL") { using (List <Dialog> .Enumerator enumerator2 = list.GetEnumerator()) { while (enumerator2.MoveNext()) { Dialog dialog = enumerator2.Current; hudselectDialogElemData = this.CreateElement(dialog.m_Name, !dialog.m_ShownInSelectDialog); if (!PlayerSanityModule.Get().IsWhispersLevel()) { dialog.m_ShownInSelectDialog = true; } this.m_Datas.Add(hudselectDialogElemData); } continue; } } bool show_new = false; using (List <Dialog> .Enumerator enumerator2 = list.GetEnumerator()) { while (enumerator2.MoveNext()) { if (!enumerator2.Current.m_ShownInSelectDialog) { show_new = true; break; } } } hudselectDialogElemData = this.CreateElement(text, show_new); hudselectDialogElemData.m_IsGroup = true; hudselectDialogElemData.m_Dialogs = list; this.m_Datas.Add(hudselectDialogElemData); } } this.m_Datas.Sort(HUDSelectDialog.s_NewComparer); for (int i = 0; i < this.m_Datas.Count; i++) { this.m_Datas[i].m_Object.transform.localPosition = Vector3.zero + Vector3.up * 40f - Vector3.up * (this.m_Datas[i].m_BG.rectTransform.sizeDelta.y + 2f) * (float)i; } HUDWalkieTalkie.Get().UpdateNewDialogsCounter(); this.UpdateVis(); }
public override bool OnEat(ItemID item, bool planned) { if (!General.IsItemCooked(item)) { return(false); } if (planned) { PlayerSanityModule.Get().OnEvent(PlayerSanityModule.SanityEventType.PlannedAction, 1); return(true); } return(false); }
public override bool OnBuild(ItemID item, bool planned) { if (item != this.m_ItemID) { return(false); } if (planned) { PlayerSanityModule.Get().OnEvent(PlayerSanityModule.SanityEventType.PlannedAction, 1); return(true); } return(false); }
public void Activate(DiseaseRequest request) { if (!this.m_Active) { this.m_Active = true; this.m_StartTime = MainLevel.Instance.GetCurrentTimeMinutes(); this.m_Level = request.m_Level; this.ActivateSymptoms(); PlayerSanityModule.Get().OnEvent(PlayerSanityModule.SanityEventType.Disease, 1); PlayerDiseasesModule.Get().UnlockKnownDisease(this.m_Type); this.m_Activated = true; } }
public void Fulfill(bool from_save = false) { this.m_Renderer.materials = this.m_DefaultMaterials; this.m_Fulfilled = true; this.m_Parent.OnGhostFulfill(from_save); if (base.m_Collider) { base.m_Collider.isTrigger = false; base.m_Collider.enabled = true; } this.SetLayer(base.transform, this.m_IgnoreRaycastLayer); base.enabled = false; PlayerSanityModule.Get().OnWhispersEvent(PlayerSanityModule.WhisperType.GhostSlot); }
private void UpdateGamePP() { float num = Player.Get().GetComponent <NotepadController>().IsActive() ? 0f : 1f; num = (((float)PlayerSanityModule.Get().m_Sanity < 10f) ? 0f : num); num = (Player.Get().IsCameraUnderwater() ? 0f : num); num = (Player.Get().m_DreamPPActive ? 0f : num); float weight = PostProcessManager.Get().GetWeight(PostProcessManager.Effect.Game); if (weight != num) { PostProcessManager.Get().SetWeight(PostProcessManager.Effect.Game, weight + (num - weight) * Time.deltaTime * 2f); } }
private void UpdatePlayerSanity() { if (this.m_Burning && Player.Get().transform.position.Distance(base.transform.position) < 5f) { this.m_PlayerCloseDuration += Time.deltaTime; } else { this.m_PlayerCloseDuration = 0f; } if (this.m_PlayerCloseDuration >= PlayerSanityModule.Get().GetEventInterval(PlayerSanityModule.SanityEventType.Firecamp)) { PlayerSanityModule.Get().OnEvent(PlayerSanityModule.SanityEventType.Firecamp, 1); this.m_PlayerCloseDuration = 0f; } }
private void UpdatePlayerSanity() { if (this.IsRain() && !this.IsInRainCutter(Player.Get().transform.position)) { this.m_PlayerWetDuration += Time.deltaTime; } else { this.m_PlayerWetDuration = 0f; } if (this.m_PlayerWetDuration >= PlayerSanityModule.Get().GetEventInterval(PlayerSanityModule.SanityEventType.Rain)) { PlayerSanityModule.Get().OnEvent(PlayerSanityModule.SanityEventType.Rain, 1); this.m_PlayerWetDuration = 0f; } }
private void UpdateEnergy() { if (this.m_Player.m_DreamActive) { return; } float deltaTime = Time.deltaTime; FPPController fppcontroller = this.m_Player.m_FPPController; if (!fppcontroller) { return; } DeathController deathController = this.m_Player.m_DeathController; if (deathController.IsActive()) { return; } ConsciousnessController component = this.m_Player.GetComponent <ConsciousnessController>(); if (component.IsActive()) { return; } if (!Cheats.m_GodMode && !this.m_LossParametersBlocked) { this.m_Energy -= this.m_EnergyConsumptionPerSecond * deltaTime; if (this.IsNutritionCarboCriticalLevel() || this.IsNutritionFatCriticalLevel() || this.IsNutritionProteinsCriticalLevel()) { this.m_Energy -= this.m_EnergyConsumptionPerSecondNoNutrition * deltaTime; } if (this.m_DiseasesModule.GetDisease(ConsumeEffect.Fever).IsActive()) { this.m_Energy -= this.m_EnergyConsumptionPerSecondFever * deltaTime; } if (this.m_DiseasesModule.GetDisease(ConsumeEffect.FoodPoisoning).IsActive()) { this.m_Energy -= this.m_EnergyConsumptionPerSecondFoodPoison * deltaTime; } } this.m_Energy = Mathf.Clamp(this.m_Energy, 0f, this.m_MaxEnergy); if (this.m_Energy <= PlayerSanityModule.Get().m_LowEnegryWhispersLevel) { PlayerSanityModule.Get().OnWhispersEvent(PlayerSanityModule.WhisperType.LowEnergy); } }
public Injury AddInjury(InjuryType type, InjuryPlace place, BIWoundSlot slot, InjuryState state, int poison_level = 0, Injury parent_injury = null) { if (!slot || PlayerConditionModule.Get().GetParameterLossBlocked()) { return(null); } if (type == InjuryType.Leech && this.GetAllInjuries(type).Count == 0 && PlayerSanityModule.Get()) { PlayerSanityModule.Get().ResetEventCooldown(PlayerSanityModule.SanityEventType.Leech); } Debug.Log("AddInjury"); Injury injury = new Injury(type, place, slot, state, poison_level, parent_injury); this.m_Injuries.Add(injury); this.OnAddInjury(type); return(injury); }