Decompiled source of MonkArmor v0.2.3

plugins\MonkArmor.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.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using MonkArmor;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("JotunnModExample")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("JotunnModExample")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
public class SetEffect_MonkArmor : SE_Stats
{
	public override void ModifyAttack(SkillType skill, ref HitData hitData)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Invalid comparison between Unknown and I4
		if ((int)skill == 11)
		{
			hitData.m_damage.m_damage += ((Character)Player.m_localPlayer).GetSkills().GetSkillLevel((SkillType)11) * global::MonkArmor.MonkArmor.MonkSetDamageSkillConfig.Value;
			HitData obj = hitData;
			obj.m_pushForce += ((Character)Player.m_localPlayer).GetSkills().GetSkillLevel((SkillType)11) * global::MonkArmor.MonkArmor.MonkSetPushForceConfig.Value;
		}
	}
}
namespace MonkArmor;

[BepInPlugin("org.bepinex.plugins.bid.monkarmor", "MonkArmor", "0.2.3")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
internal class MonkArmor : BaseUnityPlugin
{
	public const string PluginGUID = "org.bepinex.plugins.bid.monkarmor";

	public const string PluginName = "MonkArmor";

	public const string PluginVersion = "0.2.3";

	public static ConfigEntry<float> MonkSetDamageSkillConfig;

	public static ConfigEntry<float> MonkSetPushForceConfig;

	private readonly Harmony harmony = new Harmony("org.bepinex.plugins.bid.monkarmor");

	private void Awake()
	{
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		AssetBundle val = AssetUtils.LoadAssetBundleFromResources("monkarmor");
		if ((Object)(object)val == (Object)null)
		{
			MonoBehaviour.print((object)"Error loading assetbundle monkarmor");
			return;
		}
		CreateConfigValues();
		AddStatusEffects();
		AddCustomItemConversions();
		AddItemsWithConfigs();
		try
		{
			AddItems(val);
			AddCreatures(val);
			AddPieces(val);
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)$"Exception caught while adding custom creatures: {arg}");
		}
		finally
		{
			val.Unload(false);
		}
		PrefabManager.OnVanillaPrefabsAvailable += AddClonedItems;
		AddRecipes();
		new Harmony("org.bepinex.plugins.bid.monkarmor").PatchAll();
	}

	private void OnDestroy()
	{
		harmony.UnpatchSelf();
	}

	private void CreateConfigValues()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Expected O, but got Unknown
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Expected O, but got Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Expected O, but got Unknown
		((BaseUnityPlugin)this).Config.SaveOnConfigSet = true;
		MonkSetDamageSkillConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "MonkSetEffectDamageModifier", 1f, new ConfigDescription("MonkSetEffect spirit damage + (unarmed skill * config value)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		MonkSetPushForceConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Server config", "MonkSetEffectPushbackModifier", 1f, new ConfigDescription("MonkSetEffect pushback force + (unarmed skill * config value)", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		SynchronizationManager.OnConfigurationSynchronized += delegate(object obj, ConfigurationSynchronizationEventArgs attr)
		{
			if (attr.InitialSynchronization)
			{
				Logger.LogMessage((object)"Initial Config sync event received");
			}
			else
			{
				Logger.LogMessage((object)"Config sync event received");
			}
		};
	}

	private void AddStatusEffects()
	{
	}

	private void AddCustomItemConversions()
	{
	}

	private void AddItemsWithConfigs()
	{
	}

	private void AddClonedItems()
	{
		PrefabManager.OnVanillaPrefabsAvailable -= AddClonedItems;
	}

	private void AddItems(AssetBundle christianityAssetBundle)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Expected O, but got Unknown
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Expected O, but got Unknown
		//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Expected O, but got Unknown
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0290: Expected O, but got Unknown
		//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Expected O, but got Unknown
		//IL_0320: Unknown result type (might be due to invalid IL or missing references)
		//IL_0327: Expected O, but got Unknown
		//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d7: Expected O, but got Unknown
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_041e: Expected O, but got Unknown
		//IL_0467: Unknown result type (might be due to invalid IL or missing references)
		//IL_046e: Expected O, but got Unknown
		//IL_0518: Unknown result type (might be due to invalid IL or missing references)
		//IL_051e: Expected O, but got Unknown
		//IL_055e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0565: Expected O, but got Unknown
		//IL_05ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b5: Expected O, but got Unknown
		//IL_065f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0665: Expected O, but got Unknown
		//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ac: Expected O, but got Unknown
		//IL_06f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06fc: Expected O, but got Unknown
		//IL_07a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ab: Expected O, but got Unknown
		//IL_07eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f2: Expected O, but got Unknown
		//IL_083b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0842: Expected O, but got Unknown
		//IL_0869: Unknown result type (might be due to invalid IL or missing references)
		//IL_0870: Expected O, but got Unknown
		//IL_090a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0911: Expected O, but got Unknown
		//IL_0938: Unknown result type (might be due to invalid IL or missing references)
		//IL_093f: Expected O, but got Unknown
		//IL_09c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ca: Expected O, but got Unknown
		GameObject val = christianityAssetBundle.LoadAsset<GameObject>("MonkRobe");
		CustomItem val2 = new CustomItem(val, true);
		ItemManager.Instance.AddItem(val2);
		Recipe obj = ScriptableObject.CreateInstance<Recipe>();
		((Object)obj).name = "MonkRobe";
		obj.m_item = val.GetComponent<ItemDrop>();
		obj.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
		Requirement val3 = MockRequirement.Create("LinenThread", 10, true);
		val3.m_amountPerLevel = 10;
		Requirement val4 = MockRequirement.Create("Coins", 200, true);
		val4.m_amountPerLevel = 200;
		MockRequirement.Create("Ruby", 2, true).m_amountPerLevel = 2;
		Requirement val5 = MockRequirement.Create("AmberPearl", 2, true);
		val5.m_amountPerLevel = 2;
		Requirement val6 = MockRequirement.Create("FineWood", 1, true);
		val6.m_amountPerLevel = 1;
		List<Requirement> list = new List<Requirement> { val3, val4, val5, val6 };
		obj.m_resources = list.ToArray();
		CustomRecipe val7 = new CustomRecipe(obj, true, true);
		ItemManager.Instance.AddRecipe(val7);
		ItemManager.Instance.GetRecipe("MonkRobe");
		MonoBehaviour.print((object)"monk robe item added");
		FileInfo fileInfo = new FileInfo(Assembly.GetExecutingAssembly().Location);
		GameObject val8 = christianityAssetBundle.LoadAsset<GameObject>("MonkRobeAlter");
		val8.GetComponent<ItemDrop>().m_itemData.m_shared.m_name = "$item_monk_robedoubleaxe";
		string text = fileInfo.DirectoryName + "/MonkRobeSpriteAxe.png";
		val8.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons[0] = AssetUtils.LoadSpriteFromFile(text);
		CustomItem val9 = new CustomItem(val8, true);
		ItemManager.Instance.AddItem(val9);
		Recipe obj2 = ScriptableObject.CreateInstance<Recipe>();
		((Object)obj2).name = "MonkRobeDoubleAxe";
		obj2.m_item = val8.GetComponent<ItemDrop>();
		obj2.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
		obj2.m_resources = list.ToArray();
		CustomRecipe val10 = new CustomRecipe(obj2, true, true);
		ItemManager.Instance.AddRecipe(val10);
		MonoBehaviour.print((object)"monk robe double axe item added");
		GameObject val11 = PrefabManager.Instance.CreateClonedPrefab("MonkRobeSword", val8);
		val11.GetComponent<ItemDrop>().m_itemData.m_shared.m_name = "$item_monk_robesword";
		text = fileInfo.DirectoryName + "/MonkRobeSpriteSword.png";
		val11.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons[0] = AssetUtils.LoadSpriteFromFile(text);
		text = fileInfo.DirectoryName + "/sword.png";
		Material[] array = (Material[])(object)new Material[1]
		{
			new Material(((Renderer)((Component)val11.transform.GetChild(0)).GetComponentInChildren<SkinnedMeshRenderer>()).sharedMaterial)
		};
		array[0].EnableKeyword("_EMISSION");
		array[0].SetTexture("_EmissionMap", (Texture)(object)AssetUtils.LoadTexture(text, true));
		((Renderer)((Component)val11.transform.GetChild(0)).GetComponentInChildren<SkinnedMeshRenderer>()).sharedMaterials = array;
		CustomItem val12 = new CustomItem(val11, true);
		ItemManager.Instance.AddItem(val12);
		Recipe obj3 = ScriptableObject.CreateInstance<Recipe>();
		((Object)obj3).name = "MonkRobeSword";
		obj3.m_item = val11.GetComponent<ItemDrop>();
		obj3.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
		obj3.m_resources = list.ToArray();
		CustomRecipe val13 = new CustomRecipe(obj3, true, true);
		ItemManager.Instance.AddRecipe(val13);
		MonoBehaviour.print((object)"monk robe sword item added");
		GameObject val14 = PrefabManager.Instance.CreateClonedPrefab("MonkRobeBow", val8);
		val14.GetComponent<ItemDrop>().m_itemData.m_shared.m_name = "$item_monk_robebow";
		text = fileInfo.DirectoryName + "/MonkRobeSpriteBow.png";
		val14.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons[0] = AssetUtils.LoadSpriteFromFile(text);
		text = fileInfo.DirectoryName + "/bow.png";
		array = (Material[])(object)new Material[1]
		{
			new Material(((Renderer)((Component)val14.transform.GetChild(0)).GetComponentInChildren<SkinnedMeshRenderer>()).sharedMaterial)
		};
		array[0].EnableKeyword("_EMISSION");
		array[0].SetTexture("_EmissionMap", (Texture)(object)AssetUtils.LoadTexture(text, true));
		((Renderer)((Component)val14.transform.GetChild(0)).GetComponentInChildren<SkinnedMeshRenderer>()).sharedMaterials = array;
		CustomItem val15 = new CustomItem(val14, true);
		ItemManager.Instance.AddItem(val15);
		Recipe obj4 = ScriptableObject.CreateInstance<Recipe>();
		((Object)obj4).name = "MonkRobeBow";
		obj4.m_item = val14.GetComponent<ItemDrop>();
		obj4.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
		obj4.m_resources = list.ToArray();
		CustomRecipe val16 = new CustomRecipe(obj4, true, true);
		ItemManager.Instance.AddRecipe(val16);
		MonoBehaviour.print((object)"monk robe bow item added");
		GameObject val17 = PrefabManager.Instance.CreateClonedPrefab("MonkRobeHelmet", val8);
		val17.GetComponent<ItemDrop>().m_itemData.m_shared.m_name = "$item_monk_robehelmet";
		text = fileInfo.DirectoryName + "/MonkRobeSpriteHelmet.png";
		val17.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons[0] = AssetUtils.LoadSpriteFromFile(text);
		text = fileInfo.DirectoryName + "/helmet.png";
		array = (Material[])(object)new Material[1]
		{
			new Material(((Renderer)((Component)val17.transform.GetChild(0)).GetComponentInChildren<SkinnedMeshRenderer>()).sharedMaterial)
		};
		array[0].EnableKeyword("_EMISSION");
		array[0].SetTexture("_EmissionMap", (Texture)(object)AssetUtils.LoadTexture(text, true));
		((Renderer)((Component)val17.transform.GetChild(0)).GetComponentInChildren<SkinnedMeshRenderer>()).sharedMaterials = array;
		CustomItem val18 = new CustomItem(val17, true);
		ItemManager.Instance.AddItem(val18);
		Recipe obj5 = ScriptableObject.CreateInstance<Recipe>();
		((Object)obj5).name = "MonkRobeHelmet";
		obj5.m_item = val17.GetComponent<ItemDrop>();
		obj5.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
		obj5.m_resources = list.ToArray();
		CustomRecipe val19 = new CustomRecipe(obj5, true, true);
		ItemManager.Instance.AddRecipe(val19);
		MonoBehaviour.print((object)"monk robe helmet item added");
		GameObject val20 = PrefabManager.Instance.CreateClonedPrefab("MonkRobeShield", val8);
		val20.GetComponent<ItemDrop>().m_itemData.m_shared.m_name = "$item_monk_robeshield";
		text = fileInfo.DirectoryName + "/MonkRobeSpriteShield.png";
		val20.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons[0] = AssetUtils.LoadSpriteFromFile(text);
		text = fileInfo.DirectoryName + "/shield.png";
		array = (Material[])(object)new Material[1]
		{
			new Material(((Renderer)((Component)val20.transform.GetChild(0)).GetComponentInChildren<SkinnedMeshRenderer>()).sharedMaterial)
		};
		array[0].EnableKeyword("_EMISSION");
		array[0].SetTexture("_EmissionMap", (Texture)(object)AssetUtils.LoadTexture(text, true));
		((Renderer)((Component)val20.transform.GetChild(0)).GetComponentInChildren<SkinnedMeshRenderer>()).sharedMaterials = array;
		CustomItem val21 = new CustomItem(val20, true);
		ItemManager.Instance.AddItem(val21);
		Recipe obj6 = ScriptableObject.CreateInstance<Recipe>();
		((Object)obj6).name = "MonkRobeShield";
		obj6.m_item = val20.GetComponent<ItemDrop>();
		obj6.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
		obj6.m_resources = list.ToArray();
		CustomRecipe val22 = new CustomRecipe(obj6, true, true);
		ItemManager.Instance.AddRecipe(val22);
		MonoBehaviour.print((object)"monk robe shield item added");
		GameObject val23 = PrefabManager.Instance.CreateClonedPrefab("MonkRobeViking", val8);
		val23.GetComponent<ItemDrop>().m_itemData.m_shared.m_name = "$item_monk_robeviking";
		text = fileInfo.DirectoryName + "/MonkRobeSpriteViking.png";
		val20.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons[0] = AssetUtils.LoadSpriteFromFile(text);
		text = fileInfo.DirectoryName + "/viking.png";
		array = (Material[])(object)new Material[1]
		{
			new Material(((Renderer)((Component)val23.transform.GetChild(0)).GetComponentInChildren<SkinnedMeshRenderer>()).sharedMaterial)
		};
		array[0].EnableKeyword("_EMISSION");
		array[0].SetTexture("_EmissionMap", (Texture)(object)AssetUtils.LoadTexture(text, true));
		((Renderer)((Component)val23.transform.GetChild(0)).GetComponentInChildren<SkinnedMeshRenderer>()).sharedMaterials = array;
		CustomItem val24 = new CustomItem(val23, true);
		ItemManager.Instance.AddItem(val24);
		Recipe obj7 = ScriptableObject.CreateInstance<Recipe>();
		((Object)obj7).name = "MonkRobeViking";
		obj7.m_item = val23.GetComponent<ItemDrop>();
		obj7.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
		obj7.m_resources = list.ToArray();
		CustomRecipe val25 = new CustomRecipe(obj7, true, true);
		ItemManager.Instance.AddRecipe(val25);
		MonoBehaviour.print((object)"monk robe viking item added");
		GameObject val26 = christianityAssetBundle.LoadAsset<GameObject>("MonkPants");
		CustomItem val27 = new CustomItem(val26, true);
		ItemManager.Instance.AddItem(val27);
		Recipe obj8 = ScriptableObject.CreateInstance<Recipe>();
		((Object)obj8).name = "MonkPants";
		obj8.m_item = val26.GetComponent<ItemDrop>();
		obj8.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
		Requirement val28 = MockRequirement.Create("DeerHide", 5, true);
		val28.m_amountPerLevel = 5;
		Requirement val29 = MockRequirement.Create("Silver", 2, true);
		val29.m_amountPerLevel = 2;
		list = new List<Requirement> { val3, val4, val28, val29 };
		obj8.m_resources = list.ToArray();
		val7 = new CustomRecipe(obj8, true, true);
		ItemManager.Instance.AddRecipe(val7);
		MonoBehaviour.print((object)"monk pants item added");
		GameObject val30 = christianityAssetBundle.LoadAsset<GameObject>("MonkHood");
		CustomItem val31 = new CustomItem(val30, true);
		ItemManager.Instance.AddItem(val31);
		Recipe obj9 = ScriptableObject.CreateInstance<Recipe>();
		((Object)obj9).name = "MonkHood";
		obj9.m_item = val30.GetComponent<ItemDrop>();
		obj9.m_craftingStation = Mock<CraftingStation>.Create("piece_workbench");
		Requirement val32 = MockRequirement.Create("LoxPelt", 2, true);
		val32.m_amountPerLevel = 2;
		list = new List<Requirement> { val3, val4, val32, val29 };
		obj9.m_resources = list.ToArray();
		val7 = new CustomRecipe(obj9, true, true);
		ItemManager.Instance.AddRecipe(val7);
		MonoBehaviour.print((object)"monk hood item added");
	}

	private void AddCreatures(AssetBundle christianityAssetBundle)
	{
	}

	private void AddPieces(AssetBundle christianityAssetBundle)
	{
	}

	private void AddRecipes()
	{
	}

	public static void debug(string text, Vector3 pos)
	{
	}
}