Decompiled source of Frogpocalypse v1.0.0

Frogpocalypse.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("")]
[assembly: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Frogpocalypse")]
[assembly: AssemblyTitle("Frogpocalypse")]
[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.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;
		}
	}
}
[HarmonyPatch]
public class FrogChaosPatch
{
	private static Dictionary<FrogTrap, float> frogDuplicationTimers = new Dictionary<FrogTrap, float>();

	private static Dictionary<FrogTrap, float> frogJumpTimers = new Dictionary<FrogTrap, float>();

	private static List<FrogTrap> allFrogs = new List<FrogTrap>();

	[HarmonyPatch(typeof(FrogTrap), "Start")]
	[HarmonyPostfix]
	private static void InitializeFrogChaos(FrogTrap __instance)
	{
		if (!allFrogs.Contains(__instance))
		{
			allFrogs.Add(__instance);
			frogDuplicationTimers[__instance] = 3f;
			frogJumpTimers[__instance] = 1f;
			Debug.Log((object)"Frog Chaos initialized!");
		}
	}

	[HarmonyPatch(typeof(FrogTrap), "Update")]
	[HarmonyPostfix]
	private static void UpdateFrogChaos(FrogTrap __instance)
	{
		allFrogs.RemoveAll((FrogTrap f) => (Object)(object)f == (Object)null);
		if (!allFrogs.Contains(__instance))
		{
			allFrogs.Add(__instance);
			frogDuplicationTimers[__instance] = 3f;
			frogJumpTimers[__instance] = 1f;
		}
		if (__instance.everPickedUp)
		{
			if (!((Trap)__instance).trapActive)
			{
				((Trap)__instance).trapActive = true;
				((Trap)__instance).trapStart = true;
				((Trap)__instance).trapTriggered = true;
			}
			((Trap)__instance).enemyInvestigate = true;
			if (frogJumpTimers.TryGetValue(__instance, out var value))
			{
				frogJumpTimers[__instance] = value - Time.deltaTime;
				if (frogJumpTimers[__instance] <= 0f)
				{
					frogJumpTimers[__instance] = Random.Range(1f, 2.5f);
					__instance.FrogJump();
				}
			}
			if (frogDuplicationTimers.TryGetValue(__instance, out var value2))
			{
				frogDuplicationTimers[__instance] = value2 - Time.deltaTime;
				if (frogDuplicationTimers[__instance] <= 0f)
				{
					Debug.Log((object)"Cloning frog...");
					frogDuplicationTimers[__instance] = 0.5f;
					SpawnPhysicsOnlyFrog(__instance);
				}
			}
		}
		else
		{
			((Trap)__instance).trapActive = false;
			((Trap)__instance).trapStart = false;
			((Trap)__instance).trapTriggered = false;
		}
	}

	private static void SpawnPhysicsOnlyFrog(FrogTrap originalFrog)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: 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)
		try
		{
			Vector3 val = ((Component)originalFrog).transform.position + new Vector3(Random.Range(-3f, 3f), Random.Range(1f, 2f), Random.Range(-3f, 3f));
			GameObject val2 = Object.Instantiate<GameObject>(((Component)originalFrog).gameObject, val, Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f));
			PhotonView component = val2.GetComponent<PhotonView>();
			if ((Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			Component[] componentsInChildren = val2.GetComponentsInChildren<Component>(true);
			Component[] array = componentsInChildren;
			foreach (Component val3 in array)
			{
				if ((Object)(object)val3 == (Object)null)
				{
					continue;
				}
				string name = ((object)val3).GetType().Name;
				if (val3 is Transform || val3 is MeshRenderer || val3 is SkinnedMeshRenderer || val3 is MeshFilter || val3 is Collider || val3 is Rigidbody)
				{
					continue;
				}
				if (name == "AudioLowPassFilter")
				{
					Behaviour val4 = (Behaviour)(object)((val3 is Behaviour) ? val3 : null);
					if (val4 != null)
					{
						val4.enabled = false;
					}
					continue;
				}
				AudioSource val5 = (AudioSource)(object)((val3 is AudioSource) ? val3 : null);
				if (val5 != null)
				{
					val5.volume = 0f;
					((Behaviour)val5).enabled = false;
					continue;
				}
				if (name.Contains("Photon") || name.Contains("RPC") || name.Contains("Interact") || name.Contains("Valuable") || name.Contains("Grab") || name.Contains("Discover"))
				{
					Object.DestroyImmediate((Object)(object)val3);
					continue;
				}
				MonoBehaviour val6 = (MonoBehaviour)(object)((val3 is MonoBehaviour) ? val3 : null);
				if (val6 != null)
				{
					((Behaviour)val6).enabled = false;
					continue;
				}
				try
				{
					Object.DestroyImmediate((Object)(object)val3);
				}
				catch
				{
				}
			}
			Rigidbody val7 = val2.GetComponent<Rigidbody>() ?? val2.AddComponent<Rigidbody>();
			val7.isKinematic = false;
			val7.useGravity = true;
			val7.mass = 1f;
			val7.AddForce(Vector3.up * 1.5f, (ForceMode)1);
			val7.AddForce(new Vector3(Random.Range(-0.5f, 0.5f), 0f, Random.Range(-0.5f, 0.5f)), (ForceMode)1);
			val7.AddTorque(Random.insideUnitSphere * 3f, (ForceMode)1);
			Debug.Log((object)"Cloned frog dropped (physics-only)");
		}
		catch (Exception ex)
		{
			Debug.LogError((object)("Frog clone spawn failed: " + ex.Message));
		}
	}
}
namespace Frogpocalypse
{
	[BepInPlugin("Omniscye.Frogpocalypse", "Frogpocalypse", "1.0")]
	public class Frogpocalypse : BaseUnityPlugin
	{
		internal static Frogpocalypse Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			Patch();
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		internal void Patch()
		{
			//IL_001a: 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_0021: Expected O, but got Unknown
			//IL_0026: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
				Harmony val2 = val;
				Harmony = val;
			}
			Harmony.PatchAll();
		}

		internal void Unpatch()
		{
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void Update()
		{
		}
	}
}