Decompiled source of Invalid Gateway Pack v0.1.2

Sai_Inval.dll

Decompiled a month 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 BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using MoreCompany.Utils;
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 = "")]
[assembly: AssemblyCompany("Sai_Inval")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Sai_Inval")]
[assembly: AssemblyTitle("Sai_Inval")]
[assembly: AssemblyVersion("1.0.0.0")]
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;
		}
	}
}
namespace Sai_Inval
{
	[HarmonyPatch]
	internal class BugPatch
	{
		[HarmonyPatch(typeof(HoarderBugAI), "Start")]
		[HarmonyPostfix]
		public static void addController(HoarderBugAI __instance)
		{
			((Component)__instance).gameObject.AddComponent<CatController>();
		}
	}
	internal class CatController : MonoBehaviour
	{
		private HoarderBugAI BugAI;

		private Animator animator;

		private bool IsDead;

		private Vector3 prevPosition;

		private static GameObject CatModel;

		private void HideBug()
		{
			try
			{
				Renderer[] componentsInChildren = ((Component)((Component)BugAI).transform.Find("HoarderBugModel")).GetComponentsInChildren<Renderer>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					componentsInChildren[i].enabled = false;
				}
			}
			catch (Exception)
			{
				for (int j = 0; j < ((Component)BugAI).transform.childCount - 1; j++)
				{
				}
			}
		}

		private void ShowNewModel()
		{
			try
			{
				MeshRenderer[] componentsInChildren = CatModel.GetComponentsInChildren<MeshRenderer>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					((Renderer)componentsInChildren[i]).enabled = true;
				}
			}
			catch (Exception)
			{
			}
		}

		private void Start()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			BugAI = ((Component)this).GetComponent<HoarderBugAI>();
			CatModel = Object.Instantiate<GameObject>(Plugin.Cat, ((Component)BugAI).transform.position, Quaternion.identity, ((Component)BugAI).transform);
			animator = CatModel.GetComponent<Animator>();
			HideBug();
			ShowNewModel();
		}

		private void Update()
		{
			//IL_0029: 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_004b: 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)
			animator.SetBool("Hostile", ((EnemyAI)BugAI).movingTowardsTargetPlayer);
			animator.SetBool("Moving", prevPosition != ((Component)this).transform.position);
			prevPosition = ((Component)this).transform.position;
			if (((EnemyAI)BugAI).isEnemyDead && !IsDead)
			{
				Die();
			}
		}

		private void Die()
		{
			animator.SetBool("Dead", true);
			IsDead = true;
		}
	}
	[BepInPlugin("Sai.Inval", "Invalid Gateway Pack", "0.1.2")]
	public class Plugin : BaseUnityPlugin
	{
		public class ScrapObject
		{
			public string name;

			public int rarity;

			public LevelTypes levels;

			public int Special;

			private AssetBundle? bundle;

			public ScrapObject(string MyName, int MyRarity, LevelTypes MyLevels)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				name = MyName;
				rarity = MyRarity;
				levels = MyLevels;
				Special = 0;
				bundle = null;
			}

			public ScrapObject(string MyName, int MyRarity, LevelTypes MyLevels, int MySpecial)
			{
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0018: Unknown result type (might be due to invalid IL or missing references)
				name = MyName;
				rarity = MyRarity;
				levels = MyLevels;
				Special = MySpecial;
				bundle = null;
			}

			public void SetBundle(AssetBundle MyBundle)
			{
				bundle = MyBundle;
			}

			public AssetBundle GetBundle()
			{
				return bundle;
			}
		}

		private static Plugin _instance;

		private static Harmony _harmony;

		public static ManualLogSource log;

		private bool _initialized;

		private List<AssetBundle> Enemies = new List<AssetBundle>();

		private List<AssetBundle> PlayerModels = new List<AssetBundle>();

		private List<AssetBundle> Cosmetics = new List<AssetBundle>();

		private List<ScrapObject> ScrapObjects;

		private List<string> EnemyNames = new List<string>();

		private List<string> PlayerModelNames = new List<string>();

		private List<string> CosmeticNames = new List<string>();

		public static GameObject Cat;

		internal static Plugin Instance
		{
			get
			{
				return _instance;
			}
			set
			{
				if ((Object)(object)_instance == (Object)null)
				{
					_instance = value;
				}
				else
				{
					Object.Destroy((Object)(object)value);
				}
			}
		}

		private void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			_instance = this;
			if (_harmony == null)
			{
				_harmony = new Harmony("Sai.Inval");
			}
			_harmony.PatchAll(typeof(BugPatch));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin Sai_Inval is loaded!");
			ScrapObjects = new List<ScrapObject>();
			ScrapObject item = new ScrapObject("sparky", 20, (LevelTypes)(-1));
			ScrapObject item2 = new ScrapObject("swolekid", 20, (LevelTypes)(-1));
			ScrapObjects.Add(item);
			ScrapObjects.Add(item2);
			EnemyNames.Add("cat");
			LoadAssets();
		}

		private void LoadAssets()
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			if (executingAssembly == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to get assembly.");
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Scrap 1 name is {ScrapObjects[0].name} Rarity is {ScrapObjects.ElementAt(0).rarity}");
			for (int i = 0; i < ScrapObjects.Count; i++)
			{
				ScrapObjects[i].SetBundle(BundleUtilities.LoadBundleFromInternalAssembly("Sai_Inval.Bundles.Scrap." + ScrapObjects[i].name, executingAssembly));
			}
			if ((Object)(object)ScrapObjects[0].GetBundle() == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Sparky bundle returned as NULL");
			}
			for (int j = 0; j < ScrapObjects.Count; j++)
			{
				LoadScrap(ScrapObjects[j]);
			}
			AssetBundle val = BundleUtilities.LoadBundleFromInternalAssembly("Sai_Inval.Bundles.Enemies.cat", executingAssembly);
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Where the fuck is the cat");
			}
			Cat = val.LoadAsset<GameObject>("Cat.prefab");
			if ((Object)(object)Cat != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Cat Exists");
			}
		}

		private void LoadScrap(ScrapObject MyScrap)
		{
			Item val = MyScrap.GetBundle().LoadAsset<Item>("Assets/CustomScrap/ScriptableObjects/" + MyScrap.name + "Stats.asset");
			if ((Object)(object)val == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load " + MyScrap.name + " from " + ((Object)MyScrap.GetBundle()).name));
				return;
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)(MyScrap.name + " successfully loaded!"));
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			Items.RegisterScrap(val, MyScrap.rarity, (LevelTypes)(-1));
		}

		private void LoadEnemies(AssetBundle Bundle, int SpecialCase = 0)
		{
		}

		private void LoadCosmetics(AssetBundle Bundle, int SpecialCase = 0)
		{
		}

		private void LoadPlayerModels(AssetBundle Bundle, Assembly assembly)
		{
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_ID = "Sai_Inval";

		public const string PLUGIN_NAME = "Invalid Gateway Pack";

		public const string PLUGIN_VERSION = "0.1.2";

		public const string PLUGIN_GUID = "Sai.Inval";
	}
}