Decompiled source of NaturalDisasters v1.1.0

WVDWS.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using Splatform;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.UI;
using WallachianVikings.WVDWS.Audio;
using WallachianVikings.WVDWS.Commands;
using WallachianVikings.WVDWS.Compatibility;
using WallachianVikings.WVDWS.Configuration;
using WallachianVikings.WVDWS.Events;
using WallachianVikings.WVDWS.Gameplay;
using WallachianVikings.WVDWS.Networking;
using WallachianVikings.WVDWS.Scheduling;
using WallachianVikings.WVDWS.UI;
using WallachianVikings.WVDWS.Utilities;
using WallachianVikings.WVDWS.Visuals;

[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("WVDWS")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("WVDWS")]
[assembly: AssemblyTitle("WVDWS")]
[assembly: AssemblyVersion("1.1.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 WallachianVikings.WVDWS
{
	[BepInPlugin("wallachianvikings.WVDWS", "Natural Disasters", "1.1.0")]
	[BepInDependency("com.jotunn.jotunn", "2.30.1")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Guid = "wallachianvikings.WVDWS";

		public const string Version = "1.1.0";

		public const string Discord = "https://discord.gg/qBJh7Bn2k7";

		private readonly Queue<string> recent = new Queue<string>();

		private RuleSet? combined;

		private RuleSet? localSource;

		private RuleSet? serverSource;

		private WvdwsConfig settings;

		private AssetLoader assets;

		private ContentRegistry? content;

		private Harmony? harmony;

		private readonly EventZoneManager zones = new EventZoneManager();

		private EventHistory history = new EventHistory();

		private NetworkManager? network;

		private EventRuntime? runtime;

		private EventScheduler? scheduler;

		private WaterBucketService bucket = new WaterBucketService();

		private ForecastHud? hud;

		private ZNet? session;

		private long world;

		private float nextTick;

		private double tickMs;

		private bool faulted;

		private readonly Stopwatch watch = new Stopwatch();

		private const string Help = "ntldstr help | status | report\nntldstr event list | status | clear\nntldstr event force <event> [active-duration] [radius]\nntldstr diagnostic [duration] [radius]\n(wvdws works as an alias)\nreport writes a diagnostic file for Discord bug reports (https://discord.gg/qBJh7Bn2k7).\nForce/clear require server admin. Tsunami requires coast; BypassEarthquakeForConsole=1 skips earthquake history for force commands. Equip Water Bucket, then press its hotbar key again to fill/use.";

		internal static Plugin? Instance { get; private set; }

		internal RuleSet Rules
		{
			get
			{
				RuleSet rules = settings.Capture().Rules;
				RuleSet ruleSet = network?.Effective?.Rules ?? rules;
				if (combined == null || localSource != rules || serverSource != ruleSet)
				{
					combined = new RuleSet();
					foreach (KeyValuePair<string, double> number in ruleSet.Numbers)
					{
						combined.Numbers[number.Key] = number.Value;
					}
					foreach (KeyValuePair<string, string> item in ruleSet.Text)
					{
						combined.Text[item.Key] = item.Value;
					}
					foreach (KeyValuePair<string, double> number2 in rules.Numbers)
					{
						if (number2.Key.StartsWith("Audio.", StringComparison.Ordinal) || number2.Key.StartsWith("VFX.", StringComparison.Ordinal) || number2.Key == "Forecast.ShowIcons")
						{
							combined.Numbers[number2.Key] = number2.Value;
						}
					}
					combined.Text["General.Language"] = rules.Text["General.Language"];
					localSource = rules;
					serverSource = ruleSet;
				}
				return combined;
			}
		}

		private void Awake()
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Invalid comparison between Unknown and I4
			Instance = this;
			settings = new WvdwsConfig(((BaseUnityPlugin)this).Config);
			assets = new AssetLoader(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), Path.Combine(Paths.ConfigPath, "WVDWS", "Assets"), Log);
			content = new ContentRegistry(assets, () => Rules, Log);
			harmony = new Harmony("wallachianvikings.WVDWS");
			harmony.PatchAll(typeof(Plugin).Assembly);
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new WvdwsConsoleCommand());
			CommandManager.Instance.AddConsoleCommand((ConsoleCommand)(object)new WvdwsAliasCommand());
			if ((int)SystemInfo.graphicsDeviceType != 4)
			{
				((MonoBehaviour)this).StartCoroutine(assets.Load());
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Natural Disasters 1.1.0 (WVDWS) loaded. Bug reports: ntldstr report, then post the file on https://discord.gg/qBJh7Bn2k7");
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Optional Seasons detected: " + ShudnalSeasonsCompatibility.Installed + "; no seasonal textures or terrain changes."));
		}

		private void OnEnable()
		{
			Instance = this;
		}

		private void Update()
		{
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Invalid comparison between Unknown and I4
			if (settings == null || faulted || Time.realtimeSinceStartup < nextTick)
			{
				return;
			}
			nextTick = Time.realtimeSinceStartup + 0.2f;
			watch.Restart();
			try
			{
				ZNet net = ZNet.instance;
				long num = ((Object.op_Implicit((Object)(object)net) && net.IsServer() && ZNet.GetWorldIfIsHost() != null) ? net.GetWorldUID() : 0);
				if (session != net || num != world)
				{
					CleanupSession();
					session = net;
					world = num;
					if (Object.op_Implicit((Object)(object)net))
					{
						history = new EventHistory();
						bucket = new WaterBucketService();
						network = new NetworkManager(zones, settings, ExecuteServer, Log);
						runtime = new EventRuntime(zones, history, assets, settings.Capture().Rules, delegate(long peer, ZPackage p)
						{
							network.SendOwner(peer, p);
						}, Log);
						network.OwnerAction = delegate(ZPackage p)
						{
							runtime.ApplyOwner(p);
						};
						network.BucketUse = (ZNetPeer peer) => bucket.Use(peer.m_uid, peer.m_refPos, peer.m_characterID, runtime, Rules, net.GetTimeSeconds());
						network.BucketReply = BucketReply;
						if (net.IsServer())
						{
							scheduler = new EventScheduler(zones, history, ZNet.GetWorldIfIsHost()?.m_seed ?? 0, net.GetTimeSeconds());
						}
						if ((int)SystemInfo.graphicsDeviceType != 4)
						{
							hud = new ForecastHud(settings, assets);
						}
					}
				}
				if (!Object.op_Implicit((Object)(object)net) || network == null || runtime == null)
				{
					return;
				}
				network.Tick();
				content?.Refresh();
				double timeSeconds = net.GetTimeSeconds();
				if (net.IsServer())
				{
					ServerSettings serverSettings = settings.Capture();
					if (!serverSettings.Enabled)
					{
						runtime.Clear(timeSeconds);
					}
					else
					{
						scheduler?.Tick(timeSeconds, serverSettings);
					}
				}
				if (settings.DebugLogging.Value)
				{
					foreach (EventInstance @event in zones.Events)
					{
						if (@event.StateAt(timeSeconds) != @event.CurrentState)
						{
							Log(@event.Id.ToString() + ": " + @event.CurrentState.ToString() + " -> " + @event.StateAt(timeSeconds));
						}
					}
				}
				runtime.Tick(timeSeconds, Rules);
				zones.Tick(timeSeconds);
				hud?.Tick(zones, timeSeconds);
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("WVDWS session safely stopped: " + ex));
				CleanupSession();
				faulted = true;
			}
			finally
			{
				watch.Stop();
				tickMs = watch.Elapsed.TotalMilliseconds;
			}
		}

		private void LateUpdate()
		{
			if (faulted || runtime == null || !Object.op_Implicit((Object)(object)ZNet.instance))
			{
				return;
			}
			try
			{
				runtime.Frame(ZNet.instance.GetTimeSeconds());
			}
			catch (Exception ex)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("WVDWS presentation stopped safely: " + ex));
				CleanupSession();
				faulted = true;
			}
		}

		internal string RunCommand(string line, Terminal context)
		{
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CommandRequest commandRequest = CommandRequest.Parse(line);
				if (commandRequest.Verb == "help")
				{
					return "ntldstr help | status | report\nntldstr event list | status | clear\nntldstr event force <event> [active-duration] [radius]\nntldstr diagnostic [duration] [radius]\n(wvdws works as an alias)\nreport writes a diagnostic file for Discord bug reports (https://discord.gg/qBJh7Bn2k7).\nForce/clear require server admin. Tsunami requires coast; BypassEarthquakeForConsole=1 skips earthquake history for force commands. Equip Water Bucket, then press its hotbar key again to fill/use.";
				}
				if (commandRequest.Verb == "list")
				{
					StringBuilder stringBuilder = new StringBuilder();
					foreach (EventDefinition item in EventDefinition.Catalog)
					{
						stringBuilder.AppendLine(item.Id + " - " + item.DisplayName);
					}
					return stringBuilder.ToString();
				}
				if (commandRequest.Verb == "status")
				{
					return Status();
				}
				if (commandRequest.Verb == "report")
				{
					return Report();
				}
				if (faulted && commandRequest.Verb == "clear")
				{
					CleanupSession();
					faulted = false;
					return "WVDWS cleared; session recovery enabled.";
				}
				if (!Object.op_Implicit((Object)(object)ZNet.instance) || network == null)
				{
					return "Enter a world first.";
				}
				if (ServerAuthority.IsServer)
				{
					return ExecuteServer(line, Object.op_Implicit((Object)(object)Player.m_localPlayer) ? new Vector3?(((Component)Player.m_localPlayer).transform.position) : ((Vector3?)null));
				}
				network.OnReply = delegate(string message)
				{
					if (Object.op_Implicit((Object)(object)context))
					{
						context.AddString(message);
					}
				};
				return network.SendCommand(line) ? "Request sent to server." : "WVDWS server handshake is not ready.";
			}
			catch (ArgumentException ex)
			{
				return ex.Message;
			}
		}

		private string ExecuteServer(string line, Vector3? position)
		{
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			if (!ServerAuthority.IsServer || runtime == null || scheduler == null)
			{
				return "Server authority is required.";
			}
			CommandRequest commandRequest = CommandRequest.Parse(line);
			double timeSeconds = ZNet.instance.GetTimeSeconds();
			if (commandRequest.Verb == "clear")
			{
				runtime.Clear(timeSeconds);
				return "WVDWS cleared: hazards stopped, event mobs removed, remaining visuals fading out.";
			}
			if (commandRequest.Verb != "force" && commandRequest.Verb != "diagnostic")
			{
				return "Unsupported remote operation.";
			}
			EventDefinition eventDefinition = EventDefinition.Find(commandRequest.EventId);
			if (eventDefinition == null)
			{
				return "Unknown event. Use ntldstr event list.";
			}
			ServerSettings serverSettings = settings.Capture();
			if (!serverSettings.Enabled)
			{
				return "WVDWS disabled in server config.";
			}
			if (commandRequest.Verb == "diagnostic" && !serverSettings.Diagnostics)
			{
				return "Enable General.EnableDiagnostics on the server first.";
			}
			if (!position.HasValue)
			{
				return "An in-world player must start an event. The server console can clear events.";
			}
			if (commandRequest.Verb == "force" && !serverSettings.Rules.B(EventScheduler.Section(commandRequest.EventId), "Enabled"))
			{
				return "This event is disabled on the server.";
			}
			if (!scheduler.Eligible(commandRequest.EventId, position.Value, timeSeconds, serverSettings.Rules, forced: true, out var _))
			{
				if (!(commandRequest.EventId == "tsunami"))
				{
					return "Blood Moon needs night, or ForceNightWhenConsoleTriggered enabled.";
				}
				return "Tsunami needs a broad nearby coast and a recent earthquake, unless Tsunami.BypassEarthquakeForConsole=1.";
			}
			EventInstance eventInstance = scheduler.Create(commandRequest.EventId, position.Value, timeSeconds, serverSettings, commandRequest.Duration, commandRequest.RadiusSpecified ? new double?(commandRequest.Radius) : ((double?)null), forced: true);
			List<PlayerPosition> list = new List<PlayerPosition>();
			foreach (var item in NetworkTargets.Players())
			{
				list.Add(new PlayerPosition(item.Owner, item.Position.x, item.Position.y, item.Position.z));
			}
			if (!zones.TryAdd(eventInstance, serverSettings.MaximumZones, new PlayerClusterService().Group(list, serverSettings.ClusterDistance)))
			{
				return "An event already occupies this zone/player cluster, or the zone limit was reached.";
			}
			history.Started(eventInstance.EventId, timeSeconds);
			Log("Started " + eventInstance.EventId + " " + eventInstance.Id.ToString() + " at " + ((object)position.Value/*cast due to .constrained prefix*/).ToString());
			return eventDefinition.DisplayName + " started at your position; active duration " + eventInstance.Duration + "s, radius " + eventInstance.Radius + "m.";
		}

		internal void UseBucket()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (network != null && runtime != null && Object.op_Implicit((Object)(object)Player.m_localPlayer))
			{
				if (ServerAuthority.IsServer)
				{
					Player localPlayer = Player.m_localPlayer;
					BucketReply(bucket.Use(ZNet.GetUID(), ((Component)localPlayer).transform.position, ((Character)localPlayer).GetZDOID(), runtime, Rules, ZNet.instance.GetTimeSeconds()));
				}
				else
				{
					network.RequestBucket();
				}
			}
		}

		private void BucketReply(string text)
		{
			if (text.StartsWith("WVDWS_BUCKET:", StringComparison.Ordinal))
			{
				string[] array = text.Split(':');
				if (array.Length >= 3)
				{
					int.TryParse(array[1], out var result);
					if (result >= 0)
					{
						WaterBucketService.LocalCharges = result;
					}
					text = array[2];
				}
			}
			if (Object.op_Implicit((Object)(object)MessageHud.instance))
			{
				MessageHud.instance.ShowMessage((MessageType)2, text, 0, (Sprite)null, false, true);
			}
			Log(text);
		}

		private string Status()
		{
			StringBuilder stringBuilder = new StringBuilder("Natural Disasters 1.1.0 | server=" + ServerAuthority.IsServer + " | fault=" + faulted + "\n");
			stringBuilder.AppendLine("Zones=" + zones.Events.Count + " | mobs=" + (runtime?.MobCount ?? 0) + " | fires=" + (runtime?.Fires ?? 0) + " | particle systems=" + (runtime?.VfxCount ?? 0) + " | tick=" + tickMs.ToString("F2") + "ms");
			stringBuilder.AppendLine("Assets ready=" + (assets?.Ready ?? false) + " | server sync=" + (network?.Effective != null));
			if (Object.op_Implicit((Object)(object)ZNet.instance))
			{
				double timeSeconds = ZNet.instance.GetTimeSeconds();
				foreach (EventInstance @event in zones.Events)
				{
					stringBuilder.AppendLine(@event.EventId + " " + @event.Id.ToString() + " " + @event.StateAt(timeSeconds).ToString() + " remaining=" + Math.Max(0.0, @event.EndTime - timeSeconds).ToString("F1") + "s");
				}
			}
			return stringBuilder.ToString();
		}

		private void Log(string message)
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)message);
			lock (recent)
			{
				recent.Enqueue(DateTime.Now.ToString("HH:mm:ss") + " " + message);
				while (recent.Count > 80)
				{
					recent.Dequeue();
				}
			}
		}

		private string Report()
		{
			try
			{
				string text = Path.Combine(Paths.ConfigPath, "WVDWS", "reports");
				Directory.CreateDirectory(text);
				string text2 = Path.Combine(text, "report-" + DateTime.Now.ToString("yyyyMMdd-HHmmss") + ".txt");
				StringBuilder stringBuilder = new StringBuilder();
				stringBuilder.AppendLine("Natural Disasters 1.1.0 bug report " + DateTime.Now.ToString("u"));
				stringBuilder.AppendLine("Game: " + Version.GetVersionString(false) + " | Jotunn: " + typeof(Main).Assembly.GetName().Version?.ToString() + " | BepInEx: " + typeof(BaseUnityPlugin).Assembly.GetName().Version);
				stringBuilder.AppendLine("Platform: " + SystemInfo.operatingSystem + " | GPU: " + SystemInfo.graphicsDeviceName + " | CPU: " + SystemInfo.processorType + " | RAM MB: " + SystemInfo.systemMemorySize);
				stringBuilder.AppendLine("Server: " + ServerAuthority.IsServer + " | dedicated: " + (Object.op_Implicit((Object)(object)ZNet.instance) && ZNet.instance.IsDedicated()) + " | peers: " + (Object.op_Implicit((Object)(object)ZNet.instance) ? ZNet.instance.GetNrOfPlayers() : 0) + " | assets ready: " + (assets?.Ready ?? false) + " (" + (assets?.AudioCount ?? 0) + " clips)");
				stringBuilder.AppendLine();
				stringBuilder.AppendLine("== status ==");
				stringBuilder.AppendLine(Status());
				stringBuilder.AppendLine("== effective rules ==");
				RuleSet rules = Rules;
				foreach (KeyValuePair<string, double> number in rules.Numbers)
				{
					stringBuilder.AppendLine(number.Key + " = " + number.Value.ToString(CultureInfo.InvariantCulture));
				}
				foreach (KeyValuePair<string, string> item in rules.Text)
				{
					stringBuilder.AppendLine(item.Key + " = " + item.Value);
				}
				stringBuilder.AppendLine();
				stringBuilder.AppendLine("== mod log (recent) ==");
				lock (recent)
				{
					foreach (string item2 in recent)
					{
						stringBuilder.AppendLine(item2);
					}
				}
				string path = Path.Combine(Paths.BepInExRootPath, "LogOutput.log");
				if (File.Exists(path))
				{
					stringBuilder.AppendLine();
					stringBuilder.AppendLine("== BepInEx LogOutput.log tail ==");
					string[] array;
					using (FileStream stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
					{
						using StreamReader streamReader = new StreamReader(stream);
						array = streamReader.ReadToEnd().Split('\n');
					}
					for (int i = Math.Max(0, array.Length - 250); i < array.Length; i++)
					{
						stringBuilder.AppendLine(array[i].TrimEnd());
					}
				}
				File.WriteAllText(text2, stringBuilder.ToString());
				string result = "Report written: " + text2 + "\nPost it on Discord: https://discord.gg/qBJh7Bn2k7";
				if (Object.op_Implicit((Object)(object)MessageHud.instance))
				{
					MessageHud.instance.ShowMessage((MessageType)2, "Bug report saved to BepInEx/config/WVDWS/reports", 0, (Sprite)null, false, true);
				}
				return result;
			}
			catch (Exception ex)
			{
				return "Report failed: " + ex.Message;
			}
		}

		private void CleanupSession()
		{
			runtime?.Dispose();
			runtime = null;
			network?.Dispose();
			network = null;
			hud?.Dispose();
			hud = null;
			scheduler = null;
			zones.Reset();
			session = null;
			world = 0L;
			WaterBucketService.LocalCharges = 0;
		}

		private void OnDisable()
		{
			CleanupSession();
			Instance = null;
		}

		private void OnDestroy()
		{
			CleanupSession();
			((MonoBehaviour)this).StopAllCoroutines();
			content?.Dispose();
			assets?.Dispose();
			Harmony? obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			Instance = null;
		}
	}
}
namespace WallachianVikings.WVDWS.Visuals
{
	internal sealed class EventVisualController : IDisposable
	{
		private readonly ParticlePool pool;

		private readonly AssetLoader assets;

		private readonly Random random;

		private readonly ParticleSystem? dust;

		private readonly ParticleSystem? clouds;

		private readonly ParticleSystem? sparks;

		private readonly ParticleSystem? flame;

		private readonly ParticleSystem? streaks;

		private readonly ParticleSystem? debris;

		public static float Detail = 0.75f;

		private readonly TornadoFunnel? funnel;

		private readonly OceanWaveController? ocean;

		private readonly Dictionary<int, GameObject> bolts = new Dictionary<int, GameObject>();

		private readonly Dictionary<int, GameObject> meteors = new Dictionary<int, GameObject>();

		private NativeVfxPool? snowPool;

		private NativeVfxPool? impactPool;

		private GameObject? snow;

		private readonly Dictionary<int, (GameObject Object, double End)> impactFx = new Dictionary<int, (GameObject, double)>();

		private readonly HashSet<int> seenImpacts = new HashSet<int>();

		private NativeVfxPool? meteorPool;

		private NativeVfxPool? firePool;

		private readonly Dictionary<int, GameObject> fires = new Dictionary<int, GameObject>();

		private readonly List<Light> lights = new List<Light>();

		private readonly List<(float Distance, Vector3 Point, float Scale)> lightCandidates = new List<(float, Vector3, float)>();

		private readonly Vector3[] boltPoints = (Vector3[])(object)new Vector3[25];

		private Light? flash;

		private double flashUntil;

		private readonly string id;

		private float frameBudget;

		private float rainBudget;

		private EventInstance? current;

		private static Transform? Eye
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)GameCamera.instance))
				{
					if (!Object.op_Implicit((Object)(object)Player.m_localPlayer))
					{
						return null;
					}
					return ((Component)Player.m_localPlayer).transform;
				}
				return ((Component)GameCamera.instance).transform;
			}
		}

		private void Flash(Vector3 p, double now)
		{
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)flash))
			{
				GameObject val = new GameObject("WVDWS_Flash");
				flash = val.AddComponent<Light>();
				flash.type = (LightType)2;
				flash.range = 140f;
				flash.intensity = 0f;
				flash.color = new Color(0.85f, 0.9f, 1f);
				flash.shadows = (LightShadows)0;
			}
			((Component)flash).transform.position = p;
			flash.intensity = ((Detail > 0.5f) ? 3.5f : 1.5f);
			((Behaviour)flash).enabled = true;
			flashUntil = now + 0.18 + random.NextDouble() * 0.15;
		}

		public EventVisualController(EventInstance e, ParticlePool pool, AssetLoader assets, int budget)
		{
			this.pool = pool;
			this.assets = assets;
			id = e.EventId;
			random = new Random(e.Seed);
			current = e;
			try
			{
				if (id == "wildfire" || id == "meteor" || id == "supercell")
				{
					firePool = new NativeVfxPool("fx_goblinking_beam_hit", 16, continuous: true);
				}
				switch (id)
				{
				case "tornado":
					dust = pool.Rent("smoke_03", Math.Max(2500, budget));
					clouds = pool.Rent("smoke_01", 1400);
					sparks = pool.Rent("dirt_01", 900);
					debris = pool.Rent("dirt_01", 600, 0f, 0.9f, 220f);
					streaks = pool.Rent("spark_01", 900, 0.16f);
					funnel = new TornadoFunnel(assets);
					break;
				case "blizzard":
					streaks = pool.Rent("whitePuff00", 3200, 0.05f);
					dust = pool.Rent("star_01", 1400);
					clouds = pool.Rent("smoke_01", 220);
					sparks = pool.Rent("whitePuff00", 500);
					break;
				case "sandstorm":
					dust = pool.Rent("dirt_01", Math.Max(1200, budget));
					streaks = pool.Rent("dirt_01", 1200, 0.07f);
					clouds = pool.Rent("smoke_01", 260);
					sparks = pool.Rent("spark_01", 200);
					break;
				case "tsunami":
					dust = pool.Rent("whitePuff00", 1200);
					sparks = pool.Rent("whitePuff00", 900, 0.06f);
					clouds = pool.Rent("smoke_01", 120);
					ocean = new OceanWaveController(e);
					break;
				case "meteor":
					dust = pool.Rent("smoke_03", 600);
					clouds = pool.Rent("smoke_01", 300);
					sparks = pool.Rent("spark_01", 1400);
					flame = pool.Rent("fire_01", 700);
					streaks = pool.Rent("spark_01", 700, 0.14f);
					meteorPool = new NativeVfxPool("projectile_meteor", 24);
					impactPool = new NativeVfxPool("fx_goblinking_meteor_hit", 12);
					break;
				case "supercell":
					dust = pool.Rent("smoke_03", 300);
					clouds = pool.Rent("smoke_01", 300);
					sparks = pool.Rent("spark_01", 300);
					streaks = pool.Rent("spark_01", 2200, 0.16f);
					flame = pool.Rent("fire_01", 400);
					impactPool = new NativeVfxPool("lightningAOE", 10);
					break;
				case "wildfire":
					dust = pool.Rent("smoke_03", 500);
					clouds = pool.Rent("smoke_01", 500);
					sparks = pool.Rent("spark_01", 1200);
					flame = pool.Rent("fire_01", Math.Max(900, budget / 2));
					break;
				case "earthquake":
					dust = pool.Rent("smoke_03", Math.Max(800, budget / 2));
					clouds = pool.Rent("smoke_01", 120);
					sparks = pool.Rent("spark_01", 200);
					debris = pool.Rent("dirt_01", 500, 0f, 1.6f, 120f);
					break;
				default:
					dust = pool.Rent((id == "volcanicash") ? "smoke_03" : "smoke_03", Math.Max(800, budget));
					clouds = pool.Rent("smoke_01", Math.Max(48, Math.Min(180, budget / 8)));
					sparks = pool.Rent("spark_01", Math.Max(400, budget / 3));
					break;
				}
				if (!(id == "blizzard"))
				{
					return;
				}
				foreach (EnvSetup environment in EnvMan.instance.m_environments)
				{
					GameObject[] array = environment.m_psystems ?? Array.Empty<GameObject>();
					foreach (GameObject val in array)
					{
						if (Object.op_Implicit((Object)(object)val) && ((Object)val).name.IndexOf("snow", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							try
							{
								snowPool = new NativeVfxPool(val, 1, continuous: true);
								snow = snowPool.Rent();
							}
							catch (Exception)
							{
								snowPool = null;
								snow = null;
							}
							break;
						}
					}
					if (snowPool != null)
					{
						break;
					}
				}
			}
			catch
			{
				Dispose();
				throw;
			}
		}

		private float R()
		{
			return (float)random.NextDouble();
		}

		private Vector3 Wind(EventInstance e)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)EnvMan.instance))
			{
				return EventGeometry.Direction(e);
			}
			return EnvMan.instance.GetWindDir();
		}

		public void Tick(EventInstance e, double now, RuleSet rules)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0781: Unknown result type (might be due to invalid IL or missing references)
			//IL_0786: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_130b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1302: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1310: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02de: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0394: Unknown result type (might be due to invalid IL or missing references)
			//IL_0399: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f66: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fa3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fa8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fd5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fda: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fde: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fe3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0feb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fed: Unknown result type (might be due to invalid IL or missing references)
			//IL_1001: Unknown result type (might be due to invalid IL or missing references)
			//IL_101c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c58: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c61: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c66: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c70: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c90: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0497: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d40: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d47: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d63: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d68: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d8a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0daa: Unknown result type (might be due to invalid IL or missing references)
			//IL_090b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d04: Unknown result type (might be due to invalid IL or missing references)
			//IL_104d: Unknown result type (might be due to invalid IL or missing references)
			//IL_104f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1056: Unknown result type (might be due to invalid IL or missing references)
			//IL_105b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1060: Unknown result type (might be due to invalid IL or missing references)
			//IL_1074: Unknown result type (might be due to invalid IL or missing references)
			//IL_108f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ddf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ded: Unknown result type (might be due to invalid IL or missing references)
			//IL_0df7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dfc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e17: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b60: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b62: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b69: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b78: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b7d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e51: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e56: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e6d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e72: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ebc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a59: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a62: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a67: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a76: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac9: Unknown result type (might be due to invalid IL or missing references)
			//IL_091f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0921: Unknown result type (might be due to invalid IL or missing references)
			//IL_0938: Unknown result type (might be due to invalid IL or missing references)
			//IL_095a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0964: Unknown result type (might be due to invalid IL or missing references)
			//IL_0969: Unknown result type (might be due to invalid IL or missing references)
			//IL_0984: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_059f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_1174: Unknown result type (might be due to invalid IL or missing references)
			//IL_11a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_11ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_11b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ecd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ecf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ed9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ede: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b29: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a21: Unknown result type (might be due to invalid IL or missing references)
			//IL_0697: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_128a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bdb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bdd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c05: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c20: Unknown result type (might be due to invalid IL or missing references)
			//IL_128f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1297: Unknown result type (might be due to invalid IL or missing references)
			//IL_129a: Unknown result type (might be due to invalid IL or missing references)
			//IL_12ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_12b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_126d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0712: Unknown result type (might be due to invalid IL or missing references)
			//IL_072b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1250: Unknown result type (might be due to invalid IL or missing references)
			//IL_1233: Unknown result type (might be due to invalid IL or missing references)
			//IL_1216: Unknown result type (might be due to invalid IL or missing references)
			//IL_1681: Unknown result type (might be due to invalid IL or missing references)
			//IL_18cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_13f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_17dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_17df: Unknown result type (might be due to invalid IL or missing references)
			//IL_17e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_17ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_1823: Unknown result type (might be due to invalid IL or missing references)
			//IL_183c: Unknown result type (might be due to invalid IL or missing references)
			//IL_186a: Unknown result type (might be due to invalid IL or missing references)
			//IL_186c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1876: Unknown result type (might be due to invalid IL or missing references)
			//IL_188f: Unknown result type (might be due to invalid IL or missing references)
			//IL_143d: Unknown result type (might be due to invalid IL or missing references)
			//IL_143f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1449: Unknown result type (might be due to invalid IL or missing references)
			//IL_144e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1489: Unknown result type (might be due to invalid IL or missing references)
			//IL_149e: Unknown result type (might be due to invalid IL or missing references)
			//IL_19da: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a0b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a10: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a15: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a4e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a53: Unknown result type (might be due to invalid IL or missing references)
			//IL_1a69: Unknown result type (might be due to invalid IL or missing references)
			//IL_1974: Unknown result type (might be due to invalid IL or missing references)
			//IL_1976: Unknown result type (might be due to invalid IL or missing references)
			//IL_1980: Unknown result type (might be due to invalid IL or missing references)
			//IL_1985: Unknown result type (might be due to invalid IL or missing references)
			//IL_1996: Unknown result type (might be due to invalid IL or missing references)
			//IL_19b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_14e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_14e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_14ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_14f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_14f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_1510: Unknown result type (might be due to invalid IL or missing references)
			//IL_152b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ab6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ab8: Unknown result type (might be due to invalid IL or missing references)
			//IL_1acf: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ad4: Unknown result type (might be due to invalid IL or missing references)
			//IL_1ad9: Unknown result type (might be due to invalid IL or missing references)
			//IL_1af0: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b12: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b1c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b21: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b37: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b71: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b73: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b8a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1b94: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bab: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bb2: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bbc: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bc1: Unknown result type (might be due to invalid IL or missing references)
			//IL_1bdd: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c0d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c0f: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c11: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c16: Unknown result type (might be due to invalid IL or missing references)
			//IL_1c32: Unknown result type (might be due to invalid IL or missing references)
			//IL_1588: Unknown result type (might be due to invalid IL or missing references)
			//IL_158a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1594: Unknown result type (might be due to invalid IL or missing references)
			//IL_1599: Unknown result type (might be due to invalid IL or missing references)
			//IL_15b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_15c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_15e3: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)e.TemporalIntensity(now);
			Player localPlayer = Player.m_localPlayer;
			float num2 = (Object.op_Implicit((Object)(object)localPlayer) ? EventGeometry.Intensity(e, ((Component)localPlayer).transform.position, now) : 0f);
			Vector3 val = EventGeometry.Origin(e);
			Vector3 val2 = EventGeometry.Center(e, now, rules);
			float num3 = Mathf.Clamp(rules.N("VFX", "ParticleDensity"), 0f, 3f) * Detail;
			if (id == "sandstorm")
			{
				num3 *= Mathf.Clamp(rules.N("Sandstorm", "ParticleDensity"), 0f, 3f);
			}
			if (id == "volcanicash")
			{
				num3 *= Mathf.Clamp(rules.N("VolcanicAsh", "AshDensity"), 0f, 3f);
			}
			ocean?.Tick(now, rules);
			if (funnel != null)
			{
				DisasterPhysics.RegisterTornado(e, rules);
			}
			Vector3 val10;
			if (id == "tornado" && num > 0.001f)
			{
				int val3 = (int)(26f * num * num3 * rules.N("Tornado", "DebrisDensity"));
				Vector3 val4 = Wind(e);
				Vector3 val5 = default(Vector3);
				for (int i = 0; i < Math.Min(80, val3); i++)
				{
					float num4 = R() * MathF.PI * 2f;
					float num5 = 6f + R() * 30f;
					Vector3 position = val2 + new Vector3(Mathf.Cos(num4) * num5, 0.5f + R() * 3f, Mathf.Sin(num4) * num5);
					((Vector3)(ref val5))..ctor(0f - Mathf.Sin(num4), 0f, Mathf.Cos(num4));
					ParticlePool.Emit(dust, position, val5 * (10f + R() * 10f) - new Vector3(Mathf.Cos(num4), 0f, Mathf.Sin(num4)) * 3f + Vector3.up * (1f + R() * 3f), new Color(0.42f, 0.36f, 0.27f, 0.5f * num), 5f + R() * 7f, 2.4f, R() * 360f);
					if (i % 3 == 0)
					{
						ParticlePool.Emit(debris, val2 + new Vector3(Mathf.Cos(num4) * num5 * 0.6f, 1f, Mathf.Sin(num4) * num5 * 0.6f), val5 * (14f + R() * 10f) + Vector3.up * (9f + R() * 10f), new Color(0.3f, 0.24f, 0.16f, num), 0.35f + R() * 0.6f, 3.2f, R() * 360f);
					}
				}
				for (int j = 0; j < Mathf.CeilToInt(3f * num3); j++)
				{
					float num6 = R() * MathF.PI * 2f;
					float num7 = 30f + R() * 90f;
					ParticlePool.Emit(clouds, val2 + new Vector3(Mathf.Cos(num6) * num7, 86f + R() * 20f, Mathf.Sin(num6) * num7), new Vector3(0f - Mathf.Sin(num6), 0f, Mathf.Cos(num6)) * 4f + val4, new Color(0.16f, 0.17f, 0.17f, 0.85f * num), 40f + R() * 30f, 7f, R() * 360f);
				}
				for (int k = 0; k < Mathf.CeilToInt(12f * num3); k++)
				{
					float num8 = R() * MathF.PI * 2f;
					float num9 = 90f + R() * 260f;
					float num10 = 0.1f + R() * 0.1f;
					ParticlePool.Emit(clouds, val2 + new Vector3(Mathf.Cos(num8) * num9, 102f + R() * 45f, Mathf.Sin(num8) * num9), new Vector3(0f - Mathf.Sin(num8), 0f, Mathf.Cos(num8)) * (2f + R() * 3f) + val4 * 1.5f, new Color(num10, num10, num10 + 0.02f, 0.9f * num), 55f + R() * 45f, 10f, R() * 360f);
				}
				for (int l = 0; l < Mathf.CeilToInt(4f * num3); l++)
				{
					float num11 = R() * MathF.PI * 2f;
					float num12 = 60f + R() * 140f;
					ParticlePool.Emit(clouds, val2 + new Vector3(Mathf.Cos(num11) * num12, 25f + R() * 35f, Mathf.Sin(num11) * num12), -new Vector3(Mathf.Cos(num11), 0f, Mathf.Sin(num11)) * (8f + R() * 6f) + new Vector3(0f - Mathf.Sin(num11), 0f, Mathf.Cos(num11)) * 6f, new Color(0.3f, 0.3f, 0.31f, 0.55f * num), 18f + R() * 16f, 5f, R() * 360f);
				}
				if (R() < 0.22f * num)
				{
					float num13 = R() * MathF.PI * 2f;
					float num14 = 40f + R() * 160f;
					Vector3 val6 = val2 + new Vector3(Mathf.Cos(num13) * num14, 112f + R() * 30f, Mathf.Sin(num13) * num14);
					Flash(val6, now);
					for (int m = 0; m < 14; m++)
					{
						ParticlePool.Emit(sparks, val6, new Vector3((R() - 0.5f) * 10f, (0f - R()) * 12f, (R() - 0.5f) * 10f), new Color(0.9f, 0.95f, 1f, 0.9f), 0.6f + R() * 0.6f, 0.5f);
					}
				}
			}
			else if (num2 > 0.001f && Object.op_Implicit((Object)(object)localPlayer))
			{
				Vector3 position2 = ((Component)localPlayer).transform.position;
				int num15 = Math.Min(150, (int)(60f * num2 * num3));
				Vector3 val7 = Wind(e);
				for (int n = 0; n < num15; n++)
				{
					Vector3 val8 = position2 + new Vector3((R() - 0.5f) * 55f, R() * 18f + 2f, (R() - 0.5f) * 55f);
					switch (id)
					{
					case "earthquake":
					{
						if (n % 2 == 0 && WorldQuery.Surface(val8, out var ground2))
						{
							ParticlePool.Emit(dust, ground2, Vector3.up * (1f + R() * 2.5f) + new Vector3(R() - 0.5f, 0f, R() - 0.5f) * 2f, new Color(0.55f, 0.48f, 0.36f, 0.4f * num2), 1.5f + R() * 3f, 3.2f, R() * 360f);
							if (n % 6 == 0)
							{
								ParticlePool.Emit(debris, ground2 + Vector3.up * 0.3f, new Vector3((R() - 0.5f) * 4f, 3f + R() * 5f, (R() - 0.5f) * 4f), new Color(0.4f, 0.33f, 0.24f, num2), 0.12f + R() * 0.22f, 2.2f, R() * 360f);
							}
						}
						break;
					}
					case "sandstorm":
						ParticlePool.Emit(dust, val8, val7 * 24f - Vector3.up * 2f + new Vector3(R() - 0.5f, R() - 0.5f, R() - 0.5f) * 4f, new Color(0.72f, 0.53f, 0.29f, 0.6f * num2), 0.6f + R() * 1.4f, 2.6f, R() * 360f);
						if (n % 3 == 0)
						{
							ParticlePool.Emit(clouds, val8, val7 * 16f, new Color(0.6f, 0.42f, 0.2f, 0.4f * num2), 9f + R() * 6f, 3f);
						}
						break;
					case "blizzard":
					{
						if (n % 4 == 0)
						{
							ParticlePool.Emit(dust, val8, val7 * 12f - Vector3.up * 3f, new Color(0.92f, 0.97f, 1f, 0.9f * num2), 0.2f + R() * 0.25f, 3f);
						}
						if (n % 6 == 0 && WorldQuery.Surface(val8, out var ground3))
						{
							ParticlePool.Emit(sparks, ground3 + Vector3.up * 0.6f, val7 * (18f + R() * 8f), new Color(0.9f, 0.95f, 1f, 0.28f * num2), 3f + R() * 5f, 1.8f, R() * 360f);
						}
						break;
					}
					case "volcanicash":
						ParticlePool.Emit(dust, val8, val7 * 3f - Vector3.up * 1.5f, new Color(0.65f, 0.62f, 0.6f, 0.9f * num2), 0.15f + R() * 0.3f, 5f);
						if (n % 2 == 0)
						{
							ParticlePool.Emit(sparks, val8, val7 * 3f - Vector3.up * (0.5f + R()), new Color(1f, 0.18f, 0.02f, 0.95f * num2), 0.1f + R() * 0.22f, 4.5f);
						}
						break;
					case "meteor":
						if (n % 2 == 0)
						{
							ParticlePool.Emit(sparks, val8, val7 * 2.5f + Vector3.up * (0.6f + R() * 1.2f) + new Vector3(R() - 0.5f, 0f, R() - 0.5f), new Color(1f, 0.42f, 0.06f, 0.9f * num2), 0.08f + R() * 0.16f, 4.5f);
						}
						if (n % 5 == 0)
						{
							ParticlePool.Emit(dust, val8, val7 * 2f - Vector3.up * 1.2f, new Color(0.35f, 0.3f, 0.28f, 0.55f * num2), 0.4f + R() * 0.8f, 5f);
						}
						break;
					case "wildfire":
						ParticlePool.Emit(sparks, val8, val7 * 2.5f + Vector3.up * (1f + R() * 1.5f), new Color(1f, 0.3f, 0.03f, 0.8f * num2), 0.06f + R() * 0.1f, 4f);
						break;
					case "bloodmoon":
					{
						if (n % 12 == 0 && WorldQuery.Surface(val8, out var ground))
						{
							ParticlePool.Emit(clouds, ground + Vector3.up * 1.2f, val7 * 0.6f, new Color(0.55f, 0.05f, 0.03f, 0.22f * num2), 10f + R() * 8f, 7f, R() * 360f);
						}
						break;
					}
					}
				}
				if (id == "meteor" && R() < 0.7f)
				{
					Vector3 val9 = position2 + new Vector3((R() - 0.5f) * 320f, 90f + R() * 70f, (R() - 0.5f) * 320f);
					val10 = new Vector3(R() - 0.5f, 0f - (0.35f + R() * 0.5f), R() - 0.5f);
					Vector3 normalized = ((Vector3)(ref val10)).normalized;
					ParticlePool.Emit(streaks, val9, normalized * (70f + R() * 50f), new Color(1f, 0.85f, 0.6f, 0.9f * num), 1.1f + R() * 0.8f, 1.1f);
					for (int num16 = 0; num16 < 5; num16++)
					{
						ParticlePool.Emit(sparks, val9 + normalized * (float)(num16 * 3), normalized * (40f + R() * 20f), new Color(1f, 0.6f, 0.2f, 0.8f * num), 0.35f, 0.9f);
					}
				}
			}
			if (num > 0.01f && id != "earthquake" && id != "tsunami" && id != "bloodmoon" && id != "tornado")
			{
				float num17 = Mathf.Clamp(rules.N("VFX", "CloudDensity"), 0f, 6f) * num3;
				int num18 = Math.Min(10, Mathf.CeilToInt(3f * num17));
				for (int num19 = 0; num19 < num18; num19++)
				{
					int num20 = num19 % 3;
					float num21 = (float)e.Radius * ((num20 == 0) ? 1.3f : 1.9f);
					Vector3 position3 = val + new Vector3((R() - 0.5f) * num21, (float)(40 + num20 * 28) + R() * 16f, (R() - 0.5f) * num21);
					Color color = ((id == "wildfire") ? new Color(0.2f, 0.11f, 0.075f, 0.65f * num) : ((id == "sandstorm") ? new Color(0.45f, 0.31f, 0.15f, 0.65f * num) : ((id == "blizzard") ? new Color(0.38f, 0.43f, 0.48f, 0.8f * num) : ((id == "volcanicash") ? new Color(0.065f, 0.055f, 0.05f, 0.85f * num) : new Color(0.1f, 0.12f, 0.15f, 0.8f * num)))));
					ParticlePool.Emit(clouds, position3, EventGeometry.Direction(e) * (1f + (float)num20 * 0.7f), color, 40f + R() * 35f, 10 + num20 * 2, R() * 360f);
				}
			}
			lightCandidates.Clear();
			Vector3 val11 = (Object.op_Implicit((Object)(object)localPlayer) ? ((Component)localPlayer).transform.position : val);
			Vector3 val12 = default(Vector3);
			foreach (EventHazard hazard in e.Hazards)
			{
				((Vector3)(ref val12))..ctor((float)hazard.X, (float)hazard.Y, (float)hazard.Z);
				double num22 = hazard.Start + ((hazard.Kind == HazardKind.Meteor) ? 2.5 : 0.0);
				if (impactPool != null && (hazard.Kind == HazardKind.Lightning || hazard.Kind == HazardKind.Meteor) && now >= num22 && now < num22 + 0.5 && !e.ClearTime.HasValue && seenImpacts.Add(hazard.Id))
				{
					GameObject val13 = impactPool.Rent();
					if (Object.op_Implicit((Object)(object)val13))
					{
						val13.transform.position = val12;
						impactFx[hazard.Id] = (val13, now + 2.0);
					}
					if (hazard.Kind == HazardKind.Meteor)
					{
						for (int num23 = 0; num23 < 45; num23++)
						{
							ParticlePool.Emit(sparks, val12 + Vector3.up * 0.5f, new Vector3((R() - 0.5f) * 26f, 4f + R() * 18f, (R() - 0.5f) * 26f), new Color(1f, 0.45f, 0.05f, num), 0.3f + R() * 0.4f, 1.8f);
						}
						for (int num24 = 0; num24 < 8; num24++)
						{
							ParticlePool.Emit(clouds, val12 + Vector3.up * (float)(2 + num24 * 2), Vector3.up * (5f + R() * 4f), new Color(0.25f, 0.22f, 0.2f, 0.7f * num), 6f + R() * 6f, 5f, R() * 360f);
						}
						for (int num25 = 0; num25 < 18; num25++)
						{
							float num26 = R() * MathF.PI * 2f;
							ParticlePool.Emit(dust, val12 + Vector3.up * 0.5f, new Vector3(Mathf.Cos(num26), 0.15f, Mathf.Sin(num26)) * (12f + R() * 10f), new Color(0.5f, 0.42f, 0.3f, 0.65f * num), 3f + R() * 3f, 2.2f, R() * 360f);
						}
					}
				}
				if (hazard.Kind == HazardKind.Lightning)
				{
					if (!bolts.TryGetValue(hazard.Id, out GameObject value) && now >= hazard.Start && now < hazard.Start + 1.5 && !e.ClearTime.HasValue)
					{
						value = (bolts[hazard.Id] = Bolt(e, hazard, val12));
					}
					if (bolts.TryGetValue(hazard.Id, out GameObject value2))
					{
						value2.SetActive(!e.ClearTime.HasValue && now < hazard.Start + 0.95);
					}
				}
				if (hazard.Kind == HazardKind.Meteor && meteorPool != null)
				{
					GameObject value4;
					if (now >= hazard.Start && now < hazard.Start + 2.5 && !e.ClearTime.HasValue)
					{
						if (!meteors.TryGetValue(hazard.Id, out GameObject value3))
						{
							value3 = meteorPool.Rent();
							if (Object.op_Implicit((Object)(object)value3))
							{
								meteors[hazard.Id] = value3;
							}
						}
					}
					else if (meteors.TryGetValue(hazard.Id, out value4))
					{
						meteorPool.Return(value4);
						meteors.Remove(hazard.Id);
					}
				}
				if (hazard.Kind == HazardKind.Splash && now >= hazard.Start && now < hazard.End && !e.ClearTime.HasValue)
				{
					for (int num27 = 0; num27 < 12; num27++)
					{
						ParticlePool.Emit(sparks, val12 + Vector3.up * 0.6f, new Vector3((R() - 0.5f) * 8f, R() * 5f, (R() - 0.5f) * 8f), new Color(0.55f, 0.8f, 1f, 0.65f), 0.09f, 0.7f);
					}
					ParticlePool.Emit(clouds, val12, Vector3.up * 1.8f, new Color(0.9f, 0.95f, 1f, 0.25f), 2f, 1.2f);
				}
				if (hazard.Kind != HazardKind.Fire || !(now < hazard.End) || !(num > 0f) || !WorldQuery.Surface(val12, out var ground4))
				{
					continue;
				}
				float num28 = Mathf.Min(num, Mathf.Clamp01((float)(hazard.End - now)));
				float num29 = (float)hazard.Scale;
				if (firePool != null)
				{
					if (!fires.TryGetValue(hazard.Id, out GameObject value5) && fires.Count < Mathf.CeilToInt(16f * Detail))
					{
						value5 = firePool.Rent();
						if (Object.op_Implicit((Object)(object)value5))
						{
							fires[hazard.Id] = value5;
						}
					}
					if (Object.op_Implicit((Object)(object)value5))
					{
						value5.transform.position = ground4 + Vector3.up * 0.05f;
						value5.transform.localScale = Vector3.one * Mathf.Max(0.01f, num29 * 1.4f * num28);
					}
				}
				int num30 = Mathf.CeilToInt(5f * Detail);
				for (int num31 = 0; num31 < num30; num31++)
				{
					ParticlePool.Emit(flame, ground4 + new Vector3((R() - 0.5f) * 2.4f * num29, 0.2f, (R() - 0.5f) * 2.4f * num29), Vector3.up * (2.5f + R() * 3f) + new Vector3(R() - 0.5f, 0f, R() - 0.5f), new Color(1f, 0.45f, 0.1f, num28), 1.6f * num29 + R() * 1.2f, 1.1f, R() * 360f);
				}
				for (int num32 = 0; num32 < 3; num32++)
				{
					ParticlePool.Emit(sparks, ground4 + Vector3.up * (1f + R() * 2f), Vector3.up * (3f + R() * 5f) + new Vector3(R() - 0.5f, 0f, R() - 0.5f) * 4f, new Color(1f, 0.5f, 0.08f, num28), 0.08f + R() * 0.12f, 2.5f);
				}
				ParticlePool.Emit(clouds, ground4 + Vector3.up * (2.5f + R() * 2f), Vector3.up * (2.5f + R() * 2f) + Wind(e) * 2f, new Color(0.22f, 0.18f, 0.15f, 0.5f * num28), num29 * 3.5f + R() * 2f, 5f, R() * 360f);
				val10 = ground4 - val11;
				float sqrMagnitude = ((Vector3)(ref val10)).sqrMagnitude;
				if (sqrMagnitude < 4900f)
				{
					lightCandidates.Add((sqrMagnitude, ground4, num29 * num28));
				}
			}
			UpdateLights(rules);
			List<int> list = new List<int>();
			foreach (KeyValuePair<int, (GameObject, double)> item in impactFx)
			{
				if (now >= item.Value.Item2 || e.ClearTime.HasValue)
				{
					list.Add(item.Key);
				}
			}
			foreach (int item2 in list)
			{
				impactPool?.Return(impactFx[item2].Object);
				impactFx.Remove(item2);
			}
			List<int> list2 = new List<int>();
			foreach (KeyValuePair<int, GameObject> fire in fires)
			{
				bool flag = false;
				foreach (EventHazard hazard2 in e.Hazards)
				{
					if (hazard2.Id == fire.Key && hazard2.Kind == HazardKind.Fire && now < hazard2.End && num > 0f)
					{
						flag = true;
					}
				}
				if (!flag)
				{
					list2.Add(fire.Key);
				}
			}
			foreach (int item3 in list2)
			{
				firePool?.Return(fires[item3]);
				fires.Remove(item3);
			}
			List<int> list3 = new List<int>();
			foreach (KeyValuePair<int, GameObject> bolt in bolts)
			{
				bool flag2 = false;
				foreach (EventHazard hazard3 in e.Hazards)
				{
					if (hazard3.Id == bolt.Key)
					{
						flag2 = true;
					}
				}
				if (!flag2)
				{
					list3.Add(bolt.Key);
				}
			}
			foreach (int item4 in list3)
			{
				Object.Destroy((Object)(object)bolts[item4]);
				bolts.Remove(item4);
			}
		}

		private GameObject Bolt(EventInstance e, EventHazard h, Vector3 p)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: 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_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("WVDWS_Lightning");
			LineRenderer val2 = val.AddComponent<LineRenderer>();
			((Renderer)val2).sharedMaterial = assets.Particle("spark_01");
			val2.positionCount = 25;
			val2.widthMultiplier = 1.15f;
			val2.startColor = Color.white;
			val2.endColor = new Color(0.7f, 0.82f, 1f);
			val2.useWorldSpace = true;
			Random random = new Random(e.Seed ^ h.Id);
			Vector3 val3 = p + Vector3.up * 95f;
			for (int i = 0; i < 25; i++)
			{
				Vector3 val4 = Vector3.Lerp(val3, p, (float)i / 24f);
				if (i > 0 && i < 24)
				{
					val4 += new Vector3((float)random.NextDouble() * 10f - 5f, 0f, (float)random.NextDouble() * 10f - 5f);
				}
				boltPoints[i] = val4;
			}
			val2.SetPositions(boltPoints);
			for (int j = 0; j < 5; j++)
			{
				GameObject val5 = new GameObject("Branch");
				val5.transform.SetParent(val.transform, false);
				LineRenderer val6 = val5.AddComponent<LineRenderer>();
				((Renderer)val6).sharedMaterial = ((Renderer)val2).sharedMaterial;
				val6.widthMultiplier = 0.3f;
				val6.startColor = Color.white;
				val6.endColor = new Color(0.4f, 0.55f, 1f, 0.1f);
				val6.positionCount = 7;
				val6.useWorldSpace = true;
				Vector3 val7 = boltPoints[3 + j * 4];
				float num = (float)random.NextDouble() * 4f - 2f;
				float num2 = (float)random.NextDouble() * 4f - 2f;
				for (int k = 0; k < 7; k++)
				{
					val6.SetPosition(k, val7 + new Vector3(num * (float)k + (float)random.NextDouble() * 2f - 1f, (float)(-k) * 3.5f, num2 * (float)k + (float)random.NextDouble() * 2f - 1f));
				}
			}
			Light obj = val.AddComponent<Light>();
			obj.type = (LightType)2;
			obj.range = 70f;
			obj.intensity = ((Detail > 0.6f) ? 5.5f : 2.5f);
			obj.color = new Color(0.8f, 0.88f, 1f);
			obj.shadows = (LightShadows)0;
			val.transform.position = p + Vector3.up * 6f;
			for (int l = 0; l < 20; l++)
			{
				ParticlePool.Emit(sparks, p + Vector3.up * 0.5f, new Vector3((R() - 0.5f) * 14f, 3f + R() * 10f, (R() - 0.5f) * 14f), new Color(0.9f, 0.95f, 1f, 1f), 0.25f + R() * 0.3f, 0.9f);
			}
			return val;
		}

		private void UpdateLights(RuleSet rules)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			int num = ((Detail > 0.5f) ? Mathf.Clamp((int)rules.N("Wildfire", "FireLights"), 0, 8) : 0);
			lightCandidates.Sort(((float Distance, Vector3 Point, float Scale) a, (float Distance, Vector3 Point, float Scale) b) => a.Distance.CompareTo(b.Distance));
			while (lights.Count < Math.Min(num, lightCandidates.Count))
			{
				Light val = new GameObject("WVDWS_FireLight").AddComponent<Light>();
				val.type = (LightType)2;
				val.color = new Color(1f, 0.55f, 0.18f);
				val.range = 16f;
				val.intensity = 2.4f;
				val.shadows = (LightShadows)0;
				lights.Add(val);
			}
			for (int num2 = 0; num2 < lights.Count; num2++)
			{
				bool flag = num2 < num && num2 < lightCandidates.Count;
				((Behaviour)lights[num2]).enabled = flag;
				if (flag)
				{
					((Component)lights[num2]).transform.position = lightCandidates[num2].Point + Vector3.up * 2.5f;
					lights[num2].range = 12f + 6f * lightCandidates[num2].Scale;
				}
			}
		}

		public void Frame(EventInstance e, double now, RuleSet rules)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0682: Unknown result type (might be due to invalid IL or missing references)
			//IL_068c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_0696: Unknown result type (might be due to invalid IL or missing references)
			//IL_069d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_080d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0814: Unknown result type (might be due to invalid IL or missing references)
			//IL_081e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0823: Unknown result type (might be due to invalid IL or missing references)
			//IL_0828: Unknown result type (might be due to invalid IL or missing references)
			//IL_082f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0834: Unknown result type (might be due to invalid IL or missing references)
			//IL_0839: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0372: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0711: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Unknown result type (might be due to invalid IL or missing references)
			//IL_072d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0732: Unknown result type (might be due to invalid IL or missing references)
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0765: Unknown result type (might be due to invalid IL or missing references)
			//IL_076a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0785: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_09bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_0519: Unknown result type (might be due to invalid IL or missing references)
			//IL_0843: Unknown result type (might be due to invalid IL or missing references)
			//IL_087b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0880: Unknown result type (might be due to invalid IL or missing references)
			//IL_0885: Unknown result type (might be due to invalid IL or missing references)
			//IL_088d: Unknown result type (might be due to invalid IL or missing references)
			//IL_088f: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_056d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a38: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a45: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a47: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a60: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a65: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a80: Unknown result type (might be due to invalid IL or missing references)
			//IL_0572: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_057c: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0591: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b41: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b46: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b51: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b56: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b61: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b63: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b67: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b6c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b75: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b85: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bdf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bf1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c12: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c14: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c2c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c2e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c45: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c78: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c7d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c92: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ccc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cd0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d2e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d30: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d3c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d41: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d43: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d52: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d57: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d72: Unknown result type (might be due to invalid IL or missing references)
			//IL_0db5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0db7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dbe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dc3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dc8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dd4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dd9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e03: Unknown result type (might be due to invalid IL or missing references)
			float num = (float)e.TemporalIntensity(now);
			Player localPlayer = Player.m_localPlayer;
			float num2 = (Object.op_Implicit((Object)(object)localPlayer) ? EventGeometry.Intensity(e, ((Component)localPlayer).transform.position, now) : 0f);
			float num3 = Mathf.Min(0.05f, Time.deltaTime);
			float num4 = Mathf.Clamp(rules.N("VFX", "ParticleDensity"), 0f, 3f) * Detail;
			if (Object.op_Implicit((Object)(object)snow))
			{
				snow.SetActive((double)num > 0.01 && num2 > 0.01f);
				if (Object.op_Implicit((Object)(object)localPlayer))
				{
					snow.transform.position = ((Component)localPlayer).transform.position;
				}
			}
			ocean?.Frame(now, dust, sparks, Detail * num);
			Vector3 val = EventGeometry.Center(e, now, rules);
			if (funnel != null)
			{
				funnel.Tick(val, now, num, rules.N("Tornado", "FunnelDensity"));
			}
			float num5 = (float)now;
			for (int i = 0; i < lights.Count; i++)
			{
				if (((Behaviour)lights[i]).enabled)
				{
					lights[i].intensity = 2.2f * (0.75f + 0.35f * Mathf.PerlinNoise(num5 * 9f + (float)i * 3.1f, (float)i));
				}
			}
			if (Object.op_Implicit((Object)(object)flash) && ((Behaviour)flash).enabled && now >= flashUntil)
			{
				((Behaviour)flash).enabled = false;
			}
			Transform eye = Eye;
			Vector3 val2 = Wind(e);
			Vector3 val5;
			switch (id)
			{
			case "tornado":
			{
				if (num <= 0.001f)
				{
					break;
				}
				if (Object.op_Implicit((Object)(object)eye))
				{
					val5 = eye.position - val;
					if (((Vector3)(ref val5)).sqrMagnitude < 19600f)
					{
						rainBudget += 500f * num3 * num4 * num;
						int num9 = Mathf.Min(40, (int)rainBudget);
						rainBudget -= num9;
						Vector3 val10 = eye.position + eye.forward * 7f;
						Vector3 val11 = val - eye.position;
						val11.y = 0f;
						((Vector3)(ref val11)).Normalize();
						for (int m = 0; m < num9; m++)
						{
							Vector3 position3 = val10 + new Vector3((R() - 0.5f) * 30f, 5f + R() * 12f, (R() - 0.5f) * 30f);
							ParticlePool.Emit(streaks, position3, val11 * 9f + Vector3.down * (16f + R() * 5f) + new Vector3(0f - val11.z, 0f, val11.x) * 4f, new Color(0.6f, 0.68f, 0.8f, 0.5f * num), 0.07f, 0.8f);
						}
					}
				}
				frameBudget += 1000f * num3 * num4 * Mathf.Clamp(rules.N("Tornado", "FunnelDensity"), 0f, 2f) * num;
				int num10 = Mathf.Min(80, (int)frameBudget);
				frameBudget -= num10;
				Vector3 val12 = default(Vector3);
				for (int n = 0; n < num10; n++)
				{
					float num11 = Mathf.Pow(R(), 0.75f) * 92f * 0.96f;
					float num12 = R() * MathF.PI * 2f;
					float num13 = num11 / 92f;
					bool flag2 = n % 3 == 0;
					float num14 = TornadoFunnel.Radius(num13) * (flag2 ? (0.3f + R() * 0.4f) : (0.8f + R() * 0.7f));
					float num15 = Mathf.Sin(num13 * 3.2f + num5 * 0.35f) * num13 * 7f + Mathf.Sin(num13 * 7f - num5 * 0.9f) * num13 * 2.5f;
					float num16 = Mathf.Cos(num13 * 2.7f + num5 * 0.28f) * num13 * 6f;
					Vector3 position4 = val + new Vector3(Mathf.Cos(num12) * num14 + num15, num11, Mathf.Sin(num12) * num14 + num16);
					((Vector3)(ref val12))..ctor(0f - Mathf.Sin(num12), 0f, Mathf.Cos(num12));
					Color color = (flag2 ? new Color(0.2f, 0.2f, 0.19f, 0.7f * num) : new Color(0.4f, 0.38f, 0.34f, 0.42f * num));
					ParticlePool.Emit(dust, position4, val12 * (13f + num11 * 0.3f) + Vector3.up * (3f + R() * 5f) - new Vector3(Mathf.Cos(num12), 0f, Mathf.Sin(num12)) * 2f, color, 2.5f + num11 * 0.1f + R() * 2f, 2f + R() * 1.2f, R() * 360f);
				}
				break;
			}
			case "blizzard":
				if (!(num2 <= 0.001f) && Object.op_Implicit((Object)(object)eye))
				{
					frameBudget += 2000f * num3 * num4 * num2;
					int num17 = Mathf.Min(120, (int)frameBudget);
					frameBudget -= num17;
					Vector3 val13 = eye.position + eye.forward * 9f - val2 * 6f;
					for (int num18 = 0; num18 < num17; num18++)
					{
						Vector3 position5 = val13 + new Vector3((R() - 0.5f) * 40f, R() * 16f - 2f, (R() - 0.5f) * 40f);
						ParticlePool.Emit(streaks, position5, val2 * (15f + R() * 9f) + Vector3.down * (3f + R() * 3f) + new Vector3(R() - 0.5f, R() - 0.5f, R() - 0.5f) * 2.5f, new Color(0.95f, 0.98f, 1f, 0.85f * num2), 0.12f + R() * 0.2f, 1.7f);
					}
				}
				break;
			case "sandstorm":
				if (!(num2 <= 0.001f) && Object.op_Implicit((Object)(object)eye))
				{
					frameBudget += 1100f * num3 * num4 * num2;
					int num8 = Mathf.Min(70, (int)frameBudget);
					frameBudget -= num8;
					Vector3 val9 = eye.position + eye.forward * 8f - val2 * 8f;
					for (int l = 0; l < num8; l++)
					{
						Vector3 position2 = val9 + new Vector3((R() - 0.5f) * 36f, R() * 12f - 1f, (R() - 0.5f) * 36f);
						ParticlePool.Emit(streaks, position2, val2 * (24f + R() * 12f) + new Vector3(R() - 0.5f, (R() - 0.5f) * 0.6f, R() - 0.5f) * 3f, new Color(0.78f, 0.6f, 0.35f, 0.75f * num2), 0.22f + R() * 0.3f, 1.2f);
					}
				}
				break;
			case "supercell":
				if (!(num2 <= 0.001f) && Object.op_Implicit((Object)(object)eye))
				{
					frameBudget += 1700f * num3 * num4 * Mathf.Clamp(rules.N("Supercell", "RainIntensity"), 0f, 3f) * num2;
					int num7 = Mathf.Min(100, (int)frameBudget);
					frameBudget -= num7;
					Vector3 val7 = eye.position + eye.forward * 7f;
					Vector3 val8 = val2 * 3.5f * Mathf.Clamp(rules.N("Supercell", "WindIntensity"), 0f, 4f);
					for (int k = 0; k < num7; k++)
					{
						Vector3 position = val7 + new Vector3((R() - 0.5f) * 34f, 6f + R() * 12f, (R() - 0.5f) * 34f);
						ParticlePool.Emit(streaks, position, val8 + Vector3.down * (20f + R() * 6f), new Color(0.65f, 0.75f, 0.92f, 0.55f * num2), 0.07f, 0.85f);
					}
				}
				break;
			case "meteor":
			{
				Vector3 val3 = default(Vector3);
				foreach (EventHazard hazard in e.Hazards)
				{
					if (hazard.Kind != HazardKind.Meteor || !meteors.TryGetValue(hazard.Id, out GameObject value) || !Object.op_Implicit((Object)(object)value))
					{
						continue;
					}
					float num6 = Mathf.Clamp01((float)((now - hazard.Start) / 2.5));
					((Vector3)(ref val3))..ctor((float)hazard.X, (float)hazard.Y, (float)hazard.Z);
					Vector3 val4 = val3 + new Vector3(-35f, 100f, 25f);
					val5 = val3 - val4;
					Vector3 normalized = ((Vector3)(ref val5)).normalized;
					Vector3 val6 = Vector3.Lerp(val4, val3, num6);
					value.transform.position = val6;
					value.transform.rotation = Quaternion.LookRotation(normalized);
					bool flag = now >= hazard.Start && now < hazard.Start + 2.5 && !e.ClearTime.HasValue;
					value.SetActive(flag);
					if (!flag || !Object.op_Implicit((Object)(object)localPlayer))
					{
						continue;
					}
					val5 = val6 - ((Component)localPlayer).transform.position;
					if (!(((Vector3)(ref val5)).sqrMagnitude > 67600f))
					{
						for (int j = 0; j < 4; j++)
						{
							ParticlePool.Emit(sparks, val6 - normalized * (R() * 3f), -normalized * (4f + R() * 6f) + new Vector3(R() - 0.5f, R() - 0.5f, R() - 0.5f) * 5f, new Color(1f, 0.55f, 0.12f, num), 0.4f + R() * 0.5f, 1.1f);
						}
						ParticlePool.Emit(streaks, val6, -normalized * (26f + R() * 10f), new Color(1f, 0.75f, 0.35f, 0.95f * num), 1.6f + R() * 0.8f, 0.5f);
						ParticlePool.Emit(flame, val6 - normalized * 1.5f, -normalized * 2f + Vector3.up, new Color(1f, 0.5f, 0.1f, 0.9f * num), 2.4f + R() * 1.4f, 0.55f, R() * 360f);
						if (R() < 0.5f)
						{
							ParticlePool.Emit(clouds, val6 - normalized * 3f, -normalized * 1.5f + Vector3.up * 0.5f, new Color(0.3f, 0.27f, 0.25f, 0.55f * num), 3f + R() * 3f, 3.5f, R() * 360f);
						}
					}
				}
				break;
			}
			}
		}

		public void Dispose()
		{
			snowPool?.Dispose();
			impactPool?.Dispose();
			impactFx.Clear();
			if (funnel != null)
			{
				DisasterPhysics.UnregisterTornado(current);
			}
			funnel?.Dispose();
			firePool?.Dispose();
			fires.Clear();
			ocean?.Dispose();
			meteorPool?.Dispose();
			foreach (GameObject value in bolts.Values)
			{
				Object.Destroy((Object)(object)value);
			}
			bolts.Clear();
			meteors.Clear();
			foreach (Light light in lights)
			{
				if (Object.op_Implicit((Object)(object)light))
				{
					Object.Destroy((Object)(object)((Component)light).gameObject);
				}
			}
			lights.Clear();
			if (Object.op_Implicit((Object)(object)flash))
			{
				Object.Destroy((Object)(object)((Component)flash).gameObject);
			}
			pool.Return(dust);
			pool.Return(clouds);
			pool.Return(sparks);
			pool.Return(flame);
			pool.Return(streaks);
			pool.Return(debris);
		}
	}
	internal sealed class LightingController : IDisposable
	{
		private EventInstance? current;

		private RuleSet? rules;

		private float intensity;

		private bool applied;

		private Camera? activeCamera;

		private Color sunFog;

		private Color fog;

		private Color ambient;

		private Color sun;

		private Color shaderSun;

		private Color shaderAmbient;

		private float density;

		private float lightIntensity;

		private float ambientIntensity;

		private bool fogEnabled;

		private FogMode mode;

		private Vector4 skyDirection;

		private Vector4 sunDirection;

		private Vector4 wind1;

		private Vector4 wind2;

		private Vector4 windForce;

		private Quaternion rotation;

		private Light? light;

		private Material? originalSky;

		private Material? skyCopy;

		public LightingController(AssetLoader assets)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			Camera.onPreCull = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreCull, (Delegate?)new CameraCallback(Begin));
			Camera.onPostRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPostRender, (Delegate?)new CameraCallback(End));
		}

		public void Set(EventInstance? e, float value, RuleSet r)
		{
			current = e;
			intensity = value;
			rules = r;
		}

		private void Begin(Camera camera)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: 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_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_0525: Unknown result type (might be due to invalid IL or missing references)
			//IL_0529: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_058c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0593: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_061e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0623: Unknown result type (might be due to invalid IL or missing references)
			//IL_0626: Unknown result type (might be due to invalid IL or missing referen