internal static bool Prefix(CookingPotItem __instance)
        {
            if (__instance.GetCookingState() == CookingPotItem.CookingState.Cooking)
            {
                return(true);
            }

            float waterAmount = WaterUtils.GetWaterAmount(__instance);

            if (waterAmount <= 0)
            {
                return(true);
            }

            bool potable = __instance.GetCookingState() == CookingPotItem.CookingState.Ready;

            GearItem gearItem = __instance.GetComponent <GearItem>();

            WaterSupply waterSupply = gearItem.m_WaterSupply;

            if (waterSupply == null)
            {
                waterSupply            = gearItem.gameObject.AddComponent <WaterSupply>();
                gearItem.m_WaterSupply = waterSupply;
            }

            waterSupply.m_VolumeInLiters     = waterAmount;
            waterSupply.m_WaterQuality       = potable ? LiquidQuality.Potable : LiquidQuality.NonPotable;
            waterSupply.m_TimeToDrinkSeconds = GameManager.GetInventoryComponent().GetPotableWaterSupply().m_WaterSupply.m_TimeToDrinkSeconds;
            waterSupply.m_DrinkingAudio      = GameManager.GetInventoryComponent().GetPotableWaterSupply().m_WaterSupply.m_DrinkingAudio;

            GameManager.GetPlayerManagerComponent().UseInventoryItem(gearItem);

            return(false);
        }
 internal static void Prefix(CookingPotItem __instance, ref CookingPotItem.CookingState cookingState)
 {
     if (cookingState == CookingPotItem.CookingState.Cooking && !__instance.AttachedFireIsBurning() && WaterUtils.GetWaterAmount(__instance) > 0)
     {
         cookingState = __instance.GetCookingState();
     }
 }
 internal static void Prefix(CookingPotItem __instance, ref CookingPotItem.CookingState cookingState)         // circumvent the transformation to "ruined" after a long time period.
 {
     if (cookingState == CookingPotItem.CookingState.Cooking && !__instance.AttachedFireIsBurning() && WaterUtils.GetWaterAmount(__instance) > 0)
     {
         cookingState = __instance.GetCookingState();
     }
 }
Beispiel #4
0
        internal static bool Prefix(CookingPotItem __instance)
        {
            float waterAmount = __instance.m_LitersWaterBeingBoiled;

            if (Water.IsNone(waterAmount))             //only applies with water
            {
                return(true);
            }
            float waterVolumeToDrink = GameManager.GetPlayerManagerComponent().CalculateWaterVolumeToDrink(waterAmount);

            if (Water.IsNone(waterVolumeToDrink))             // Not thirsty.
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Youarenotthirsty"));
                GameAudioManager.PlayGUIError();
                return(false);
            }
            bool is_ready = __instance.GetCookingState() == CookingPotItem.CookingState.Ready;
            bool is_not_ready_and_no_fire = __instance.GetCookingState() == CookingPotItem.CookingState.Cooking && !__instance.AttachedFireIsBurning();

            if (is_ready || is_not_ready_and_no_fire)             //patch applies if ready or if still cooking but no fire.
            {
                DrinkFromPot.cookingPot = __instance;

                DrinkFromPot.OnDrink();

                if (Water.IsNone(__instance.m_LitersWaterBeingBoiled))
                {
                    return(true);
                }
                else
                {
                    GameManager.GetPlayerManagerComponent().ExitInspectGearMode(false);
                    return(false);
                }
            }
            return(true);
        }
        internal static void Postfix(CookingPotItem __instance)
        {
            if (__instance.AttachedFireIsBurning())
            {
                return;
            }

            if ((__instance.m_ParticlesWaterBoiling.activeInHierarchy || __instance.m_ParticlesWaterReady.activeInHierarchy) && WaterUtils.IsCooledDown(__instance))
            {
                Utils.SetActive(__instance.m_ParticlesWaterReady, false);
                Utils.SetActive(__instance.m_ParticlesWaterBoiling, false);

                if (__instance.GetCookingState() == CookingPotItem.CookingState.Ready)
                {
                    ModUtils.GetOrCreateComponent <OverrideCookingState>(__instance).ForceReady = true;
                    WaterUtils.SetElapsedCookingTimeForWater(__instance, WaterUtils.GetWaterAmount(__instance));
                }
            }
        }
Beispiel #6
0
        internal static void OnDrink()
        {
            float waterAmount = cookingPot.m_LitersWaterBeingBoiled;

            waterVolumeToDrink = GameManager.GetPlayerManagerComponent().CalculateWaterVolumeToDrink(waterAmount);
            gearItem           = cookingPot.GetComponent <GearItem>();
            waterSupply        = gearItem.m_WaterSupply;
            if (waterSupply == null)
            {
                waterSupply            = gearItem.gameObject.AddComponent <WaterSupply>();
                gearItem.m_WaterSupply = waterSupply;
            }
            waterSupply.m_VolumeInLiters = waterAmount;
            bool potable = cookingPot.GetCookingState() == CookingPotItem.CookingState.Ready;

            waterSupply.m_WaterQuality       = potable ? LiquidQuality.Potable : LiquidQuality.NonPotable;
            waterSupply.m_TimeToDrinkSeconds = GameManager.GetInventoryComponent().GetPotableWaterSupply().m_WaterSupply.m_TimeToDrinkSeconds;
            waterSupply.m_DrinkingAudio      = GameManager.GetInventoryComponent().GetPotableWaterSupply().m_WaterSupply.m_DrinkingAudio;

            GameManager.GetThirstComponent().AddThirstOverTime(waterVolumeToDrink, waterSupply.m_TimeToDrinkSeconds);
            InterfaceManager.m_Panel_GenericProgressBar.Launch(Localization.Get("GAMEPLAY_DrinkingProgress"), waterSupply.m_TimeToDrinkSeconds, 0f, 0f, null, waterSupply.m_DrinkingAudio, true, false, new System.Action <bool, bool, float>(OnDrinkComplete));
            GameManager.GetPlayerVoiceComponent().BlockNonCriticalVoiceForDuration(waterSupply.m_TimeToDrinkSeconds + 2f);
        }
Beispiel #7
0
        void Update()
        {
            if (fire.GetFireState() == FireState.Off)
            {
                "AutoCook.Update: fire isn't lit, aborting".logDbg();
                Destroy(this);
                return;
            }

            CookingPotItem pot = null;

            if (gearPlacePoint.m_PlacedGear)
            {
                if (!gearPlacePoint.m_PlacedGear.name.Contains("CookingPot"))                 // GEAR_CookingPot or GEAR_CookingPotDummy
                {
                    "AutoCook.Update: gear in place point isn't a cooking pot, aborting".logDbg();
                    Destroy(this);
                    return;
                }

                pot = gearPlacePoint.m_PlacedGear.GetComponent <CookingPotItem>();

                if (pot.m_LitersSnowBeingMelted > 0f || pot.m_LitersWaterBeingBoiled > 0f)                 // if we started with water in pot
                {
                    if (pot.m_CookingState == CookingPotItem.CookingState.Cooking || pot.m_LitersWaterBeingBoiled == 0f)
                    {
                        return;
                    }
                    "AutoCook.Update: picking up boiled water".logDbg();
                    pot.PickUpCookedItem();
                }

                if (pot.m_GearItemBeingCooked)
                {
                    if (pot.GetCookingState() == CookingPotItem.CookingState.Cooking)
                    {
                        return;
                    }
                    $"AutoCook.Update: picking up cooked item {pot.m_GearItemBeingCooked.name}".logDbg();
                    pot.PickUpCookedItem();
                }
            }

            var item = getRawFood(!cookMeatToo);

            if (!item)
            {
                return;
            }
            $"AutoCook.Update: start cooking {item.name}".logDbg();
            item.m_Cookable.m_DoNotCookWhenDropped = true;

            if (pot)
            {
                pot.StartCooking(item);
            }
            else
            {
                gearPlacePoint.DropAndPlaceItem(item);
            }

            item.m_Cookable.m_DoNotCookWhenDropped = false;
        }