Decompiled source of BetterTotems v1.0.0

BetterTotems.dll

Decompiled a month ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using DiskCardGame;
using HarmonyLib;
using InscryptionAPI.Ascension;
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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("BetterTotems")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Placeholder description")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterTotems")]
[assembly: AssemblyTitle("BetterTotems")]
[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 BetterTotems
{
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "BetterTotems";

		public const string PLUGIN_NAME = "BetterTotems";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ExampleMod
{
	[BepInPlugin("tvflabs.inscryption.BetterTotems", "BetterTotems", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(BuildTotemSequencer), "GenerateTotemChoices")]
		private class BuildTotemSequencer_GenerateTotemChoices_Patch
		{
			private static void Postfix(BuildTotemSequencer __instance, ref List<ItemData> __result, BuildTotemNodeData nodeData, int randomSeed)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_0164: Unknown result type (might be due to invalid IL or missing references)
				//IL_0169: Unknown result type (might be due to invalid IL or missing references)
				//IL_016c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				//IL_0182: Unknown result type (might be due to invalid IL or missing references)
				if (!AscensionSaveData.Data.ChallengeIsActive(betterTotems.Challenge.challengeType))
				{
					return;
				}
				List<Ability> list = new List<Ability>(ProgressionData.Data.learnedAbilities);
				list.RemoveAll((Ability x) => RunState.Run.totemBottoms.Contains(x) || AbilitiesUtil.GetInfo(x).powerLevel < 2 || !AbilitiesUtil.GetInfo(x).metaCategories.Contains((AbilityMetaCategory)1));
				foreach (ItemData item in __result)
				{
					if (item is TotemBottomData && list.Contains(((TotemBottomData)((item is TotemBottomData) ? item : null)).effectParams.ability))
					{
						list.Remove(((TotemBottomData)((item is TotemBottomData) ? item : null)).effectParams.ability);
					}
				}
				foreach (ItemData item2 in __result)
				{
					if (item2 is TotemBottomData && AbilitiesUtil.GetInfo(((TotemBottomData)((item2 is TotemBottomData) ? item2 : null)).effectParams.ability).powerLevel < 2)
					{
						int powerLevelRoll = SeededRandom.Range(2, 7, randomSeed++);
						List<Ability> list2 = list.FindAll((Ability x) => AbilitiesUtil.GetInfo(x).powerLevel <= powerLevelRoll);
						Ability val = list2[SeededRandom.Range(0, list2.Count, randomSeed++)];
						list.Remove(val);
						((TotemBottomData)((item2 is TotemBottomData) ? item2 : null)).effectParams.ability = val;
					}
				}
			}
		}

		private Harmony harmony = new Harmony("tvflabs.inscryption.BetterTotems");

		private const string PluginGuid = "tvflabs.inscryption.BetterTotems";

		private const string PluginName = "BetterTotems";

		private const string PluginVersion = "1.0.0";

		private const string PluginPrefix = "BetterTotems";

		private static FullChallenge betterTotems;

		private void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded BetterTotems!");
			AscensionChallengeInfo val = new AscensionChallengeInfo();
			val.iconSprite = Resources.Load<Sprite>("art/ui/ascension/ascensionicon_totems");
			val.activatedSprite = Resources.Load<Sprite>("art/ui/ascension/ascensionicon_activated_totems");
			val.title = "Better Totems";
			val.pointValue = -5;
			val.description = "The Woodcarver will no longer give you totems with weak sigils";
			betterTotems = ChallengeManager.Add("tvflabs.inscryption.BetterTotems", val, 0, false);
			harmony.PatchAll();
		}
	}
}