Esempio n. 1
0
        internal static void Refuel(GearItem gearItem)
        {
            Panel_Inventory_Examine panel = InterfaceManager.m_Panel_Inventory_Examine;

            float currentLiters  = GetCurrentLiters(panel.m_GearItem);
            float capacityLiters = GetCapacityLiters(panel.m_GearItem);

            if (Mathf.Approximately(currentLiters, capacityLiters))
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_AlreadyFilled"), false);
                return;
            }

            float totalCurrent = GetTotalCurrentLiters(panel.m_GearItem);

            if (totalCurrent < Implementation.MIN_LITERS)
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_NoKeroseneavailable"), false);
                return;
            }

            GameAudioManager.PlayGuiConfirm();
            InterfaceManager.m_Panel_GenericProgressBar.Launch(
                Localization.Get("GAMEPLAY_RefuelingProgress"),
                REFUEL_TIME,
                0,
                0,
                REFUEL_AUDIO,
                null,
                false,
                true,
                new OnExitDelegate(OnRefuelFinished));
        }
Esempio n. 2
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));
        }
Esempio n. 3
0
        static bool Prefix(Panel_FireStart __instance, Campfire ___m_CampFireInstance, FireStarterItem ___m_KeroseneAccelerant, FireManager ___m_FireManager, bool skipResearchItemCheck = false)
        {
            var traverseInstance = Traverse.Create(__instance);

            traverseInstance.Field("m_FireManager").SetValue(GameManager.GetFireManagerComponent());

            var selectedFireStarter = traverseInstance.Method("GetSelectedFireStarter").GetValue <FireStarterItem>();
            var selectedTinder      = traverseInstance.Method("GetSelectedTinder").GetValue <FuelSourceItem>();
            var selectedFuelSource  = traverseInstance.Method("GetSelectedFuelSource").GetValue <FuelSourceItem>();
            var selectedAccelerant  = traverseInstance.Method("GetSelectedAccelerant").GetValue <FireStarterItem>();

            if (___m_CampFireInstance && ___m_CampFireInstance.TooWindyToStart())
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Itstoowindytostartafirethere"), false);
                return(false);
            }
            if (selectedFireStarter == null || (GameManager.GetSkillFireStarting().TinderRequired() && selectedTinder == null) || selectedFuelSource == null)
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Insufficientmaterialstocreatefire"), false);
                return(false);
            }

            if (selectedFireStarter.m_RequiresSunLight && !traverseInstance.Method("HasDirectSunlight").GetValue <bool>())
            {
                GameAudioManager.PlayGUIError();
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Magnifyinglensrequiresdirectsunlight"), false);
                return(false);
            }
            if (!skipResearchItemCheck)
            {
                ResearchItem component = selectedFuelSource.GetComponent <ResearchItem>();
                if (component != null && !component.IsResearchComplete())
                {
                    Panel_Confirmation.CallbackDelegate forceBurnResearchItem = () => traverseInstance.Method("ForceBurnResearchItem").GetValue();
                    InterfaceManager.m_Panel_Confirmation.ShowBurnResearchNotification(forceBurnResearchItem);
                    return(false);
                }
            }
            if (selectedAccelerant != null && selectedAccelerant == ___m_KeroseneAccelerant)
            {
                GameManager.GetPlayerManagerComponent().DeductLiquidFromInventory(GameManager.GetFireManagerComponent().m_KeroseneLitersAccelerant, GearLiquidTypeEnum.Kerosene);
            }
            float percentChanceSuccess = TinderHelper.CalculateFireStartSuccess(selectedFireStarter, selectedTinder, selectedFuelSource, selectedAccelerant);

            ___m_FireManager.PlayerStartFire(___m_CampFireInstance, selectedFireStarter, selectedTinder, selectedFuelSource, selectedAccelerant, percentChanceSuccess);
            __instance.Enable(false);
            GameAudioManager.PlayGuiConfirm();
            return(false);
        }
Esempio n. 4
0
            private static bool Prefix(Panel_OptionsMenu __instance)
            {
                ModSettingsGUI gui = GetModSettingsGUI(__instance);

                if (!gui.gameObject.activeInHierarchy)
                {
                    return(true);
                }

                GameAudioManager.PlayGuiConfirm();
                gui.CallOnConfirm();

                return(false);
            }
Esempio n. 5
0
        private static void OnFill()
        {
            //MelonLoader.MelonLogger.Log("Fill");
            var liquidItem = WaterButtons.currentLiquidItemShowing;

            if (liquidItem == null)
            {
                return;
            }
            if (liquidItem.m_LiquidLiters >= liquidItem.m_LiquidCapacityLiters)            //if the container is already full
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BWM_AlreadyFull"));
                GameAudioManager.PlayGUIError();
                return;
            }

            //If an empty container held nonpotable water before, we want to fill it with potable water.
            if (Water.IsEmpty(liquidItem) && liquidItem.m_LiquidQuality == LiquidQuality.NonPotable)
            {
                liquidItem.m_LiquidQuality = LiquidQuality.Potable;
            }

            //If the current water supply is empty.
            if (Water.IsNone(Water.GetActual(liquidItem.m_LiquidQuality)))
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BWM_Empty"));
                GameAudioManager.PlayGUIError();
                return;
            }
            float maxWaterInBottle   = Mathf.Min(Water.GetActual(liquidItem.m_LiquidQuality), liquidItem.m_LiquidCapacityLiters);
            float maximumWaterRefill = Mathf.Max(maxWaterInBottle - liquidItem.m_LiquidLiters, 0);

            if (Water.IsNone(maximumWaterRefill))             // If nothing gets transferred.
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_None"));
                GameAudioManager.PlayGUIError();
                return;
            }
            GameAudioManager.PlayGuiConfirm();
            float refuelDuration = Mathf.Max(maximumWaterRefill * 4, 1);

            InterfaceManager.m_Panel_GenericProgressBar.Launch(Localization.Get("GAMEPLAY_BWM_FillingProgress"), refuelDuration, 0f, 0f,
                                                               "Play_SndActionRefuelLantern", null, false, true, new System.Action <bool, bool, float>(OnFillFinished));
        }
Esempio n. 6
0
 internal static void Postfix(Panel_PickWater __instance)
 {
     if (InputManager.GetEquipPressed(__instance))
     {
         var waterSource = __instance.m_WaterSource;
         if (!waterSource)
         {
             Implementation.LogError("UpdateCapacityInfo: Could not find WaterSource");
             return;
         }
         if (Water.IsNone(waterSource.m_CurrentLiters))
         {
             HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BWM_Empty"));
             GameAudioManager.PlayGUIError();
             return;
         }
         float waterVolumeToDrink = GameManager.GetPlayerManagerComponent().CalculateWaterVolumeToDrink(waterSource.m_CurrentLiters);
         if (Water.IsNone(waterVolumeToDrink))
         {
             GameAudioManager.PlayGUIError();
             HUDMessage.AddMessage(Localization.Get("GAMEPLAY_Youarenotthirsty"));
             return;
         }
         GameAudioManager.PlayGuiConfirm();
         WaterSupply waterSupply;
         if (waterSource.GetQuality() == LiquidQuality.Potable)
         {
             waterSupply = __instance.InstantiateWaterSupply(__instance.m_WaterSupply_Potable).m_WaterSupply;
         }
         else
         {
             waterSupply = __instance.InstantiateWaterSupply(__instance.m_WaterSupply_NonPotable).m_WaterSupply;
         }
         waterSupply.m_VolumeInLiters = waterSource.m_CurrentLiters;
         waterSource.RemoveLiters(waterVolumeToDrink);
         GameManager.GetPlayerManagerComponent().DrinkFromWaterSupply(waterSupply, waterSupply.m_VolumeInLiters);
         UnityEngine.Object.Destroy(waterSupply.gameObject);
         __instance.ExitInterface();
     }
 }
Esempio n. 7
0
        private static void OnDump()
        {
            //MelonLoader.MelonLogger.Log("Dump");
            LiquidItem liquidItem = WaterButtons.currentLiquidItemShowing;

            if (liquidItem == null)
            {
                return;
            }
            if (liquidItem.m_LiquidLiters <= 0.001f)
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_BWM_Empty"));
                GameAudioManager.PlayGUIError();
                return;
            }

            GameAudioManager.PlayGuiConfirm();
            float lostLitersDuration = Mathf.Max(liquidItem.m_LiquidLiters * 4, 1);

            InterfaceManager.m_Panel_GenericProgressBar.Launch(Localization.Get("GAMEPLAY_BWM_DumpingProgress"), lostLitersDuration, 0f, 0f,
                                                               "Play_SndActionRefuelLantern", null, false, true, new System.Action <bool, bool, float>(OnDumpFinished));
        }
Esempio n. 8
0
        internal static void Drain(GearItem gearItem)
        {
            Panel_Inventory_Examine panel = InterfaceManager.m_Panel_Inventory_Examine;

            float currentLiters = GetCurrentLiters(panel.m_GearItem);

            if (currentLiters < MIN_LITERS)
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_AlreadyEmpty"));
                GameAudioManager.PlayGUIError();
                return;
            }

            float totalCapacity = GetTotalCapacityLiters(panel.m_GearItem);
            float totalCurrent  = GetTotalCurrentLiters(panel.m_GearItem);

            if (Mathf.Approximately(totalCapacity, totalCurrent))
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_NoFuelCapacityAvailable"));
                GameAudioManager.PlayGUIError();
                return;
            }

            GameAudioManager.PlayGuiConfirm();
            InterfaceManager.m_Panel_GenericProgressBar.Launch(
                Localization.Get("GAMEPLAY_DrainingProgress"),
                REFUEL_TIME,
                0,
                0,
                REFUEL_AUDIO,
                null,
                false,
                true,
                new OnExitDelegate(OnDrainFinished));

            // HACK: somehow this is needed to revert the button text to "Refuel", which will be active when draining finishes
            BetterFuelManagementUtils.SetButtonLocalizationKey(panel.m_RefuelPanel.GetComponentInChildren <UIButton>(), "GAMEPLAY_Refuel");
        }