Decompiled source of MoreHouse v1.0.0

MoreHouse.dll

Decompiled 14 hours ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using Microsoft.CodeAnalysis;
using R2API;
using RoR2;
using RoR2.Skills;
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("MoreHouse")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MoreHouse")]
[assembly: AssemblyTitle("MoreHouse")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MoreHouse
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("MoreHouse", "MoreHouse", "1.0.0")]
	internal class MoreHouse : BaseUnityPlugin
	{
		internal class SkillDefInfo
		{
			public string skillName;

			public string skillNameToken;

			public string skillDescriptionToken;

			public Sprite skillIcon;

			public SerializableEntityStateType activationState;

			public string activationStateMachineName;

			public int baseMaxStock;

			public float baseRechargeInterval;

			public bool beginSkillCooldownOnSkillEnd;

			public bool canceledFromSprinting;

			public bool forceSprintDuringState;

			public bool fullRestockOnAssign;

			public InterruptPriority interruptPriority;

			public bool resetCooldownTimerOnUse;

			public bool isCombatSkill;

			public bool mustKeyPress;

			public bool cancelSprintingOnActivation;

			public int rechargeStock;

			public int requiredStock;

			public int stockToConsume;

			public string[] keywordTokens;
		}

		public static AssetBundle assetBundle;

		public static ConfigEntry<bool> debug { get; set; }

		public static int[] firstDeckCards { get; set; }

		public static ConfigEntry<string> firstDeck { get; set; }

		public static ConfigEntry<string> firstDeckName { get; set; }

		public static ConfigEntry<string> firstDeckDescription { get; set; }

		public static ConfigEntry<string> cardNumbers { get; set; }

		private void Awake()
		{
			assetBundle = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("MoreHouse.dll", "morehouseassets"));
			debug = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Debug mode", true, "Toggles debug messages");
			firstDeck = ((BaseUnityPlugin)this).Config.Bind<string>("Decks", "First Deck Cards", "16,16,16,6,6,19,19,20,20,2,2,2,2,1,1,1,1,4,4,4,4,14,14,14,14,34,34,34,34,34,31,31,31,31,31,32,32,9,9,13,13,8,8,26", "Cards used by the first Deck");
			firstDeckName = ((BaseUnityPlugin)this).Config.Bind<string>("Decks", "First Deck Name", "First Deck", "The displayed name for the first Deck");
			firstDeckDescription = ((BaseUnityPlugin)this).Config.Bind<string>("Decks", "First Deck Description", "Hier könnte ihre Werbung stehen.", "The displayed description for the first Deck");
			string[] array = firstDeck.Value.Split(',');
			firstDeckCards = new int[array.Length];
			for (int i = 0; i < array.Length; i++)
			{
				firstDeckCards[i] = int.Parse(array[i]);
			}
			cardNumbers = ((BaseUnityPlugin)this).Config.Bind<string>("Indexes", "Indexes of cards", "", "7HEARTS:1\r\n7DIAMONDS:2\r\n7CLUBS:3\r\n7SPADES:4\r\nJACKPOT:5\r\n52:6\r\nBUST:7\r\nSNAKE:8\r\nCOINS:9\r\nSWORDS:10\r\nTOWER:11\r\nJOKER:12\r\n7JACK:13\r\n7ACE:14\r\n7KING:15\r\n7QUEEN:16\r\nRROULETTE:17\r\nWILDCARD:18\r\nFORTUNE:19\r\nTHREEOFAKIND:20\r\nGHEARTS:21\r\nGCLUBS:22\r\nGSPADES:23\r\nCRAZYCARD:24\r\nTHESUN:25\r\nTHEMOON:26\r\nTHESTAR:27\r\nTHEWORLD:28\r\nJUDGEMENT:29\r\nKINGOFWANDS:30\r\nKNIGHTOFSWORDS:31\r\nQUEENOFCUPS:32\r\nPAGEOFPENTACLES:33\r\nANTEUP:34");
			changeHouse();
			LanguageTokens();
			if (debug.Value)
			{
				Console.WriteLine("MoreHouse awake completed.");
			}
		}

		private void changeHouse()
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly asm) => asm.GetName().Name == "HouseMod");
			Type type = assembly.GetType("HouseMod.SkillStates.House.TheGame.HouseCardDefs");
			FieldInfo field = type.GetField("houseDecks", BindingFlags.Static | BindingFlags.Public);
			object value = field.GetValue(null);
			Type type2 = assembly.GetType("HouseMod.SkillStates.House.TheGame.HouseDeckDef");
			FieldInfo field2 = type2.GetField("deckSkillDef", BindingFlags.Instance | BindingFlags.Public);
			FieldInfo field3 = type2.GetField("deckCards", BindingFlags.Instance | BindingFlags.Public);
			object obj = Activator.CreateInstance(type2);
			SkillDef val = CreateSkillDef(new SkillDefInfo
			{
				skillName = "SUPERTEST",
				skillNameToken = "FIRST_DECK_NAME",
				skillDescriptionToken = "FIRST_DECK_DESCRIPTION",
				skillIcon = assetBundle.LoadAsset<Sprite>("customDeck.png")
			});
			field2.SetValue(obj, val);
			field3.SetValue(obj, firstDeckCards);
			MethodInfo method = value.GetType().GetMethod("Add");
			method.Invoke(value, new object[1] { obj });
			Type type3 = assembly.GetType("HouseMod.Modules.Survivors.House");
			FieldInfo field4 = type3.GetField("characterPrefab", BindingFlags.Static | BindingFlags.NonPublic);
			object? value2 = field4.GetValue(value);
			GameObject val2 = (GameObject)((value2 is GameObject) ? value2 : null);
			GenericSkill[] components = val2.GetComponents<GenericSkill>();
			SkillFamily skillFamily = components[0]._skillFamily;
			AddExtraSkill(val2, val, skillFamily);
		}

		internal static SkillDef CreateSkillDef(SkillDefInfo skillDefInfo)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			SkillDef val = ScriptableObject.CreateInstance<SkillDef>();
			val.skillName = skillDefInfo.skillName;
			val.skillNameToken = skillDefInfo.skillNameToken;
			val.skillDescriptionToken = skillDefInfo.skillDescriptionToken;
			val.icon = skillDefInfo.skillIcon;
			val.activationState = skillDefInfo.activationState;
			val.activationStateMachineName = skillDefInfo.activationStateMachineName;
			val.baseMaxStock = skillDefInfo.baseMaxStock;
			val.baseRechargeInterval = skillDefInfo.baseRechargeInterval;
			val.beginSkillCooldownOnSkillEnd = skillDefInfo.beginSkillCooldownOnSkillEnd;
			val.canceledFromSprinting = skillDefInfo.canceledFromSprinting;
			val.forceSprintDuringState = skillDefInfo.forceSprintDuringState;
			val.fullRestockOnAssign = skillDefInfo.fullRestockOnAssign;
			val.interruptPriority = skillDefInfo.interruptPriority;
			val.resetCooldownTimerOnUse = skillDefInfo.resetCooldownTimerOnUse;
			val.isCombatSkill = skillDefInfo.isCombatSkill;
			val.mustKeyPress = skillDefInfo.mustKeyPress;
			val.cancelSprintingOnActivation = skillDefInfo.cancelSprintingOnActivation;
			val.rechargeStock = skillDefInfo.rechargeStock;
			val.requiredStock = skillDefInfo.requiredStock;
			val.stockToConsume = skillDefInfo.stockToConsume;
			val.keywordTokens = skillDefInfo.keywordTokens;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			Assembly assembly = AppDomain.CurrentDomain.GetAssemblies().FirstOrDefault((Assembly asm) => asm.GetName().Name == "HouseMod");
			Type type = assembly.GetType("HouseMod.Modules.Skills");
			FieldInfo field = type.GetField("skillDefs", BindingFlags.Static | BindingFlags.NonPublic);
			object value = field.GetValue(null);
			MethodInfo method = value.GetType().GetMethod("Add");
			method.Invoke(value, new object[1] { val });
			return val;
		}

		internal static void AddExtraSkill(GameObject targetPrefab, SkillDef skillDef, SkillFamily skillFamily)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			Array.Resize(ref skillFamily.variants, skillFamily.variants.Length + 1);
			Variant[] variants = skillFamily.variants;
			int num = skillFamily.variants.Length - 1;
			Variant val = new Variant
			{
				skillDef = skillDef
			};
			((Variant)(ref val)).viewableNode = new Node(skillDef.skillNameToken, false, (Node)null);
			variants[num] = val;
		}

		private void LanguageTokens()
		{
			LanguageAPI.Add("FIRST_DECK_NAME", firstDeckName.Value);
			string text = "Hier könnte ihre Werbung stehen. <style=cStack>\n\n";
			LanguageAPI.Add("FIRST_DECK_DESCRIPTION", firstDeckDescription.Value);
		}
	}
}
namespace ExamplePlugin
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}