public void OnTransferButton() { if (thisKettle.readyToTransfer == true) { GameObject[] fermenters = GameObject.FindGameObjectsWithTag("fermenter"); List <GameObject> availableFermenters = new List <GameObject>(); foreach (GameObject fermenter in availableFermenters) { Fermenter fermenterComponent = fermenter.GetComponent <Fermenter>(); Debug.Log(fermenterComponent.empty); if (fermenterComponent.empty == true) { availableFermenters.Add(fermenter); } } if (availableFermenters.Count < 1) { //If there are no available fermenters Debug.Log("There are no empty fermenters available"); } else { SpawnFermenterSelectMenu(availableFermenters); } } else { Debug.Log("This wort is not ready for transfer yet!"); } }
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); } }
public async Task <IActionResult> Edit(int id, [Bind("FermenterID,Name,TargetTemp,BeerID,Address")] Fermenter fermenter) { if (id != fermenter.FermenterID) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(fermenter); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!FermenterExists(fermenter.FermenterID)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["Address"] = new SelectList(_context.Sensors, "Address", "Address", fermenter.Address); ViewData["BeerID"] = new SelectList(_context.BrewHistory, "BeerID", "BeerID", fermenter.BeerID); return(View(fermenter)); }
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(); } }
public IActionResult Temperature() { Fermenter ferm1 = new Fermenter { Name = "test_ferm1", TargetTemp = 65 }; Fermenter ferm2 = new Fermenter { Name = "test_ferm2", TargetTemp = 65 }; Fermenter ferm3 = new Fermenter { Name = "test_ferm3", TargetTemp = 65 }; List <Fermenter> ferms = new List <Fermenter> { ferm1, ferm2, ferm3 }; ViewData["Message"] = ferms; return(View()); }
public void OnDropDownMenuChange() { Dropdown dropDownmenu = GameObject.Find("FermenterSelectDropdown").GetComponent <Dropdown>(); int fermIndex = dropDownmenu.value; fermenter = availableFermenters[fermIndex].GetComponent <Fermenter>(); UpdateInfoText(); }
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); }
private static bool DropItemToNearbyChest(Fermenter __instance, ref Fermenter.ItemConversion itemConversion) { List <Container> nearbyChests = InventoryAssistant.GetNearbyChests(__instance.gameObject, Configuration.Current.Fermenter.autoRange, !Configuration.Current.Fermenter.ignorePrivateAreaCheck); int spawnedInChests = 0; for (int i = 0; i < itemConversion.m_producedItems; i++) { GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(itemConversion.m_to.gameObject.name); ZNetView.m_forceDisableInit = true; GameObject itemObject = Object.Instantiate <GameObject>(itemPrefab); ZNetView.m_forceDisableInit = false; ItemDrop comp = itemObject.GetComponent <ItemDrop>(); bool result = spawnNearbyChest(comp, true); Object.Destroy(itemObject); if (!result) { itemConversion.m_producedItems -= spawnedInChests; return(false); } spawnedInChests++; } return(true); bool spawnNearbyChest(ItemDrop item, bool mustHaveItem) { foreach (Container chest in nearbyChests) { Inventory cInventory = chest.GetInventory(); if (mustHaveItem && !cInventory.HaveItem(item.m_itemData.m_shared.m_name)) { continue; } if (!cInventory.AddItem(item.m_itemData)) { //Chest full, move to the next continue; } InventoryAssistant.ConveyContainerToNetwork(chest); return(true); } if (mustHaveItem) { return(spawnNearbyChest(item, false)); } return(false); } }
private static void InvokeRPCTap(Fermenter __instance) { if (!Configuration.Current.Fermenter.autoDeposit) { return; } __instance.m_nview.InvokeRPC("Tap", new object[] { }); }
public static void FermenterAwake_Patch(Fermenter __instance) { if (customFermentTime.Value) { __instance.m_fermentationDuration = newFermentTime.Value * 60; } if (noCover.Value) { __instance.m_updateCoverTimer = -100f; } }
protected override IEnumerable <Toil> MakeNewToils() { CompUniversalFermenter comp = Fermenter.TryGetComp <CompUniversalFermenter>(); // Verify fermenter and ingredient validity this.FailOn(() => comp.SpaceLeftForIngredient <= 0); this.FailOnDespawnedNullOrForbidden(FermenterInd); this.FailOnBurningImmobile(FermenterInd); this.FailOnDestroyedNullOrForbidden(IngredientInd); // Reserve resources // Creating the toil before yielding allows for CheckForGetOpportunityDuplicate Toil ingrToil = Toils_Reserve.Reserve(IngredientInd); yield return(ingrToil); // Reserve fermenter yield return(Toils_Reserve.Reserve(FermenterInd)); // Go to the ingredient yield return(Toils_Goto.GotoThing(IngredientInd, PathEndMode.ClosestTouch) .FailOnSomeonePhysicallyInteracting(IngredientInd) .FailOnDestroyedNullOrForbidden(IngredientInd)); // Haul the ingredients yield return(Toils_Haul.StartCarryThing(IngredientInd, false, true).FailOnDestroyedNullOrForbidden(IngredientInd)); yield return(Toils_Haul.CheckForGetOpportunityDuplicate(ingrToil, IngredientInd, TargetIndex.None, true)); // Carry ingredients to the fermenter yield return(Toils_Haul.CarryHauledThingToCell(FermenterInd)); // Add delay for adding ingredients to the fermenter yield return(Toils_General.Wait(Duration).FailOnDestroyedNullOrForbidden(FermenterInd).WithProgressBarToilDelay(FermenterInd)); // Use ingredients // The UniversalFermenter automatically destroys held ingredients Toil add = new Toil(); add.initAction = () => { if (!comp.AddIngredient(Ingredient)) { // The ingredient is not allowed, end the job EndJobWith(JobCondition.Incompletable); Log.Message("JobCondition.Incompletable"); } }; add.defaultCompleteMode = ToilCompleteMode.Instant; yield return(add); // End the current job yield break; }
private static bool Prefix(ref float ___m_fermentationDuration, ref Fermenter __instance) { if (Config["Fermenter"]["enabled"] == "true") { float fermenterDuration = toFloat(Config["Fermenter"]["fermenterDuration"]); if (fermenterDuration > 0) { ___m_fermentationDuration = fermenterDuration; } } return(true); }
private static bool Prefix(ref float ___m_fermentationDuration, ref Fermenter __instance) { if (Settings.isEnabled("Fermenter")) { float fermenterDuration = Settings.getFloat("Fermenter", "fermenterDuration"); if (fermenterDuration > 0) { ___m_fermentationDuration = fermenterDuration; } } return(true); }
private static bool Prefix(ref float ___m_fermentationDuration, ref Fermenter __instance) { if (Conf.Fermenter != null) { float fermenterDuration = Conf.Fermenter.FermenterDuration;//toFloat(Config["Fermenter"]["fermenterDuration"]); if (fermenterDuration > 0) { ___m_fermentationDuration = fermenterDuration; } } return(true); }
private static bool Prefix(ref float ___m_fermentationDuration, ref Fermenter __instance) { if (Configuration.Current.Fermenter.IsEnabled) { float fermenterDuration = Configuration.Current.Fermenter.fermenterDuration; if (fermenterDuration > 0) { ___m_fermentationDuration = fermenterDuration; } } return(true); }
protected override IEnumerable <Toil> MakeNewToils() { CompUniversalFermenter comp = Fermenter.TryGetComp <CompUniversalFermenter>(); // Verify fermenter and ingredient validity this.FailOnDespawnedNullOrForbidden(FermenterInd); this.FailOnBurningImmobile(FermenterInd); base.AddEndCondition(delegate { if (comp.SpaceLeftForIngredient > 0) { return(JobCondition.Ongoing); } return(JobCondition.Succeeded); }); yield return(Toils_General.DoAtomic(delegate { job.count = comp.SpaceLeftForIngredient; })); // Creating the toil before yielding allows for CheckForGetOpportunityDuplicate Toil reserveIngredient = Toils_Reserve.Reserve(IngredientInd); yield return(reserveIngredient); yield return(Toils_Goto.GotoThing(IngredientInd, PathEndMode.ClosestTouch).FailOnDespawnedNullOrForbidden(IngredientInd).FailOnSomeonePhysicallyInteracting(IngredientInd)); yield return(Toils_Haul.StartCarryThing(IngredientInd, false, true, false).FailOnDestroyedNullOrForbidden(IngredientInd)); yield return(Toils_Haul.CheckForGetOpportunityDuplicate(reserveIngredient, IngredientInd, TargetIndex.None, true)); // Carry ingredients to the fermenter yield return(Toils_Goto.GotoThing(FermenterInd, PathEndMode.Touch)); // Add delay for adding ingredients to the fermenter yield return(Toils_General.Wait(Duration, FermenterInd).FailOnDestroyedNullOrForbidden(IngredientInd).FailOnDestroyedNullOrForbidden(FermenterInd) .FailOnCannotTouch(FermenterInd, PathEndMode.Touch).WithProgressBarToilDelay(FermenterInd, false, -0.5f)); // Use ingredients // The UniversalFermenter automatically destroys held ingredients yield return(new Toil { initAction = delegate() { comp.AddIngredient(Ingredient); }, defaultCompleteMode = ToilCompleteMode.Instant }); }
static void Prefix(ref Fermenter __instance, Humanoid user, bool hold) { if (hold || !PrivateArea.CheckAccess(__instance.transform.position)) { return; } int status = Traverse.Create(__instance).Method("GetStatus").GetValue <int>(); if (status == 3) // 3 is the enum value for Ready { ((Player)user).RaiseSkill((Skills.SkillType)COOKING_SKILL_ID, configFermenterXPIncrease.Value * 0.5f); //Log($"[Removed Item from Fermenter] Increase Cooking Skill by {configFermenterXPIncrease.Value * 0.5f}"); } }
public void TransferWortToFermenter(Fermenter fermenter) { if (fermenter.empty == true) { Recipe currentRecipe = thisKettle.recipe; fermenter.OnTransferWortIn(currentRecipe); thisKettle.boiling = false; thisKettle.readyToTransfer = false; thisKettle.empty = true; } else { Debug.Log("Cannot transfer to fermenter: fermenter not empty!"); } }
private static bool GetHoverText(Fermenter __instance, ref string __result) { if (Main.timeLeftStyleFermenter.Value == 0) { return(true); } if (!PrivateArea.CheckAccess(__instance.transform.position, 0f, false, false)) { __result = Localization.instance.Localize(__instance.m_name + "\n$piece_noaccess"); return(false); } return(Patches.HoverText.PatchFermenter(__instance, ref __result)); }
public async Task <IActionResult> Create([Bind("FermenterID,Name,TargetTemp,BeerID,Address")] Fermenter fermenter) { if (ModelState.IsValid) { fermenter.Wort = await _context.BrewHistory.SingleOrDefaultAsync(x => x.BeerID == fermenter.BeerID); fermenter.TempSensor = await _context.Sensors.SingleOrDefaultAsync(x => x.Address == fermenter.Address); _context.Fermenters.Add(fermenter); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["Address"] = new SelectList(_context.Sensors, "Address", "Address", fermenter.Address); ViewData["BeerID"] = new SelectList(_context.BrewHistory, "BeerID", "BeerID", fermenter.BeerID); return(View(fermenter)); }
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); }
protected override IEnumerable <Toil> MakeNewToils() { CompUniversalFermenter comp = Fermenter.TryGetComp <CompUniversalFermenter>(); // Verify fermenter validity this.FailOn(() => !comp.Fermented); this.FailOnDestroyedNullOrForbidden(FermenterInd); // Reserve fermenter yield return(Toils_Reserve.Reserve(FermenterInd)); // Go to the fermenter yield return(Toils_Goto.GotoThing(FermenterInd, PathEndMode.ClosestTouch)); // Add delay for collecting product from fermenter, if it is ready yield return(Toils_General.Wait(Duration).FailOnDestroyedNullOrForbidden(FermenterInd).WithProgressBarToilDelay(FermenterInd)); // Collect product Toil collect = new Toil(); collect.initAction = () => { Thing product = comp.TakeOutProduct(); GenPlace.TryPlaceThing(product, pawn.Position, Map, ThingPlaceMode.Near); StoragePriority storagePriority = StoreUtility.CurrentStoragePriorityOf(product); IntVec3 c; // Try to find a suitable storage spot for the product if (StoreUtility.TryFindBestBetterStoreCellFor(product, pawn, Map, storagePriority, pawn.Faction, out c)) { this.job.SetTarget(TargetIndex.B, product); this.job.count = product.stackCount; this.job.SetTarget(TargetIndex.C, c); } // If there is no spot to store the product, end this job else { EndJobWith(JobCondition.Incompletable); } }; collect.defaultCompleteMode = ToilCompleteMode.Instant; yield return(collect); // Reserve the product yield return(Toils_Reserve.Reserve(ProductToHaulInd)); // Reserve the storage cell yield return(Toils_Reserve.Reserve(StorageCellInd)); // Go to the product yield return(Toils_Goto.GotoThing(ProductToHaulInd, PathEndMode.ClosestTouch)); // Pick up the product yield return(Toils_Haul.StartCarryThing(ProductToHaulInd)); // Carry the product to the storage cell, then place it down Toil carry = Toils_Haul.CarryHauledThingToCell(StorageCellInd); yield return(carry); yield return(Toils_Haul.PlaceHauledThingInCell(StorageCellInd, carry, true)); // End the current job yield break; }
public static void GetHoverText_light(ref Fermenter __instance, ref string __result) { if (__result.IsNullOrWhiteSpace()) { return; } ZNetView m_nview = (ZNetView)AccessTools.Field(typeof(Fermenter), "m_nview").GetValue(__instance); if (!m_nview.GetZDO().GetString("Content", "").IsNullOrWhiteSpace()) { DateTime d = new DateTime(m_nview.GetZDO().GetLong("StartTime", 0L)); if (d.Ticks != 0L) { double time = (ZNet.instance.GetTime() - d).TotalSeconds; if (!time.Equals(-1) && time < (double)__instance.m_fermentationDuration) { if ((bool)AccessTools.Field(typeof(Fermenter), "m_exposed").GetValue(__instance)) { if (hudData != null) { hudData.m_gui.SetActive(false); } return; } float percentage = (float)(time / (double)__instance.m_fermentationDuration * 100); int perc = (int)percentage; if (hudData == null && !ProgressBar.OFF.Equals(progressBar.Value)) { hudData = new HudData(); hudData.m_gui = UnityEngine.Object.Instantiate <GameObject>(EnemyHud.instance.m_baseHud, EnemyHud.instance.m_hudRoot.transform); hudData.m_gui.SetActive(true); hudData.m_gui.transform.SetPositionAndRotation(Hud.instance.m_crosshair.transform.position, new Quaternion()); hudData.m_healthRoot = hudData.m_gui.transform.Find("Health").gameObject; hudData.m_healthFast = hudData.m_healthRoot.transform.Find("health_fast").GetComponent <GuiBar>(); hudData.m_healthSlow = hudData.m_healthRoot.transform.Find("health_slow").GetComponent <GuiBar>(); hudData.m_name = hudData.m_gui.transform.Find("Name").GetComponent <Text>(); hudData.m_name.text = ""; hudData.m_level2 = hudData.m_gui.transform.Find("level_2") as RectTransform; hudData.m_level2.gameObject.SetActive(false); hudData.m_level3 = hudData.m_gui.transform.Find("level_3") as RectTransform; hudData.m_level3.gameObject.SetActive(false); hudData.m_alerted = hudData.m_gui.transform.Find("Alerted") as RectTransform; hudData.m_alerted.gameObject.SetActive(false); hudData.m_aware = hudData.m_gui.transform.Find("Aware") as RectTransform; hudData.m_aware.gameObject.SetActive(false); } if (hudData != null) { hudData.m_gui.transform.SetPositionAndRotation(Hud.instance.m_crosshair.transform.position, new Quaternion()); hudData.m_gui.SetActive(true); if (ProgressBar.YELLOW.Equals(progressBar.Value)) { hudData.m_healthSlow.SetValue(percentage); hudData.m_healthSlow.SetMaxValue(100); hudData.m_healthFast.SetValue(0); } else { hudData.m_healthFast.SetValue(percentage); hudData.m_healthFast.SetMaxValue(100); hudData.m_healthSlow.SetValue(0); } } if (color.Value) { string colorHex = $"#{(255 / 100 * (100 - perc)):X2}{(255 / 100 * perc):X2}{0:X2}"; if (ProgressText.PERCENT.Equals(progressText.Value)) { __result = __result.Replace(")", $"<color={colorHex}>{perc}%</color> )"); } else if (ProgressText.TIME.Equals(progressText.Value)) { double left = (double)__instance.m_fermentationDuration * percentage; int min = (int)Math.Floor(left / 60); int sec = ((int)left) % 60; __result = __result.Replace(")", $"<color={colorHex}>{min}m {sec}s</color> )"); } return; } else { if (ProgressText.PERCENT.Equals(progressText.Value)) { __result = __result.Replace(")", $"{perc}% )"); } else if (ProgressText.TIME.Equals(progressText.Value)) { double left = ((double)__instance.m_fermentationDuration) - time; int min = (int)Math.Floor(left / 60); int sec = ((int)left) % 60; __result = __result.Replace(")", $"{min}m {sec}s )"); } return; } } } } if (hudData != null) { hudData.m_gui.SetActive(false); } }