Decompiled source of ElGrinchosAndFriends v1.0.0

plugins/El Grinchos and Friends/El Grinchos and Friends.dll

Decompiled 4 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using El Grinchos and Friends.NetcodePatcher;
using ElGrinchosAndFriends.Configuration;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("El Grinchos and Friends")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4f4c394ee103fc03394c4fe85ea5778e299d27f7")]
[assembly: AssemblyProduct("ElGrinchosAndFriends")]
[assembly: AssemblyTitle("El Grinchos and Friends")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: NetcodePatchedAssembly]
internal class <Module>
{
	static <Module>()
	{
	}
}
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;
		}
	}
	[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 ExampleEnemy
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "El Grinchos and Friends";

		public const string PLUGIN_NAME = "ElGrinchosAndFriends";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ElGrinchosAndFriends
{
	[BepInPlugin("Kyriso.ElGrinchosAndFriends", "ElGrinchosAndFriends", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static AssetBundle? ModAssets;

		internal static PluginConfig BoundConfig { get; private set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			BoundConfig = new PluginConfig(((BaseUnityPlugin)this).Config);
			Logger.LogInfo((object)"\r\n                                                                                                    \r\n                                                                                                    \r\n                                              ========                                              \r\n                                            ===     ===                                             \r\n                                            ======    ==                                            \r\n                                                       ==                                           \r\n                                                       ===                                          \r\n                                                         =                                          \r\n                                                         =                                          \r\n                                       #+    ========== ==                                          \r\n                                       =%%* ==============                                          \r\n                                         -#@+=========#@%#                                          \r\n                                       --==========*@@+===                                          \r\n                                    **----===============                                           \r\n                                   -------===========----%-                                         \r\n                                   -------===========-------                                        \r\n                                    -----=============-----                                         \r\n                                     -===================                                           \r\n                             ===========================                                            \r\n                            =======+%@%#%%##%##%@*====-----                                         \r\n                            ====+@%==============+@*===========                                     \r\n                            ===*@=================+%@#+========-                                    \r\n                            ==#@@@@%@@@%#######%@@@@@@@%=======-                                    \r\n                             ==============================--==                                     \r\n                               =============================                                        \r\n                                      ================                                              \r\n                                       =========                                                    \r\n                                       =========                                                    \r\n               =====-                 -=========                                                    \r\n               ===-===                ===========-                                                  \r\n               ====-====             ===============-                                               \r\n               ==-===-==             ================-                                              \r\n                ========-           ===================================--                           \r\n                 ===========--      ========================================                        \r\n                   ====-====================-.==========               ==-===                       \r\n                      -=======================-:-=======                  ===-                      \r\n                                    ======================                 =--=                     \r\n                                    =====================                          \r\n\r\n___________.__      ________      .__              .__                  \r\n\\_   _____/|  |    /  _____/______|__| ____   ____ |  |__   ____  ______\r\n |    __)_ |  |   /   \\  __\\_  __ \\  |/    \\_/ ___\\|  |  \\ /  _ \\/  ___/\r\n |        \\|  |__ \\    \\_\\  \\  | \\/  |   |  \\  \\___|   Y  (  <_> )___ \\ \r\n/_______  /|____/  \\______  /__|  |__|___|  /\\___  >___|  /\\____/____  >\r\n        \\/                \\/              \\/     \\/     \\/           \\/                  \r\n                                                                                            \r\n");
			InitializeNetworkBehaviours();
			string path = "modassets";
			ModAssets = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), path));
			if ((Object)(object)ModAssets == (Object)null)
			{
				Logger.LogError((object)"Failed to load custom assets.");
				return;
			}
			Item val = ModAssets.LoadAsset<Item>("ElGrinchosItem");
			if ((Object)(object)val == (Object)null)
			{
				Logger.LogError((object)"Failed to load ElGrinchosItem item from AssetBundle.");
				return;
			}
			NetworkPrefabs.RegisterNetworkPrefab(val.spawnPrefab);
			int value = BoundConfig.SpawnWeightElGrinchos.Value;
			Items.RegisterScrap(val, value, (LevelTypes)(-1));
			Logger.LogInfo((object)"ElGrinchos is in the game !");
			Item val2 = ModAssets.LoadAsset<Item>("ElGoldchosItem");
			if ((Object)(object)val2 == (Object)null)
			{
				Logger.LogError((object)"Failed to load ElGoldchosItem item from AssetBundle.");
				return;
			}
			NetworkPrefabs.RegisterNetworkPrefab(val2.spawnPrefab);
			int value2 = BoundConfig.SpawnWeightELGoldchos.Value;
			Items.RegisterScrap(val2, value2, (LevelTypes)(-1));
		}

		private static void InitializeNetworkBehaviours()
		{
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			Type[] array = types;
			foreach (Type type in array)
			{
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.NonPublic);
				MethodInfo[] array2 = methods;
				foreach (MethodInfo methodInfo in array2)
				{
					object[] customAttributes = methodInfo.GetCustomAttributes(typeof(RuntimeInitializeOnLoadMethodAttribute), inherit: false);
					if (customAttributes.Length != 0)
					{
						methodInfo.Invoke(null, null);
					}
				}
			}
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "Kyriso.ElGrinchosAndFriends";

		public const string PLUGIN_NAME = "ElGrinchosAndFriends";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ElGrinchosAndFriends.Configuration
{
	public class PluginConfig
	{
		public ConfigEntry<int> SpawnWeightElGrinchos;

		public ConfigEntry<int> SpawnWeightELGoldchos;

		public PluginConfig(ConfigFile cfg)
		{
			SpawnWeightElGrinchos = cfg.Bind<int>("General", "Spawn weight ElGrinchos", 20, "The spawn chance weight for ElGrinchos, relative to other existing items.\nGoes up from 0, lower is more rare, 100 and up is very common.");
			SpawnWeightELGoldchos = cfg.Bind<int>("General", "Spawn weight ELGoldchos", 5, "The spawn chance weight for ELGoldchos, relative to other existing items.\nGoes up from 0, lower is more rare, 100 and up is very common.");
			ClearUnusedEntries(cfg);
		}

		private void ClearUnusedEntries(ConfigFile cfg)
		{
			PropertyInfo property = ((object)cfg).GetType().GetProperty("OrphanedEntries", BindingFlags.Instance | BindingFlags.NonPublic);
			Dictionary<ConfigDefinition, string> dictionary = (Dictionary<ConfigDefinition, string>)property.GetValue(cfg, null);
			dictionary.Clear();
			cfg.Save();
		}
	}
}
namespace El Grinchos and Friends.NetcodePatcher
{
	[AttributeUsage(AttributeTargets.Module)]
	internal class NetcodePatchedAssemblyAttribute : Attribute
	{
	}
}