internal static float GetLitersToRefuel(GearItem gearItem) { float currentLiters = BetterFuelManagement.GetCurrentLiters(gearItem); float capacityLiters = BetterFuelManagement.GetCapacityLiters(gearItem); float totalCurrent = BetterFuelManagement.GetTotalCurrentLiters(gearItem); return(Mathf.Min(capacityLiters - currentLiters, totalCurrent)); }
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); }