Decompiled source of Arrow Rain v1.0.1

ArrowRain.dll

Decompiled 6 months ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BoplFixedMath;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("ArrowRain")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("My first plugin")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ArrowRain")]
[assembly: AssemblyTitle("ArrowRain")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace AntiKick
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "ArrowRain";

		public const string PLUGIN_NAME = "ArrowRain";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ArrowRain
{
	[BepInPlugin("com.David_Loves_JellyCar_Worlds.ArrowRain", "ArrowRain", "1.0.0")]
	public class Plugin : BaseUnityPlugin, IUpdatable
	{
		public static ConfigEntry<int> TicksPerRain;

		public static ConfigEntry<int> TicksBeforeStart;

		public static ConfigEntry<int> MinDist;

		public static ConfigEntry<int> MaxDist;

		public static Fix Ticks = (Fix)0L;

		public static GameObject BowObject;

		public static BoplBody Arrow;

		public static GameSessionHandler GameSessionHandler2;

		public static RingBuffer<BoplBody> Arrows;

		public static ConfigFile config;

		private int hierarchyNumber;

		public bool IsDestroyed { get; set; }

		public int HierarchyNumber
		{
			get
			{
				return hierarchyNumber;
			}
			set
			{
				hierarchyNumber = value;
			}
		}

		private void Awake()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin ArrowRain is loaded!");
			Harmony val = new Harmony("com.David_Loves_JellyCar_Worlds.ArrowRain");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"harmany created");
			val.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"ArrowRain Patch Compleate!");
			config = ((BaseUnityPlugin)this).Config;
			TicksPerRain = config.Bind<int>("Settings", "TicksPerRain", 240, "the number of ticks bettewen the Rains. 60 ticks is 1 second");
			TicksBeforeStart = config.Bind<int>("Settings", "TicksBeforeStart", 300, "the number of ticks before the rain starts. 60 ticks is 1 second");
			MinDist = config.Bind<int>("Settings", "MinDist", 5, "the minimum distance between arrows in bopl units");
			MaxDist = config.Bind<int>("Settings", "MaxDist", 10, "the maximum distance between arrows in bopl units");
			GameObject[] array = Resources.FindObjectsOfTypeAll(typeof(GameObject)) as GameObject[];
			((BaseUnityPlugin)this).Logger.LogInfo((object)"getting Bow object");
			GameObject[] array2 = array;
			foreach (GameObject val2 in array2)
			{
				if (((Object)val2).name == "Bow")
				{
					BowObject = val2;
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Found the object: " + ((Object)val2).name));
					break;
				}
			}
			SceneManager.sceneLoaded += OnSceneLoaded;
			Component component = BowObject.GetComponent(typeof(BowTransform));
			BowTransform obj = (BowTransform)(object)((component is BowTransform) ? component : null);
			Arrow = (BoplBody)AccessTools.Field(typeof(BowTransform), "Arrow").GetValue(obj);
			Arrows = new RingBuffer<BoplBody>(50, true);
		}

		public void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Ticks = Fix.Zero;
			if (!IsLevelName(((Scene)(ref scene)).name))
			{
				return;
			}
			GameObject[] array = Resources.FindObjectsOfTypeAll(typeof(GameObject)) as GameObject[];
			((BaseUnityPlugin)this).Logger.LogInfo((object)"getting GameSessionHandler");
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if (((Object)val).name == "PlayerList")
				{
					GameSessionHandler2 = val.GetComponent<GameSessionHandler>();
					break;
				}
			}
			Updater.RegisterUpdatable((IUpdatable)(object)this);
		}

		public void Init()
		{
		}

		public bool IsEnabled()
		{
			return ((Behaviour)this).isActiveAndEnabled;
		}

		public void LateUpdateSim(Fix SimDeltaTime)
		{
		}

		public void OnDestroyUpdatable()
		{
		}

		public void UpdateSim(Fix SimDeltaTime)
		{
			//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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: 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_0142: 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_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)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: 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_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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)
			//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)
			bool flag = (bool)AccessTools.Field(typeof(GameSessionHandler), "gameInProgress").GetValue(GameSessionHandler2);
			Ticks += Fix.One;
			if (flag && Fix.SlowMod(Ticks, (Fix)(long)TicksPerRain.Value) == 0L && Ticks > (long)TicksBeforeStart.Value && !GameTime.IsTimeStopped())
			{
				Fix val = Updater.RandomFix((Fix)(-10L), (Fix)0L);
				Fix val2 = Updater.RandomFix((Fix)(long)MinDist.Value, (Fix)(long)MaxDist.Value);
				Fix val3 = (Fix)(-97.27) + val;
				Vec2 pos = default(Vec2);
				while (val3 <= (Fix)97.6)
				{
					val2 = Updater.RandomFix((Fix)(long)MinDist.Value, (Fix)(long)MaxDist.Value);
					((Vec2)(ref pos))..ctor(val3, (Fix)60L);
					SpawnArrow(pos, Fix.Zero, Fix.One, Vec2.down);
					val3 += val2;
				}
			}
		}

		public void SpawnArrow(Vec2 pos, Fix angle, Fix scale, Vec2 StartVel)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: 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)
			//IL_0019: 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)
			BoplBody val = FixTransform.InstantiateFixed<BoplBody>(Arrow, pos, angle);
			val.Scale = scale;
			val.StartVelocity = StartVel;
			val.rotation = angle;
			Arrows.Add(val);
		}

		public static bool IsLevelName(string input)
		{
			Regex regex = new Regex("Level[0-9]+", RegexOptions.IgnoreCase);
			return regex.IsMatch(input);
		}
	}
}