Decompiled source of StinkySpell v1.0.1

StinkySpell.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
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.Logging;
using BlackMagicAPI.Helpers;
using BlackMagicAPI.Managers;
using BlackMagicAPI.Modules.Spells;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using StinkySpell.Spells.StinkySpell;
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(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("StinkySpell")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StinkySpell")]
[assembly: AssemblyTitle("StinkySpell")]
[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.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 StinkySpell
{
	[BepInProcess("MageArena")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.filo0.stinkyspell", "StinkySpell", "1.0.0")]
	public class MSPlugin : BaseUnityPlugin
	{
		private const string MyGUID = "com.filo0.stinkyspell";

		internal const string PluginName = "StinkySpell";

		private const string VersionString = "1.0.0";

		private static Harmony? Harmony;

		private ManualLogSource? _log;

		public static string modsync = "all";

		internal static AssetBundle? SpellsAssets;

		internal static MSPlugin Instance { get; private set; }

		internal static ManualLogSource Log => Instance._log;

		private void Awake()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			_log = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			Harmony = new Harmony("com.filo0.stinkyspell");
			Harmony.PatchAll();
			SpellsAssets = Utils.LoadAssetBundleFromResources(Assembly.GetExecutingAssembly(), "StinkySpell.Resources.stinkybundle");
			BlackMagicManager.RegisterDeathIcon((BaseUnityPlugin)(object)this, "stinky", Utils.LoadTextureFromResources(Assembly.GetExecutingAssembly(), "StinkySpell.Resources.stinky_icon.png"));
			BlackMagicManager.RegisterSpell((BaseUnityPlugin)(object)this, typeof(StinkySpellData), typeof(StinkySpellLogic));
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin StinkySpell is loaded!");
		}
	}
}
namespace StinkySpell.Spells.StinkySpell
{
	internal class StinkySpellData : SpellData
	{
		public override string Name => "Stinky";

		public override string[] SubNames => new string[2] { "Stinker", "You Stink" };

		public override float Cooldown => 10f;

		public override Color GlowColor => Color.yellow;

		public override Texture2D? GetMainTexture()
		{
			return Utils.LoadTextureFromResources(Assembly.GetExecutingAssembly(), "StinkySpell.Resources.stinky_main.png");
		}

		public override Texture2D? GetEmissionTexture()
		{
			return Utils.LoadTextureFromResources(Assembly.GetExecutingAssembly(), "StinkySpell.Resources.stinky_emission.png");
		}
	}
	internal class StinkySpellLogic : SpellLogic
	{
		[CompilerGenerated]
		private sealed class <Explode>d__7 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public PlayerMovement[] players;

			public int castingLevel;

			public StinkySpellLogic <>4__this;

			private PlayerMovement[] <array>5__1;

			private PlayerMovement[] <>s__2;

			private int <>s__3;

			private PlayerMovement <val>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <Explode>d__7(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<array>5__1 = null;
				<>s__2 = null;
				<val>5__4 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0142: Unknown result type (might be due to invalid IL or missing references)
				//IL_014c: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					<>4__this.explosion = Object.Instantiate<GameObject>(explosionPrefab);
					GameObject? explosion2 = <>4__this.explosion;
					if (explosion2 != null)
					{
						explosion2.transform.position = <>4__this.stinky.transform.position;
					}
					<array>5__1 = Object.FindObjectsByType<PlayerMovement>((FindObjectsSortMode)0);
					<>s__2 = <array>5__1;
					for (<>s__3 = 0; <>s__3 < <>s__2.Length; <>s__3++)
					{
						<val>5__4 = <>s__2[<>s__3];
						if (Vector3.Distance(((Component)<val>5__4).transform.position, <>4__this.explosion.transform.position) < 4f)
						{
							<val>5__4.NonRpcDamagePlayer(30f + (float)(10 * castingLevel), (GameObject)null, "stinky");
						}
						<val>5__4 = null;
					}
					<>s__2 = null;
					Object.Destroy((Object)(object)<>4__this.stinky);
					<>2__current = (object)new WaitForSeconds(1.75f);
					<>1__state = 1;
					return true;
				}
				case 1:
				{
					<>1__state = -1;
					GameObject? explosion = <>4__this.explosion;
					if (explosion != null)
					{
						((Renderer)explosion.GetComponent<SpriteRenderer>()).enabled = false;
					}
					Object.Destroy((Object)(object)<>4__this.explosion);
					((SpellLogic)<>4__this).DisposeSpell();
					return false;
				}
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <WaitForPlayerInRange>d__6 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public PlayerMovement owner;

			public PlayerMovement[] players;

			public int castingLevel;

			public StinkySpellLogic <>4__this;

			private PlayerMovement[] <>s__1;

			private int <>s__2;

			private PlayerMovement <player>5__3;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <WaitForPlayerInRange>d__6(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>s__1 = null;
				<player>5__3 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Expected O, but got Unknown
				//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(2f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					goto IL_014b;
				case 2:
					<>1__state = -1;
					goto IL_014b;
				case 3:
					{
						<>1__state = -1;
						return false;
					}
					IL_014b:
					if (!<>4__this.isExploded)
					{
						<>s__1 = players;
						for (<>s__2 = 0; <>s__2 < <>s__1.Length; <>s__2++)
						{
							<player>5__3 = <>s__1[<>s__2];
							if (!((Object)(object)<player>5__3 == (Object)null))
							{
								if (Vector3.Distance(<>4__this.stinky.transform.position, ((Component)<player>5__3).transform.position) < 2f)
								{
									((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.Explode(players, castingLevel));
									<>4__this.isExploded = true;
									break;
								}
								<player>5__3 = null;
							}
						}
						<>s__1 = null;
						<>2__current = null;
						<>1__state = 2;
						return true;
					}
					<>2__current = null;
					<>1__state = 3;
					return true;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static GameObject? stinkyPrefab;

		private GameObject? stinky;

		private static GameObject? explosionPrefab;

		private GameObject? explosion;

		private bool isExploded = false;

		public override void CastSpell(GameObject playerObj, PageController page, Vector3 spawnPos, Vector3 viewDirectionVector, int castingLevel)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
			PlayerMovement component = playerObj.GetComponent<PlayerMovement>();
			PlayerMovement[] source = (from obj in GameObject.FindGameObjectsWithTag("Player")
				select obj.GetComponent<PlayerMovement>()).ToArray();
			stinky = Object.Instantiate<GameObject>(stinkyPrefab);
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(viewDirectionVector.x, 0f, viewDirectionVector.z);
			stinky.transform.position = playerObj.transform.position + new Vector3(0f, 1.5f, 0f) + val * 2.5f;
			stinky.transform.rotation = Quaternion.LookRotation(viewDirectionVector);
			Rigidbody component2 = stinky.GetComponent<Rigidbody>();
			component2.isKinematic = false;
			component2.velocity = (10f + 2f * (float)castingLevel) * viewDirectionVector;
			component2.mass = 5f;
			component2.useGravity = true;
			((MonoBehaviour)this).StartCoroutine(WaitForPlayerInRange(component, source.ToArray(), castingLevel));
		}

		[IteratorStateMachine(typeof(<WaitForPlayerInRange>d__6))]
		private IEnumerator WaitForPlayerInRange(PlayerMovement owner, PlayerMovement[] players, int castingLevel)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WaitForPlayerInRange>d__6(0)
			{
				<>4__this = this,
				owner = owner,
				players = players,
				castingLevel = castingLevel
			};
		}

		[IteratorStateMachine(typeof(<Explode>d__7))]
		private IEnumerator Explode(PlayerMovement[] players, int castingLevel)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Explode>d__7(0)
			{
				<>4__this = this,
				players = players,
				castingLevel = castingLevel
			};
		}

		public override void OnPrefabCreatedAutomatically(GameObject prefab)
		{
			AssetBundle? spellsAssets = MSPlugin.SpellsAssets;
			stinkyPrefab = ((spellsAssets != null) ? spellsAssets.LoadAsset<GameObject>("stinky.prefab") : null);
			AssetBundle? spellsAssets2 = MSPlugin.SpellsAssets;
			explosionPrefab = ((spellsAssets2 != null) ? spellsAssets2.LoadAsset<GameObject>("explosion.prefab") : null);
			Object.DontDestroyOnLoad((Object)(object)stinkyPrefab);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}