Exemplo n.º 1
0
        private static void OnTransfer()
        {
            //MelonLoader.MelonLogger.Log("Transfer");
            var liquidItem = WaterButtons.currentLiquidItemShowing;

            if (liquidItem == null)
            {
                return;
            }
            if (Water.IsEmpty(liquidItem))             // If the selected liquid container is empty.
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BWM_Empty"));
                GameAudioManager.PlayGUIError();
                return;
            }
            float spaceAvailable = Water.GetRemainingCapacityEmpty() + Water.GetRemainingCapacity(liquidItem.m_LiquidQuality) - liquidItem.m_LiquidCapacityLiters + liquidItem.m_LiquidLiters;

            if (Water.IsNone(spaceAvailable))
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BWM_NoCapacityAvailable"));
                GameAudioManager.PlayGUIError();
                return;
            }
            float maximumWaterTransfer = Mathf.Min(spaceAvailable, liquidItem.m_LiquidLiters);

            GameAudioManager.PlayGuiConfirm();
            float refillDuration = Mathf.Max(maximumWaterTransfer * 4, 1);

            InterfaceManager.m_Panel_GenericProgressBar.Launch(Localization.Get("GAMEPLAY_BWM_TransferingProgress"), refillDuration, 0f, 0f,
                                                               "Play_SndActionRefuelLantern", null, false, true, new System.Action <bool, bool, float>(OnTransferFinished));
        }
Exemplo n.º 2
0
        internal static void ClampBoilWaterAmount(Panel_FeedFire panel)
        {
            float totalCapacity = Water.GetRemainingCapacity(LiquidQuality.Potable) + Water.GetRemainingCapacityEmpty();

            labelCookingWarning.gameObject.SetActive(Cookware == null);

            FieldInfo boilWaterLitersField = AccessTools.Field(panel.GetType(), "m_BoilWaterLiters");
            float     value = Mathf.Clamp((float)boilWaterLitersField.GetValue(panel), 0, MaxLiters);

            boilWaterLitersField.SetValue(panel, value);

            panel.m_ButtonIncreaseWater.SetActive(panel.m_ButtonIncreaseWater.activeSelf && value < MaxLiters);
            panel.m_WaterAmountLabel.text = Utils.GetLiquidQuantityStringWithUnitsNoOunces(InterfaceManager.m_Panel_OptionsMenu.m_State.m_Units, value);
        }
Exemplo n.º 3
0
        private static void OnTransferFinished(bool success, bool playerCancel, float progress)
        {
            //MelonLoader.MelonLogger.Log("Transfer Finished");
            var   liquidItem           = WaterButtons.currentLiquidItemShowing;
            float liquidBefore         = liquidItem.m_LiquidLiters;
            float spaceAvailable       = Water.GetRemainingCapacityEmpty() + Water.GetRemainingCapacity(liquidItem.m_LiquidQuality) - liquidItem.m_LiquidCapacityLiters + liquidItem.m_LiquidLiters;
            float maximumWaterTransfer = Mathf.Min(spaceAvailable, liquidItem.m_LiquidLiters);
            float actualWaterTransfer  = progress * maximumWaterTransfer;

            liquidItem.m_LiquidLiters = liquidItem.m_LiquidCapacityLiters;
            Water.WATER.Add(actualWaterTransfer, liquidItem.m_LiquidQuality);
            liquidItem.m_LiquidLiters = liquidBefore - actualWaterTransfer;
            Water.AdjustWaterSupplyToWater();
        }
Exemplo n.º 4
0
        internal static void UpdateButtons(Panel_PickWater panel)
        {
            WaterSource waterSource = GetWaterSource(panel);

            if (!waterSource)
            {
                Debug.LogError("Could not find WaterSource");
                return;
            }

            float limit = Water.GetRemainingCapacity(waterSource.GetQuality()) + Water.GetRemainingCapacityEmpty();

            panel.m_ButtonIncrease.SetActive(panel.m_numLiters < limit);
        }
Exemplo n.º 5
0
        internal static void ClampAmount(Panel_PickWater panel)
        {
            WaterSource waterSource = GetWaterSource(panel);

            if (!waterSource)
            {
                Debug.LogError("Could not find WaterSupply to transfer to");
                return;
            }

            float limit = Water.GetRemainingCapacity(waterSource.GetQuality()) + Water.GetRemainingCapacityEmpty();

            panel.m_numLiters = Mathf.Min(panel.m_numLiters, limit);
        }
        public static void ClampAmount(Panel_PickWater panel)
        {
            WaterSupply waterSupply = AccessTools.Field(panel.GetType(), "m_WaterSupplyInventory").GetValue(panel) as WaterSupply;

            if (!waterSupply)
            {
                Debug.LogError("Could not find WaterSupply to transfer to");
                return;
            }

            float limit = Water.GetRemainingCapacity(waterSupply.m_WaterQuality) + Water.GetRemainingCapacityEmpty();

            panel.m_numLiters = Mathf.Clamp(panel.m_numLiters, 0, limit);
            panel.m_maxLiters = Mathf.Clamp(panel.m_maxLiters, 0, limit);

            AccessTools.Method(panel.GetType(), "Refresh").Invoke(panel, null);

            labelNoCapacityWarning.gameObject.SetActive(limit == 0);
        }
Exemplo n.º 7
0
        internal static void ClampMeltSnowAmount(Panel_FeedFire panel)
        {
            float totalCapacity = Water.GetRemainingCapacity(LiquidQuality.NonPotable) + Water.GetRemainingCapacityEmpty();

            float limit = MaxLiters;

            if (limit > 0 && totalCapacity == 0)
            {
                labelCookingWarning.text = Localization.Get("GAMEPLAY_NoCapacityAvailable");
                limit = 0;
            }
            labelCookingWarning.gameObject.SetActive(limit == 0);

            FieldInfo meltSnowLitersField = AccessTools.Field(panel.GetType(), "m_MeltSnowLiters");
            float     value = Mathf.Clamp((float)meltSnowLitersField.GetValue(panel), 0, limit);

            meltSnowLitersField.SetValue(panel, value);

            panel.m_ButtonIncreaseWater.SetActive(panel.m_ButtonIncreaseWater.activeSelf && value < limit);
            panel.m_WaterAmountLabel.text = Utils.GetLiquidQuantityStringWithUnitsNoOunces(InterfaceManager.m_Panel_OptionsMenu.m_State.m_Units, value);
        }
Exemplo n.º 8
0
        internal static void UpdateCapacityInfo(Panel_PickWater panel)
        {
            WaterSource waterSource = GetWaterSource(panel);

            if (!waterSource)
            {
                Debug.LogError("UpdateCapacityInfo: Could not find WaterSource");
                return;
            }

            labelCapacityInfo.text = GetWaterInfo(LiquidQuality.Potable) + "    " +
                                     GetWaterInfo(LiquidQuality.NonPotable) + "    " +
                                     Localization.Get("GAMEPLAY_Empty") + ": " + WaterUtils.FormatWaterAmount(0) + "/" + WaterUtils.FormatWaterAmount(Water.GetRemainingCapacityEmpty());

            labelNoCapacityWarning.gameObject.SetActive(Water.GetRemainingCapacityEmpty() == 0 && Water.GetRemainingCapacity(waterSource.GetQuality()) == 0);
        }