Decompiled source of ForsakenFumos v0.1.1

Mods/ForsakenFumos/ForsakenFumos.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using ForsakenFumos;
using ForsakenFumos.Patches;
using HarmonyLib;
using Il2CppFishNet.Managing;
using Il2CppFishNet.Object;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2Cppmadeinfairyland.fairyengine;
using Il2Cppmadeinfairyland.fairyengine.generation;
using Il2Cppmadeinfairyland.fairyengine.kit;
using MelonLoader;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(global::ForsakenFumos.ForsakenFumos), "ForsakenFumos", "0.1.1", "Adi", null)]
[assembly: MelonGame("made in fairyland", "Forsaken Frontiers")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ForsakenFumos")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.1")]
[assembly: AssemblyInformationalVersion("1.0.0+89edb00b6638f4763c98a69b5ebbebc8ea28bcf3")]
[assembly: AssemblyProduct("ForsakenFumos")]
[assembly: AssemblyTitle("ForsakenFumos")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.1.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ForsakenFumos
{
	public class ForsakenFumos : MelonMod
	{
		public static Il2CppAssetBundle FumoAssets;

		public static FairySpawnableKit FumoKit;

		public override void OnInitializeMelon()
		{
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "fumos");
			((MelonBase)this).LoggerInstance.Msg("Loading assets from " + text);
			FumoAssets = Il2CppAssetBundleManager.LoadFromFile(text);
			if (FumoAssets == null)
			{
				((MelonBase)this).LoggerInstance.Error("Failed to load custom assets.");
				return;
			}
			FumoKit = FumoAssets.LoadAsset<FairySpawnableKit>("Assets/Fumos/SpawnableFumos.asset");
			((MelonBase)this).HarmonyInstance.PatchAll(typeof(NetworkManagerPatches));
			((MelonBase)this).HarmonyInstance.PatchAll(typeof(FairyGeneratorPatches));
			((MelonBase)this).LoggerInstance.Msg("Initialized.");
		}
	}
}
namespace ForsakenFumos.Patches
{
	internal class FairyGeneratorPatches
	{
		[HarmonyPatch(typeof(FairyGenerator), "Awake")]
		[HarmonyPrefix]
		private static void FairyGeneratorAwakePrefix(FairyGenerator __instance)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			KitToGenerate val = new KitToGenerate();
			val.kit = ForsakenFumos.FumoKit;
			val.chance = Percent.op_Implicit(30f);
			__instance.kitsToGenerate = new Il2CppReferenceArray<KitToGenerate>(((IEnumerable<KitToGenerate>)__instance.kitsToGenerate).Append(val).ToArray());
		}
	}
	internal class NetworkManagerPatches
	{
		[HarmonyPatch(typeof(NetworkManager), "Start")]
		[HarmonyPrefix]
		private static void NetworkManagerAwakePrefix(NetworkManager __instance)
		{
			Melon<ForsakenFumos>.Logger.Msg("Adding Fumos :3");
			int objectCount = __instance.SpawnablePrefabs.GetObjectCount();
			foreach (Spawnable item in (Il2CppArrayBase<Spawnable>)(object)ForsakenFumos.FumoKit.spawnables)
			{
				__instance.SpawnablePrefabs.AddObject(item.gameObject.GetComponent<NetworkObject>(), false);
			}
			Melon<ForsakenFumos>.Logger.Msg($"Added {__instance.SpawnablePrefabs.GetObjectCount() - objectCount} Fumos");
		}
	}
}