excellent breakpoint - we found the soil and track the remaining uses. going to clean up the file

This commit is contained in:
2026-05-18 22:13:02 -04:00
parent df8a62295e
commit 162a1ce795
9 changed files with 20 additions and 16 deletions
+1
View File
@@ -7,6 +7,7 @@
<LangVersion>latest</LangVersion>
<Nullable>disable</Nullable>
<GameDir>/home/attila/.local/share/Steam/steamapps/common/Schedule I</GameDir>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>
+17 -14
View File
@@ -341,31 +341,34 @@ namespace AbsorbentSoil
[HarmonyPatch(typeof(PourSoilTask), "OnInitialPour")]
internal static class PourSoilTask_OnInitialPour_Patch
{
private static readonly FieldInfo SoilDefinitionField =
AccessTools.Field(typeof(PourSoilTask), "_soilDefinition");
private static readonly FieldInfo GrowContainerField =
AccessTools.Field(typeof(PourSoilTask), "_growContainer");
private static void Postfix(PourSoilTask __instance)
private static unsafe void Postfix(PourSoilTask __instance)
{
try
{
var soilDef = SoilDefinitionField?.GetValue(__instance) as SoilDefinition;
var growContainer = GrowContainerField?.GetValue(__instance) as GrowContainer;
var pot = growContainer?.TryCast<Pot>();
nint basePtr = (nint)IL2CPP.Il2CppObjectBaseToPtrNotNull(__instance);
MelonLogger.Msg($"PourSoilTask.OnInitialPour fired. Soil={soilDef?.ID}, Uses={soilDef?.Uses}, Pot={pot?.name}");
nint soilDefPtr = *(nint*)(basePtr + 0xD0);
nint growContainerPtr = *(nint*)(basePtr + 0xE8);
SoilDefinition soilDef = soilDefPtr != 0
? new SoilDefinition(soilDefPtr)
: null;
GrowContainer growContainer = growContainerPtr != 0
? new GrowContainer(growContainerPtr)
: null;
Pot pot = growContainer?.TryCast<Pot>();
MelonLogger.Msg($"PourSoilTask.OnInitialPour offset-read fired. Soil={soilDef?.ID}, Uses={soilDef?.Uses}, Pot={pot?.name}");
if (pot == null || soilDef == null)
return;
SoilHelper.SetRemainingSoilUses(pot, soilDef.Uses);
// New soil means fresh soil. Clear old retained additives.
AdditiveMemory.Forget(pot);
MelonLogger.Msg($"[Absorbent Soil] Fresh soil added to pot '{PotKeyHelper.GetPotKey(pot)}'. Max uses={soilDef.Uses}. Cleared old additives.");
MelonLogger.Msg($"[Absorbent Soil] Fresh soil added. Pot='{PotKeyHelper.GetPotKey(pot)}', Soil='{soilDef.ID}', Uses={soilDef.Uses}. Cleared old additives.");
}
catch (Exception ex)
{
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("AbsorbentSoil")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+37e8635b49f6dac44b046923e2d6164f21e21c5e")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+df8a62295eea38ad16e750280eea878da48af3ae")]
[assembly: System.Reflection.AssemblyProductAttribute("AbsorbentSoil")]
[assembly: System.Reflection.AssemblyTitleAttribute("AbsorbentSoil")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
@@ -1 +1 @@
e91a6e148fbebb52137b7ddb0d020d001faa537353e4a942e8c7b383650eef69
205b227cc6bf36a9df78289d110ec64054a771277aee03d496358bdc65fdfb7b
Binary file not shown.
Binary file not shown.