Decompiled source of KinsChaoticTrials v0.1.2

plugins/com.github.KinTheInfinite.KinsChaoticTrials.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using KinsChaoticTrials.Events;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;
using UnityEngine.SceneManagement;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.KinTheInfinite.KinsChaoticTrials")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.2.0")]
[assembly: AssemblyInformationalVersion("0.1.2")]
[assembly: AssemblyProduct("com.github.KinTheInfinite.KinsChaoticTrials")]
[assembly: AssemblyTitle("KinsChaoticTrials")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.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]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace KinsChaoticTrials
{
	public static class KCTDebug
	{
		public static bool enabled = true;

		public static void Start()
		{
			if (!enabled)
			{
				return;
			}
			Debug.Log((object)"Listing all Photon-instantiable prefabs...");
			List<string> list = new List<string>();
			GameObject[] array = Resources.LoadAll("", typeof(GameObject)).Cast<GameObject>().ToArray();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				list.Add(((Object)val).name);
				Component[] components = val.GetComponents<Component>();
				foreach (Component val2 in components)
				{
					list.Add("\t" + ((object)val2).GetType().ToString());
				}
			}
			string text = Path.Combine(Application.dataPath, "../PhotonPrefabs.txt");
			File.WriteAllLines(text, list);
			Debug.Log((object)("Prefab list written to: " + text));
		}

		public static void Run()
		{
			if (enabled)
			{
				PhotonView[] array = Object.FindObjectsByType<PhotonView>((FindObjectsSortMode)0);
				foreach (PhotonView val in array)
				{
					KinsChaoticTrials.LogInfo(((Object)val).name + " has PhotonView");
				}
			}
		}
	}
	[BepInPlugin("kintheinfinite.kinschaotictrials", "Kin's Chaotic Trials", "1.0.0")]
	public class KinsChaoticTrials : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(OrbFogHandler), "WaitToMove")]
		public class FogWaitToMovePatch
		{
			private static bool Prefix(OrbFogHandler __instance)
			{
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0103: Unknown result type (might be due to invalid IL or missing references)
				//IL_0104: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				__instance.currentWaitTime += Time.deltaTime;
				if (!PhotonNetwork.IsMasterClient)
				{
					return false;
				}
				if (Ascents.currentAscent < 0)
				{
					return false;
				}
				if (__instance.currentID <= 0 && !config_fog_shore.Value)
				{
					return false;
				}
				if (!__instance.PlayersHaveMovedOn() && config_fog_waits.Value)
				{
					return false;
				}
				if (__instance.currentWaitTime <= config_fog_delay.Value)
				{
					return false;
				}
				if (config_fog_use_distance.Value)
				{
					int currentSegment = Singleton<MapHandler>.Instance.currentSegment;
					Vector3 position = default(Vector3);
					((Vector3)(ref position))..ctor(0f, 0f, -380f);
					Vector3 position2 = default(Vector3);
					((Vector3)(ref position2))..ctor(0f, 0f, 1700f);
					if (currentSegment > 0)
					{
						position = Singleton<MapHandler>.Instance.segments[currentSegment - 1].segmentCampfire.transform.position;
					}
					if ((Object)(object)Singleton<MapHandler>.Instance.segments[currentSegment].segmentCampfire != (Object)null)
					{
						position2 = Singleton<MapHandler>.Instance.segments[currentSegment].segmentCampfire.transform.position;
					}
					float num = Vector3.Distance(position, position2);
					__instance.currentSize = num + config_fog_custom_distance.Value;
				}
				orb_fog_handler = __instance;
				__instance.speed = config_fog_speed.Value;
				__instance.syncCounter = 30f;
				__instance.photonView.RPC("StartMovingRPC", (RpcTarget)0, Array.Empty<object>());
				return false;
			}
		}

		public static KinsChaoticTrials instance;

		public static Harmony harmony;

		private static ConfigEntry<float> config_min_event_delay;

		private static ConfigEntry<float> config_max_event_delay;

		private static ConfigEntry<bool> config_fog_waits;

		private static ConfigEntry<bool> config_fog_shore;

		private static ConfigEntry<bool> config_fog_use_distance;

		private static ConfigEntry<float> config_fog_custom_distance;

		private static ConfigEntry<float> config_fog_delay;

		private static ConfigEntry<float> config_fog_speed;

		private static OrbFogHandler orb_fog_handler;

		private static float event_delay = 0f;

		public static List<ChaosEvent> all_events = new List<ChaosEvent>();

		private void Awake()
		{
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Expected O, but got Unknown
			instance = this;
			config_min_event_delay = ((BaseUnityPlugin)this).Config.Bind<float>("Events", "MinEventDelay", 60f, "Minimum Delay (in seconds) between events.");
			config_max_event_delay = ((BaseUnityPlugin)this).Config.Bind<float>("Events", "MaxEventDelay", 60f, "Maximum Delay (in seconds) between events.");
			config_fog_waits = ((BaseUnityPlugin)this).Config.Bind<bool>("Events", "FogWaits", true, "If true the fog will wait for players to get a bit up the mountain.");
			config_fog_shore = ((BaseUnityPlugin)this).Config.Bind<bool>("Events", "FogShore", false, "If true the fog will activate on the shore.");
			config_fog_use_distance = ((BaseUnityPlugin)this).Config.Bind<bool>("Events", "FogUseDistance", false, "If true the custom fog distance will be used.");
			config_fog_custom_distance = ((BaseUnityPlugin)this).Config.Bind<float>("Events", "FogCustomDistance", 30f, "The distance from the campfire where the fog will start.");
			config_fog_delay = ((BaseUnityPlugin)this).Config.Bind<float>("Events", "FogDelay", 500f, "Delay in seconds before fog starts moving after a campfire is lit.");
			config_fog_speed = ((BaseUnityPlugin)this).Config.Bind<float>("Events", "FogSpeed", 0.3f, "Speed that the fog moves at.");
			harmony = new Harmony("kintheinfinite.kinschaotictrials");
			harmony.PatchAll(typeof(FogWaitToMovePatch));
			all_events.Add(new EruptionChaosEvent());
			all_events.Add(new TumbleweedChaosEvent());
			all_events.Add(new DynamiteChaosEvent());
			all_events.Add(new TornadoChaosEvent());
			all_events.Add(new PeelChaosEvent());
			all_events.Add(new RemedyChaosEvent());
			all_events.Add(new ScorpionChaosEvent());
		}

		private void Update()
		{
			if (!PhotonNetwork.IsMasterClient)
			{
				return;
			}
			if ((Object)(object)orb_fog_handler != (Object)null)
			{
				OrbFogHandler obj = orb_fog_handler;
				obj.syncCounter += Time.deltaTime * 4f;
			}
			if (!InGameScene())
			{
				event_delay = Random.Range(config_min_event_delay.Value, config_max_event_delay.Value);
				return;
			}
			foreach (ChaosEvent all_event in all_events)
			{
				all_event.Update();
			}
			event_delay -= Time.deltaTime;
			if (event_delay > 0f)
			{
				return;
			}
			event_delay = Random.Range(config_min_event_delay.Value, config_max_event_delay.Value);
			Dictionary<ChaosEvent, float> dictionary = new Dictionary<ChaosEvent, float>();
			float num = 0f;
			foreach (ChaosEvent all_event2 in all_events)
			{
				float eventWeight = all_event2.GetEventWeight();
				if (eventWeight != 0f)
				{
					num += eventWeight;
					dictionary.Add(all_event2, eventWeight);
				}
			}
			float num2 = Random.Range(0f, num);
			foreach (ChaosEvent key in dictionary.Keys)
			{
				num2 -= dictionary[key];
				if (num2 <= 0f)
				{
					key.Trigger();
					break;
				}
			}
		}

		public static Vector3 GetRandomGroundLocation()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			int currentSegment = Singleton<MapHandler>.Instance.currentSegment;
			float num = Random.Range(-135f, 135f);
			float num2 = 3000f;
			float num3 = -380f;
			float num4 = 1700f;
			if (currentSegment > 0)
			{
				num3 = Singleton<MapHandler>.Instance.segments[currentSegment - 1].segmentCampfire.transform.position.z;
			}
			if ((Object)(object)Singleton<MapHandler>.Instance.segments[currentSegment].segmentCampfire != (Object)null)
			{
				num4 = Singleton<MapHandler>.Instance.segments[currentSegment].segmentCampfire.transform.position.z;
			}
			if (num4 < num3)
			{
				num4 = num3 + 380f;
			}
			float num5 = Random.Range(num3 + 50f, num4 - 50f);
			Vector3 point = default(Vector3);
			((Vector3)(ref point))..ctor(num, num2, num5);
			RaycastHit groundPosRaycast = HelperFunctions.GetGroundPosRaycast(point, (LayerType)1, 0f);
			point = ((RaycastHit)(ref groundPosRaycast)).point;
			return point;
		}

		public static Vector3 GetRandomGroundLocationAway(float min_distance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: 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)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Vector3 randomGroundLocation = GetRandomGroundLocation();
			while (GetClosestPlayerDistance(randomGroundLocation) < min_distance)
			{
				randomGroundLocation = GetRandomGroundLocation();
			}
			return randomGroundLocation;
		}

		public static Vector3 GetRandomLocationNearPlayer(float min_distance, float max_distance)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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)
			Character val = Util.RandomSelection<Character>((IEnumerable<Character>)Character.AllCharacters, (Func<Character, int>)((Character character) => Convert.ToInt32(!character.data.dead)));
			if ((Object)(object)val == (Object)null)
			{
				return new Vector3(0f, 0f, 0f);
			}
			return GetRandomLocationNearLocation(val.Center + new Vector3(0f, 300f, 0f), min_distance, max_distance);
		}

		public static Vector3 GetRandomLocationNearLocation(Vector3 position, float min_distance, float max_distance)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(Random.Range(min_distance, max_distance), 0f, Random.Range(min_distance, max_distance));
			if (Random.Range(0f, 1f) < 0.5f)
			{
				val.x *= -1f;
			}
			if (Random.Range(0f, 1f) < 0.5f)
			{
				val.z *= -1f;
			}
			RaycastHit groundPosRaycast = HelperFunctions.GetGroundPosRaycast(position + val, (LayerType)1, 0f);
			return ((RaycastHit)(ref groundPosRaycast)).point;
		}

		public static Luggage[] GetCurrentSegmentLuggage()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			Luggage[] array = Object.FindObjectsByType<Luggage>((FindObjectsSortMode)0);
			int current_segment = Singleton<MapHandler>.Instance.currentSegment;
			if (current_segment == 4)
			{
				return array;
			}
			float start = -380f;
			float end = (Object.op_Implicit((Object)(object)Singleton<MapHandler>.Instance.segments[current_segment].segmentCampfire) ? Singleton<MapHandler>.Instance.segments[current_segment].segmentCampfire.transform.position.z : ((Component)Object.FindObjectsByType<Campfire>((FindObjectsInactive)1, (FindObjectsSortMode)0).First((Campfire campfire) => (int)campfire.advanceToSegment == current_segment + 1)).transform.position.z);
			if (current_segment != 0)
			{
				start = Singleton<MapHandler>.Instance.segments[current_segment - 1].segmentCampfire.transform.position.z;
			}
			if (end <= start)
			{
				end = 1700f;
			}
			return array.Where((Luggage luggage) => (double)((Component)luggage).transform.position.z > (double)start + 50.0 && (double)((Component)luggage).transform.position.z < (double)end - 50.0).ToArray();
		}

		public static float GetClosestPlayerDistance(Vector3 position)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			float num = float.MaxValue;
			foreach (Character allCharacter in Character.AllCharacters)
			{
				num = Mathf.Min(num, Vector3.Distance(position, allCharacter.Center));
			}
			return num;
		}

		public static float DistanceToCampfire(Vector3 position)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			int currentSegment = Singleton<MapHandler>.Instance.currentSegment;
			if ((Object)(object)Singleton<MapHandler>.Instance.segments[currentSegment].segmentCampfire == (Object)null)
			{
				return float.MaxValue;
			}
			return Vector3.Distance(position, Singleton<MapHandler>.Instance.segments[currentSegment].segmentCampfire.transform.position);
		}

		public static bool InGameScene()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			Scene activeScene = SceneManager.GetActiveScene();
			string name = ((Scene)(ref activeScene)).name;
			if (name == "Title" || name == "Airport")
			{
				return false;
			}
			return true;
		}

		public static void LogInfo(string text)
		{
			((BaseUnityPlugin)instance).Logger.LogInfo((object)text);
		}
	}
}
namespace KinsChaoticTrials.Events
{
	public interface ChaosEvent
	{
		float GetEventWeight();

		void Trigger();

		void Update();
	}
	public class DynamiteChaosEvent : ChaosEvent
	{
		private static ConfigEntry<float> config_event_weight;

		private static ConfigEntry<float> config_amount;

		private static ConfigEntry<float> config_lit_chance;

		private static ConfigEntry<float> config_lifetime;

		private static ConfigEntry<float> config_min_distance;

		private static ConfigEntry<float> config_max_distance;

		public DynamiteChaosEvent()
		{
			config_event_weight = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Dynamite", "Weight", 1f, "Weight for this event to occur.");
			config_amount = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Dynamite", "Amount", 20f, "Amount of dynamite that will spawn.");
			config_lit_chance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Dynamite", "LitChance", 0f, "Lit on spawn chance, 1.0 for 100% chance.");
			config_lifetime = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Dynamite", "Lifetime", 60f, "Seconds before dynamite despawn.");
			config_min_distance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Dynamite", "MinDistance", 10f, "Minimum spawn distance from player.");
			config_max_distance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Dynamite", "MaxDistance", 60f, "Maximum spawn distance from player.");
		}

		public float GetEventWeight()
		{
			return config_event_weight.Value;
		}

		public void Trigger()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; (float)i < config_amount.Value; i++)
			{
				Vector3 randomLocationNearPlayer = KinsChaoticTrials.GetRandomLocationNearPlayer(config_min_distance.Value, config_max_distance.Value);
				randomLocationNearPlayer += new Vector3(0f, 0f, 0f);
				if (!(KinsChaoticTrials.GetClosestPlayerDistance(randomLocationNearPlayer) < config_min_distance.Value))
				{
					GameObject val = PhotonNetwork.Instantiate("0_items/Dynamite", randomLocationNearPlayer, Quaternion.identity, (byte)0, (object[])null);
					Dynamite component = val.GetComponent<Dynamite>();
					if (Random.Range(0f, 1f) < config_lit_chance.Value)
					{
						component.LightFlare();
					}
					RemoveAfterSeconds val2 = val.AddComponent<RemoveAfterSeconds>();
					val2.photonRemove = true;
					val2.seconds = config_lifetime.Value;
				}
			}
		}

		public void Update()
		{
		}
	}
	public class EruptionChaosEvent : ChaosEvent
	{
		private static ConfigEntry<float> config_event_weight;

		private static ConfigEntry<float> config_amount;

		private static ConfigEntry<float> config_min_distance;

		private static ConfigEntry<float> config_max_distance;

		private static EruptionSpawner eruption_spawner;

		public EruptionChaosEvent()
		{
			config_event_weight = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Eruption", "Weight", 1f, "Weight for this event to occur.");
			config_amount = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Eruption", "Amount", 2f, "Amount of eruptions that will occur.");
			config_min_distance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Eruption", "MinDistance", 0f, "Minimum spawn distance from player.");
			config_max_distance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Eruption", "MaxDistance", 15f, "Maximum spawn distance from player.");
		}

		public float GetEventWeight()
		{
			return config_event_weight.Value;
		}

		public void Trigger()
		{
			//IL_003d: 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)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)eruption_spawner == (Object)null)
			{
				eruption_spawner = Object.FindAnyObjectByType<EruptionSpawner>();
			}
			if ((Object)(object)eruption_spawner == (Object)null)
			{
				return;
			}
			for (int i = 0; (float)i < config_amount.Value; i++)
			{
				Vector3 randomLocationNearPlayer = KinsChaoticTrials.GetRandomLocationNearPlayer(config_min_distance.Value, config_max_distance.Value);
				if (!(KinsChaoticTrials.GetClosestPlayerDistance(randomLocationNearPlayer) < config_min_distance.Value))
				{
					eruption_spawner.photonView.RPC("RPCA_SpawnEruption", (RpcTarget)0, new object[1] { randomLocationNearPlayer });
				}
			}
		}

		public void Update()
		{
		}
	}
	public class PeelChaosEvent : ChaosEvent
	{
		private static ConfigEntry<float> config_event_weight;

		private static ConfigEntry<float> config_amount;

		private static ConfigEntry<float> config_lifetime;

		private static ConfigEntry<float> config_height;

		private static ConfigEntry<float> config_min_distance;

		private static ConfigEntry<float> config_max_distance;

		public PeelChaosEvent()
		{
			config_event_weight = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Peels", "Weight", 1f, "Weight for this event to occur.");
			config_amount = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Peels", "Amount", 20f, "Amount of peels that will spawn.");
			config_lifetime = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Peels", "Lifetime", 120f, "Seconds before peels despawn.");
			config_height = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Peels", "Height", 20f, "Height the peels spawn at.");
			config_min_distance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Peels", "MinDistance", 5f, "Minimum spawn distance from player.");
			config_max_distance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Peels", "MaxDistance", 20f, "Maximum spawn distance from player.");
		}

		public float GetEventWeight()
		{
			return config_event_weight.Value;
		}

		public void Trigger()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; (float)i < config_amount.Value; i++)
			{
				Vector3 randomLocationNearPlayer = KinsChaoticTrials.GetRandomLocationNearPlayer(config_min_distance.Value, config_max_distance.Value);
				randomLocationNearPlayer += new Vector3(0f, config_height.Value, 0f);
				if (!(KinsChaoticTrials.GetClosestPlayerDistance(randomLocationNearPlayer) < config_min_distance.Value))
				{
					GameObject val = PhotonNetwork.Instantiate("0_items/Berrynana Peel Yellow", randomLocationNearPlayer, Quaternion.identity, (byte)0, (object[])null);
					RemoveAfterSeconds val2 = val.AddComponent<RemoveAfterSeconds>();
					val2.photonRemove = true;
					val2.seconds = config_lifetime.Value;
				}
			}
		}

		public void Update()
		{
		}
	}
	public class RemedyChaosEvent : ChaosEvent
	{
		private static ConfigEntry<float> config_event_weight;

		private static ConfigEntry<float> config_amount;

		private static ConfigEntry<float> config_scorpion_chance;

		private static ConfigEntry<float> config_min_distance;

		private static ConfigEntry<float> config_max_distance;

		public RemedyChaosEvent()
		{
			config_event_weight = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Remedy", "Weight", 0.2f, "Weight for this event to occur.");
			config_amount = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Remedy", "Amount", 8f, "Amount of remedy shrooms that will spawn.");
			config_scorpion_chance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Remedy", "ScorpionChance", 0.5f, "Scorpion on spawn chance, 1.0 for 100% chance.");
			config_min_distance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Remedy", "MinDistance", 0f, "Minimum spawn distance from player.");
			config_max_distance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Remedy", "MaxDistance", 30f, "Maximum spawn distance from player.");
		}

		public float GetEventWeight()
		{
			return config_event_weight.Value;
		}

		public void Trigger()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; (float)i < config_amount.Value; i++)
			{
				Vector3 randomLocationNearPlayer = KinsChaoticTrials.GetRandomLocationNearPlayer(config_min_distance.Value, config_max_distance.Value);
				randomLocationNearPlayer += new Vector3(0f, 2f, 0f);
				if (!(KinsChaoticTrials.GetClosestPlayerDistance(randomLocationNearPlayer) < config_min_distance.Value))
				{
					GameObject val = PhotonNetwork.Instantiate("0_items/HealingPuffShroom", randomLocationNearPlayer, Quaternion.identity, (byte)0, (object[])null);
					Item component = val.GetComponent<Item>();
					component.view.RPC("SetKinematicRPC", (RpcTarget)0, new object[3]
					{
						false,
						randomLocationNearPlayer,
						Quaternion.identity
					});
					if (Random.Range(0f, 1f) < config_scorpion_chance.Value)
					{
						GameObject val2 = PhotonNetwork.Instantiate("0_items/Scorpion", randomLocationNearPlayer, Quaternion.identity, (byte)0, (object[])null);
						Item component2 = val2.GetComponent<Item>();
						component2.view.RPC("SetKinematicRPC", (RpcTarget)0, new object[3]
						{
							false,
							randomLocationNearPlayer,
							Quaternion.identity
						});
					}
				}
			}
		}

		public void Update()
		{
		}
	}
	public class ScorpionChaosEvent : ChaosEvent
	{
		private static ConfigEntry<float> config_event_weight;

		private static ConfigEntry<float> config_amount;

		private static ConfigEntry<float> config_lifetime;

		private static ConfigEntry<float> config_min_distance;

		private static ConfigEntry<float> config_max_distance;

		public ScorpionChaosEvent()
		{
			config_event_weight = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Scorpion", "Weight", 0.25f, "Weight for this event to occur.");
			config_amount = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Scorpion", "Amount", 10f, "Amount of scorpions that will spawn.");
			config_lifetime = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Scorpion", "Lifetime", 120f, "Seconds before scorpions despawn.");
			config_min_distance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Scorpion", "MinDistance", 0f, "Minimum spawn distance from luggage.");
			config_max_distance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Scorpion", "MaxDistance", 0f, "Maximum spawn distance from luggage.");
		}

		public float GetEventWeight()
		{
			return config_event_weight.Value;
		}

		public void Trigger()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			Luggage[] currentSegmentLuggage = KinsChaoticTrials.GetCurrentSegmentLuggage();
			if (currentSegmentLuggage.Length != 0)
			{
				for (int i = 0; (float)i < config_amount.Value; i++)
				{
					Vector3 position = currentSegmentLuggage[Random.Range(0, currentSegmentLuggage.Length)].Center() + new Vector3(0f, 5f, 0f);
					Vector3 randomLocationNearLocation = KinsChaoticTrials.GetRandomLocationNearLocation(position, config_min_distance.Value, config_max_distance.Value);
					GameObject val = PhotonNetwork.Instantiate("0_items/Scorpion", randomLocationNearLocation, Quaternion.identity, (byte)0, (object[])null);
					Item component = val.GetComponent<Item>();
					component.view.RPC("SetKinematicRPC", (RpcTarget)0, new object[3]
					{
						false,
						randomLocationNearLocation,
						Quaternion.identity
					});
					RemoveAfterSeconds val2 = val.AddComponent<RemoveAfterSeconds>();
					val2.seconds = config_lifetime.Value;
				}
			}
		}

		public void Update()
		{
		}
	}
	public class TornadoChaosEvent : ChaosEvent
	{
		[CompilerGenerated]
		private sealed class <TornadoCoroutine>d__13 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Expected O, but got Unknown
				int num = <>1__state;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					SpawnTornado();
				}
				else
				{
					<>1__state = -1;
				}
				<>2__current = (object)new WaitForSeconds(Random.Range(config_min_delay.Value, config_max_delay.Value));
				<>1__state = 1;
				return true;
			}

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

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

		private static ConfigEntry<float> config_event_weight;

		private static ConfigEntry<float> config_amount;

		private static ConfigEntry<float> config_lifetime;

		private static ConfigEntry<float> config_min_distance;

		private static ConfigEntry<bool> config_perpetual;

		public static ConfigEntry<float> config_min_delay;

		public static ConfigEntry<float> config_max_delay;

		public static HashSet<Tornado> tornado_set = new HashSet<Tornado>();

		public TornadoChaosEvent()
		{
			config_event_weight = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Tornado", "Weight", 0f, "Weight for this event to occur.");
			config_amount = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Tornado", "Amount", 3f, "Amount of tornados that will spawn.");
			config_lifetime = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Tornado", "Lifetime", 120f, "Seconds before tornado despawn.");
			config_min_distance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Tornado", "MinDistance", 30f, "Minimum spawn distance from player.");
			config_perpetual = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<bool>("Events.Tornado.Perpetual", "Perpetual", true, "Instead of rolling as an event, spawn after these delays.");
			config_min_delay = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Tornado.Perpetual", "MinDelay", 60f, "Minimum seconds before spawning.");
			config_max_delay = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Tornado.Perpetual", "MaxDelay", 120f, "Maximum seconds before spawning.");
			if (config_perpetual.Value)
			{
				((MonoBehaviour)KinsChaoticTrials.instance).StartCoroutine(TornadoCoroutine());
			}
			KinsChaoticTrials.harmony.PatchAll(typeof(TornadoMovementPatch));
			KinsChaoticTrials.harmony.PatchAll(typeof(TornadoPickTargetPatch));
			KinsChaoticTrials.harmony.PatchAll(typeof(RespawnStatuePatch));
		}

		public float GetEventWeight()
		{
			if (Singleton<MapHandler>.Instance.currentSegment == 4)
			{
				return 0f;
			}
			return config_event_weight.Value;
		}

		public void Trigger()
		{
			for (int i = 0; (float)i < config_amount.Value; i++)
			{
				SpawnTornado();
			}
		}

		public void Update()
		{
		}

		public static void SpawnTornado()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (PhotonNetwork.IsMasterClient && KinsChaoticTrials.InGameScene() && Singleton<MapHandler>.Instance.currentSegment != 4)
			{
				Vector3 randomGroundLocationAway = KinsChaoticTrials.GetRandomGroundLocationAway(config_min_distance.Value);
				GameObject val = PhotonNetwork.Instantiate("Tornado", randomGroundLocationAway, Quaternion.identity, (byte)0, (object[])null);
				Tornado component = val.GetComponent<Tornado>();
				component.lifeTime = config_lifetime.Value;
			}
		}

		[IteratorStateMachine(typeof(<TornadoCoroutine>d__13))]
		private IEnumerator TornadoCoroutine()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <TornadoCoroutine>d__13(0);
		}
	}
	[HarmonyPatch(typeof(Tornado), "Movement")]
	public class TornadoMovementPatch
	{
		private static bool Prefix(Tornado __instance)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_007f: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: 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_00e5: 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_014e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance.target == (Object)null)
			{
				return false;
			}
			Vector3 vel = __instance.vel;
			Vector3 val = Vector3Extensions.Flat(__instance.target.position - __instance.tornadoPos);
			Vector3 val2 = ((Vector3)(ref val)).normalized * 5f;
			Vector3 vel2 = FRILerp.Lerp(vel, val2, 0.2f, true);
			__instance.vel = vel2;
			__instance.tornadoPos += __instance.vel * Time.deltaTime;
			RaycastHit groundPosRaycast = HelperFunctions.GetGroundPosRaycast(__instance.tornadoPos + new Vector3(0f, 60f, 0f), (LayerType)1, 0.25f);
			RaycastHit val3 = groundPosRaycast;
			if ((double)Mathf.Abs(((RaycastHit)(ref val3)).point.y - __instance.tornadoPos.y) < 1.0)
			{
				ref Vector3 tornadoPos = ref __instance.tornadoPos;
				val3 = groundPosRaycast;
				tornadoPos.y = ((RaycastHit)(ref val3)).point.y;
			}
			else
			{
				ref float y = ref __instance.tornadoPos.y;
				float num = y;
				val3 = groundPosRaycast;
				y = num + Mathf.Clamp((float)(((double)((RaycastHit)(ref val3)).point.y - (double)__instance.tornadoPos.y) * 7.5), -40f, 15f) * Time.deltaTime;
			}
			((Component)__instance).transform.position = __instance.tornadoPos;
			return false;
		}
	}
	[HarmonyPatch(typeof(Tornado), "PickTarget")]
	public class TornadoPickTargetPatch
	{
		private static bool Prefix(Tornado __instance)
		{
			TornadoChaosEvent.tornado_set.Add(__instance);
			Luggage[] currentSegmentLuggage = KinsChaoticTrials.GetCurrentSegmentLuggage();
			if (currentSegmentLuggage.Length != 0)
			{
				__instance.target = ((Component)currentSegmentLuggage[Random.Range(0, currentSegmentLuggage.Length)]).transform;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(RespawnChest), "SpawnItems")]
	public class RespawnStatuePatch
	{
		private static bool Prefix(RespawnChest __instance, List<Transform> spawnSpots)
		{
			foreach (Tornado item in TornadoChaosEvent.tornado_set)
			{
				if (!((Object)(object)item == (Object)null))
				{
					item.lifeTime = 0f;
				}
			}
			TornadoChaosEvent.tornado_set.Clear();
			return true;
		}
	}
	public class TumbleweedChaosEvent : ChaosEvent
	{
		private static ConfigEntry<float> config_event_weight;

		private static ConfigEntry<float> config_amount;

		private static ConfigEntry<float> config_lifetime;

		private static ConfigEntry<float> config_min_distance;

		private static ConfigEntry<float> config_max_distance;

		public TumbleweedChaosEvent()
		{
			config_event_weight = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Tumbleweed", "Weight", 1f, "Weight for this event to occur.");
			config_amount = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Tumbleweed", "Amount", 50f, "Amount of tumbleweeds that will spawn.");
			config_lifetime = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Tumbleweed", "Lifetime", 20f, "Seconds before tumbleweeds despawn.");
			config_min_distance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Tumbleweed", "MinDistance", 20f, "Minimum spawn distance from player.");
			config_max_distance = ((BaseUnityPlugin)KinsChaoticTrials.instance).Config.Bind<float>("Events.Tumbleweed", "MaxDistance", 30f, "Maximum spawn distance from player.");
		}

		public float GetEventWeight()
		{
			return config_event_weight.Value;
		}

		public void Trigger()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; (float)i < config_amount.Value; i++)
			{
				Vector3 randomLocationNearPlayer = KinsChaoticTrials.GetRandomLocationNearPlayer(config_min_distance.Value, config_max_distance.Value);
				randomLocationNearPlayer += new Vector3(0f, 2f, 0f);
				if (!(KinsChaoticTrials.GetClosestPlayerDistance(randomLocationNearPlayer) < config_min_distance.Value))
				{
					GameObject val = PhotonNetwork.Instantiate("tumbleweed", randomLocationNearPlayer, Quaternion.identity, (byte)0, (object[])null);
					RemoveAfterSeconds component = val.GetComponent<RemoveAfterSeconds>();
					component.seconds = config_lifetime.Value;
				}
			}
		}

		public void Update()
		{
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}