Decompiled source of ShamanDiveBind v1.0.1

ShamanBindBuff.dll

Decompiled 5 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using GlobalSettings;
using HarmonyLib;
using HutongGames.PlayMaker;
using HutongGames.PlayMaker.Actions;
using Microsoft.CodeAnalysis;
using ShamanBindBuff.FSMEdits;
using Silksong.FsmUtil;
using TeamCherry.Localization;
using TeamCherry.SharedUtils;
using UnityEngine;
using UnityEngine.Events;

[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("ShamanBindBuff")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.1.0")]
[assembly: AssemblyInformationalVersion("1.0.1")]
[assembly: AssemblyProduct("Shaman Bind Buff")]
[assembly: AssemblyTitle("ShamanBindBuff")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.1.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 ShamanBindBuff
{
	[Harmony]
	internal static class ChangeShamanDiveSpeed
	{
		private static ToolItem quickbindTool;

		internal static void GetQuickbindTool(HeroController hc)
		{
			quickbindTool = ToolItemManager.GetToolByName("Quickbind");
		}

		[HarmonyPatch(typeof(HeroController), "GetMaxFallVelocity")]
		[HarmonyPostfix]
		private static void ChangeDiveSpeed(HeroController __instance, ref float __result)
		{
			if (__instance.spellControl.ActiveStateName == "Shaman Fall" && ((ToolBase)quickbindTool).IsEquipped)
			{
				__result *= 2f;
			}
		}
	}
	public static class Extensions
	{
		public static Transform FindIncludeInactive(this Transform self, string path)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			string[] array = path.Split('/');
			Transform val = self;
			string[] array2 = array;
			foreach (string text in array2)
			{
				bool flag = false;
				foreach (Transform item in val)
				{
					Transform val2 = item;
					if (((Object)val2).name == text)
					{
						val = val2;
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					return null;
				}
			}
			return val;
		}

		public static GameObject Duplicate(this GameObject self, bool active)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = Object.Instantiate<GameObject>(self);
			val.SetActive(active);
			val.transform.parent = self.transform.parent;
			val.transform.position = self.transform.position;
			val.transform.rotation = self.transform.rotation;
			val.transform.localScale = self.transform.localScale;
			return val;
		}
	}
	[BepInPlugin("ShamanBindBuff", "Shaman Bind Buff", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[Harmony]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Harmony val = new Harmony("ShamanBindBuff");
			val.PatchAll();
			Logger.LogInfo((object)"Plugin ShamanBindBuff is loaded!");
		}

		[HarmonyPatch(typeof(PlayMakerFSM), "Start")]
		[HarmonyPostfix]
		private static void FSMEdits(PlayMakerFSM __instance)
		{
			NoDistanceLimit.RemoveDistanceLimitCondition(__instance);
		}

		[HarmonyPatch(typeof(FsmState), "OnEnter")]
		[HarmonyPostfix]
		private static void FSMStateHooksEnter(FsmState __instance)
		{
			DiveEffect.EnableAnimationAndDamager(__instance);
		}

		[HarmonyPatch(typeof(FsmState), "OnExit")]
		[HarmonyPrefix]
		private static void FSMStateHooksExit(FsmState __instance)
		{
			DiveEffect.DisableDamager(__instance);
		}

		[HarmonyPatch(typeof(HeroController), "Start")]
		[HarmonyPostfix]
		private static void OnHeroControllerStart(HeroController __instance)
		{
			ChangeShamanDiveSpeed.GetQuickbindTool(__instance);
			DiveEffect.SetupDive(__instance);
		}

		[HarmonyPatch(typeof(ToolItemManager), "Awake")]
		[HarmonyPostfix]
		private static void OverrideDescription()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			LocalisedString val = default(LocalisedString);
			((LocalisedString)(ref val))..ctor("Mods.ShamanBindBuff", "CREST_SPELL_DESC");
			if (!((LocalisedString)(ref val)).Exists)
			{
				Logger.LogWarning((object)"SpellCrest descriptions could not be replaced as LocalizedString(Mods.ShamanBindBuff, CREST_SPELL_DESC) does not exist. The original descriptions will be used. To replace the descriptions, use the I18N mod. If you are already using the mod then there is a bug here.");
				return;
			}
			Gameplay.SpellCrest.description = val;
			Gameplay.SpellCrest.getPromptDesc = val;
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "ShamanBindBuff";

		public const string PLUGIN_NAME = "Shaman Bind Buff";

		public const string PLUGIN_VERSION = "1.0.1";
	}
}
namespace ShamanBindBuff.FSMEdits
{
	internal static class DiveEffect
	{
		internal static GameObject DiveBurstFX;

		internal static GameObject DiveBonkFX;

		internal static GameObject Dive;

		internal static GameObject DiveShockwave;

		internal static GameObject DiveContainer;

		internal static ToolItemSkill DiveTool;

		internal static void EnableAnimationAndDamager(FsmState state)
		{
			if (state.fsm.Name == "Bind" && state.Name == "Shaman Impact")
			{
				Dive.SetActive(true);
				DiveBonkFX.SetActive(true);
				DiveBurstFX.SetActive(true);
				HeroController.instance.parryInvulnTimer = 0.4f;
			}
		}

		internal static void DisableDamager(FsmState state)
		{
			if (state.fsm.Name == "Bind" && state.Name == "Bind Ground" && Dive.activeSelf)
			{
				Dive.SetActive(false);
				DiveShockwave.SetActive(true);
			}
		}

		internal static void SetupDive(HeroController hc)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Expected O, but got Unknown
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Expected O, but got Unknown
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			DiveTool = new ToolItemSkill();
			((ToolItem)DiveTool).type = (ToolItemType)3;
			((ToolItem)DiveTool).zapDamageTicks = 1;
			((ToolItem)DiveTool).name = "Shaman Dive";
			DiveContainer = new GameObject("Shaman Dive");
			DiveContainer.transform.parent = hc.transform.Find("Attacks");
			DiveContainer.transform.localPosition = new Vector3(0f, -0.885f, 0f);
			DiveContainer.layer = 17;
			DiveContainer.SetActive(true);
			DiveBurstFX = ((Component)hc.transform.FindIncludeInactive("Special Attacks/Silk Charge DashBurst")).gameObject.Duplicate(active: false);
			((Object)DiveBurstFX).name = "Dive FX";
			DiveBurstFX.transform.localEulerAngles = new Vector3(0f, 0f, 90f);
			DiveBurstFX.transform.localPosition = new Vector3(-0.17f, 5f, 0f);
			DiveBurstFX.transform.GetChild(1).localPosition = new Vector3(0f, 0f, 0.003f);
			DiveBurstFX.transform.GetChild(0).localPosition = new Vector3(-3f, 0f, 0f);
			DiveBurstFX.transform.parent = DiveContainer.transform;
			DiveBonkFX = ((Component)hc.transform.FindIncludeInactive("Special Attacks/Silk Charge WallBonk")).gameObject.Duplicate(active: true);
			((Object)DiveBonkFX).name = "Shockwave FX";
			DiveBonkFX.transform.localEulerAngles = new Vector3(0f, 0f, 90f);
			DiveBonkFX.transform.localPosition = new Vector3(0.125f, -0.7f, -0.008f);
			DiveBonkFX.transform.localScale = Vector3.one;
			DiveBonkFX.transform.parent = DiveContainer.transform;
			DiveBonkFX = ((Component)DiveBonkFX.transform.GetChild(0)).gameObject;
			DiveBonkFX.SetActive(false);
			Dive = new GameObject("Dive");
			Dive.transform.parent = DiveContainer.transform;
			Dive.transform.localPosition = Vector3.zero;
			Dive.layer = 17;
			Dive.SetActive(false);
			SetupCollider(Dive.AddComponent<PolygonCollider2D>(), 1f);
			SetupDamager(Dive.AddComponent<DamageEnemies>(), 0.75f);
			DiveShockwave = new GameObject("Shockwave");
			DiveShockwave.transform.parent = DiveContainer.transform;
			DiveShockwave.transform.localPosition = Vector3.zero;
			DiveShockwave.layer = 17;
			DiveShockwave.SetActive(false);
			SetupCollider(DiveShockwave.AddComponent<PolygonCollider2D>(), 1.5f);
			SetupDamager(DiveShockwave.AddComponent<DamageEnemies>(), 2.5f);
			DisableAfterTime val = DiveShockwave.AddComponent<DisableAfterTime>();
			val.waitTime = 0.2f;
			val.isRealtime = false;
		}

		private static void SetupDamager(DamageEnemies dmg, float mult)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			dmg.attackType = (AttackTypes)2;
			dmg.useNailDamage = true;
			dmg.nailDamageMultiplier = mult;
			dmg.damageMultiplier = Gameplay.SpellCrestRuneDamageMult;
			dmg.representingTool = (ToolItem)(object)DiveTool;
			dmg.slashEffectOverrides = Array.Empty<GameObject>();
			dmg.damageFSMEvent = string.Empty;
			dmg.deathEvent = string.Empty;
			dmg.targetRecordedFSMEvent = string.Empty;
			dmg.contactFSMEvent = string.Empty;
			dmg.dealtDamageFSMEvent = string.Empty;
			dmg.silkGeneration = (HitSilkGeneration)2;
			dmg.specialType = (SpecialTypes)192;
			dmg.corpseDirection = new OverrideFloat();
			dmg.corpseMagnitudeMult = new OverrideFloat();
			dmg.currencyMagnitudeMult = new OverrideFloat();
			dmg.sourceIsHero = false;
			dmg.damageDealt = 15;
			dmg.damageMultPerHit = Array.Empty<float>();
			dmg.ignoreInvuln = false;
			dmg.magnitudeMult = 1.25f;
			dmg.DealtDamage = new UnityEvent();
			dmg.Tinked = new UnityEvent();
			dmg.allowedTinkFlags = (TinkFlags)2;
			dmg.doesNotTink = true;
			dmg.directionSourceOverride = (DirectionSourceOverrides)1;
			dmg.useHeroDamageAffectors = true;
			dmg.hitOnceUntilEnd = true;
		}

		private static void SetupCollider(PolygonCollider2D col, float mult)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			((Collider2D)col).isTrigger = true;
			col.points = (Vector2[])(object)new Vector2[9]
			{
				new Vector2(0f, 3.85f) * mult,
				new Vector2(-1.75f, 3.25f) * mult,
				new Vector2(-2.5f, 2.25f) * mult,
				new Vector2(-3f, -1f) * mult,
				new Vector2(-2.5f, -1.5f) * mult,
				new Vector2(2.5f, -1.5f) * mult,
				new Vector2(3f, -1f) * mult,
				new Vector2(2.5f, 2.25f) * mult,
				new Vector2(1.75f, 3.25f) * mult
			};
		}
	}
	internal static class NoDistanceLimit
	{
		internal static void RemoveDistanceLimitCondition(PlayMakerFSM fsm)
		{
			if (!(fsm.FsmName != "Bind"))
			{
				FsmState state = FsmUtil.GetState(fsm, "Shaman Fall");
				FsmStateAction stateAction = FsmUtil.GetStateAction(state, 8);
				FloatTestToBool val = (FloatTestToBool)(object)((stateAction is FloatTestToBool) ? stateAction : null);
				val.greaterThanBool = val.lessThanBool;
			}
		}
	}
}