Decompiled source of ShogunEra v1.0.0

ShogunEra.dll

Decompiled 9 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ShogunEra")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ShogunEra")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bbdc753f-4c35-48c6-9cca-1956bbe12bd2")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ShogunEra;

[BepInPlugin("com.azathoth.shogunera", "Shogun Era", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
public class ShogunEra : BaseUnityPlugin
{
	private class Patches
	{
	}

	public const string PluginGUID = "com.azathoth.shogunera";

	public const string PluginName = "Shogun Era";

	public const string PluginVersion = "1.0.0";

	private bool addedPrefabs = false;

	public static CustomLocalization Localization;

	public static List<AssetBundle> bundles = new List<AssetBundle>();

	public static Dictionary<string, List<GameObject>> loadedAssets = new Dictionary<string, List<GameObject>>();

	private static Harmony harm = new Harmony("AzathothShogunEra");

	private void Awake()
	{
		LoadBundles();
		LoadAssets();
		PrefabManager.OnVanillaPrefabsAvailable += OnVanillaPrefabsAvailable;
		harm.PatchAll();
	}

	private void OnVanillaPrefabsAvailable()
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Expected O, but got Unknown
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Expected O, but got Unknown
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Expected O, but got Unknown
		if (addedPrefabs)
		{
			return;
		}
		foreach (GameObject item in loadedAssets["items"])
		{
			ItemConfig val = new ItemConfig();
			val.Enabled = true;
			val.Icon = RenderManager.Instance.Render(item, RenderManager.IsometricRotation);
			val.CraftingStation = CraftingStations.None;
			val.Requirements = (RequirementConfig[])(object)new RequirementConfig[1]
			{
				new RequirementConfig
				{
					Item = "Wood",
					Amount = 1
				}
			};
			CustomItem val2 = new CustomItem(item, false, val);
			ItemManager.Instance.AddItem(val2);
			Debug.Log((object)("Added Item: " + ((Object)item).name));
		}
		addedPrefabs = true;
	}

	private void LoadAssets()
	{
		foreach (AssetBundle bundle in bundles)
		{
			GameObject[] array = bundle.LoadAllAssets<GameObject>();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if ((Object)(object)val.GetComponent<ItemDrop>() != (Object)null)
				{
					if (loadedAssets.ContainsKey("items"))
					{
						loadedAssets["items"].Add(val);
						continue;
					}
					loadedAssets.Add("items", new List<GameObject> { val });
				}
			}
		}
	}

	private void LoadBundles()
	{
		AssetBundle item = AssetUtils.LoadAssetBundleFromResources("shogunera");
		bundles.Add(item);
	}
}