Decompiled source of BattleMemoriesDebuffYi v0.1.0

BattleMemoriesDebuffYi.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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("BattleMemoriesDebuffYi")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("A Nine Sols mod that removes some or all of the buffs/upgrades Yi normally has in Battle Memories mode")]
[assembly: AssemblyFileVersion("0.0.2.0")]
[assembly: AssemblyInformationalVersion("0.0.2+fa86b9fa1e808dd38d640d0f847f9e58fb36cac1")]
[assembly: AssemblyProduct("BattleMemoriesDebuffYi")]
[assembly: AssemblyTitle("BattleMemoriesDebuffYi")]
[assembly: AssemblyVersion("0.0.2.0")]
[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.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;
		}
	}
	[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 BattleMemoriesDebuffYi
{
	internal class AbilityToggles
	{
		private static string[] otherSkillFlags = new string[27]
		{
			"ae3f7be7afb294d2eba0f6f4d129c6d0SkillNodeData", "b3e48a60ad0b84648952dc21712b27c0SkillNodeData", "0c8ce74dd338f4ecaa525eee0b37cc1cSkillNodeData", "f168f2477ae5a481ca147ee9ce61833bSkillNodeData", "c57cd9a29dca44f9d94fe76f4b6c248dSkillNodeData", "f44bf0d0544f84e548eb76a00f12cccdSkillNodeData", "411e38c06854a484cb7eb7e2d5cd9b9eSkillNodeData", "6ce6b20889a30401d89edbea192fdb70SkillNodeData", "930431c2cc50341778d2f9736d27ee6eSkillNodeData", "08fecc31de6974aaca652b6beb1cbbfeSkillNodeData",
			"41ea48c62b044a041bdf3f7640dbeb4cSkillNodeData", "b24699dc273034e34867754a3c97c4c4SkillNodeData", "cee53a9ab05cb4f25bc3d5f900fa523cSkillNodeData", "92e91b67a2b794671a74c275d4c1d2b6SkillNodeData", "b969aebcc39544a1eb88a6dc4f538052SkillNodeData", "3c5bc531c4961479189e171da6b1ca5dSkillNodeData", "f9c12b4ba239e49ff8992d316de77179SkillNodeData", "304e6970e1f624f0d9254b428b81a73eSkillNodeData", "459bd9b1979414acdbcba2a3644c056cSkillNodeData", "66ae60d46a1bf4e46aafe55fa7a0a34bSkillNodeData",
			"c2c80a7aa73a24226b410bd2064b2a5cSkillNodeData", "9efa79aa5093f4681b650e0dbc0d02feSkillNodeData", "fadab0801872448a088b7cc05d63aac0SkillNodeData", "9811579f8600a48ecbb002eba20f5bcbSkillNodeData", "f0db8641341dc4fd39368da2b3a8a821SkillNodeData", "fcb5a8efa2ca14f818f53071b10aab11SkillNodeData", "42fd1d09af02e41229825f330c193658SkillNodeData"
		};

		public static void SetTaiChiKick(bool enabled)
		{
			((FlagField<bool>)(object)((GameFlagDescriptable)Player.i.mainAbilities.ParryJumpKickAbility).acquired).SetCurrentValue(enabled, (Object)null);
			((FlagField<bool>)(object)Player.i.mainAbilities.ParryJumpKickAbility.equipped).SetCurrentValue(enabled, (Object)null);
		}

		public static void SetAirDash(bool enabled)
		{
			((FlagField<bool>)(object)((GameFlagDescriptable)Player.i.mainAbilities.RollDodgeInAirUpgrade).acquired).SetCurrentValue(enabled, (Object)null);
			((FlagField<bool>)(object)Player.i.mainAbilities.RollDodgeInAirUpgrade.equipped).SetCurrentValue(enabled, (Object)null);
		}

		public static void SetChargedStrike(bool enabled)
		{
			((FlagField<bool>)(object)((GameFlagDescriptable)Player.i.mainAbilities.ChargedAttackAbility).acquired).SetCurrentValue(enabled, (Object)null);
			((FlagField<bool>)(object)Player.i.mainAbilities.ChargedAttackAbility.equipped).SetCurrentValue(enabled, (Object)null);
		}

		public static void SetCloudLeap(bool enabled)
		{
			((FlagField<bool>)(object)((GameFlagDescriptable)Player.i.mainAbilities.AirJumpAbility).acquired).SetCurrentValue(enabled, (Object)null);
			((FlagField<bool>)(object)Player.i.mainAbilities.AirJumpAbility.equipped).SetCurrentValue(enabled, (Object)null);
		}

		public static void SetUnboundedCounter(bool enabled)
		{
			((FlagField<bool>)(object)((GameFlagDescriptable)Player.i.mainAbilities.ParryCounterAbility).acquired).SetCurrentValue(enabled, (Object)null);
			((FlagField<bool>)(object)Player.i.mainAbilities.ParryCounterAbility.equipped).SetCurrentValue(enabled, (Object)null);
		}

		public static void SetAzureBow(bool enabled)
		{
			((FlagField<bool>)(object)((GameFlagDescriptable)Player.i.mainAbilities.ArrowAbility).acquired).SetCurrentValue(enabled, (Object)null);
			((FlagField<bool>)(object)Player.i.mainAbilities.ArrowAbility.equipped).SetCurrentValue(enabled, (Object)null);
		}

		public static void SetAllJades(bool enabled)
		{
			foreach (JadeData gameFlagData in ((GameFlagBaseCollection<JadeData>)(object)Player.i.mainAbilities.jadeDataColleciton).gameFlagDataList)
			{
				((FlagField<bool>)(object)((GameFlagDescriptable)gameFlagData).acquired).SetCurrentValue(enabled, (Object)null);
				((FlagField<bool>)(object)((GameFlagDescriptable)gameFlagData).unlocked).SetCurrentValue(enabled, (Object)null);
			}
		}

		public static void SetAllPipeVials(bool enabled)
		{
			Dictionary<string, GameFlagBase> flagDict = SingletonBehaviour<SaveManager>.Instance.allFlags.FlagDict;
			string[] array = new string[6] { "5c864e36f2cef9d4f8c24c0aa84010bePlayerAbilityData", "3f6040257515a41499d36e910a4a6e79PlayerAbilityData", "ec1fe3b64944cd643b2020f35e82f023PlayerAbilityData", "dd5adfbe0ac50fe4795b796153ee646dPlayerAbilityData", "ce7166af4ef39d7468c4ccc464fd90b9PlayerAbilityData", "41c960dfcaaf7a14f813342db16f0481PlayerAbilityData" };
			foreach (string key in array)
			{
				GameFlagBase obj = flagDict[key];
				PlayerAbilityData val = (PlayerAbilityData)(object)((obj is PlayerAbilityData) ? obj : null);
				((FlagField<bool>)(object)((GameFlagDescriptable)val).unlocked).CurrentValue = enabled;
				((FlagField<bool>)(object)((GameFlagDescriptable)val).acquired).CurrentValue = enabled;
				if (enabled)
				{
					AccessTools.Method(typeof(PlayerAbilityData), "Activate", Array.Empty<Type>(), (Type[])null).Invoke(val, Array.Empty<object>());
				}
				else
				{
					AccessTools.Method(typeof(PlayerAbilityData), "DeActivate", Array.Empty<Type>(), (Type[])null).Invoke(val, Array.Empty<object>());
				}
			}
		}

		public static void SetAllHealthUpgrades(bool enabled)
		{
			Dictionary<string, GameFlagBase> flagDict = SingletonBehaviour<SaveManager>.Instance.allFlags.FlagDict;
			string[] array = new string[8] { "4e9b068d7b812a84b9f1b52efee467acPlayerAbilityData", "b11ba30bd3a72eb49ae3d1746fb686b7PlayerAbilityData", "d0a9876111d725d4298833323bb082d0PlayerAbilityData", "1b8f6278e3ead824e8352349a8f7cb6dPlayerAbilityData", "aa396485060a82d4db9ab2a1fb02c429PlayerAbilityData", "a2f84651129789d468ad8fde13a54c4fPlayerAbilityData", "3c1022c896f9ca44e9c588b76797e3d0PlayerAbilityData", "aae70b5ca7663504eb9967182234dc6bPlayerAbilityData" };
			foreach (string key in array)
			{
				GameFlagBase obj = flagDict[key];
				PlayerAbilityData val = (PlayerAbilityData)(object)((obj is PlayerAbilityData) ? obj : null);
				((FlagField<bool>)(object)((GameFlagDescriptable)val).unlocked).CurrentValue = enabled;
				((FlagField<bool>)(object)((GameFlagDescriptable)val).acquired).CurrentValue = enabled;
				if (enabled)
				{
					AccessTools.Method(typeof(PlayerAbilityData), "Activate", Array.Empty<Type>(), (Type[])null).Invoke(val, Array.Empty<object>());
				}
				else
				{
					AccessTools.Method(typeof(PlayerAbilityData), "DeActivate", Array.Empty<Type>(), (Type[])null).Invoke(val, Array.Empty<object>());
				}
			}
		}

		public static void SetAllOtherSkills(bool enabled)
		{
			Dictionary<string, GameFlagBase> flagDict = SingletonBehaviour<SaveManager>.Instance.allFlags.FlagDict;
			string[] array = otherSkillFlags;
			foreach (string key in array)
			{
				GameFlagBase obj = flagDict[key];
				PlayerAbilityData val = (PlayerAbilityData)(object)((obj is PlayerAbilityData) ? obj : null);
				((FlagField<bool>)(object)((GameFlagDescriptable)val).unlocked).CurrentValue = enabled;
				((FlagField<bool>)(object)((GameFlagDescriptable)val).acquired).CurrentValue = enabled;
				if (enabled)
				{
					AccessTools.Method(typeof(PlayerAbilityData), "Activate", Array.Empty<Type>(), (Type[])null).Invoke(val, Array.Empty<object>());
				}
				else
				{
					AccessTools.Method(typeof(PlayerAbilityData), "DeActivate", Array.Empty<Type>(), (Type[])null).Invoke(val, Array.Empty<object>());
				}
			}
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("BattleMemoriesDebuffYi", "BattleMemoriesDebuffYi", "0.0.2")]
	public class BattleMemoriesDebuffYi : BaseUnityPlugin
	{
		public ConfigEntry<bool> RemoveTaiChiKick;

		public ConfigEntry<bool> RemoveAirDash;

		public ConfigEntry<bool> RemoveChargedStrike;

		public ConfigEntry<bool> RemoveCloudLeap;

		public ConfigEntry<bool> RemoveUnboundedCounter;

		public ConfigEntry<bool> RemoveAzureBow;

		public ConfigEntry<bool> RemoveAllJades;

		public ConfigEntry<bool> RemoveAllPipeVials;

		public ConfigEntry<bool> RemoveAllHealthUpgrades;

		public ConfigEntry<bool> RemoveAllOtherSkills;

		public static BattleMemoriesDebuffYi Instance;

		private Harmony harmony;

		private void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			RCGLifeCycle.DontDestroyForever(((Component)this).gameObject);
			Instance = this;
			harmony = Harmony.CreateAndPatchAll(typeof(BattleMemoriesDebuffYi).Assembly, (string)null);
			RemoveTaiChiKick = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Remove Tai-Chi Kick", true, "");
			RemoveTaiChiKick.SettingChanged += delegate
			{
				if (PlayerGamePlayData.Instance.memoryMode.CurrentValue)
				{
					Log.Info($"RemoveTaiChiKick setting changed to {RemoveTaiChiKick.Value}, applying now since you're already in Battle Memories");
					AbilityToggles.SetTaiChiKick(!RemoveTaiChiKick.Value);
				}
			};
			RemoveAirDash = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Remove Air Dash", true, "");
			RemoveAirDash.SettingChanged += delegate
			{
				if (PlayerGamePlayData.Instance.memoryMode.CurrentValue)
				{
					Log.Info($"RemoveAirDash setting changed to {RemoveAirDash.Value}, applying now since you're already in Battle Memories");
					AbilityToggles.SetAirDash(!RemoveAirDash.Value);
				}
			};
			RemoveChargedStrike = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Remove Charged Strike", true, "");
			RemoveChargedStrike.SettingChanged += delegate
			{
				if (PlayerGamePlayData.Instance.memoryMode.CurrentValue)
				{
					Log.Info($"RemoveChargedStrike setting changed to {RemoveChargedStrike.Value}, applying now since you're already in Battle Memories");
					AbilityToggles.SetChargedStrike(!RemoveChargedStrike.Value);
				}
			};
			RemoveCloudLeap = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Remove Cloud Leap", true, "");
			RemoveCloudLeap.SettingChanged += delegate
			{
				if (PlayerGamePlayData.Instance.memoryMode.CurrentValue)
				{
					Log.Info($"RemoveCloudLeap setting changed to {RemoveCloudLeap.Value}, applying now since you're already in Battle Memories");
					AbilityToggles.SetCloudLeap(!RemoveCloudLeap.Value);
				}
			};
			RemoveUnboundedCounter = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Remove Unbounded Counter", true, "");
			RemoveUnboundedCounter.SettingChanged += delegate
			{
				if (PlayerGamePlayData.Instance.memoryMode.CurrentValue)
				{
					Log.Info($"RemoveUnboundedCounter setting changed to {RemoveUnboundedCounter.Value}, applying now since you're already in Battle Memories");
					AbilityToggles.SetUnboundedCounter(!RemoveUnboundedCounter.Value);
				}
			};
			RemoveAzureBow = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Remove Azure Bow", true, "");
			RemoveAzureBow.SettingChanged += delegate
			{
				if (PlayerGamePlayData.Instance.memoryMode.CurrentValue)
				{
					Log.Info($"RemoveAzureBow setting changed to {RemoveAzureBow.Value}, applying now since you're already in Battle Memories");
					AbilityToggles.SetAzureBow(!RemoveAzureBow.Value);
				}
			};
			RemoveAllJades = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Remove All Jades", true, "");
			RemoveAllJades.SettingChanged += delegate
			{
				if (PlayerGamePlayData.Instance.memoryMode.CurrentValue)
				{
					Log.Info($"RemoveAllJades setting changed to {RemoveAllJades.Value}, applying now since you're already in Battle Memories");
					AbilityToggles.SetAllJades(!RemoveAllJades.Value);
				}
			};
			RemoveAllPipeVials = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Remove All Pipe Vials", true, "");
			RemoveAllPipeVials.SettingChanged += delegate
			{
				if (PlayerGamePlayData.Instance.memoryMode.CurrentValue)
				{
					Log.Info($"RemoveAllPipeVials setting changed to {RemoveAllPipeVials.Value}, applying now since you're already in Battle Memories");
					AbilityToggles.SetAllPipeVials(!RemoveAllPipeVials.Value);
				}
			};
			RemoveAllHealthUpgrades = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Remove All Health Upgrades", true, "");
			RemoveAllHealthUpgrades.SettingChanged += delegate
			{
				if (PlayerGamePlayData.Instance.memoryMode.CurrentValue)
				{
					Log.Info($"RemoveAllHealthUpgrades setting changed to {RemoveAllHealthUpgrades.Value}, applying now since you're already in Battle Memories");
					AbilityToggles.SetAllHealthUpgrades(!RemoveAllHealthUpgrades.Value);
				}
			};
			RemoveAllOtherSkills = ((BaseUnityPlugin)this).Config.Bind<bool>("", "Remove All Other Skills", true, "");
			RemoveAllOtherSkills.SettingChanged += delegate
			{
				if (PlayerGamePlayData.Instance.memoryMode.CurrentValue)
				{
					Log.Info($"RemoveAllOtherSkills setting changed to {RemoveAllOtherSkills.Value}, applying now since you're already in Battle Memories");
					AbilityToggles.SetAllOtherSkills(!RemoveAllOtherSkills.Value);
				}
			};
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin BattleMemoriesDebuffYi is loaded!");
		}

		private void OnDestroy()
		{
			harmony.UnpatchSelf();
		}
	}
	internal static class Log
	{
		private static ManualLogSource? logSource;

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

		internal static void Debug(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogDebug(data);
			}
		}

		internal static void Error(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogError(data);
			}
		}

		internal static void Fatal(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogFatal(data);
			}
		}

		internal static void Info(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogInfo(data);
			}
		}

		internal static void Message(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogMessage(data);
			}
		}

		internal static void Warning(object data)
		{
			ManualLogSource? obj = logSource;
			if (obj != null)
			{
				obj.LogWarning(data);
			}
		}
	}
	[HarmonyPatch]
	public class Patches
	{
		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameLevel), "Awake")]
		private static void GameLevel_Awake(GameLevel __instance)
		{
			if (!(((Object)__instance).name != "GameLevel_VR_Challenge"))
			{
				Log.Info("BattleMemoriesDebuffYi detected load into Battle Memories hub. Applying all debuffs (and re-buffs) to Yi now.");
				AbilityToggles.SetTaiChiKick(!BattleMemoriesDebuffYi.Instance.RemoveTaiChiKick.Value);
				AbilityToggles.SetAirDash(!BattleMemoriesDebuffYi.Instance.RemoveAirDash.Value);
				AbilityToggles.SetChargedStrike(!BattleMemoriesDebuffYi.Instance.RemoveChargedStrike.Value);
				AbilityToggles.SetCloudLeap(!BattleMemoriesDebuffYi.Instance.RemoveCloudLeap.Value);
				AbilityToggles.SetUnboundedCounter(!BattleMemoriesDebuffYi.Instance.RemoveUnboundedCounter.Value);
				AbilityToggles.SetAzureBow(!BattleMemoriesDebuffYi.Instance.RemoveAzureBow.Value);
				AbilityToggles.SetAllJades(!BattleMemoriesDebuffYi.Instance.RemoveAllJades.Value);
				AbilityToggles.SetAllPipeVials(!BattleMemoriesDebuffYi.Instance.RemoveAllPipeVials.Value);
				AbilityToggles.SetAllHealthUpgrades(!BattleMemoriesDebuffYi.Instance.RemoveAllHealthUpgrades.Value);
				AbilityToggles.SetAllOtherSkills(!BattleMemoriesDebuffYi.Instance.RemoveAllOtherSkills.Value);
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "BattleMemoriesDebuffYi";

		public const string PLUGIN_NAME = "BattleMemoriesDebuffYi";

		public const string PLUGIN_VERSION = "0.0.2";
	}
}