Decompiled source of GeckoMoria v0.1.0

Pocket.GeckoMoria.dll

Decompiled 6 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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.Logging;
using GameNetcodeStuff;
using GeckoMoria.LCInput;
using HarmonyLib;
using LethalCompanyInputUtils.Api;
using LobbyCompatibility.Attributes;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.InputSystem;

[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: AssemblyCompany("Pocket.GeckoMoria")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MyFirstMod")]
[assembly: AssemblyTitle("Pocket.GeckoMoria")]
[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;
		}
	}
}
namespace GeckoMoria
{
	[BepInPlugin("Pocket.GeckoMoria", "MyFirstMod", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[LobbyCompatibility(/*Could not decode attribute arguments.*/)]
	public class GeckoMoria : BaseUnityPlugin
	{
		internal static MyExampleInputClass InputActionsInstance;

		private static float range = 5f;

		public static GeckoMoria Instance { get; private set; } = null;


		internal static ManualLogSource Logger { get; private set; } = null;


		internal static Harmony? Harmony { get; set; }

		private static SelectableLevel currentLevel => RoundManager.Instance.currentLevel;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			InputActionsInstance = new MyExampleInputClass();
			Patch();
			SetupKeybindCallbacks();
			Logger.LogInfo((object)"Pocket.GeckoMoria v1.0.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: 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
			if (Harmony == null)
			{
				Harmony = new Harmony("Pocket.GeckoMoria");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}

		public void SetupKeybindCallbacks()
		{
			InputActionsInstance.ThreeKey.performed += SpawnInsideEnemy;
			InputActionsInstance.FourKey.performed += SpawnOutsideEnemy;
			InputActionsInstance.FiveKey.performed += SpawnObject;
			InputActionsInstance.SixKey.performed += SpawnScrap;
		}

		public static void buttonpress(CallbackContext keypressContext)
		{
			if (((CallbackContext)(ref keypressContext)).performed)
			{
				Logger.LogMessage((object)"success");
			}
		}

		public static void SpawnInsideEnemy(CallbackContext keypressContext)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			if (((CallbackContext)(ref keypressContext)).performed)
			{
				Logger.LogMessage((object)"Spawn Inside Enemy...");
				PlayerControllerB val = Object.FindObjectsOfType<PlayerControllerB>()[0];
				List<SpawnableEnemyWithRarity> enemies = currentLevel.Enemies;
				SpawnableEnemyWithRarity val2 = enemies[Random.Range(0, enemies.Count - 1)];
				if (GameObject.FindGameObjectsWithTag("EnemySpawn").Length != 0)
				{
					Vector3 position = GameObject.FindGameObjectsWithTag("EnemySpawn")[Random.Range(0, GameObject.FindGameObjectsWithTag("EnemySpawn").Length - 1)].transform.position;
					Spawn(val2.enemyType.enemyPrefab, position);
				}
				else
				{
					Vector3 position2 = ((Component)val).transform.position;
					Vector3 val3 = default(Vector3);
					((Vector3)(ref val3))..ctor(Random.Range(0f - range, range), 0f, Random.Range(0f - range, range));
					Spawn(val2.enemyType.enemyPrefab, position2 + val3);
				}
			}
		}

		public static void SpawnOutsideEnemy(CallbackContext keypressContext)
		{
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: 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_0097: Unknown result type (might be due to invalid IL or missing references)
			if (((CallbackContext)(ref keypressContext)).performed)
			{
				Logger.LogMessage((object)"Spawn Outside Enemy...");
				PlayerControllerB val = Object.FindObjectsOfType<PlayerControllerB>()[0];
				List<SpawnableEnemyWithRarity> outsideEnemies = currentLevel.OutsideEnemies;
				SpawnableEnemyWithRarity val2 = outsideEnemies[Random.Range(0, outsideEnemies.Count - 1)];
				if (GameObject.FindGameObjectsWithTag("OutsideAINode").Length != 0)
				{
					Vector3 position = GameObject.FindGameObjectsWithTag("OutsideAINode")[Random.Range(0, GameObject.FindGameObjectsWithTag("OutsideAINode").Length - 1)].transform.position;
					Spawn(val2.enemyType.enemyPrefab, position);
				}
				else
				{
					Vector3 position2 = ((Component)val).transform.position;
					Vector3 val3 = default(Vector3);
					((Vector3)(ref val3))..ctor(Random.Range(0f - range, range), 0f, Random.Range(0f - range, range));
					Spawn(val2.enemyType.enemyPrefab, position2 + val3);
				}
			}
		}

		public static void SpawnObject(CallbackContext keypressContext)
		{
			//IL_0063: 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_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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)
			if (((CallbackContext)(ref keypressContext)).performed)
			{
				Logger.LogMessage((object)"Spawn Map Object...");
				GameObject val = RoundManager.Instance.playersManager.allPlayerObjects[0];
				List<SpawnableMapObject> list = currentLevel.spawnableMapObjects.ToList();
				SpawnableMapObject val2 = list[Random.Range(0, list.Count - 1)];
				Vector3 val3 = val.transform.position + Vector3.up * 0f;
				Vector3 val4 = default(Vector3);
				((Vector3)(ref val4))..ctor(Random.Range(0f - range, range), 0f, Random.Range(0f - range, range));
				Spawn(val2.prefabToSpawn, val3 + val4);
			}
		}

		public static void SpawnScrap(CallbackContext keypressContext)
		{
			//IL_0060: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			if (((CallbackContext)(ref keypressContext)).performed)
			{
				Logger.LogMessage((object)"Spawn Scrap...");
				GameObject val = RoundManager.Instance.playersManager.allPlayerObjects[0];
				List<SpawnableItemWithRarity> list = currentLevel.spawnableScrap.ToList();
				SpawnableItemWithRarity val2 = list[Random.Range(0, list.Count - 1)];
				Vector3 position = val.transform.position;
				Spawn(val2.spawnableItem.spawnPrefab, position, isScrap: true);
			}
		}

		private static void Spawn(GameObject prefab, Vector3 pos, bool isScrap = false)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			float num = Random.Range(0, 360);
			GameObject val = Object.Instantiate<GameObject>(prefab, pos, Quaternion.Euler(Vector3.zero), RoundManager.Instance.mapPropsContainer.transform);
			val.gameObject.GetComponentInChildren<NetworkObject>().Spawn(true);
			if (isScrap)
			{
				val.gameObject.GetComponentInChildren<GrabbableObject>().itemProperties.itemSpawnsOnGround = false;
				val.gameObject.GetComponentInChildren<GrabbableObject>().SetScrapValue(999);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Pocket.GeckoMoria";

		public const string PLUGIN_NAME = "MyFirstMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace GeckoMoria.Patches
{
	[HarmonyPatch(typeof(PlayerControllerB))]
	public class PlayerControllerBPatch
	{
		[HarmonyPatch("Update")]
		[HarmonyPostfix]
		private static void UpdatePatch(ref PlayerControllerB __instance)
		{
			__instance.sprintMeter = 1f;
		}
	}
}
namespace GeckoMoria.LCInput
{
	public class MyExampleInputClass : LcInputActions
	{
		[InputAction("<Keyboard>/3", Name = "3")]
		public InputAction ThreeKey { get; set; }

		[InputAction("<Keyboard>/4", Name = "4")]
		public InputAction FourKey { get; set; }

		[InputAction("<Keyboard>/5", Name = "5")]
		public InputAction FiveKey { get; set; }

		[InputAction("<Keyboard>/6", Name = "6")]
		public InputAction SixKey { get; set; }
	}
}