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 OnDrink(LiquidData data, float hydration_amount, float fat_amount, float proteins_amount, float carbo_amount, float energy_amount) { if (data.m_ConsumeEffect != ConsumeEffect.None && UnityEngine.Random.Range(0f, 1f) <= data.m_ConsumeEffectChance && data.m_ConsumeEffectLevel >= 0) { PlayerDiseasesModule.Get().RequestDisease(data.m_ConsumeEffect, data.m_ConsumeEffectDelay, data.m_ConsumeEffectLevel); } PlayerDiseasesModule.Get().OnDrink(data.m_LiquidType, hydration_amount); PlayerInjuryModule.Get().OnDrink(data); if (data.m_Disgusting) { PlayerAudioModule.Get().PlayDrinkingDisgustingSound(1f, false); } else { PlayerAudioModule.Get().PlayDrinkingSound(1f, false); } Localization localization = GreenHellGame.Instance.GetLocalization(); HUDMessages hudmessages = (HUDMessages)HUDManager.Get().GetHUD(typeof(HUDMessages)); string text = string.Empty; if (energy_amount > 0f) { text = energy_amount.ToString("F0") + " " + localization.Get("HUD_Energy"); hudmessages.AddMessage(text, null, HUDMessageIcon.Energy, string.Empty); } if (hydration_amount > 0f) { text = hydration_amount.ToString("F0") + " " + localization.Get("HUD_Hydration"); hudmessages.AddMessage(text, null, HUDMessageIcon.Hydration, string.Empty); } if (fat_amount > 0f) { text = fat_amount.ToString("F0") + " " + localization.Get("HUD_Nutrition_Fat"); hudmessages.AddMessage(text, null, HUDMessageIcon.Fat, string.Empty); } if (proteins_amount > 0f) { text = proteins_amount.ToString("F0") + " " + localization.Get("HUD_Nutrition_Protein"); hudmessages.AddMessage(text, null, HUDMessageIcon.Proteins, string.Empty); } if (carbo_amount > 0f) { text = carbo_amount.ToString("F0") + " " + localization.Get("HUD_Nutrition_Carbo"); hudmessages.AddMessage(text, null, HUDMessageIcon.Carbo, string.Empty); } text = localization.Get(TriggerAction.GetTextPerfect(TriggerAction.TYPE.Drink)) + ": " + GreenHellGame.Instance.GetLocalization().Get(data.m_LiquidType.ToString()); hudmessages.AddMessage(text, null, HUDMessageIcon.None, string.Empty); EventsManager.OnEvent(Enums.Event.Drink, 1, (int)data.m_LiquidType); }
private void OnDrink(LiquidData data, float hydration_amount, float fat_amount, float proteins_amount, float carbo_amount, float energy_amount) { string text = string.Empty; Localization localization = GreenHellGame.Instance.GetLocalization(); HUDMessages hudmessages = (HUDMessages)HUDManager.Get().GetHUD(typeof(HUDMessages)); bool flag = false; bool flag2 = false; for (int i = 0; i < data.m_ConsumeEffects.Count; i++) { if (data.m_ConsumeEffects[i].m_ConsumeEffect != ConsumeEffect.None && UnityEngine.Random.Range(0f, 1f) <= data.m_ConsumeEffects[i].m_ConsumeEffectChance && data.m_ConsumeEffects[i].m_ConsumeEffectLevel != 0) { if (data.m_ConsumeEffects[i].m_ConsumeEffectLevel > 0) { PlayerDiseasesModule.Get().RequestDisease(data.m_ConsumeEffects[i].m_ConsumeEffect, data.m_ConsumeEffects[i].m_ConsumeEffectDelay, 0); flag = true; } if (data.m_ConsumeEffects[i].m_ConsumeEffectLevel < 0) { flag2 = true; } if (data.m_ConsumeEffects[i].m_ConsumeEffect == ConsumeEffect.FoodPoisoning) { text = data.m_ConsumeEffects[i].m_ConsumeEffectLevel.ToString("F0") + " " + localization.Get("HUD_FoodPoisoning", true); hudmessages.AddMessage(text, null, HUDMessageIcon.FoodPoisoning, "", null); } else if (data.m_ConsumeEffects[i].m_ConsumeEffect == ConsumeEffect.ParasiteSickness) { text = data.m_ConsumeEffects[i].m_ConsumeEffectLevel.ToString("F0") + " " + localization.Get("HUD_ParasiteSickness", true); hudmessages.AddMessage(text, null, HUDMessageIcon.ParasiteSickness, "", null); } } } if (flag || flag2) { PlayerDiseasesModule.Get().OnDrink(data.m_LiquidType, hydration_amount); } PlayerInjuryModule.Get().OnDrink(data); if (data.m_Disgusting) { PlayerAudioModule.Get().PlayDrinkingDisgustingSound(1f, false); } else { PlayerAudioModule.Get().PlayDrinkingSound(1f, false); } if (energy_amount > 0f) { text = energy_amount.ToString("F0") + " " + localization.Get("HUD_Energy", true); hudmessages.AddMessage(text, null, HUDMessageIcon.Energy, "", null); } if (hydration_amount > 0f) { text = hydration_amount.ToString("F0") + " " + localization.Get("HUD_Hydration", true); hudmessages.AddMessage(text, null, HUDMessageIcon.Hydration, "", null); } if (fat_amount > 0f) { text = fat_amount.ToString("F0") + " " + localization.Get("HUD_Nutrition_Fat", true); hudmessages.AddMessage(text, null, HUDMessageIcon.Fat, "", null); } if (proteins_amount > 0f) { text = proteins_amount.ToString("F0") + " " + localization.Get("HUD_Nutrition_Protein", true); hudmessages.AddMessage(text, null, HUDMessageIcon.Proteins, "", null); } if (carbo_amount > 0f) { text = carbo_amount.ToString("F0") + " " + localization.Get("HUD_Nutrition_Carbo", true); hudmessages.AddMessage(text, null, HUDMessageIcon.Carbo, "", null); } text = localization.Get(TriggerAction.GetTextPerfect(TriggerAction.TYPE.Drink), true) + ": " + GreenHellGame.Instance.GetLocalization().Get(data.m_LiquidType.ToString(), true); hudmessages.AddMessage(text, null, HUDMessageIcon.None, "", null); EventsManager.OnEvent(Enums.Event.Drink, 1, (int)data.m_LiquidType); InventoryBackpack.Get().CalculateCurrentWeight(); }
public void ExecuteTrigger(Trigger trigger, TriggerAction.TYPE action) { if (this.IsGrabInProgress()) { return; } if (Time.time - this.m_LastTrigerExecutionTime < 0.1f) { return; } if (!trigger) { return; } if (this.m_TriggerToExecute) { if (Time.time - this.m_TriggerToExecuteTime > 2f) { this.m_TriggerToExecute = null; this.m_TriggerActionToExecute = TriggerAction.TYPE.None; } return; } if (trigger.PlayGrabAnimOnExecute(action)) { this.m_TriggerToExecute = trigger; this.m_TriggerActionToExecute = action; this.m_TriggerToExecuteTime = Time.time; } else { trigger.OnExecute(action); this.m_LastTrigerExecutionTime = Time.time; } if (action == TriggerAction.TYPE.Use) { HUDMessages hudmessages = (HUDMessages)HUDManager.Get().GetHUD(typeof(HUDMessages)); string text = GreenHellGame.Instance.GetLocalization().Get(TriggerAction.GetTextPerfect(action)) + ": " + GreenHellGame.Instance.GetLocalization().Get(trigger.GetName()); if (action == TriggerAction.TYPE.Drink && trigger.IsItem() && ((Item)trigger).m_Info.IsLiquidContainer()) { Localization localization = GreenHellGame.Instance.GetLocalization(); LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)((Item)trigger).m_Info; text += liquidContainerInfo.m_Amount.ToString("F1"); text += localization.Get("HUD_Hydration"); } hudmessages.AddMessage(text, null, (action != TriggerAction.TYPE.Drink) ? HUDMessageIcon.None : HUDMessageIcon.Hydration, string.Empty); } else if (action != TriggerAction.TYPE.Eat) { if (action == TriggerAction.TYPE.Take || action == TriggerAction.TYPE.TakeHold || action == TriggerAction.TYPE.PickUp) { Item currentItem = this.m_Player.GetCurrentItem(Hand.Left); if (currentItem != null && currentItem.m_Info.m_ID == ItemID.Bow) { this.m_Animator.SetBool(TriggerController.s_BGrabItemBow, true); } else if (currentItem != null && currentItem.m_Info.m_ID == ItemID.Bamboo_Bow) { this.m_Animator.SetBool(TriggerController.s_BGrabItemBambooBow, true); } else if (currentItem && currentItem.m_Info.IsBow()) { this.m_Animator.SetBool(TriggerController.s_BGrabItemBow, true); } else if (trigger.PlayGrabAnimOnExecute(action)) { this.m_Animator.SetBool(TriggerController.s_BGrabItem, true); } } else if (action == TriggerAction.TYPE.DrinkHold) { this.m_Animator.SetBool(this.m_BDrinkWater, true); this.m_TriggerInAction = true; } } }