Decompiled source of HSRChimerasLIB v1.2.2

HonkaiChimeras.dll

Decompiled 3 weeks 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("HonkaiChimeras")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HonkaiChimeras")]
[assembly: AssemblyTitle("HonkaiChimeras")]
[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 HSRChimerasLIB
{
	[BepInPlugin("CraftyGlitches.HSRChimerasLIB", "Honkai Chimeras LIB", "1.2.2")]
	public class Plugin : BaseUnityPlugin
	{
		private const string GUID = "CraftyGlitches.HSRChimerasLIB";

		private const string NAME = "Honkai Chimeras LIB";

		private const string VERSION = "1.2.2";

		public static Plugin Instance;

		public static ChimerasConfig config;

		public static List<string> ItemAssets = new List<string>
		{
			"Assets/chimeras/anaxa/scholarly chimera.asset", "Assets/chimeras/blade/wounded chimera.asset", "Assets/chimeras/beagle coconut/beagle coconut.asset", "Assets/chimeras/robin/harmonious chimera.asset", "Assets/chimeras/castorice/nightbloom chimera.asset", "Assets/chimeras/ratio/intelligent chimera.asset", "Assets/chimeras/nihility acheron/true nihility chimera.asset", "Assets/chimeras/seele/butterfly chimera.asset", "Assets/chimeras/mydei/pomegranate chimera.asset", "Assets/chimeras/bubbles/bubbles.asset",
			"Assets/chimeras/aventurine/gambler chimera.asset", "Assets/chimeras/tribbie/daisy chimera.asset", "Assets/chimeras/boothill/mechanical chimera.asset", "Assets/chimeras/aglaea/marigold chimera.asset", "Assets/chimeras/fig stew/fig stew.asset", "Assets/chimeras/phainon/moonstone chimera.asset", "Assets/chimeras/acheron/nihility chimera.asset", "Assets/chimeras/chimera youre huge/chimera youre huge.asset"
		};

		public static List<Item> ItemList;

		private void Awake()
		{
			Instance = this;
			ItemList = new List<Item>();
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "hsrchimeraslib");
			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 ChimerasConfig(((BaseUnityPlugin)this).Config);
			foreach (KeyValuePair<Item, SyncedEntry<int>> item in ChimerasConfig.ItemRarity)
			{
				RegisterChimeras(item.Key, SyncedEntry<int>.op_Implicit(item.Value));
				ValidateShopItem(item.Key);
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"CraftyGlitches.HSRChimerasLIB is loaded ! ... Finally a break from work ~ AWOO!");
		}

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

		private void ValidateShopItem(Item item)
		{
			List<string> list = new List<string> { "Beagle Coconut", "Fig Stew" };
			if (!list.Contains(item.itemName))
			{
				return;
			}
			TerminalNode val = ScriptableObject.CreateInstance<TerminalNode>();
			val.clearPreviousText = true;
			string text = "These chimeras seem to have escaped the Garden of Life in Okhema and fled to the company. Perhaps they wanted a change in leadership?";
			string itemName = item.itemName;
			string text2 = itemName;
			if (!(text2 == "Beagle Coconut"))
			{
				if (text2 == "Fig Stew")
				{
					val.displayText = text + "This Chimera seems to enjoy the baths... It also looks like its actively trying to escape being dragged to the baths by Beagle Coconut!";
				}
			}
			else
			{
				val.displayText = text + "For some reason they seem to remind you of a certain... companion. It has a mischievious look to its face. Please do not separate from Fig Stew.";
			}
			Items.RegisterShopItem(item, (TerminalNode)null, (TerminalNode)null, val, Mathf.FloorToInt((float)Random.Range(100, 150)));
		}
	}
	public class ChimerasConfig : SyncedConfig2<ChimerasConfig>
	{
		[field: SyncedEntryField]
		public static Dictionary<Item, SyncedEntry<int>> ItemRarity { get; private set; }

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

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