Snow.dll

Decompiled 18 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using MelonLoader;
using Microsoft.CodeAnalysis;
using SnowTerrainMod;
using UnityEngine;
using VersionChecker;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(global::SnowTerrainMod.SnowTerrainMod), "Snow :3", "1.0.3", "Estonia", null)]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: MelonPlatformDomain(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Snow")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Snow")]
[assembly: AssemblyTitle("Snow")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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 VersionChecker
{
	public static class VersionChecker
	{
		private const string PROBLEMATIC_VERSION = "0.7.1.0";

		private const string RECOMMENDED_VERSION_1 = "0.7.0";

		private const string RECOMMENDED_VERSION_2 = "0.7.2-nightly";

		public static void CheckMelonLoaderVersion()
		{
			try
			{
				string melonLoaderVersion = GetMelonLoaderVersion();
				if (string.IsNullOrEmpty(melonLoaderVersion))
				{
					MelonLogger.Warning("[VersionChecker] Could not determine MelonLoader version!");
					return;
				}
				MelonLogger.Msg("========================================");
				MelonLogger.Msg("[VersionChecker] MelonLoader Version Detected: " + melonLoaderVersion);
				MelonLogger.Msg("========================================");
				if (melonLoaderVersion == "0.7.1.0")
				{
					ShowBigWarning(melonLoaderVersion);
				}
				else if (IsVersionCloseToProblematic(melonLoaderVersion))
				{
					MelonLogger.Warning("[VersionChecker] Warning: You are using a version very close to 0.7.1.0");
					MelonLogger.Warning("[VersionChecker] It is recommended to use 0.7.0 or 0.7.2-nightly");
				}
				else
				{
					MelonLogger.Msg("[VersionChecker] Your MelonLoader version appears to be compatible!");
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("[VersionChecker] Version check failed: " + ex.Message);
			}
		}

		private static string GetMelonLoaderVersion()
		{
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string fullName = executingAssembly.FullName;
				Type type = Type.GetType("MelonLoader.MelonMod, MelonLoader");
				if (type != null)
				{
					Assembly assembly = type.Assembly;
					Version version = assembly.GetName().Version;
					if (version != null)
					{
						return version.ToString();
					}
				}
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly2 in assemblies)
				{
					string name = assembly2.GetName().Name;
					if (name != null && (name.Equals("MelonLoader") || name.Equals("MelonLoader.Core")))
					{
						Version version2 = assembly2.GetName().Version;
						if (version2 != null)
						{
							return version2.ToString();
						}
					}
				}
				return null;
			}
			catch
			{
				return null;
			}
		}

		private static bool IsVersionCloseToProblematic(string version)
		{
			try
			{
				if (version.StartsWith("0.7.1"))
				{
					if (version == "0.7.1" || version == "0.7.1.0")
					{
						return false;
					}
					return true;
				}
				return false;
			}
			catch
			{
				return false;
			}
		}

		private static void ShowBigWarning(string detectedVersion)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("");
			stringBuilder.AppendLine("╔════════════════════════════════════════════════════════════════════════╗");
			stringBuilder.AppendLine("║                                                                        ║");
			stringBuilder.AppendLine("║                    !!! URGENT WARNING !!!                              ║");
			stringBuilder.AppendLine("║                                                                        ║");
			stringBuilder.AppendLine("║           YOU ARE USING MELONLOADER VERSION " + detectedVersion.PadRight(8) + "                  ║");
			stringBuilder.AppendLine("║                                                                        ║");
			stringBuilder.AppendLine("║  This version is KNOWN TO HAVE CRITICAL ISSUES and may cause:        ║");
			stringBuilder.AppendLine("║                                                                        ║");
			stringBuilder.AppendLine("║    - Game crashes and unexpected behavior                             ║");
			stringBuilder.AppendLine("║    - Mod incompatibility and loading failures                          ║");
			stringBuilder.AppendLine("║    - Performance issues and memory leaks                               ║");
			stringBuilder.AppendLine("║    - Random errors and instability                                     ║");
			stringBuilder.AppendLine("║                                                                        ║");
			stringBuilder.AppendLine("║  PLEASE UPDATE IMMEDIATELY to one of these recommended versions:       ║");
			stringBuilder.AppendLine("║                                                                        ║");
			stringBuilder.AppendLine("║    ► " + "0.7.0".PadRight(20) + " (Stable Release)                          ║");
			stringBuilder.AppendLine("║    ► " + "0.7.2-nightly".PadRight(20) + " (Latest Nightly)                          ║");
			stringBuilder.AppendLine("║                                                                        ║");
			stringBuilder.AppendLine("║  Download from: https://melonwiki.xyz/#/?id=automated-installation      ║");
			stringBuilder.AppendLine("║                                                                        ║");
			stringBuilder.AppendLine("║      ║");
			stringBuilder.AppendLine("║                                                                        ║");
			stringBuilder.AppendLine("╚════════════════════════════════════════════════════════════════════════╝");
			stringBuilder.AppendLine("");
			for (int i = 0; i < 3; i++)
			{
				MelonLogger.Error(stringBuilder.ToString());
			}
			MelonLogger.Error("[VersionChecker] DETECTED PROBLEMATIC MELONLOADER VERSION: " + detectedVersion);
			MelonLogger.Error("[VersionChecker] PLEASE UPDATE TO 0.7.0 OR 0.7.2-nightly");
			MelonLogger.Error("[VersionChecker] Download: https://github.com/LavaGang/MelonLoader/releases");
		}
	}
}
namespace SnowTerrainMod
{
	public class SnowTerrainMod : MelonMod
	{
		[CompilerGenerated]
		private sealed class <ApplySnowAfterDelay>d__16 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public SnowTerrainMod <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <ApplySnowAfterDelay>d__16(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(5f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.ApplySnowEffect();
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<>4__this.RefreshTerrainEffect();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <InitializeTexture>d__13 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public SnowTerrainMod <>4__this;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <InitializeTexture>d__13(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>4__this.LoadSnowTexture();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private const float SCENE_LOAD_DELAY = 5f;

		private const string SNOW_TEXTURE_NAME = "snow.png";

		private bool _isSnowActive = true;

		private Dictionary<int, TerrainLayer[]> _originalTerrainLayers = new Dictionary<int, TerrainLayer[]>();

		private Dictionary<int, float[,,]> _originalAlphamaps = new Dictionary<int, float[,,]>();

		private Texture2D _snowTexture = null;

		private HashSet<int> _processedTerrainIds = new HashSet<int>();

		private bool _textureLoaded = false;

		private GameObject _snowParticles = null;

		private ParticleSystem _particleSystem = null;

		public override void OnApplicationStart()
		{
			MelonLogger.Msg("Mod loaded successfully! Happy christmas everyone <3 - estonia");
			global::VersionChecker.VersionChecker.CheckMelonLoaderVersion();
			CreateSnowParticles();
			MelonCoroutines.Start(InitializeTexture());
		}

		public override void OnUpdate()
		{
			UpdateParticlePosition();
			if ((Object)(object)_snowParticles != (Object)null && _snowParticles.activeSelf && (Object)(object)_particleSystem != (Object)null && !_particleSystem.isPlaying)
			{
				_particleSystem.Play();
			}
		}

		public override void OnSceneWasLoaded(int buildIndex, string sceneName)
		{
			_originalTerrainLayers.Clear();
			_originalAlphamaps.Clear();
			_processedTerrainIds.Clear();
			if (sceneName != "Main" && sceneName != "Main")
			{
				SetParticlesActive(active: false);
			}
			else if (_isSnowActive && _textureLoaded)
			{
				MelonCoroutines.Start(ApplySnowAfterDelay());
				SetParticlesActive(active: true);
			}
			else
			{
				SetParticlesActive(active: false);
			}
		}

		[IteratorStateMachine(typeof(<InitializeTexture>d__13))]
		private IEnumerator InitializeTexture()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InitializeTexture>d__13(0)
			{
				<>4__this = this
			};
		}

		private void LoadSnowTexture()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			try
			{
				string path = Path.Combine(Application.dataPath, "..", "snow.png");
				if (File.Exists(path))
				{
					byte[] array = File.ReadAllBytes(path);
					_snowTexture = new Texture2D(2, 2, (TextureFormat)4, false);
					if (ImageConversion.LoadImage(_snowTexture, array))
					{
						((Texture)_snowTexture).wrapMode = (TextureWrapMode)0;
						((Texture)_snowTexture).filterMode = (FilterMode)1;
						_textureLoaded = true;
						UpdateParticleTexture();
						SetParticlesActive(_isSnowActive);
						return;
					}
				}
				_snowTexture = GenerateSnowTexture();
				_textureLoaded = true;
				UpdateParticleTexture();
				SetParticlesActive(_isSnowActive);
			}
			catch (Exception)
			{
				_snowTexture = GenerateSnowTexture();
				_textureLoaded = true;
				UpdateParticleTexture();
				SetParticlesActive(_isSnowActive);
			}
		}

		private Texture2D GenerateSnowTexture()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			int num = 256;
			Texture2D val = new Texture2D(num, num, (TextureFormat)4, false);
			((Texture)val).wrapMode = (TextureWrapMode)0;
			((Texture)val).filterMode = (FilterMode)1;
			Color[] array = (Color[])(object)new Color[num * num];
			for (int i = 0; i < num; i++)
			{
				for (int j = 0; j < num; j++)
				{
					float num2 = Random.Range(0.95f, 1f);
					float num3 = Random.Range(0.97f, 1f);
					array[i * num + j] = new Color(num2, num2, num3, 1f);
				}
			}
			val.SetPixels(array);
			val.Apply(false);
			return val;
		}

		[IteratorStateMachine(typeof(<ApplySnowAfterDelay>d__16))]
		private IEnumerator ApplySnowAfterDelay()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ApplySnowAfterDelay>d__16(0)
			{
				<>4__this = this
			};
		}

		private void ToggleSnowEffect()
		{
			_isSnowActive = !_isSnowActive;
			if (_isSnowActive)
			{
				ApplySnowEffect();
				SetParticlesActive(active: true);
			}
			else
			{
				RestoreOriginalTerrain();
				SetParticlesActive(active: false);
			}
		}

		private void RefreshTerrainEffect()
		{
			_originalTerrainLayers.Clear();
			_originalAlphamaps.Clear();
			_processedTerrainIds.Clear();
			if (_isSnowActive)
			{
				ApplySnowEffect();
			}
		}

		private void ApplySnowEffect()
		{
			if ((Object)(object)_snowTexture == (Object)null || !_textureLoaded)
			{
				return;
			}
			Terrain[] array = Terrain.activeTerrains;
			if (array == null || array.Length == 0)
			{
				array = Object.FindObjectsOfType<Terrain>();
			}
			if (array == null || array.Length == 0)
			{
				return;
			}
			Terrain[] array2 = array;
			foreach (Terrain val in array2)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val.terrainData == (Object)null))
				{
					int instanceID = ((Object)val).GetInstanceID();
					if (!_processedTerrainIds.Contains(instanceID))
					{
						ApplySnowToTerrain(val, instanceID);
					}
				}
			}
		}

		private void ApplySnowToTerrain(Terrain terrain, int instanceId)
		{
			try
			{
				TerrainData terrainData = terrain.terrainData;
				if (!((Object)(object)terrainData == (Object)null))
				{
					StoreOriginalTerrainData(terrain, instanceId);
					if (ApplySnowTextureToTerrain(terrainData, instanceId))
					{
						_processedTerrainIds.Add(instanceId);
					}
				}
			}
			catch (Exception)
			{
			}
		}

		private void StoreOriginalTerrainData(Terrain terrain, int instanceId)
		{
			TerrainData terrainData = terrain.terrainData;
			if (!_originalTerrainLayers.ContainsKey(instanceId))
			{
				try
				{
					TerrainLayer[] terrainLayers = terrainData.terrainLayers;
					_originalTerrainLayers[instanceId] = terrainLayers;
				}
				catch (Exception)
				{
				}
			}
			if (_originalAlphamaps.ContainsKey(instanceId))
			{
				return;
			}
			try
			{
				int alphamapWidth = terrainData.alphamapWidth;
				int alphamapHeight = terrainData.alphamapHeight;
				if (alphamapWidth > 0 && alphamapHeight > 0)
				{
					float[,,] alphamaps = terrainData.GetAlphamaps(0, 0, alphamapWidth, alphamapHeight);
					_originalAlphamaps[instanceId] = alphamaps;
				}
			}
			catch (Exception)
			{
			}
		}

		private bool ApplySnowTextureToTerrain(TerrainData terrainData, int instanceId)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				int alphamapWidth = terrainData.alphamapWidth;
				int alphamapHeight = terrainData.alphamapHeight;
				int alphamapLayers = terrainData.alphamapLayers;
				if (alphamapWidth <= 0 || alphamapHeight <= 0)
				{
					return false;
				}
				TerrainLayer val = new TerrainLayer();
				val.diffuseTexture = _snowTexture;
				val.tileSize = new Vector2(terrainData.size.x, terrainData.size.z);
				val.diffuseRemapMin = Vector4.zero;
				val.diffuseRemapMax = new Vector4(1f, 1f, 1f, 1f);
				terrainData.terrainLayers = (TerrainLayer[])(object)new TerrainLayer[1] { val };
				float[,,] alphamaps = terrainData.GetAlphamaps(0, 0, alphamapWidth, alphamapHeight);
				int num = Mathf.Min(alphamapLayers, 4);
				for (int i = 0; i < alphamapHeight; i++)
				{
					for (int j = 0; j < alphamapWidth; j++)
					{
						alphamaps[i, j, 0] = 1f;
						for (int k = 1; k < num; k++)
						{
							alphamaps[i, j, k] = 0f;
						}
					}
				}
				terrainData.SetAlphamaps(0, 0, alphamaps);
				return true;
			}
			catch (Exception)
			{
				return false;
			}
		}

		private void RestoreOriginalTerrain()
		{
			Terrain[] activeTerrains = Terrain.activeTerrains;
			if (activeTerrains == null)
			{
				return;
			}
			Terrain[] array = activeTerrains;
			foreach (Terrain val in array)
			{
				if ((Object)(object)val == (Object)null || (Object)(object)val.terrainData == (Object)null)
				{
					continue;
				}
				int instanceID = ((Object)val).GetInstanceID();
				if (_originalTerrainLayers.ContainsKey(instanceID))
				{
					try
					{
						val.terrainData.terrainLayers = _originalTerrainLayers[instanceID];
					}
					catch (Exception)
					{
					}
				}
				if (_originalAlphamaps.ContainsKey(instanceID))
				{
					try
					{
						val.terrainData.SetAlphamaps(0, 0, _originalAlphamaps[instanceID]);
					}
					catch (Exception)
					{
					}
				}
				_processedTerrainIds.Remove(instanceID);
			}
		}

		private void CreateSnowParticles()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Expected O, but got Unknown
			if ((Object)(object)_snowParticles != (Object)null)
			{
				return;
			}
			try
			{
				_snowParticles = new GameObject("SnowParticles");
				_particleSystem = _snowParticles.AddComponent<ParticleSystem>();
				ParticleSystemRenderer component = _snowParticles.GetComponent<ParticleSystemRenderer>();
				MainModule main = _particleSystem.main;
				((MainModule)(ref main)).loop = true;
				((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(15f);
				((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(10f);
				((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.08f);
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 1f, 1f, 0.8f));
				((MainModule)(ref main)).maxParticles = 200000;
				((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
				((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(1f);
				((MainModule)(ref main)).playOnAwake = false;
				((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)0;
				EmissionModule emission = _particleSystem.emission;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(5500f);
				ShapeModule shape = _particleSystem.shape;
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)5;
				((ShapeModule)(ref shape)).scale = new Vector3(125f, 1f, 125f);
				((ShapeModule)(ref shape)).rotation = new Vector3(0f, 0f, 0f);
				VelocityOverLifetimeModule velocityOverLifetime = _particleSystem.velocityOverLifetime;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = false;
				NoiseModule noise = _particleSystem.noise;
				((NoiseModule)(ref noise)).enabled = false;
				CollisionModule collision = _particleSystem.collision;
				((CollisionModule)(ref collision)).enabled = false;
				TrailModule trails = _particleSystem.trails;
				((TrailModule)(ref trails)).enabled = false;
				component.renderMode = (ParticleSystemRenderMode)0;
				component.sortMode = (ParticleSystemSortMode)1;
				component.maxParticleSize = 1f;
				component.minParticleSize = 0f;
				component.enableGPUInstancing = true;
				Material val = new Material(Shader.Find("Particles/Standard Unlit"));
				val.SetFloat("_Mode", 2f);
				val.SetInt("_SrcBlend", 5);
				val.SetInt("_DstBlend", 10);
				val.SetInt("_ZWrite", 0);
				val.DisableKeyword("_ALPHATEST_ON");
				val.EnableKeyword("_ALPHABLEND_ON");
				val.DisableKeyword("_ALPHAPREMULTIPLY_ON");
				val.renderQueue = 3000;
				val.enableInstancing = true;
				val.SetFloat("_GlowStrength", 0f);
				val.SetFloat("_Contrast", 1f);
				val.SetFloat("_Brightness", 1f);
				if ((Object)(object)_snowTexture != (Object)null)
				{
					val.mainTexture = (Texture)(object)_snowTexture;
				}
				((Renderer)component).material = val;
				component.sortMode = (ParticleSystemSortMode)1;
				_snowParticles.SetActive(false);
				Object.DontDestroyOnLoad((Object)(object)_snowParticles);
				MelonLogger.Msg("[SnowTerrainMod] Snow particle system created");
			}
			catch (Exception)
			{
			}
		}

		private void UpdateParticlePosition()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_snowParticles == (Object)null) && _snowParticles.activeSelf)
			{
				Camera main = Camera.main;
				if ((Object)(object)main != (Object)null)
				{
					Vector3 position = ((Component)main).transform.position;
					_snowParticles.transform.position = new Vector3(position.x, position.y + 20f, position.z);
				}
			}
		}

		private void SetParticlesActive(bool active)
		{
			if ((Object)(object)_snowParticles == (Object)null)
			{
				if (active)
				{
					CreateSnowParticles();
				}
				return;
			}
			_snowParticles.SetActive(active);
			if (active)
			{
				_particleSystem.Play();
			}
			else
			{
				_particleSystem.Stop();
			}
		}

		private void UpdateParticleTexture()
		{
			if (!((Object)(object)_particleSystem == (Object)null) && !((Object)(object)_snowTexture == (Object)null))
			{
				ParticleSystemRenderer component = _snowParticles.GetComponent<ParticleSystemRenderer>();
				if ((Object)(object)component != (Object)null && (Object)(object)((Renderer)component).material != (Object)null)
				{
					((Renderer)component).material.mainTexture = (Texture)(object)_snowTexture;
				}
			}
		}
	}
}