Decompiled source of ZilverK Mod v1.0.0

BepInEx\plugins\ZilverkMod.dll

Decompiled a year ago
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("LaserTweaks")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LaserTweaks")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4963e0ea-7a99-4390-9cae-a4bdd01b6b43")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[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 System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}
namespace ZilverkMod
{
	public class Assets
	{
		public static AssetBundle MainAssetBundle;

		public static EnemyType EnemyType;

		public static TerminalNode EnemyNode;

		public static TerminalKeyword EnemyKeyword;

		internal static Stream GetEmbededResource(string name)
		{
			return Assembly.GetExecutingAssembly().GetManifestResourceStream("ZilverkMod." + name);
		}

		public static void Init()
		{
			MainAssetBundle = AssetBundle.LoadFromStream(GetEmbededResource("zilverk.bundle"));
			EnemyType = MainAssetBundle.LoadAsset<EnemyType>("Assets/Mods/ZilverK_Monster/ZilverK.asset");
		}
	}
	[BepInPlugin("Kittenji.ZilverK.AI", "ZilverKMod", "1.0.0")]
	public class Loader : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(GameNetworkManager))]
		internal class GameNetworkManagerPatch
		{
			[HarmonyPatch("Start")]
			[HarmonyPostfix]
			private static void StartPatch()
			{
				((Component)GameNetworkManager.Instance).GetComponent<NetworkManager>().AddNetworkPrefab(Assets.EnemyType.enemyPrefab);
				Debug.Log((object)"[ZK] Added network prefab");
			}
		}

		[HarmonyPatch(typeof(StartOfRound))]
		internal class StartOfRoundPatch
		{
			[HarmonyPatch("Awake")]
			[HarmonyPostfix]
			private static void AwakePatch(ref StartOfRound __instance)
			{
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Expected O, but got Unknown
				EnemyType enemyDef = Assets.EnemyType;
				SelectableLevel[] levels = __instance.levels;
				foreach (SelectableLevel val in levels)
				{
					if (!val.Enemies.Any((SpawnableEnemyWithRarity e) => (Object)(object)e.enemyType == (Object)(object)enemyDef))
					{
						SpawnableEnemyWithRarity val2 = val.Enemies.Find((SpawnableEnemyWithRarity e) => Object.op_Implicit((Object)(object)e.enemyType) && Object.op_Implicit((Object)(object)e.enemyType.enemyPrefab) && ((Object)e.enemyType.enemyPrefab).name == "HoarderBug");
						if (val2 != null)
						{
							Debug.Log((object)("[ZK] Adding entity to level: " + val.PlanetName));
							val.Enemies.Add(new SpawnableEnemyWithRarity
							{
								enemyType = enemyDef,
								rarity = val2.rarity
							});
						}
					}
				}
			}
		}

		private const string modGUID = "Kittenji.ZilverK.AI";

		private readonly Harmony harmony = new Harmony("Kittenji.ZilverK.AI");

		private void Awake()
		{
			Assets.Init();
			harmony.PatchAll();
		}
	}
}