Decompiled source of Beggars Bazooka v1.0.0

UltraBazooka.dll

Decompiled 4 days ago
using System.CodeDom.Compiler;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Audio;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[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: AssemblyVersion("1.0.0.0")]
namespace UltraBazooka
{
	public class Beggars : MonoBehaviour
	{
		public Projectile projectile;

		public Transform shootPoint;

		public Animator anim;

		private int ammo;

		public GameObject selfExplosion;

		public GameObject loadSound;

		public GameObject shootSound;

		private bool overcharge;

		private bool Ready = true;

		private PlayerInput inman;

		private int loadState;

		public void Start()
		{
			inman = MonoSingleton<InputManager>.Instance.InputSource;
		}

		public void SetReady()
		{
			Ready = true;
		}

		public void OnEnable()
		{
			SetReady();
			ammo = 0;
			FistControl instance = MonoSingleton<FistControl>.Instance;
			instance.forceNoHold++;
		}

		public void OnDisable()
		{
			FistControl instance = MonoSingleton<FistControl>.Instance;
			instance.forceNoHold--;
		}

		public void Update()
		{
			if (!MonoSingleton<OptionsManager>.Instance.paused && !MonoSingleton<FistControl>.Instance.shopping)
			{
				if (inman.Fire1.IsPressed && Ready)
				{
					Ready = false;
					Load();
				}
				if (!inman.Fire1.IsPressed && Ready && ammo > 0)
				{
					Ready = false;
					Shoot();
					overcharge = false;
					anim.SetTrigger("Shoot");
					loadState = 0;
				}
			}
		}

		public void Shoot()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: 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_0032: 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)
			Object.Instantiate<GameObject>(shootSound, ((Component)this).transform.position, Quaternion.identity);
			Projectile obj = Object.Instantiate<Projectile>(projectile, ((Component)shootPoint).transform.position, Quaternion.identity);
			((Component)obj).transform.LookAt(MainCode.bgbeam.hitPosition);
			obj.sourceWeapon = ((Component)this).gameObject;
			ammo--;
		}

		public void Load()
		{
			if (loadState == 0)
			{
				anim.SetTrigger("LoadStart");
				loadState = 1;
			}
			if (loadState == 1)
			{
				anim.SetTrigger("Load");
			}
		}

		public void AddAmmo()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			if (ammo <= 3 && !overcharge)
			{
				ammo++;
				AudioSource val = default(AudioSource);
				if (Object.Instantiate<GameObject>(loadSound, ((Component)this).transform.position, Quaternion.identity).TryGetComponent<AudioSource>(ref val))
				{
					val.pitch = 0.67f + 0.11f * (float)ammo;
				}
			}
			if (ammo > 3)
			{
				overcharge = true;
				ammo--;
			}
			if (overcharge && ammo > 0)
			{
				ammo--;
				Object.Instantiate<GameObject>(selfExplosion, ((Component)this).transform.position, Quaternion.identity);
			}
			if (ammo <= 0)
			{
				overcharge = false;
			}
		}
	}
	public class PlySCBeam : MonoBehaviour
	{
		private GameObject hitParticle;

		public bool active = true;

		public Vector3 hitPosition;

		public Quaternion hitRotation;

		private void Start()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			hitParticle = new GameObject();
		}

		private void FixedUpdate()
		{
		}

		private void Update()
		{
			//IL_0007: 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_001c: 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_0026: 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_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_0042: 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_004e: 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_0094: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			hitPosition = ((Component)this).transform.position + ((Component)this).transform.forward * 100f;
			Vector3 forward = ((Component)this).transform.forward * -1f;
			LayerMask val = LayerMaskDefaults.Get((LMD)3);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(((Component)this).transform.position, ((Component)this).transform.forward, ref val2, 100f, LayerMask.op_Implicit(val), (QueryTriggerInteraction)1))
			{
				hitPosition = ((RaycastHit)(ref val2)).point;
				forward = ((RaycastHit)(ref val2)).normal;
			}
			hitParticle.transform.position = hitPosition;
			hitParticle.transform.forward = forward;
			hitRotation = hitParticle.transform.rotation;
		}
	}
	[BepInPlugin("plonk.ultrabazooker", "UltraBazooka", "1.0.0")]
	public class MainCode : BaseUnityPlugin
	{
		[HarmonyPatch]
		public class Patches
		{
			[HarmonyPrefix]
			[HarmonyPatch(typeof(LeaderboardController), "SubmitLevelScore")]
			[HarmonyPatch(typeof(LeaderboardController), "SubmitCyberGrindScore")]
			private static bool DisableLeaderboardSubmissions()
			{
				return false;
			}

			[HarmonyPrefix]
			[HarmonyPatch(typeof(GunSetter), "ResetWeapons")]
			public static void AddZooka()
			{
				if ((Object)(object)gun == (Object)null)
				{
					gun = Object.Instantiate<GameObject>(MainCode.FetchFromBundle<GameObject>("beggars.prefab", autofill: true), ((Component)MonoSingleton<GunControl>.Instance).transform);
				}
				if (MonoSingleton<GunControl>.Instance.slot6.Count > 0 && MonoSingleton<GunControl>.Instance.slot6 != null)
				{
					if ((Object)(object)MonoSingleton<GunControl>.Instance.slot6[0] != (Object)(object)gun)
					{
						MonoSingleton<GunControl>.Instance.slot6.Insert(0, gun);
					}
				}
				else
				{
					MonoSingleton<GunControl>.Instance.slot6 = new List<GameObject> { gun };
				}
				MonoSingleton<GunControl>.Instance.slots[5] = MonoSingleton<GunControl>.Instance.slot6;
				MonoSingleton<GunControl>.Instance.noWeapons = false;
				((Behaviour)MonoSingleton<GunSetter>.Instance).enabled = true;
				MonoSingleton<GunControl>.Instance.ForceWeapon(gun, true);
			}
		}

		public static bool tcenabled;

		public static AssetBundle tcbundle;

		public static GameObject stray;

		public static GameObject bluearm;

		public static Shader MainShader;

		private static bool candoshit;

		public static bool overhealed;

		public static bool Debugging;

		public static GameObject beam;

		public static PlySCBeam bgbeam;

		public static GameObject gun;

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

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

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

		public static void SetLayerRecursive(GameObject gobject, string layername)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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);
				if ((Object)(object)((Component)val).GetComponentInChildren<Transform>() != (Object)null)
				{
					SetLayerRecursive(((Component)val).gameObject, layername);
				}
			}
		}

		public static GameObject FindChild(Transform parent, string objPath)
		{
			return ((Component)parent.Find(objPath)).gameObject;
		}

		public Vector3 Shake(Vector3 originpos, Vector3 pos, float shakeamt)
		{
			//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_0006: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_0078: 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_009a: 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 static void ReplaceAssets()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_0039: 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_006e: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			List<Material> list = new List<Material>();
			Dictionary<string, AudioMixer> dictionary = new Dictionary<string, AudioMixer>();
			dictionary["AllAudio"] = Addressables.LoadAssetAsync<AudioMixer>((object)"AllAudio").WaitForCompletion();
			dictionary["DoorAudio"] = Addressables.LoadAssetAsync<AudioMixer>((object)"DoorAudio").WaitForCompletion();
			dictionary["GoreAudio"] = Addressables.LoadAssetAsync<AudioMixer>((object)"GoreAudio").WaitForCompletion();
			dictionary["MusicAudio"] = Addressables.LoadAssetAsync<AudioMixer>((object)"MusicAudio").WaitForCompletion();
			dictionary["UnfreezeableAudio"] = Addressables.LoadAssetAsync<AudioMixer>((object)"UnfreezeableAudio").WaitForCompletion();
			GameObject[] array = tcbundle.LoadAllAssets<GameObject>();
			Material[] sharedMaterials;
			foreach (GameObject val in array)
			{
				if (val.GetComponentsInChildren<AudioSource>(true) != null)
				{
					AudioSource[] componentsInChildren = val.GetComponentsInChildren<AudioSource>(true);
					foreach (AudioSource val2 in componentsInChildren)
					{
						if ((Object)(object)val2.outputAudioMixerGroup != (Object)null && dictionary.TryGetValue(((Object)val2.outputAudioMixerGroup.audioMixer).name, out var value))
						{
							val2.outputAudioMixerGroup.audioMixer.outputAudioMixerGroup = value.FindMatchingGroups("Master").FirstOrDefault();
						}
					}
				}
				if (val.GetComponentsInChildren<Renderer>(true) != null)
				{
					Renderer[] componentsInChildren2 = val.GetComponentsInChildren<Renderer>(true);
					foreach (Renderer val3 in componentsInChildren2)
					{
						if ((Object)(object)val3.sharedMaterial != (Object)null)
						{
							ReplaceShader(val3.sharedMaterial, MainShader);
						}
						if (val3.sharedMaterials != null && val3.sharedMaterials.Length != 0)
						{
							sharedMaterials = val3.sharedMaterials;
							foreach (Material val4 in sharedMaterials)
							{
								list.Add(val4);
								ReplaceShader(val4, MainShader);
							}
						}
					}
				}
				if (val.GetComponentsInChildren<ParticleSystemRenderer>(true) == null)
				{
					continue;
				}
				ParticleSystemRenderer[] componentsInChildren3 = val.GetComponentsInChildren<ParticleSystemRenderer>(true);
				foreach (ParticleSystemRenderer val5 in componentsInChildren3)
				{
					if ((Object)(object)((Renderer)val5).sharedMaterial != (Object)null)
					{
						ReplaceShader(((Renderer)val5).sharedMaterial, MainShader);
					}
					if (((Renderer)val5).sharedMaterials != null && ((Renderer)val5).sharedMaterials.Length != 0)
					{
						sharedMaterials = ((Renderer)val5).sharedMaterials;
						foreach (Material val6 in sharedMaterials)
						{
							list.Add(val6);
							ReplaceShader(val6, MainShader);
						}
					}
				}
			}
			Log("[Straymode] Replaced all audio and Shader assets");
			sharedMaterials = tcbundle.LoadAllAssets<Material>();
			foreach (Material val7 in sharedMaterials)
			{
				if (!list.Contains(val7))
				{
					list.Add(val7);
					ReplaceShader(val7, MainShader);
				}
			}
			Log("[Straymode] Replaced all shader assets");
		}

		public static void ReplaceShader(Material mat, Shader shader)
		{
			if ((Object)(object)mat == (Object)null || (Object)(object)mat.shader == (Object)null)
			{
				return;
			}
			int renderQueue = mat.renderQueue;
			Shader shader2 = mat.shader;
			if ((Object)(object)Shader.Find(((Object)shader2).name) != (Object)null)
			{
				if (((Object)mat.shader).name != "Standard")
				{
					mat.shader = Shader.Find(((Object)shader2).name);
				}
				else
				{
					mat.shader = shader;
				}
				mat.renderQueue = renderQueue;
			}
			else if (((Object)shader2).name == ((Object)shader).name)
			{
				mat.shader = shader;
				mat.renderQueue = renderQueue;
			}
			else
			{
				mat.renderQueue = renderQueue;
			}
		}

		public void Awake()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Invalid comparison between Unknown and I4
			if ((Object)(object)((Component)this).gameObject != (Object)null && (int)((Object)((Component)this).gameObject).hideFlags != 61)
			{
				((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			}
			MainShader = Fetch<Shader>("Assets/Shaders/MasterShader/ULTRAKILL-Standard.shader");
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("UltraBazooka.Bundle.beggars"))
			{
				if (stream == null)
				{
					Log("[Bazooka] Failed to load asset bundle stream: Resource not found", 3);
					return;
				}
				AssetBundle val = AssetBundle.LoadFromStream(stream);
				if ((Object)(object)val == (Object)null)
				{
					Log("[Bazooka] Failed to load asset bundle from stream", 3);
					return;
				}
				tcbundle = val;
				string[] allAssetNames = tcbundle.GetAllAssetNames();
				for (int i = 0; i < allAssetNames.Length; i++)
				{
					Log("[Bazooka] " + allAssetNames[i]);
				}
			}
			SceneManager.sceneLoaded += OnSceneLoad;
		}

		public void OnSceneLoad(Scene scene, LoadSceneMode mode)
		{
			if (SceneHelper.CurrentScene != "Main Menu")
			{
				ReplaceAssets();
			}
		}

		public void Start()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("plonk.bazooka").PatchAll();
		}

		public void Update()
		{
			//IL_0049: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			if (!candoshit && SceneHelper.CurrentScene == "Main Menu")
			{
				candoshit = true;
			}
			_ = candoshit;
			if (candoshit && SceneHelper.CurrentScene != "Main Menu" && (Object)(object)beam == (Object)null)
			{
				beam = Object.Instantiate<GameObject>(new GameObject(), ((Component)MonoSingleton<CameraController>.Instance).transform.position, ((Component)MonoSingleton<CameraController>.Instance).transform.rotation, ((Component)MonoSingleton<CameraController>.Instance).transform);
				bgbeam = beam.AddComponent<PlySCBeam>();
			}
		}
	}
}
namespace UltraBazooka.Properties
{
	[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
	[DebuggerNonUserCode]
	[CompilerGenerated]
	public class Resources
	{
		private static ResourceManager resourceMan;

		private static CultureInfo resourceCulture;

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		public static ResourceManager ResourceManager
		{
			get
			{
				if (resourceMan == null)
				{
					resourceMan = new ResourceManager("UltraBazooka.Properties.Resources", typeof(Resources).Assembly);
				}
				return resourceMan;
			}
		}

		[EditorBrowsable(EditorBrowsableState.Advanced)]
		public static CultureInfo Culture
		{
			get
			{
				return resourceCulture;
			}
			set
			{
				resourceCulture = value;
			}
		}

		public static byte[] beggars => (byte[])ResourceManager.GetObject("beggars", resourceCulture);

		internal Resources()
		{
		}
	}
}