private static void TransferLiquids(LiquidContainer from, LiquidContainer to) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)from.m_Info; LiquidContainerInfo liquidContainerInfo2 = (LiquidContainerInfo)to.m_Info; if (liquidContainerInfo.m_LiquidType != liquidContainerInfo2.m_LiquidType) { if (liquidContainerInfo2.m_Amount >= 1f) { HUDMessages.Get().AddMessage(GreenHellGame.Instance.GetLocalization().Get("Liquids_Conflict", true), null, HUDMessageIcon.None, "", null); return; } liquidContainerInfo2.m_LiquidType = liquidContainerInfo.m_LiquidType; } float amount = liquidContainerInfo2.m_Amount; liquidContainerInfo2.m_Amount += liquidContainerInfo.m_Amount; liquidContainerInfo2.m_Amount = Mathf.Clamp(liquidContainerInfo2.m_Amount, 0f, liquidContainerInfo2.m_Capacity); float num = liquidContainerInfo2.m_Amount - amount; liquidContainerInfo.m_Amount -= num; to.ReplRequestOwnership(false); to.OnGet(); from.ReplRequestOwnership(false); from.OnPour(); }
public override void OnExecute(TriggerAction.TYPE action) { base.OnExecute(action); if (action == TriggerAction.TYPE.Pour) { base.Fill(LiquidInHandsController.Get().m_Container); } else if (action == TriggerAction.TYPE.Drink) { this.Drink(); LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)this.m_Info; if (liquidContainerInfo.m_Amount == 0f) { if (this.m_Item) { UnityEngine.Object.Destroy(this.m_Item.gameObject); this.m_Item = null; } this.m_ItemSlot.gameObject.SetActive(false); if (this.m_ItemVis) { this.m_ItemVis.gameObject.SetActive(false); this.m_ItemVis = null; } this.SetState(Bowl.State.None); } } }
private void UpdateSlotActivity() { if (!Inventory3DManager.Get().m_CarriedItem) { this.m_GetSlot.gameObject.SetActive(false); return; } if (Inventory3DManager.Get().m_CarriedItem.m_Info.m_ID == ItemID.Coconut) { this.m_GetSlot.gameObject.SetActive(false); return; } if (this.m_GetSlot.gameObject.activeSelf) { if (!this.m_GetSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { this.m_GetSlot.gameObject.SetActive(false); return; } } else if (this.m_GetSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info; if (liquidContainerInfo.m_Amount < liquidContainerInfo.m_Capacity) { this.m_GetSlot.gameObject.SetActive(true); } } }
public void OnInsertItem(ItemSlot slot) { if (slot == this.m_WaterSlot) { Item item = slot.m_Item; LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)item.m_Info; float waterAmount = this.m_WaterAmount; this.m_WaterAmount += liquidContainerInfo.m_Amount; this.m_WaterAmount = Mathf.Min(this.m_WaterAmount, this.m_RequiredWaterAmount); float num = this.m_WaterAmount - waterAmount; liquidContainerInfo.m_Amount -= num; slot.RemoveItem(); InventoryBackpack.Get().InsertItem(item, null, null, true, true, true, true, true); if (this.m_WaterAmount >= this.m_RequiredWaterAmount) { this.SetState(MudMixer.State.Full); } if (num > 0f) { PlayerAudioModule.Get().PlayWaterSpillSound(1f, false); return; } } else if (slot == this.m_AshSlot) { UnityEngine.Object.Destroy(slot.m_Item.gameObject); this.SetState(MudMixer.State.WaitingForWater); } }
private void CreateHerb() { if (!this.m_Item) { return; } LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)this.m_Info; LiquidData liquidDataByComponents = LiquidManager.Get().GetLiquidDataByComponents(liquidContainerInfo.m_LiquidType, this.m_Item.m_Info.m_ID); if (liquidDataByComponents != null) { liquidContainerInfo.m_LiquidType = liquidDataByComponents.m_LiquidType; } else { liquidContainerInfo.m_LiquidType = LiquidType.Default_Infusion; } ItemsManager.Get().OnLiquidBoiled(liquidContainerInfo.m_LiquidType); if (liquidContainerInfo.m_LiquidType == LiquidType.None) { DebugUtils.Assert("Can't set liquid type - " + this.m_Item.m_Info.m_ID.ToString(), true, DebugUtils.AssertType.Info); } UnityEngine.Object.Destroy(this.m_Item.gameObject); this.m_Item = null; }
private void FillWithLiquid(Item item) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)((LiquidContainer)item).m_Info; this.m_Amount += liquidContainerInfo.m_Amount; liquidContainerInfo.m_Amount = 0f; Mathf.Clamp(this.m_Amount, 0f, this.m_Capacity); }
private void Execute(LiquidContainerInfo info0, LiquidContainerInfo info1) { float amount = info0.m_Amount; info0.m_Amount += info1.m_Amount; info0.m_Amount = Mathf.Clamp(info0.m_Amount, 0f, info0.m_Capacity); float num = info0.m_Amount - amount; info1.m_Amount -= num; }
private void Fill(LiquidContainerInfo lc_info) { if (lc_info.m_Amount == 0f) { return; } float amount = this.m_Amount; this.m_Amount += lc_info.m_Amount; this.m_Amount = Mathf.Clamp(this.m_Amount, 0f, this.m_Capacity); float num = this.m_Amount - amount; lc_info.m_Amount -= num; PlayerAudioModule.Get().PlayWaterSpillSound(1f, false); }
private void TransferLiquids(LiquidContainer to) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)to.m_Info; if (this.m_LiquidType != liquidContainerInfo.m_LiquidType) { if (liquidContainerInfo.m_Amount > 0f) { HUDMessages.Get().AddMessage(GreenHellGame.Instance.GetLocalization().Get("Liquids_Conflict"), null, HUDMessageIcon.None, string.Empty); return; } liquidContainerInfo.m_LiquidType = this.m_LiquidType; } liquidContainerInfo.m_Amount = liquidContainerInfo.m_Capacity; to.OnGet(); }
public void Drink(LiquidContainerInfo info) { if (info == null || info.m_Amount == 0f) { return; } float hydration; float num = Mathf.Max(Mathf.Clamp((hydration = PlayerConditionModule.Get().m_Hydration) + info.m_Amount, 0f, PlayerConditionModule.Get().m_MaxHydration) - hydration, Mathf.Min(this.m_MinAmount, info.m_Amount)); info.m_Amount -= Mathf.Max(num, Mathf.Min(this.m_MinAmount, info.m_Amount)); if (info.m_Amount < 0.1f) { info.m_Amount = 0f; } this.Drink(info.m_LiquidType, num); }
private void TransferLiquids(LiquidContainer to) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)to.m_Info; if (this.m_LiquidType != liquidContainerInfo.m_LiquidType) { if (liquidContainerInfo.m_Amount > 0f) { HUDMessages.Get().AddMessage(GreenHellGame.Instance.GetLocalization().Get("Liquids_Conflict", true), null, HUDMessageIcon.None, "", null); return; } liquidContainerInfo.m_LiquidType = this.m_LiquidType; } liquidContainerInfo.m_Amount = liquidContainerInfo.m_Capacity; to.OnGet(); to.ReplRequestOwnership(false); }
public bool HaveLiquid(string liquid_type, float amount) { LiquidType liquidType = (LiquidType)Enum.Parse(typeof(LiquidType), liquid_type); foreach (Item item in this.m_Items) { if (item.m_Info.IsLiquidContainer()) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)item.m_Info; if (liquidContainerInfo.m_LiquidType == liquidType && liquidContainerInfo.m_Amount >= amount) { return(true); } } } return(false); }
public override void OnGet() { base.OnGet(); LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)this.m_Info; if (liquidContainerInfo.m_LiquidType == LiquidType.UnsafeWater || liquidContainerInfo.m_LiquidType == LiquidType.DirtyWater) { this.SetState(Bowl.State.UnsafeWater); return; } if (liquidContainerInfo.m_LiquidType == LiquidType.Water) { this.SetState(Bowl.State.WaterCooked); return; } this.SetState(Bowl.State.HerbCooked); }
public bool Activate(LiquidContainer container0, LiquidContainer container1) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)container0.m_Info; LiquidContainerInfo liquidContainerInfo2 = (LiquidContainerInfo)container1.m_Info; if (liquidContainerInfo == null || liquidContainerInfo2 == null) { return(false); } if (liquidContainerInfo.m_LiquidType != liquidContainerInfo2.m_LiquidType && liquidContainerInfo.m_Amount != 0f && liquidContainerInfo2.m_Amount != 0f) { return(false); } this.m_Container0 = container0; this.m_Container0.StaticPhxRequestAdd(); this.m_Container1 = container1; base.transform.position = Input.mousePosition; this.UpdateSelection(); this.m_Active = true; return(true); }
private void TransferLiquids(LiquidType liquid_type, ContainerData from, LiquidContainer to) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)to.m_Info; if (liquid_type != liquidContainerInfo.m_LiquidType) { if (liquidContainerInfo.m_Amount > 0f) { HUDMessages.Get().AddMessage(GreenHellGame.Instance.GetLocalization().Get("Liquids_Conflict", true), null, HUDMessageIcon.None, "", null); return; } liquidContainerInfo.m_LiquidType = liquid_type; } float num = liquidContainerInfo.m_Capacity - liquidContainerInfo.m_Amount; num = Mathf.Min(num, from.m_Amount); liquidContainerInfo.m_Amount += num; to.OnGet(); from.m_Amount -= num; PlayerAudioModule.Get().PlayWaterSpillSound(1f, false); }
private void TransferLiquids(LiquidType liquid_type, LiquidContainer from, ContainerData to) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)from.m_Info; if (liquid_type != liquidContainerInfo.m_LiquidType) { if (to.m_Amount > 0f) { HUDMessages.Get().AddMessage(GreenHellGame.Instance.GetLocalization().Get("Liquids_Conflict", true), null, HUDMessageIcon.None, "", null); return; } this.SetCollectorLiquidType(liquidContainerInfo.m_LiquidType); } to.m_Amount += liquidContainerInfo.m_Amount; if (to.m_Amount > to.m_Capacity) { to.m_Amount = to.m_Capacity; } liquidContainerInfo.m_Amount = 0f; PlayerAudioModule.Get().PlayWaterSpillSound(1f, false); }
public void Fill(LiquidContainer other) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)other.m_Info; if (this.m_LCInfo.m_LiquidType != liquidContainerInfo.m_LiquidType) { if (this.m_LCInfo.m_Amount > 0f) { return; } this.m_LCInfo.m_LiquidType = liquidContainerInfo.m_LiquidType; } float amount = this.m_LCInfo.m_Amount; this.m_LCInfo.m_Amount += liquidContainerInfo.m_Amount; this.m_LCInfo.m_Amount = Mathf.Clamp(this.m_LCInfo.m_Amount, 0f, this.m_LCInfo.m_Capacity); float num = this.m_LCInfo.m_Amount - amount; liquidContainerInfo.m_Amount -= num; this.OnGet(); other.OnPour(); }
public void OnInsertItem(ItemSlot slot) { if (slot == null || slot.m_Item == null) { return; } if (slot == this.m_ItemSlot) { this.OnInsertSeeds(slot.m_Item); return; } if (slot == this.m_WaterSlot) { if (EnumTools.IsItemSpoiled(slot.m_Item.m_Info.m_ID) || slot.m_Item.m_Info.m_ID == ItemID.animal_droppings_item) { this.m_FertilizerAmount += slot.m_Item.m_Info.m_FertilizeAmount; this.m_FertilizerAmount = Mathf.Clamp(this.m_FertilizerAmount, 0f, this.m_MaxFertilizerAmount); UnityEngine.Object.Destroy(slot.m_Item.gameObject); slot.RemoveItem(); return; } Item item = slot.m_Item; LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)item.m_Info; float waterAmount = this.m_WaterAmount; this.m_WaterAmount += liquidContainerInfo.m_Amount; this.m_WaterAmount = Mathf.Min(this.m_WaterAmount, this.m_MaxWaterAmount); float num = this.m_WaterAmount - waterAmount; liquidContainerInfo.m_Amount -= num; slot.RemoveItem(); InventoryBackpack.Get().InsertItem(item, null, null, true, true, true, true, true); if (num > 0f) { PlayerAudioModule.Get().PlayWaterSpillSound(1f, false); } } }
public bool Activate(Item item) { if (!item || !item.CanExecuteActions()) { return(false); } this.ResetItems(); this.m_Item = item; this.ClearSlots(); bool flag = Player.Get().m_SwimController.IsActive(); if (this.m_Item.m_Info.m_Craftable && !this.m_Item.m_OnCraftingTable && !flag) { this.AddSlot(HUDItem.Action.Craft); } if (this.m_Item.m_Info.IsHeavyObject() && !this.m_Item.m_Info.m_CanBeAddedToInventory) { if (!MakeFireController.Get().IsActive()) { this.AddSlot(HUDItem.Action.PickUp); } } else if (this.m_Item.m_Info.m_CanEquip) { if (this.m_Item.IsFireTool()) { if (!InventoryBackpack.Get().Contains(this.m_Item)) { this.AddSlot(HUDItem.Action.Take); } this.AddSlot(HUDItem.Action.Use); } else if (this.m_Item.m_InInventory) { if (item != InventoryBackpack.Get().m_EquippedItem) { this.AddSlot(HUDItem.Action.Equip); } } else { ItemSlot exists = InventoryBackpack.Get().FindFreeSlot(this.m_Item); if (exists) { this.AddSlot(HUDItem.Action.Take); } else { this.AddSlot(HUDItem.Action.Swap); } } } else if (this.m_Item.m_Info.m_CanBeAddedToInventory && !InventoryBackpack.Get().Contains(this.m_Item)) { this.AddSlot(HUDItem.Action.Take); } if (this.m_Item.m_Info.m_Eatable && !flag) { this.AddSlot(HUDItem.Action.Eat); } if (this.m_Item.m_Info.CanDrink() && !flag) { this.AddSlot(HUDItem.Action.Drink); } if (this.m_Item.m_Info.IsLiquidContainer()) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)this.m_Item.m_Info; if (liquidContainerInfo.m_Amount > 0f) { this.AddSlot(HUDItem.Action.Spill); } } if (this.m_Item.m_Info.m_Harvestable && !flag) { this.AddSlot(HUDItem.Action.Harvest); } this.Activate(); return(true); }
private void UpdateSlotActivity() { if (!Inventory3DManager.Get().m_CarriedItem) { this.m_GetFromContainerSlot.gameObject.SetActive(false); } else if (Inventory3DManager.Get().m_CarriedItem.m_Info.m_ID == ItemID.Coconut) { this.m_GetFromContainerSlot.gameObject.SetActive(false); } else if (this.m_GetFromContainerSlot.gameObject.activeSelf) { if (!this.m_GetFromContainerSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { this.m_GetFromContainerSlot.gameObject.SetActive(false); } } else if (this.m_GetFromContainerSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info; if (liquidContainerInfo.m_Amount < liquidContainerInfo.m_Capacity) { this.m_GetFromContainerSlot.gameObject.SetActive(true); } } if (this.m_Info.m_ID == ItemID.Coconut) { this.m_GetFromCollectorSlot.gameObject.SetActive(false); this.m_PourToCollectorSlot.gameObject.SetActive(false); } if (this.m_GetFromCollectorSlot) { if (this.m_CollectorData.m_Amount < 1f) { this.m_GetFromCollectorSlot.gameObject.SetActive(false); } else if (this.m_CollectorData.m_Amount > 0f && this.m_CollectorLiquidType != LiquidType.Water && this.m_CollectorLiquidType != LiquidType.UnsafeWater && this.m_CollectorLiquidType != LiquidType.DirtyWater) { this.m_GetFromCollectorSlot.gameObject.SetActive(false); } else if (this.m_GetFromCollectorSlot.gameObject.activeSelf) { if (this.m_CollectorData.m_Amount < 1f) { this.m_GetFromCollectorSlot.gameObject.SetActive(false); } else if (!this.m_GetFromCollectorSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { this.m_GetFromCollectorSlot.gameObject.SetActive(false); } else { LiquidContainerInfo liquidContainerInfo2 = (LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info; if (liquidContainerInfo2.m_Amount >= liquidContainerInfo2.m_Capacity) { this.m_GetFromCollectorSlot.gameObject.SetActive(false); } } } else if (this.m_GetFromCollectorSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { if (Inventory3DManager.Get().m_CarriedItem.m_Info.m_ID == ItemID.Coconut) { this.m_GetFromCollectorSlot.gameObject.SetActive(false); } else { LiquidContainerInfo liquidContainerInfo3 = (LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info; if (liquidContainerInfo3.m_Amount < liquidContainerInfo3.m_Capacity) { this.m_GetFromCollectorSlot.gameObject.SetActive(true); } } } } if (this.m_PourToCollectorSlot) { if (this.m_PourToCollectorSlot.gameObject.activeSelf) { if (!Inventory3DManager.Get().m_CarriedItem) { this.m_PourToCollectorSlot.gameObject.SetActive(false); return; } if (((LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info).m_Amount < 1f) { this.m_PourToCollectorSlot.gameObject.SetActive(false); return; } if (!this.m_PourToCollectorSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { this.m_PourToCollectorSlot.gameObject.SetActive(false); return; } if (this.m_CollectorData.m_Amount >= this.m_CollectorData.m_Capacity) { this.m_PourToCollectorSlot.gameObject.SetActive(false); return; } } else if (this.m_PourToCollectorSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { if ((this.m_Info.m_ID == ItemID.Bidon || this.m_Info.m_ID == ItemID.Coconut_Bidon) && Inventory3DManager.Get().m_CarriedItem.m_Info.IsLiquidContainer() && ((LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info).m_Amount >= 1f && ((LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info).m_LiquidType != LiquidType.Water && ((LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info).m_LiquidType != LiquidType.UnsafeWater && ((LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info).m_LiquidType != LiquidType.DirtyWater) { this.m_PourToCollectorSlot.gameObject.SetActive(false); return; } if (this.m_CollectorData.m_Amount < this.m_CollectorData.m_Capacity) { this.m_PourToCollectorSlot.gameObject.SetActive(true); } } } }
protected virtual void UpdateSlotsActivity() { if (this.m_GetSlot) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)this.m_Info; if (liquidContainerInfo.m_Amount > 0f && liquidContainerInfo.m_LiquidType != LiquidType.Water && liquidContainerInfo.m_LiquidType != LiquidType.UnsafeWater && liquidContainerInfo.m_LiquidType != LiquidType.DirtyWater) { this.m_GetSlot.gameObject.SetActive(false); } else if (this.m_GetSlot.gameObject.activeSelf) { if (liquidContainerInfo.m_Amount == 0f) { this.m_GetSlot.gameObject.SetActive(false); } else if (!this.m_GetSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { this.m_GetSlot.gameObject.SetActive(false); } else { LiquidContainerInfo liquidContainerInfo2 = (LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info; if (liquidContainerInfo2.m_Amount >= liquidContainerInfo2.m_Capacity) { this.m_GetSlot.gameObject.SetActive(false); } } } else if (this.m_GetSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { LiquidContainerInfo liquidContainerInfo3 = (LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info; if (liquidContainerInfo3.m_Amount < liquidContainerInfo3.m_Capacity) { this.m_GetSlot.gameObject.SetActive(true); } } } if (this.m_PourSlot) { if (this.m_PourSlot.gameObject.activeSelf) { if (!Inventory3DManager.Get().m_CarriedItem) { this.m_PourSlot.gameObject.SetActive(false); } else if (((LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info).m_Amount == 0f) { this.m_PourSlot.gameObject.SetActive(false); } else if (!this.m_PourSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { this.m_PourSlot.gameObject.SetActive(false); } else { LiquidContainerInfo liquidContainerInfo4 = (LiquidContainerInfo)this.m_Info; if (liquidContainerInfo4.m_Amount >= liquidContainerInfo4.m_Capacity) { this.m_PourSlot.gameObject.SetActive(false); } } } else if (this.m_PourSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { LiquidContainerInfo liquidContainerInfo5 = (LiquidContainerInfo)this.m_Info; if (liquidContainerInfo5.m_Amount < liquidContainerInfo5.m_Capacity) { this.m_PourSlot.gameObject.SetActive(true); } } } }
private void SetupConsumableEffects() { if (!this.m_ConsumableEffects) { return; } if (!Inventory3DManager.Get().gameObject.activeSelf || this.IsExpanded()) { this.m_ConsumableEffects.gameObject.SetActive(false); return; } Trigger trigger = this.GetTrigger(); if (trigger == null || !trigger.IsItem()) { this.m_ConsumableEffects.gameObject.SetActive(false); return; } Item item = (Item)trigger; if (!item.m_Info.IsConsumable() && !item.m_Info.IsLiquidContainer()) { this.m_ConsumableEffects.gameObject.SetActive(false); return; } int num = 0; if (item.m_Info.IsConsumable()) { if (!ItemsManager.Get().WasConsumed(item.m_Info.m_ID)) { this.m_UnknownEffect.SetActive(true); } else { this.m_UnknownEffect.SetActive(false); ConsumableInfo consumableInfo = (ConsumableInfo)item.m_Info; if (consumableInfo.m_Proteins > 0f) { this.SetupEffect("Watch_protein_icon", IconColors.GetColor(IconColors.Icon.Proteins), consumableInfo.m_Proteins, "HUD_Nutrition_Protein", ref num, -1f); } if (consumableInfo.m_Fat > 0f) { this.SetupEffect("Watch_fat_icon", IconColors.GetColor(IconColors.Icon.Fat), consumableInfo.m_Fat, "HUD_Nutrition_Fat", ref num, -1f); } if (consumableInfo.m_Carbohydrates > 0f) { this.SetupEffect("Watch_carbo_icon", IconColors.GetColor(IconColors.Icon.Carbo), consumableInfo.m_Carbohydrates, "HUD_Nutrition_Carbo", ref num, -1f); } if (consumableInfo.m_Water > 0f) { this.SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), consumableInfo.m_Water, "HUD_Hydration", ref num, -1f); } if (consumableInfo.m_AddEnergy > 0f) { this.SetupEffect("Energy_icon", Color.white, consumableInfo.m_AddEnergy, "HUD_Energy", ref num, -1f); } if ((float)consumableInfo.m_SanityChange > 0f) { this.SetupEffect("Default_Pickup", Color.white, (float)consumableInfo.m_SanityChange, "HUD_Sanity", ref num, -1f); } if (consumableInfo.m_ConsumeEffect == ConsumeEffect.FoodPoisoning) { this.SetupEffect("Vomit_icon_H", Color.white, (float)consumableInfo.m_ConsumeEffectLevel, "HUD_FoodPoisoning", ref num, -1f); } } } else if (item.m_Info.IsLiquidContainer()) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)item.m_Info; if (liquidContainerInfo.m_Amount > 0f) { LiquidData liquidData = LiquidManager.Get().GetLiquidData(liquidContainerInfo.m_LiquidType); if (liquidContainerInfo.m_Amount > 0f) { this.SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), liquidContainerInfo.m_Amount, "HUD_Hydration", ref num, liquidContainerInfo.m_Capacity); } if (liquidData.m_Energy > 0f) { this.SetupEffect("Energy_icon", Color.white, liquidData.m_Energy, "HUD_Energy", ref num, -1f); } if (liquidData.m_ConsumeEffect == ConsumeEffect.FoodPoisoning) { this.SetupEffect("Vomit_icon_H", Color.white, (float)liquidData.m_ConsumeEffectLevel, "HUD_FoodPoisoning", ref num, -1f); } } this.m_UnknownEffect.SetActive(num == 0); } for (int i = num; i < this.m_EffectsData.Count; i++) { this.m_EffectsData[i].m_Parent.SetActive(false); } this.m_ConsumableEffects.gameObject.SetActive(true); }
protected virtual void UpdateSlotsActivity() { if (this.m_Info.m_ID == ItemID.Coconut) { this.m_GetSlot.gameObject.SetActive(false); this.m_PourSlot.gameObject.SetActive(false); } if (base.m_InInventory) { this.m_GetSlot.gameObject.SetActive(false); this.m_PourSlot.gameObject.SetActive(false); return; } if (this.m_GetSlot) { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)this.m_Info; if (liquidContainerInfo.m_Amount < 1f) { this.m_GetSlot.gameObject.SetActive(false); } else if (liquidContainerInfo.m_Amount > 0f && liquidContainerInfo.m_LiquidType != LiquidType.Water && liquidContainerInfo.m_LiquidType != LiquidType.UnsafeWater && liquidContainerInfo.m_LiquidType != LiquidType.DirtyWater) { this.m_GetSlot.gameObject.SetActive(false); } else if (this.m_GetSlot.gameObject.activeSelf) { if (liquidContainerInfo.m_Amount < 1f) { this.m_GetSlot.gameObject.SetActive(false); } else if (!this.m_GetSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { this.m_GetSlot.gameObject.SetActive(false); } else { LiquidContainerInfo liquidContainerInfo2 = (LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info; if (liquidContainerInfo2.m_Amount >= liquidContainerInfo2.m_Capacity) { this.m_GetSlot.gameObject.SetActive(false); } } } else if (this.m_GetSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { if (Inventory3DManager.Get().m_CarriedItem.m_Info.m_ID == ItemID.Coconut) { this.m_GetSlot.gameObject.SetActive(false); } else { LiquidContainerInfo liquidContainerInfo3 = (LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info; if (liquidContainerInfo3.m_Amount < liquidContainerInfo3.m_Capacity) { this.m_GetSlot.gameObject.SetActive(true); } } } } if (this.m_PourSlot) { if (this.m_PourSlot.gameObject.activeSelf) { if (!Inventory3DManager.Get().m_CarriedItem) { this.m_PourSlot.gameObject.SetActive(false); return; } if (((LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info).m_Amount < 1f) { this.m_PourSlot.gameObject.SetActive(false); return; } if (!this.m_PourSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { this.m_PourSlot.gameObject.SetActive(false); return; } LiquidContainerInfo liquidContainerInfo4 = (LiquidContainerInfo)this.m_Info; if (liquidContainerInfo4.m_Amount >= liquidContainerInfo4.m_Capacity) { this.m_PourSlot.gameObject.SetActive(false); return; } } else if (this.m_PourSlot.CanInsertItem(Inventory3DManager.Get().m_CarriedItem)) { if ((this.m_Info.m_ID == ItemID.Bidon || this.m_Info.m_ID == ItemID.Coconut_Bidon) && Inventory3DManager.Get().m_CarriedItem.m_Info.IsLiquidContainer() && ((LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info).m_Amount >= 1f && ((LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info).m_LiquidType != LiquidType.Water && ((LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info).m_LiquidType != LiquidType.UnsafeWater && ((LiquidContainerInfo)Inventory3DManager.Get().m_CarriedItem.m_Info).m_LiquidType != LiquidType.DirtyWater) { this.m_PourSlot.gameObject.SetActive(false); return; } LiquidContainerInfo liquidContainerInfo5 = (LiquidContainerInfo)this.m_Info; if (liquidContainerInfo5.m_Amount < liquidContainerInfo5.m_Capacity) { this.m_PourSlot.gameObject.SetActive(true); } } } }
private void UpdateState() { LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)this.m_Info; if (this.m_State != Bowl.State.None && liquidContainerInfo.m_Amount == 0f) { this.SetState(Bowl.State.None); return; } switch (this.m_State) { case Bowl.State.None: if (liquidContainerInfo.m_Amount >= 1f) { LiquidType liquidType = liquidContainerInfo.m_LiquidType; if (liquidType == LiquidType.UnsafeWater || liquidType == LiquidType.DirtyWater) { this.SetState(Bowl.State.UnsafeWater); return; } if (liquidType == LiquidType.Water) { this.SetState(Bowl.State.WaterCooked); return; } this.SetState(Bowl.State.HerbCooked); return; } break; case Bowl.State.UnsafeWater: if (this.m_Firecamp && this.m_Firecamp.m_Burning) { this.SetState(Bowl.State.UnsafeWaterCooking); return; } break; case Bowl.State.UnsafeWaterCooking: this.m_CookingDuration += Time.deltaTime; if (this.m_CookingDuration >= this.m_CookingLength) { this.SetState(Bowl.State.WaterCooked); return; } if (this.m_Firecamp && !this.m_Firecamp.m_Burning) { this.SetState(Bowl.State.UnsafeWater); return; } break; case Bowl.State.WaterCooked: if (this.m_Item) { this.SetState(Bowl.State.Herb); return; } this.m_ItemSlot.gameObject.SetActive(this.m_Firecamp != null); return; case Bowl.State.Herb: if (this.m_Firecamp && this.m_Firecamp.m_Burning) { this.SetState(Bowl.State.HerbCooking); return; } break; case Bowl.State.HerbCooking: this.m_CookingDuration += Time.deltaTime; if (this.m_CookingDuration >= this.m_CookingLength) { this.CreateHerb(); this.SetState(Bowl.State.HerbCooked); return; } if (this.m_Firecamp && !this.m_Firecamp.m_Burning) { this.SetState(Bowl.State.Herb); } break; case Bowl.State.HerbCooked: break; default: return; } }
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; } } }
private void OnEnterState() { if (this.m_DefaultVis) { this.m_DefaultVis.SetActive(false); } this.m_UnsafeWaterVis.SetActive(false); this.m_WaterVis.SetActive(false); foreach (string key in this.m_HerbVisualisations.Keys) { this.m_HerbVisualisations[key].SetActive(false); } this.m_HerbVis.SetActive(false); if (this.m_ItemVis) { this.m_ItemVis.SetActive(false); } if (this.m_State != Bowl.State.None) { this.InitializeAudio(); } LiquidContainerInfo liquidContainerInfo = (LiquidContainerInfo)this.m_Info; LiquidManager.Get().GetLiquidData(liquidContainerInfo.m_LiquidType); switch (this.m_State) { case Bowl.State.None: this.m_ItemSlot.gameObject.SetActive(false); if (this.m_ItemVis) { this.m_ItemVis.gameObject.SetActive(false); this.m_ItemVis = null; return; } break; case Bowl.State.UnsafeWater: case Bowl.State.UnsafeWaterCooking: this.m_CookingDuration = 0f; this.m_UnsafeWaterVis.SetActive(true); return; case Bowl.State.WaterCooked: liquidContainerInfo.OnCooked(); this.m_WaterVis.SetActive(true); return; case Bowl.State.Herb: if (this.m_ItemVis) { this.m_ItemVis.SetActive(true); return; } break; case Bowl.State.HerbCooking: this.m_CookingDuration = 0f; if (this.m_ItemVis) { this.m_ItemVis.SetActive(true); return; } break; case Bowl.State.HerbCooked: { this.m_HerbVis.SetActive(true); LiquidData liquidData = LiquidManager.Get().GetLiquidData(this.m_LCInfo.m_LiquidType); bool flag = false; foreach (string text in this.m_HerbVisualisations.Keys) { bool flag2 = liquidData != null && text == liquidData.m_ItemComponent.ToString(); this.m_HerbVisualisations[text].SetActive(flag2); if (!flag && flag2) { flag = true; } } if (!flag && this.m_DefaultVis) { this.m_DefaultVis.SetActive(true); } break; } default: return; } }
// While hovering over a food, show food's consumable effects // Code below is mostly copy&pasted from original implementation protected override void SetupConsumableEffects() { if (!m_ConsumableEffects) { return; } if (IsExpanded()) { m_ConsumableEffects.gameObject.SetActive(false); } else { Trigger trigger = GetTrigger(); ItemInfo m_Info = null; if (trigger) { if (trigger.IsItem()) { m_Info = ((Item)trigger).m_Info; } else if (trigger is PlantFruit) { m_Info = ((PlantFruit)trigger).m_ItemInfo; } else if (trigger is ItemReplacer) { m_Info = ((ItemReplacer)trigger).m_ReplaceInfo; } } if (m_Info == null) { m_ConsumableEffects.gameObject.SetActive(false); } else { if (!m_Info.IsConsumable() && !m_Info.IsLiquidContainer()) { m_ConsumableEffects.gameObject.SetActive(false); } else { int index1 = 0; if (m_Info.IsConsumable()) { if (!ItemsManager.Get().WasConsumed(m_Info.m_ID)) { m_UnknownEffect.SetActive(true); } else { m_UnknownEffect.SetActive(false); ConsumableInfo info = (ConsumableInfo)m_Info; if (info.m_Proteins > 0.0) { SetupEffect("Watch_protein_icon", IconColors.GetColor(IconColors.Icon.Proteins), info.m_Proteins, "HUD_Nutrition_Protein", ref index1, -1f); } if (info.m_Fat > 0.0) { SetupEffect("Watch_fat_icon", IconColors.GetColor(IconColors.Icon.Fat), info.m_Fat, "HUD_Nutrition_Fat", ref index1, -1f); } if (info.m_Carbohydrates > 0.0) { SetupEffect("Watch_carbo_icon", IconColors.GetColor(IconColors.Icon.Carbo), info.m_Carbohydrates, "HUD_Nutrition_Carbo", ref index1, -1f); } if (info.m_Water > 0.0) { SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), info.m_Water, "HUD_Hydration", ref index1, -1f); } if (info.m_Dehydration > 0.0) { SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), -1f * info.m_Dehydration, "HUD_Hydration", ref index1, -1f); } if (info.m_AddEnergy > 0.0) { SetupEffect("Energy_icon", Color.white, info.m_AddEnergy, "HUD_Energy", ref index1, -1f); } if (info.m_SanityChange != 0.0) { SetupEffect("sanity_icon_H", Color.white, info.m_SanityChange, "HUD_Sanity", ref index1, -1f); } if (info.m_ConsumeEffect == ConsumeEffect.Fever) { SetupEffect("Fever_icon_T", Color.white, info.m_ConsumeEffectLevel, "Fever", ref index1, -1f); } if (info.m_ConsumeEffect == ConsumeEffect.FoodPoisoning) { SetupEffect("Vomit_icon_H", Color.white, info.m_ConsumeEffectLevel, "HUD_FoodPoisoning", ref index1, -1f); } else if (info.m_ConsumeEffect == ConsumeEffect.ParasiteSickness) { SetupEffect("ParasiteSichness_icon_H", Color.white, info.m_ConsumeEffectLevel, "HUD_ParasiteSickness", ref index1, -1f); } } } else if (m_Info.IsLiquidContainer()) { LiquidContainerInfo info = (LiquidContainerInfo)m_Info; if (info.m_Amount > 0.0) { LiquidData liquidData = LiquidManager.Get().GetLiquidData(info.m_LiquidType); if (info.m_Amount >= 1.0) { SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), info.m_Amount, "HUD_Hydration", ref index1, info.m_Capacity); } if (liquidData.m_Energy > 0.0) { SetupEffect("Energy_icon", Color.white, liquidData.m_Energy, "HUD_Energy", ref index1, -1f); } for (int index2 = 0; index2 < liquidData.m_ConsumeEffects.Count; ++index2) { if (liquidData.m_ConsumeEffects[index2].m_ConsumeEffect == ConsumeEffect.FoodPoisoning) { SetupEffect("Vomit_icon_H", Color.white, liquidData.m_ConsumeEffects[index2].m_ConsumeEffectLevel, "HUD_FoodPoisoning", ref index1, -1f); } else if (liquidData.m_ConsumeEffects[index2].m_ConsumeEffect == ConsumeEffect.Fever) { SetupEffect("Fever_icon_T", Color.white, liquidData.m_ConsumeEffects[index2].m_ConsumeEffectLevel, "Fever", ref index1, -1f); } else if (liquidData.m_ConsumeEffects[index2].m_ConsumeEffect == ConsumeEffect.ParasiteSickness) { SetupEffect("ParasiteSichness_icon_H", Color.white, liquidData.m_ConsumeEffects[index2].m_ConsumeEffectLevel, "Parasite Sickness", ref index1, -1f); } } if (info.IsBowl()) { if (liquidData.m_Proteins > 0.0) { SetupEffect("Watch_protein_icon", IconColors.GetColor(IconColors.Icon.Proteins), liquidData.m_Proteins, "HUD_Nutrition_Protein", ref index1, -1f); } if (liquidData.m_Fat > 0.0) { SetupEffect("Watch_fat_icon", IconColors.GetColor(IconColors.Icon.Fat), liquidData.m_Fat, "HUD_Nutrition_Fat", ref index1, -1f); } if (liquidData.m_Carbohydrates > 0.0) { SetupEffect("Watch_carbo_icon", IconColors.GetColor(IconColors.Icon.Carbo), liquidData.m_Carbohydrates, "HUD_Nutrition_Carbo", ref index1, -1f); } if (liquidData.m_Dehydration > 0.0) { SetupEffect("Watch_water_icon", IconColors.GetColor(IconColors.Icon.Hydration), -1f * liquidData.m_Dehydration, "HUD_Hydration", ref index1, -1f); } if (liquidData.m_SanityChange != 0) { SetupEffect("sanity_icon_H", Color.white, liquidData.m_SanityChange, "HUD_Sanity", ref index1, -1f); } } } m_UnknownEffect.SetActive(index1 == 0); } for (int index2 = index1; index2 < m_EffectsData.Count; ++index2) { m_EffectsData[index2].m_Parent.SetActive(false); } m_ConsumableEffects.gameObject.SetActive(true); } } } }