Decompiled source of PlantsAlwaysGrowMono v1.0.2

Mods\PlantsAlwaysGrowMono.dll

Decompiled a month ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using PlantsAlwaysGrow;
using ScheduleOne.DevUtilities;
using ScheduleOne.GameTime;
using ScheduleOne.Growing;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(PlantsAlwaysGrowMod), "PlantsAlwaysGrowMod", "1.0.0", "lasersquid", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PlantsAlwaysGrowMono")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2")]
[assembly: AssemblyInformationalVersion("1.0.2+131fd6f12e1a3e7a67026e1d67c6aac4bf2cb6c5")]
[assembly: AssemblyProduct("PlantsAlwaysGrowMono")]
[assembly: AssemblyTitle("PlantsAlwaysGrowMono")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PlantsAlwaysGrow
{
	public class PlantsAlwaysGrowMod : MelonMod
	{
		private static bool _isPatchApplied;

		private static Harmony _harmonyInstance;

		public override void OnInitializeMelon()
		{
			((MelonEventBase<LemonAction<int, string>>)(object)MelonEvents.OnSceneWasLoaded).Subscribe((LemonAction<int, string>)OnSceneLoaded, 0, false);
			((MelonBase)this).LoggerInstance.Msg("PlantsAlwaysGrow initialized.");
		}

		private void OnSceneLoaded(int buildIndex, string sceneName)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			if (sceneName == "Main" && !_isPatchApplied)
			{
				try
				{
					_harmonyInstance = new Harmony("PlantsAlwaysGrowMod");
					_harmonyInstance.PatchAll();
					_isPatchApplied = true;
					((MelonBase)this).LoggerInstance.Msg("Plants Always Grow successfully initialized in scene: " + sceneName);
				}
				catch (Exception ex)
				{
					((MelonBase)this).LoggerInstance.Error("Failed to patch mod: " + ex.Message);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Plant), "MinPass")]
	public static class PlantMinPassPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(Plant __instance)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if (__instance.NormalizedGrowthProgress >= 1f)
			{
				return false;
			}
			TimeManager instance = NetworkSingleton<TimeManager>.Instance;
			if ((Object)instance == (Object)null || !instance.IsEndOfDay)
			{
				return true;
			}
			float num = 1f / ((float)__instance.GrowthTime * 60f);
			num *= __instance.Pot.GetAdditiveGrowthMultiplier();
			float num2 = default(float);
			num *= __instance.Pot.GetAverageLightExposure(ref num2);
			num *= __instance.Pot.GrowSpeedMultiplier;
			num *= num2;
			if (__instance.Pot.NormalizedWaterLevel <= 0f || __instance.Pot.NormalizedWaterLevel > 1f)
			{
				num *= 0f;
			}
			__instance.SetNormalizedGrowthProgress(__instance.NormalizedGrowthProgress + num);
			return false;
		}
	}
}