internal static bool Prefix(Panel_Inventory_Examine __instance)
            {
                float hoursResearchRemaining = GetHoursResearchRemaining(__instance);
                float readingInterval        = Settings.GetReadingIntervalHours();
                int   maximumIntervals       = Mathf.CeilToInt(hoursResearchRemaining / readingInterval);

                int intervalsToRead = Mathf.Clamp(__instance.m_HoursToRead, 1, maximumIntervals);

                __instance.m_HoursToRead = intervalsToRead;

                float hoursToRead = Math.Min(intervalsToRead * readingInterval, hoursResearchRemaining);

                __instance.m_TimeToReadLabel.text = hoursToRead.ToString("0.##");
                __instance.m_ReadHoursDecrease.gameObject.SetActive(intervalsToRead > 1);
                __instance.m_ReadHoursIncrease.gameObject.SetActive(intervalsToRead < maximumIntervals);

                if (Utils.IsGamepadActive())
                {
                    ButtonLegend buttonLegend = __instance.m_ButtonLegendContainer.m_ButtonLegend;
                    UISprite     decrease     = __instance.m_GamepadReadHoursSpriteDecrease;
                    UISprite     increase     = __instance.m_GamepadReadHoursSpriteIncrease;
                    // The second argument is declared as ref, but is never assigned to in ConfigureButtonIconSpriteName.
                    buttonLegend.ConfigureButtonIconSpriteName("Inventory_FilterLeft", ref decrease);
                    buttonLegend.ConfigureButtonIconSpriteName("Inventory_FilterRight", ref increase);
                }

                return(false);                // Never run the original
            }
示例#2
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));
        }
 public static void Postfix(Panel_Inventory_Examine __instance)
 {
     if (Implementation.IsFuelItem(__instance.m_GearItem) && BetterFuelManagementUtils.IsSelected(__instance.m_Button_Unload))
     {
         __instance.m_ButtonLegendContainer.UpdateButton("Continue", "GAMEPLAY_Drain", true, 1, true);
     }
 }
示例#4
0
        public static bool Prefix(Panel_Inventory_Examine __instance)
        {
            if (!BetterFuelManagement.IsFuelItem(__instance.m_GearItem))
            {
                return(true);
            }

            BetterFuelManagement.Drain(__instance.m_GearItem);
            return(false);
        }
        public static bool Prefix(Panel_Inventory_Examine __instance)
        {
            if (!Implementation.IsFuelItem(__instance.m_GearItem))
            {
                return(true);
            }

            Implementation.Drain(__instance.m_GearItem);
            return(false);
        }
        public static void Prefix(Panel_Inventory_Examine __instance, bool selected)
        {
            if (!Implementation.IsFuelItem(__instance.m_GearItem))
            {
                return;
            }

            if (selected)
            {
                BetterFuelManagementUtils.SetButtonLocalizationKey(__instance.m_RefuelPanel.GetComponentInChildren <UIButton>(), "GAMEPLAY_Refuel");
            }
        }
示例#7
0
        private static void OnRefuelFinished(bool success, bool playerCancel, float progress)
        {
            Panel_Inventory_Examine panel = InterfaceManager.m_Panel_Inventory_Examine;

            if (Implementation.IsFuelItem(panel.m_GearItem))
            {
                float litersToTransfer = Implementation.GetLitersToRefuel(panel.m_GearItem) * progress;
                Implementation.AddTotalCurrentLiters(-litersToTransfer, panel.m_GearItem);
                Implementation.AddLiters(panel.m_GearItem, litersToTransfer);
            }

            panel.RefreshMainWindow();
        }
            internal static void Postfix(Panel_Inventory_Examine __instance)
            {
                if (!__instance.m_GearItem?.m_ResearchItem)
                {
                    return;
                }

                string text = Localization.Get("GAMEPLAY_HoursResearched");

                text = text.Replace("{val1}", __instance.m_GearItem.m_ResearchItem.GetElapsedHours().ToString("0.##"));
                text = text.Replace("{val2}", __instance.m_GearItem.m_ResearchItem.m_TimeRequirementHours.ToString());
                __instance.m_TimeToReadRemainingLabel.text = text;
            }
示例#9
0
        private static void OnDrainFinished(bool success, bool playerCancel, float progress)
        {
            Panel_Inventory_Examine panel = InterfaceManager.m_Panel_Inventory_Examine;

            if (BetterFuelManagement.IsFuelItem(panel.m_GearItem))
            {
                float litersToDrain = BetterFuelManagement.GetLitersToDrain(panel.m_GearItem) * progress;
                BetterFuelManagement.AddTotalCurrentLiters(litersToDrain, panel.m_GearItem);
                BetterFuelManagement.AddLiters(panel.m_GearItem, -litersToDrain);
            }

            panel.RefreshMainWindow();
        }
            internal static void Prefix(Panel_Inventory_Examine __instance, ref int minutes)
            {
                if (!__instance.m_GearItem?.m_ResearchItem)
                {
                    return;
                }

                float hoursResearchRemaining = GetHoursResearchRemaining(__instance);
                float minutesToRead          = Math.Min(minutes * Settings.GetReadingIntervalHours(), hoursResearchRemaining * 60f);
                float hoursToRead            = minutesToRead / 60f;

                __instance.m_ReadTimeSeconds        = 1 + 3 * Mathf.Log(1 + hoursToRead);
                __instance.m_ProgressBarTimeSeconds = __instance.m_ReadTimeSeconds;
                minutes = Mathf.CeilToInt(minutesToRead);
            }
        public static bool Prefix(Panel_Inventory_Examine __instance, bool selected)
        {
            if (!Implementation.IsFuelItem(__instance.m_GearItem))
            {
                return(true);
            }

            if (selected)
            {
                BetterFuelManagementUtils.SetButtonLocalizationKey(__instance.m_RefuelPanel.GetComponentInChildren <UIButton>(), "GAMEPLAY_Drain");
            }

            __instance.m_RefuelPanel.SetActive(selected || BetterFuelManagementUtils.IsSelected(__instance.m_Button_Refuel));

            return(false);
        }
            internal static bool Prefix(Panel_Inventory_Examine __instance)
            {
                float hoursResearchRemaining = GetHoursResearchRemaining(__instance);
                int   maximumIntervals       = Mathf.CeilToInt(hoursResearchRemaining / Settings.GetReadingIntervalHours());
                int   intervalsToRead        = __instance.m_HoursToRead;

                if (intervalsToRead >= maximumIntervals)
                {
                    GameAudioManager.PlayGUIError();
                }
                else
                {
                    ++__instance.m_HoursToRead;
                    GameAudioManager.PlayGUIScroll();
                    __instance.RefreshHoursToRead();
                }
                return(false);                // Never run the original
            }
        public static bool Prefix(Panel_Inventory_Examine __instance)
        {
            if (!Implementation.IsFuelItem(__instance.m_GearItem))
            {
                return(true);
            }

            if (BetterFuelManagementUtils.IsSelected(__instance.m_Button_Unload))
            {
                Implementation.Drain(__instance.m_GearItem);
            }
            else
            {
                Implementation.Refuel(__instance.m_GearItem);
            }

            return(false);
        }
        public static bool Prefix(Panel_Inventory_Examine __instance)
        {
            if (!Implementation.IsFuelItem(__instance.m_GearItem))
            {
                return(true);
            }

            __instance.m_RefuelPanel.SetActive(false);
            __instance.m_Button_Refuel.gameObject.SetActive(true);

            float currentLiters  = Implementation.GetCurrentLiters(__instance.m_GearItem);
            float capacityLiters = Implementation.GetCapacityLiters(__instance.m_GearItem);

            var  fuelAvailable = Implementation.GetTotalCurrentLiters(__instance.m_GearItem) > Implementation.MIN_LITERS;
            bool canRefuel     = !Mathf.Approximately(currentLiters, capacityLiters) && fuelAvailable;

            __instance.m_Refuel_X.gameObject.SetActive(!canRefuel);
            __instance.m_Button_Refuel.gameObject.GetComponent <Panel_Inventory_Examine_MenuItem>().SetDisabled(!canRefuel);

            __instance.m_MouseRefuelButton.SetActive(canRefuel);
            __instance.m_RequiresFuelMessage.SetActive(false);

            __instance.m_LanternFuelAmountLabel.text =
                Utils.GetLiquidQuantityString(InterfaceManager.m_Panel_OptionsMenu.m_State.m_Units, Implementation.GetCurrentLiters(__instance.m_GearItem)) +
                "/" +
                Utils.GetLiquidQuantityStringWithUnitsNoOunces(InterfaceManager.m_Panel_OptionsMenu.m_State.m_Units, Implementation.GetCapacityLiters(__instance.m_GearItem));

            float totalCurrent  = Implementation.GetTotalCurrentLiters(__instance.m_GearItem);
            float totalCapacity = Implementation.GetTotalCapacityLiters(__instance.m_GearItem);

            __instance.m_FuelSupplyAmountLabel.text =
                Utils.GetLiquidQuantityString(InterfaceManager.m_Panel_OptionsMenu.m_State.m_Units, totalCurrent) +
                "/" +
                Utils.GetLiquidQuantityStringWithUnitsNoOunces(InterfaceManager.m_Panel_OptionsMenu.m_State.m_Units, totalCapacity);

            Traverse method = Traverse.Create(__instance).Method("UpdateCondition");

            if (method.MethodExists())
            {
                method.GetValue();
            }

            return(false);
        }
        public static void Postfix(Panel_Inventory_Examine __instance)
        {
            if (!Implementation.IsFuelItem(__instance.m_GearItem))
            {
                return;
            }

            Vector3 position = BetterFuelManagementUtils.GetBottomPosition(
                __instance.m_Button_Harvest,
                __instance.m_Button_Refuel,
                __instance.m_Button_Repair);

            position.y += __instance.m_ButtonSpacing;
            __instance.m_Button_Unload.transform.localPosition = position;

            __instance.m_Button_Unload.gameObject.SetActive(true);

            float litersToDrain = Implementation.GetLitersToDrain(__instance.m_GearItem);

            __instance.m_Button_Unload.GetComponent <Panel_Inventory_Examine_MenuItem>().SetDisabled(litersToDrain < Implementation.MIN_LITERS);
        }
        public static void Prefix(Panel_Inventory_Examine __instance, bool enable)
        {
            if (!enable)
            {
                return;
            }

            if (Implementation.IsFuelItem(__instance.m_GearItem))
            {
                // repurpose the "Unload" button to "Drain"
                BetterFuelManagementUtils.SetButtonLocalizationKey(__instance.m_Button_Unload, "GAMEPLAY_Drain");
                BetterFuelManagementUtils.SetButtonSprite(__instance.m_Button_Unload, "ico_lightSource_lantern");

                Transform lanternTexture = __instance.m_RefuelPanel.transform.Find("FuelDisplay/Lantern_Texture");
                BetterFuelManagementUtils.SetTexture(lanternTexture, Utils.GetInventoryIconTexture(__instance.m_GearItem));
            }
            else
            {
                BetterFuelManagementUtils.SetButtonLocalizationKey(__instance.m_Button_Unload, "GAMEPLAY_Unload");
                BetterFuelManagementUtils.SetButtonSprite(__instance.m_Button_Unload, "ico_ammo_rifle");
            }
        }
示例#17
0
        private static bool Prefix(Panel_Inventory_Examine __instance)
        {
            if (GameManager.GetWeatherComponent().IsTooDarkForAction(ActionsToBlock.Harvest))
            {
                HUDMessage.AddMessage(Localization.Get("GAMEPLAY_RequiresLightToHarvest"), false);
                GameAudioManager.PlayGUIError();
                return(false);
            }
            Harvest component = __instance.m_GearItem.GetComponent <Harvest>();

            Debug.Log("gear:" + component.m_YieldGear[0].name);
            if (component.m_YieldGear[0].name == "GEAR_Stick")
            {
                __instance.m_HarvestTimeSeconds /= 6.0f;
            }
            __instance.StartHarvest(component.m_DurationMinutes, component.m_Audio);
            if (component.m_YieldGear[0].name == "GEAR_Stick")
            {
                __instance.m_HarvestTimeSeconds *= 6.0f;
            }
            return(false);
        }
示例#18
0
        public static bool Prefix(Panel_Inventory_Examine __instance)
        {
            if (!BetterFuelManagement.IsFuelItem(__instance.m_GearItem))
            {
                return(true);
            }

            __instance.m_RefuelPanel.SetActive(false);
            __instance.m_Button_Refuel.gameObject.SetActive(true);

            float currentLiters  = BetterFuelManagement.GetCurrentLiters(__instance.m_GearItem);
            float capacityLiters = BetterFuelManagement.GetCapacityLiters(__instance.m_GearItem);

            var  fuelAvailable = BetterFuelManagement.GetTotalCurrentLiters(__instance.m_GearItem) > BetterFuelManagement.MIN_LITERS;
            bool canRefuel     = !Mathf.Approximately(currentLiters, capacityLiters) && fuelAvailable;

            __instance.m_Refuel_X.gameObject.SetActive(!canRefuel);
            __instance.m_Button_Refuel.gameObject.GetComponent <Panel_Inventory_Examine_MenuItem>().SetDisabled(!canRefuel);

            __instance.m_MouseRefuelButton.SetActive(canRefuel);
            __instance.m_RequiresFuelMessage.SetActive(false);

            __instance.m_LanternFuelAmountLabel.text =
                Utils.GetLiquidQuantityString(InterfaceManager.m_Panel_OptionsMenu.m_State.m_Units, BetterFuelManagement.GetCurrentLiters(__instance.m_GearItem)) +
                "/" +
                Utils.GetLiquidQuantityStringWithUnitsNoOunces(InterfaceManager.m_Panel_OptionsMenu.m_State.m_Units, BetterFuelManagement.GetCapacityLiters(__instance.m_GearItem));

            float totalCurrent  = BetterFuelManagement.GetTotalCurrentLiters(__instance.m_GearItem);
            float totalCapacity = BetterFuelManagement.GetTotalCapacityLiters(__instance.m_GearItem);

            __instance.m_FuelSupplyAmountLabel.text =
                Utils.GetLiquidQuantityString(InterfaceManager.m_Panel_OptionsMenu.m_State.m_Units, totalCurrent) +
                "/" +
                Utils.GetLiquidQuantityStringWithUnitsNoOunces(InterfaceManager.m_Panel_OptionsMenu.m_State.m_Units, totalCapacity);

            AccessTools.Method(__instance.GetType(), "UpdateCondition")?.Invoke(__instance, null);

            return(false);
        }
        internal static void Postfix(Panel_Inventory_Examine __instance)
        {
            if (__instance.m_HarvestYields is null || __instance.m_HarvestYields.Length > 2)
            {
                return;
            }

            HarvestRepairMaterial[] array = new HarvestRepairMaterial[3];
            for (int i = 0; i < array.Length; i++)
            {
                array[i] = Object.Instantiate(__instance.m_HarvestYields[0].gameObject, __instance.m_HarvestYields[0].transform.parent).GetComponent <HarvestRepairMaterial>();
                array[i].Hide();
            }

            for (int i = 0; i < __instance.m_HarvestYields.Length; i++)
            {
                Object.Destroy(__instance.m_HarvestYields[i].gameObject);
            }

            __instance.m_HarvestYields        = array;
            __instance.m_HarvestYieldSpacing *= 0.8f;
        }
            internal static void Prefix(Panel_Inventory_Examine __instance, ref float normalizedProgress)
            {
                if (!__instance.m_GearItem?.m_ResearchItem)
                {
                    return;
                }

                int   hoursToRead   = __instance.m_HoursToRead;
                float intervalsRead = normalizedProgress * hoursToRead;

                if (!Settings.GetAllowInterruptions())
                {
                    intervalsRead = Mathf.Floor(intervalsRead);
                }

                float hoursRead = intervalsRead * Settings.GetReadingIntervalHours();

                __instance.m_GearItem.m_ResearchItem.Read(hoursRead);

                // Do the rest of the method as if we read for 0 minutes
                normalizedProgress = 0;
            }
示例#21
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");
        }
示例#22
0
 private static void Prefix(Panel_Inventory_Examine __instance)
 {
     Implementation.SplitStack(__instance.m_GearItem);
 }
        private static float GetHoursResearchRemaining(Panel_Inventory_Examine panel)
        {
            ResearchItem researchItem = panel.m_GearItem.m_ResearchItem;

            return(researchItem.m_TimeRequirementHours - researchItem.GetElapsedHours());
        }
示例#24
0
 private static void Postfix(Panel_Inventory_Examine __instance)
 {
     Implementation.AddToExistingStack(__instance.m_GearItem);
 }
 public static void Prefix(Panel_Inventory_Examine __instance)
 {
     Debug.LogFormat("Panel_Inventory_Examine::OnRefuel");
     lastAction = FasterGenericAction.REFUEL;
 }
 public static void Prefix(Panel_Inventory_Examine __instance)
 {
     Debug.LogFormat("Panel_Inventory_Examine::StartSharpen");
     __instance.m_SharpenTimeSeconds = actionTime;
 }