public static bool PatchFermenter(Fermenter fermenter, ref string hoverText) { switch (fermenter.GetStatus()) { case Fermenter.Status.Fermenting: string contentName = fermenter.GetContentName(); if (fermenter.m_exposed) // Why do we need to re-check? Ain't Fermenter.Status.Exposed enough? - Wack original code. { hoverText = Localization.instance.Localize(fermenter.m_name + " ( " + contentName + ", $piece_fermenter_exposed )"); return(false); } string time = Main.timeLeftStyleFermenter.Value == 1 ? $"{fermenter.GetFermentationTime() / fermenter.m_fermentationDuration:P0}" : Helpers.TimeString(fermenter.m_fermentationDuration - fermenter.GetFermentationTime()); hoverText = Localization.instance.Localize($"{contentName}\n$piece_fermenter_fermenting: {time}"); return(false); case Fermenter.Status.Ready: string contentName2 = fermenter.GetContentName(); hoverText = Localization.instance.Localize($"{fermenter.m_name}, $piece_fermenter_ready \n{contentName2}\n[<color=yellow><b>$KEY_Use</b></color>] $piece_fermenter_tap"); return(false); default: return(true); } }
private static void AddItemFromNearbyChests(Fermenter __instance) { if (!Configuration.Current.Fermenter.autoFuel || __instance.GetStatus() != Fermenter.Status.Empty || !__instance.m_nview.IsOwner()) { return; } Stopwatch delta = GameObjectAssistant.GetStopwatch(__instance.gameObject); if (!delta.IsRunning || delta.ElapsedMilliseconds > 1000) { List <Container> nearbyChests = InventoryAssistant.GetNearbyChests(__instance.gameObject, Configuration.Current.Fermenter.autoRange, !Configuration.Current.Fermenter.ignorePrivateAreaCheck); foreach (Container c in nearbyChests) { ItemDrop.ItemData item = __instance.FindCookableItem(c.GetInventory()); if (item != null) { if (InventoryAssistant.RemoveItemFromChest(c, item) == 0) { continue; } __instance.m_nview.InvokeRPC("AddItem", new object[] { item.m_dropPrefab.name }); ZLog.Log("Added " + item.m_shared.m_name + " to " + __instance.m_name); break; } } delta.Restart(); } }
private static bool Prefix(ref Fermenter __instance, ref string __result) { if (!Configuration.Current.Fermenter.IsEnabled || !Configuration.Current.Fermenter.showFermenterDuration) { return(true); } if (!PrivateArea.CheckAccess(__instance.transform.position, 0f, false)) { __result = Localization.instance.Localize(__instance.m_name + "\n$piece_noaccess"); return(false); } switch (__instance.GetStatus()) { case Fermenter.Status.Empty: __result = Localization.instance.Localize(__instance.m_name + " ( $piece_container_empty )\n[<color=yellow><b>$KEY_Use</b></color>] $piece_fermenter_add"); return(false); case Fermenter.Status.Fermenting: { string contentName = __instance.GetContentName(); if (__instance.m_exposed) { __result = Localization.instance.Localize(__instance.m_name + " ( " + contentName + ", $piece_fermenter_exposed )"); return(false); } double durationUntilDone = (double)__instance.m_fermentationDuration - __instance.GetFermentationTime(); string info = ""; int minutes = (int)durationUntilDone / 60; if (((int)durationUntilDone) >= 120) { info = minutes + " minutes"; } else { info = (int)durationUntilDone + " seconds"; } __result = Localization.instance.Localize(__instance.m_name + " ( " + contentName + ", $piece_fermenter_fermenting )") + " (" + info + ")"; return(false); } case Fermenter.Status.Ready: { string contentName2 = __instance.GetContentName(); __result = Localization.instance.Localize(__instance.m_name + " ( " + contentName2 + ", $piece_fermenter_ready )\n[<color=yellow><b>$KEY_Use</b></color>] $piece_fermenter_tap"); return(false); } } __result = __instance.m_name; return(false); }
public static string FermenterGetHoverText_Patch(string __result, Fermenter __instance) { if (__instance == null) { return(__result); } if (showPercentage.Value && __instance.GetStatus() == Fermenter.Status.Fermenting) { string replaceString = Localization.instance.Localize("$piece_fermenter_fermenting"); double percentage = __instance.GetFermentationTime() / __instance.m_fermentationDuration * 100; string colour = GetColour(percentage); string newString = $"<color={colour}>{decimal.Round((decimal)percentage, showPercentageDecimal.Value, MidpointRounding.AwayFromZero)}%</color>"; return(__result.Replace(replaceString, newString)); } return(__result); }