Decompiled source of HSRFigurinesMod v1.3.1

HSRFigurinesMod.dll

Decompiled 4 days 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("HSRFigurinesMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HSRFigurinesMod")]
[assembly: AssemblyTitle("HSRFigurinesMod")]
[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 HSRFigurinesMod
{
	[BepInPlugin("CraftyGlitches.HSRFigurinesMod", "Honkai Figurines Mod", "1.3.1")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "CraftyGlitches.HSRFigurinesMod";

		private const string NAME = "Honkai Figurines Mod";

		private const string VERSION = "1.3.1";

		public static Plugin Instance;

		public static HSRFigurinesConfig config;

		public static List<string> ItemAssets = new List<string>
		{
			"Assets/figurines/sparxievtuber/sparxieconfigure.asset", "Assets/figurines/sundayfigure/sundayfigure.asset", "Assets/figurines/bladebase/bladebasefigure.asset", "Assets/figurines/imbibitorlunae/imbibitorlunaefigure.asset", "Assets/figurines/phainon/phainonfigure.asset", "Assets/figurines/aventurine/aventurinefigure.asset", "Assets/figurines/fugue/fuguefigure.asset", "Assets/figurines/cyrene/cyrenefigure.asset", "Assets/figurines/serval/servalfigure.asset", "Assets/figurines/acheron/acheronfigure.asset",
			"Assets/figurines/seele/seelefigure.asset", "Assets/figurines/robin/robinfigure.asset", "Assets/figurines/pearl/pearlfigure.asset", "Assets/figurines/hysilens/hysilensfigure.asset", "Assets/figurines/ashveil/ashveilfigure.asset", "Assets/figurines/kafka/kafkafigure.asset", "Assets/figurines/blackswan/blackswanfigure.asset", "Assets/figurines/jingyuan/jingyuanfigure.asset", "Assets/figurines/silverwolf999/silverwolf999figure.asset", "Assets/figurines/sparxie/sparxiefigure.asset",
			"Assets/figurines/boothill/boothillfigure.asset", "Assets/figurines/aglaea/aglaeafigure.asset", "Assets/figurines/evanescia/evanesciafigure.asset", "Assets/figurines/anaxa/anaxafigure.asset", "Assets/figurines/feixiao/feixiaofigure.asset", "Assets/figurines/march/marchfigure.asset"
		};

		public static List<Item> ItemList;

		private void Awake()
		{
			Instance = this;
			ItemList = new List<Item>();
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "hsrfigurinesmod");
			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 HSRFigurinesConfig(((BaseUnityPlugin)this).Config);
			foreach (KeyValuePair<Item, SyncedEntry<int>> item in HSRFigurinesConfig.ItemRarity)
			{
				RegisterFigurines(item.Key, SyncedEntry<int>.op_Implicit(item.Value));
				ValidateShopItem(item.Key);
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"CraftyGlitches.HSRFigurinesMod 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> { "SparxieConOfficial Figurine", "ImbibitorLunaeFigurine", "SundayFigurine", "BladeFigurine", "AventurineFigurine", "AshveilFigurine", "KafkaFigurine", "RobinFigurine" };
			if (list.Contains(item.itemName))
			{
				TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
				val.clearPreviousText = true;
				string text = "Figurines for sale!";
				switch (item.itemName)
				{
				case "SparxieConOfficial Figurine":
					val.displayText = text + "Thanks for the gifted!";
					break;
				case "ImbibitorLunaeFigurine":
					val.displayText = text + "You don't know why this figure isn't quite popular amongst the vidyadharas.";
					break;
				case "SundayFigurine":
					val.displayText = text + "Let him cleanse your sins...";
					break;
				case "BladeFigurine":
					val.displayText = text + "Its all apart of the script.";
					break;
				case "AventurineFigurine":
					val.displayText = text + "Not an official figurine, please report fakes to the IPC!";
					break;
				case "AshveilFigurine":
					val.displayText = text + "Got him straight from a freezer!";
					break;
				case "KafkaFigurine":
					val.displayText = text + "The IPC questions why you would purchase this very illegal figurine.";
					break;
				case "RobinFigurine":
					val.displayText = text + "Show support to Robin!";
					break;
				}
				Items.RegisterShopItem(item, (TerminalNode)null, (TerminalNode)null, val, Mathf.FloorToInt((float)Random.Range(100, 150)));
			}
		}
	}
	public class HSRFigurinesConfig : SyncedConfig2<HSRFigurinesConfig>
	{
		[field: SyncedEntryField]
		public static Dictionary<Item, SyncedEntry<int>> ItemRarity { get; private set; }

		public HSRFigurinesConfig(ConfigFile config)
			: base("CraftyGlitches.HSRFigurinesMod")
		{
			ItemRarity = new Dictionary<Item, SyncedEntry<int>>();
			List<string> list = new List<string> { "SparxieConOfficial Figurine", "BladeFigurine" };
			foreach (Item item in Plugin.ItemList)
			{
				if (list.Contains(item.itemName))
				{
					string itemName = item.itemName;
					string text = itemName;
					if (!(text == "SparxieConOfficial Figurine"))
					{
						if (text == "BladeFigurine")
						{
							ItemRarity[item] = SyncedBindingExtensions.BindSyncedEntry<int>(config, "Figurines rarity", item.itemName ?? "", 30, "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 ?? "", 30, "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<HSRFigurinesConfig>((SyncedConfig2<HSRFigurinesConfig>)(object)this);
		}

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