Skip to content

Commit

Permalink
bug: food was cooked in background when temp was low; add 'keep heati…
Browse files Browse the repository at this point in the history
…ng' on low temp
  • Loading branch information
ttr committed Jun 3, 2024
1 parent 283d0f9 commit 2a8569d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: MelonInfo(typeof(FireAddons.FireAddons), "FireAddons", "3.1.2", "ttr")]
[assembly: MelonInfo(typeof(FireAddons.FireAddons), "FireAddons", "3.1.3", "ttr")]
[assembly: MelonGame("Hinterland", "TheLongDark")]
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ If temperature is between "Normal High threshold" and "Maximal Boost Temperature
Any temperature above will cause cooking to be scaled by "High Temp time factor" setting.

This also applies to time until food will be ruined (burned), melting snow, boiling and boiling out water.

Additionally, keeping cooked and hot item on a stove while it's below "Minimal Cooking Temperature" will keep an item hot.
![Cooking time](https://raw.githubusercontent.com/ttr/tld-fireAddons/master/media/cooking.png)

## Notes / Issues.
Expand Down
20 changes: 17 additions & 3 deletions src/Patches.cs
Original file line number Diff line number Diff line change
Expand Up @@ -271,10 +271,19 @@ internal static class CookingPotItem_AttachedFireIsBurning
{
public static void Postfix(CookingPotItem __instance, ref bool __result)
{
if (__instance.m_FireBeingUsed && __instance.m_FireBeingUsed.m_IsPerpetual) { return; }
if (Settings.options.embersSystem && Settings.options.embersSystemNoCooking && __result && __instance.m_FireBeingUsed?.m_EmberTimer > 0)
if (__instance.m_FireBeingUsed)
{
__result = false;
if (__instance.m_FireBeingUsed.m_IsPerpetual) { return; }
if (Settings.options.embersSystem && Settings.options.embersSystemNoCooking && __result && __instance.m_FireBeingUsed.m_EmberTimer > 0)
{
__result = false;
}
/* this will work but will prevent using placed items on stove
if (Settings.options.cookingSystem && __result && FireAddons.CookSpeedFromTemp(__instance.m_FireBeingUsed.GetCurrentTempIncrease()) == float.PositiveInfinity)
{
__result = false;
}
*/
}
}
}
Expand All @@ -298,6 +307,11 @@ public static void Prefix(CookingPotItem __instance, ref float cookTimeMinutes,
{
if (Settings.options.cookingSystem && __instance.m_FireBeingUsed)
{
if (FireAddons.CookSpeedFromTemp(__instance.m_FireBeingUsed.GetCurrentTempIncrease()) == float.PositiveInfinity && __instance.AttachedFireIsBurning())
{
// roll-back cooking counter as temp is too low
__instance.m_CookingElapsedHours -= GameManager.GetTimeOfDayComponent().GetTODHours(Time.deltaTime);
}
cookTimeMinutes *= FireAddons.CookSpeedFromTemp(__instance.m_FireBeingUsed.GetCurrentTempIncrease());
readyTimeMinutes *= FireAddons.CookSpeedFromTemp(__instance.m_FireBeingUsed.GetCurrentTempIncrease());
//MelonLogger.Msg("Cooking speed2: " + cookTimeMinutes + " " + readyTimeMinutes + " " + FireAddons.CookSpeedFromTemp(__instance.m_FireBeingUsed.GetCurrentTempIncrease()));
Expand Down

0 comments on commit 2a8569d

Please sign in to comment.