multiplayer guards - config file for logging started
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
using MelonLoader;
|
||||||
|
|
||||||
|
namespace AbsorbentSoil.Config
|
||||||
|
{
|
||||||
|
internal static class AbsorbentSoilConfig
|
||||||
|
{
|
||||||
|
private static MelonPreferences_Category Category;
|
||||||
|
private static MelonPreferences_Entry<bool> VerboseLoggingEntry;
|
||||||
|
|
||||||
|
public static bool VerboseLogging => VerboseLoggingEntry?.Value ?? false;
|
||||||
|
|
||||||
|
public static void Init()
|
||||||
|
{
|
||||||
|
Category = MelonPreferences.CreateCategory("AbsorbentSoil");
|
||||||
|
|
||||||
|
VerboseLoggingEntry = Category.CreateEntry(
|
||||||
|
"VerboseLogging",
|
||||||
|
false,
|
||||||
|
"Verbose Logging",
|
||||||
|
"Enable detailed troubleshooting logs for Absorbent Soil.");
|
||||||
|
|
||||||
|
Category.SaveToFile(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
using Il2CppScheduleOne.Persistence;
|
||||||
|
using MelonLoader;
|
||||||
|
|
||||||
|
internal static class RuntimeSafety
|
||||||
|
{
|
||||||
|
public static bool CanMutateState()
|
||||||
|
{
|
||||||
|
// Single-player usually passes.
|
||||||
|
// In multiplayer, this should ideally be host/server only.
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,6 +12,9 @@ namespace AbsorbentSoil
|
|||||||
{
|
{
|
||||||
public static void Postfix(Plant __instance, AdditiveDefinition additive, bool isInitialApplication)
|
public static void Postfix(Plant __instance, AdditiveDefinition additive, bool isInitialApplication)
|
||||||
{
|
{
|
||||||
|
if (!RuntimeSafety.CanMutateState())
|
||||||
|
return;
|
||||||
|
|
||||||
if (__instance == null || additive == null)
|
if (__instance == null || additive == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
@@ -35,6 +35,9 @@ namespace AbsorbentSoil
|
|||||||
{
|
{
|
||||||
public static void Prefix(Pot __instance)
|
public static void Prefix(Pot __instance)
|
||||||
{
|
{
|
||||||
|
if (!RuntimeSafety.CanMutateState())
|
||||||
|
return;
|
||||||
|
|
||||||
// If the pot itself is destroyed/sold, stop tracking its additives.
|
// If the pot itself is destroyed/sold, stop tracking its additives.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -14,6 +14,9 @@ namespace AbsorbentSoil
|
|||||||
{
|
{
|
||||||
private static unsafe void Postfix(PourSoilTask __instance)
|
private static unsafe void Postfix(PourSoilTask __instance)
|
||||||
{
|
{
|
||||||
|
if (!RuntimeSafety.CanMutateState())
|
||||||
|
return;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
nint basePtr = (nint)IL2CPP.Il2CppObjectBaseToPtrNotNull(__instance);
|
nint basePtr = (nint)IL2CPP.Il2CppObjectBaseToPtrNotNull(__instance);
|
||||||
|
|||||||
@@ -11,6 +11,9 @@ namespace AbsorbentSoil
|
|||||||
|
|
||||||
public static int DecrementRemainingSoilUses(Pot pot)
|
public static int DecrementRemainingSoilUses(Pot pot)
|
||||||
{
|
{
|
||||||
|
if (!RuntimeSafety.CanMutateState())
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (pot == null)
|
if (pot == null)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
@@ -28,6 +31,9 @@ namespace AbsorbentSoil
|
|||||||
|
|
||||||
public static void SetRemainingSoilUses(Pot pot, int uses)
|
public static void SetRemainingSoilUses(Pot pot, int uses)
|
||||||
{
|
{
|
||||||
|
if (!RuntimeSafety.CanMutateState())
|
||||||
|
return;
|
||||||
|
|
||||||
if (pot == null)
|
if (pot == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|||||||
Binary file not shown.
@@ -13,7 +13,7 @@ using System.Reflection;
|
|||||||
[assembly: System.Reflection.AssemblyCompanyAttribute("AbsorbentSoil")]
|
[assembly: System.Reflection.AssemblyCompanyAttribute("AbsorbentSoil")]
|
||||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
[assembly: System.Reflection.AssemblyConfigurationAttribute("Release")]
|
||||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+b21db135dbb267f14ba001c06d5e767684e16748")]
|
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+75ee5ce621b167f1457e04cef2d427eb9879c0e5")]
|
||||||
[assembly: System.Reflection.AssemblyProductAttribute("AbsorbentSoil")]
|
[assembly: System.Reflection.AssemblyProductAttribute("AbsorbentSoil")]
|
||||||
[assembly: System.Reflection.AssemblyTitleAttribute("AbsorbentSoil")]
|
[assembly: System.Reflection.AssemblyTitleAttribute("AbsorbentSoil")]
|
||||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
b9ad6f2e98c8850d94d764bf380f030dbfc6c348e959950e4fa42b574c0504d4
|
e3d03f6c9dfc521324738d04ad4228faed1bb64eafad7288d3a595d219e15990
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
5c030080472ae1536e3626b995d635d8af1656efb3cdf494e4087a4281d4934d
|
04cacbb88ccbdb0ef16f25557f16c2a1f76e1e74a1eff95472a744bd5aa2b973
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user