Decompiled source of MHAFigurinesMod v1.0.0

MHAFigurinesMod.dll

Decompiled 18 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 BepInEx;
using BepInEx.Configuration;
using CSync.Extensions;
using CSync.Lib;
using LethalLib.Modules;
using Microsoft.CodeAnalysis;
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 = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MHAFigurinesMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MHAFigurinesMod")]
[assembly: AssemblyTitle("MHAFigurinesMod")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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 MHAFigurinesMod
{
	[BepInPlugin("CraftyGlitches.MHAFigurinesMod", "MHA Figurines Mod", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "CraftyGlitches.MHAFigurinesMod";

		private const string NAME = "MHA Figurines Mod";

		private const string VERSION = "1.0.0";

		public static Plugin Instance;

		public static MHAFigurinesConfig config;

		public static List<string> ItemAssets = new List<string> { "Assets/MHAFigurine/aizawa/AizawaFigurine.asset", "Assets/MHAFigurine/endeavor/EndeavorFigurine.asset", "Assets/MHAFigurine/dabi/DabiFigurine.asset", "Assets/MHAFigurine/shigaraki/ShigarakiFigurine.asset", "Assets/MHAFigurine/shoto/ShotoFigurine.asset" };

		public static List<Item> ItemList;

		private void Awake()
		{
			Instance = this;
			ItemList = new List<Item>();
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "mhafigurinesmod");
			AssetBundle val = AssetBundle.LoadFromFile(text);
			foreach (string itemAsset in ItemAssets)
			{
				Item val2 = val.LoadAsset<Item>(itemAsset);
				if ((Object)(object)val2 == (Object)null)
				{
					Debug.LogError((object)(itemAsset + " is not accessible, please check your asset path again"));
				}
				else
				{
					ItemList.Add(val2);
				}
			}
			config = new MHAFigurinesConfig(((BaseUnityPlugin)this).Config);
			foreach (KeyValuePair<Item, SyncedEntry<int>> item in MHAFigurinesConfig.ItemRarity)
			{
				RegisterFigurines(item.Key, SyncedEntry<int>.op_Implicit(item.Value));
				ValidateShopItem(item.Key);
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"CraftyGlitches.MHAFigurinesMod is loaded ! ... Figurine collection!");
		}

		public static void RemovePostProcessing(GameObject spawnPrefab)
		{
			if (!((Object)(object)spawnPrefab != (Object)null))
			{
				return;
			}
			MeshRenderer[] componentsInChildren = spawnPrefab.GetComponentsInChildren<MeshRenderer>();
			MeshRenderer[] array = componentsInChildren;
			MeshRenderer[] array2 = array;
			foreach (MeshRenderer val in array2)
			{
				Material[] materials = ((Renderer)val).materials;
				foreach (Material val2 in materials)
				{
					if (val2.renderQueue < 3000)
					{
						val2.renderQueue = 2900;
					}
				}
			}
		}

		private void RegisterFigurines(Item item, int value)
		{
			GameObject spawnPrefab = item.spawnPrefab;
			RemovePostProcessing(spawnPrefab);
			NetworkPrefabs.RegisterNetworkPrefab(spawnPrefab);
			Utilities.FixMixerGroups(spawnPrefab);
			if (item.itemName == "testname")
			{
				Items.RegisterScrap(item, value, (LevelTypes)12288);
			}
			else
			{
				Items.RegisterScrap(item, value, (LevelTypes)(-1));
			}
		}

		private void ValidateShopItem(Item item)
		{
			List<string> list = new List<string> { "ShotoFigurine", "DabiFigurine", "ShigarakiFigurine", "EndeavorFigurine", "AizawaFigurine" };
			if (list.Contains(item.itemName))
			{
				TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
				val.clearPreviousText = true;
				string text = "Figurines for sale!";
				switch (item.itemName)
				{
				case "ShotoFigurine":
					val.displayText = text + "A totally officially licensed figurine, best served with cold soba.";
					break;
				case "DabiFigurine":
					val.displayText = text + "Made from a mysterious source, smells a little like a forest fire.";
					break;
				case "ShigarakiFigurine":
					val.displayText = text + "All Might judges you not politely.";
					break;
				case "EndeavorFigurine":
					val.displayText = text + "SHOTOOOOOOOOOOOOOOOOOOOOOO!";
					break;
				case "AizawaFigurine":
					val.displayText = text + "Officially licensed figurine of the pro hero Eraser Head!";
					break;
				}
				Items.RegisterShopItem(item, (TerminalNode)null, (TerminalNode)null, val, Mathf.FloorToInt((float)Random.Range(100, 150)));
			}
		}
	}
	public class MHAFigurinesConfig : SyncedConfig2<MHAFigurinesConfig>
	{
		[field: SyncedEntryField]
		public static Dictionary<Item, SyncedEntry<int>> ItemRarity { get; private set; }

		public MHAFigurinesConfig(ConfigFile config)
			: base("CraftyGlitches.MHAFigurinesMod")
		{
			ItemRarity = new Dictionary<Item, SyncedEntry<int>>();
			List<string> list = new List<string> { "ShotoFigurine" };
			foreach (Item item in Plugin.ItemList)
			{
				if (list.Contains(item.itemName))
				{
					string itemName = item.itemName;
					string text = itemName;
					if (text == "ShotoFigurine")
					{
						ItemRarity[item] = SyncedBindingExtensions.BindSyncedEntry<int>(config, "Figurines rarity", item.itemName ?? "", 20, "Changing rarity value for: " + item.itemName + ".\n\nEnter your desired value.\n\nYou can check the names of the figurines on my thunderstore wiki page.");
					}
				}
				else
				{
					ItemRarity[item] = SyncedBindingExtensions.BindSyncedEntry<int>(config, "Figurines rarity", item.itemName ?? "", 20, "Changing rarity value for: " + item.itemName + ".\n\nEnter your desired value.\n\nYou can check the names of the figurines on my thunderstore wiki page.");
				}
			}
			ConfigManager.Register<MHAFigurinesConfig>((SyncedConfig2<MHAFigurinesConfig>)(object)this);
		}

		public static void AssetLoader(List<string> list)
		{
		}
	}
}