Decompiled source of So Many Ghosts v1.0.0

GhostDrones.dll

Decompiled 3 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using Configgy;
using HarmonyLib;
using UnityEngine;
using UnityEngine.AddressableAssets;
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: AssemblyTitle("ThundergunRevised")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ThundergunRevised")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("5711e2a0-d5a7-4ddf-b8d4-00f355fe9397")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("en-FI")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace GhostDrones
{
	[BepInPlugin("plonk.ghostdrones", "So_Many_Ghosts", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class MainCode : BaseUnityPlugin
	{
		[HarmonyPatch]
		public class Patches
		{
		}

		[Configgable("", "Enabled", 0, "Defines if the mod is enabled.")]
		public static ConfigToggle modEnabled = new ConfigToggle(true);

		[Configgable("", "Dont spawn more than one drone", 0, "Makes the mod not spawn more than one drone.")]
		public static ConfigToggle noMultiSpawn = new ConfigToggle(false);

		[Configgable("", "Spawn Timer", 0, "The time the ghost drones take to spawn")]
		public static ConfigInputField<float> droneSpawnTimer = new ConfigInputField<float>(2f, (Func<float, bool>)null, (Func<string, ValueTuple<bool, float>>)null);

		public static GameObject beam;

		public static BeamgunBeam bgbeam;

		public static AssetBundle tcbundle;

		private static bool candoshit;

		private static float spawnTimer;

		private static Vector3 lastPosition;

		private static GameObject drone;

		private static GameObject dronePrivate;

		public static ConfigBuilder ConfigBuilder { get; private set; }

		public static void SendHudMessage(string msg, int delay, bool silent)
		{
			MonoSingleton<HudMessageReceiver>.Instance.SendHudMessage(msg, "", "", delay, silent);
		}

		public static Type Fetch<Type>(string name)
		{
			//IL_0002: 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)
			return Addressables.LoadAssetAsync<Type>((object)name).WaitForCompletion();
		}

		public static Type FetchFromBundle<Type>(string name, bool autofill = false) where Type : Object
		{
			if (!autofill)
			{
				return tcbundle.LoadAsset<Type>(name);
			}
			return tcbundle.LoadAsset<Type>("assets/formods/crabbytank/" + name);
		}

		public static void SetLayerRecursive(GameObject gobject, string layername)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			gobject.layer = LayerMask.NameToLayer(layername);
			foreach (Transform item in gobject.transform)
			{
				Transform val = item;
				((Component)val).gameObject.layer = LayerMask.NameToLayer(layername);
				Transform componentInChildren = ((Component)val).GetComponentInChildren<Transform>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					SetLayerRecursive(((Component)val).gameObject, layername);
				}
			}
		}

		public Vector3 Shake(Vector3 originpos, Vector3 pos, float shakeamt)
		{
			//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)
			//IL_0007: 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_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_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_003f: 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_0056: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = Vector3.zero;
			val = pos + new Vector3(Random.Range(0f - shakeamt, shakeamt), Random.Range(0f - shakeamt, shakeamt), Random.Range(0f - shakeamt, shakeamt));
			((Vector3)(ref val))..ctor(Mathf.Clamp(val.x, originpos.x - 0.01f, originpos.x + 0.01f), Mathf.Clamp(val.y, originpos.y - 0.01f, originpos.y + 0.01f), Mathf.Clamp(val.z, originpos.z - 0.01f, originpos.z + 0.01f));
			return val;
		}

		public static void Log(string log, int type = 1)
		{
			switch (type)
			{
			case 1:
				Debug.Log((object)log);
				break;
			case 2:
				Debug.LogWarning((object)log);
				break;
			case 3:
				Debug.LogError((object)log);
				break;
			}
		}

		public void Awake()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			ConfigBuilder = new ConfigBuilder("plonk.ghostDrones", "So many Ghosts!");
			ConfigBuilder.Build();
			SceneManager.sceneLoaded += OnLoaded;
		}

		private void Update()
		{
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			if (SceneHelper.CurrentScene == "Main Menu" && !candoshit)
			{
				drone = Fetch<GameObject>("Assets/Prefabs/Enemies/DroneGhost.prefab");
				candoshit = true;
			}
			spawnTimer = Mathf.MoveTowards(spawnTimer, 0f, Time.deltaTime);
			if (!candoshit || !(SceneHelper.CurrentScene != "Main Menu") || !((ConfigValueElement<bool>)(object)modEnabled).Value)
			{
				return;
			}
			if (spawnTimer <= 0f)
			{
				if (!((ConfigValueElement<bool>)(object)noMultiSpawn).Value | ((Object)(object)dronePrivate == (Object)null))
				{
					GameObject val = Object.Instantiate<GameObject>(drone, lastPosition, Quaternion.identity);
					val.AddComponent<DestroyOnCheckpointRestart>();
					val.GetComponent<GhostDrone>().alwaysAggro = true;
					GhostDrone component = val.GetComponent<GhostDrone>();
					component.variableAttackSpeed *= 1.5f;
					dronePrivate = val;
				}
				if (((ConfigValueElement<bool>)(object)noMultiSpawn).Value)
				{
					dronePrivate.transform.position = lastPosition;
				}
				spawnTimer = ((ConfigValueElement<float>)(object)droneSpawnTimer).Value;
			}
			if ((spawnTimer * 2f < ((ConfigValueElement<float>)(object)droneSpawnTimer).Value + 0.1f) & (spawnTimer * 2f > ((ConfigValueElement<float>)(object)droneSpawnTimer).Value - 0.1f))
			{
				lastPosition = ((Component)MonoSingleton<NewMovement>.instance).transform.position;
			}
		}

		public void OnLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_000b: 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)
			lastPosition = ((Component)MonoSingleton<NewMovement>.instance).transform.position;
			spawnTimer = 2f;
		}

		public void Start()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			Harmony val = new Harmony("plonk.GhostDronesPatches");
			val.PatchAll();
		}
	}
}
namespace BigSillyGutterman
{
	internal class BeamID : MonoBehaviour
	{
	}
}