Decompiled source of SnowyWeeds v1.3.4

SnowyWeeds.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using WeatherRegistry;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SnowyWeeds")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Template plugin description")]
[assembly: AssemblyFileVersion("1.3.4.0")]
[assembly: AssemblyInformationalVersion("1.3.4")]
[assembly: AssemblyProduct("SnowyWeeds")]
[assembly: AssemblyTitle("SnowyWeeds")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.3.4.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 SnowyWeeds
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "SnowyWeeds";

		public const string PLUGIN_NAME = "SnowyWeeds";

		public const string PLUGIN_VERSION = "1.3.4";
	}
}
namespace TemplatePluginName
{
	[BepInPlugin("dopadream.lethalcompany.snowyweeds", "SnowyWeeds", "1.3.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch]
		private class SnowyWeedPatches
		{
			[HarmonyPatch(typeof(MoldSpreadManager), "GenerateMold")]
			[HarmonyPostfix]
			private static void PostSpreadMold(MoldSpreadManager __instance)
			{
				if (!IsSnowLevel() || (Object)(object)StartOfRound.Instance == (Object)null)
				{
					return;
				}
				for (int i = 0; i < __instance.moldContainer.childCount; i++)
				{
					Renderer[] componentsInChildren = ((Component)__instance.moldContainer).GetComponentsInChildren<Renderer>();
					foreach (Renderer val in componentsInChildren)
					{
						val.material.mainTexture = weedTexture;
						Logger.LogDebug((object)(((Object)val.material.mainTexture).name + " applied to shroud"));
					}
				}
			}
		}

		private const string PLUGIN_GUID = "dopadream.lethalcompany.snowyweeds";

		private const string PLUGIN_NAME = "SnowyWeeds";

		private const string PLUGIN_VERSION = "1.3.4";

		private const string WEATHER_REGISTRY = "mrov.WeatherRegistry";

		internal static ManualLogSource Logger;

		internal static Texture weedTexture;

		private void Awake()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			try
			{
				Object obj = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "snowyweeds")).LoadAsset("InvasiveWeedSnowy", typeof(Texture));
				weedTexture = (Texture)(object)((obj is Texture) ? obj : null);
			}
			catch
			{
				Logger.LogError((object)"Encountered some error loading asset bundle. Did you install the plugin correctly?");
				return;
			}
			new Harmony("dopadream.lethalcompany.snowyweeds").PatchAll();
			Logger.LogInfo((object)"SnowyWeeds v1.3.4 loaded");
		}

		private static bool IsSnowLevel()
		{
			if (Chainloader.PluginInfos.ContainsKey("mrov.WeatherRegistry"))
			{
				return WeatherRegistrySnowCheck();
			}
			return StartOfRound.Instance.currentLevel.levelIncludesSnowFootprints;
		}

		private static bool WeatherRegistrySnowCheck()
		{
			if (!StartOfRound.Instance.currentLevel.levelIncludesSnowFootprints && !((Object)WeatherManager.GetCurrentLevelWeather()).name.Equals("Snowfall"))
			{
				return ((Object)WeatherManager.GetCurrentLevelWeather()).name.Equals("Blizzard");
			}
			return true;
		}
	}
}