Decompiled source of ShockStunDebuff v1.0.2

ShockStunDebuff.dll

Decompiled 3 months 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.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2;
using R2API;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;

[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("ShockStunDebuff")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("ShockStunDebuff")]
[assembly: AssemblyTitle("ShockStunDebuff")]
[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 ShockStunDebuff
{
	[BepInPlugin("HIFU.ShockStunDebuff", "ShockStunDebuff", "1.0.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "HIFU.ShockStunDebuff";

		public const string PluginAuthor = "HIFU";

		public const string PluginName = "ShockStunDebuff";

		public const string PluginVersion = "1.0.2";

		public static AssetBundle assetBundle;

		public static BuffDef stunDebuff;

		public static BuffDef shockDebuff;

		public static BuffDef freezeDebuff;

		public static ManualLogSource ssdLogger;

		public static bool wolfoqolLoaded;

		public static ConfigEntry<bool> useStun { get; private set; }

		public static ConfigEntry<bool> useShock { get; private set; }

		public static ConfigEntry<bool> useFreeze { get; private set; }

		public void Awake()
		{
			//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)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Expected O, but got Unknown
			assetBundle = AssetBundle.LoadFromFile(Assembly.GetExecutingAssembly().Location.Replace("ShockStunDebuff.dll", "shockstundebuff"));
			useStun = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Make Stun a Debuff?", true, "");
			useShock = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Make Shock a Debuff?", true, "");
			useFreeze = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Make Freeze a Debuff?", true, "Disabled by if WolfoQoL is detected");
			ssdLogger = ((BaseUnityPlugin)this).Logger;
			if (useStun.Value)
			{
				stunDebuff = ScriptableObject.CreateInstance<BuffDef>();
				((Object)stunDebuff).name = "Stun Debuff";
				stunDebuff.isHidden = false;
				stunDebuff.isDebuff = true;
				stunDebuff.isCooldown = false;
				stunDebuff.canStack = false;
				stunDebuff.buffColor = Color32.op_Implicit(new Color32((byte)131, (byte)185, (byte)193, byte.MaxValue));
				stunDebuff.iconSprite = assetBundle.LoadAsset<Sprite>("texStunBuff.png");
				ContentAddition.AddBuffDef(stunDebuff);
				SetStateOnHurt.SetStun += new hook_SetStun(SetStateOnHurt_SetStun);
			}
			if (useShock.Value)
			{
				shockDebuff = ScriptableObject.CreateInstance<BuffDef>();
				((Object)shockDebuff).name = "Shock Debuff";
				shockDebuff.isHidden = false;
				shockDebuff.isDebuff = true;
				shockDebuff.isCooldown = false;
				shockDebuff.canStack = false;
				shockDebuff.buffColor = Color32.op_Implicit(new Color32((byte)31, (byte)161, (byte)226, byte.MaxValue));
				shockDebuff.iconSprite = assetBundle.LoadAsset<Sprite>("texShockBuff.png");
				ContentAddition.AddBuffDef(shockDebuff);
				SetStateOnHurt.SetShock += new hook_SetShock(SetStateOnHurt_SetShock);
			}
			wolfoqolLoaded = Chainloader.PluginInfos.ContainsKey("com.Wolfo.WolfoQualityOfLife");
			InitFreeze();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private void InitFreeze()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			if (!wolfoqolLoaded)
			{
				freezeDebuff = ScriptableObject.CreateInstance<BuffDef>();
				((Object)freezeDebuff).name = "Freeze Debuff";
				freezeDebuff.isHidden = false;
				freezeDebuff.isDebuff = true;
				freezeDebuff.isCooldown = false;
				freezeDebuff.canStack = false;
				freezeDebuff.buffColor = Color32.op_Implicit(new Color32((byte)104, (byte)226, (byte)226, byte.MaxValue));
				freezeDebuff.iconSprite = assetBundle.LoadAsset<Sprite>("texFreezeBuff.png");
				ContentAddition.AddBuffDef(freezeDebuff);
				SetStateOnHurt.SetFrozen += new hook_SetFrozen(SetStateOnHurt_SetFrozen);
			}
		}

		private void SetStateOnHurt_SetShock(orig_SetShock orig, SetStateOnHurt self, float duration)
		{
			orig.Invoke(self, duration);
			SetDebuff(self, duration, shockDebuff);
		}

		private void SetDebuff(SetStateOnHurt self, float duration, BuffDef buffType)
		{
			if (NetworkServer.active)
			{
				GameObject gameObject = ((Component)self.targetStateMachine).gameObject;
				CharacterBody val = default(CharacterBody);
				if (gameObject.TryGetComponent<CharacterBody>(ref val))
				{
					val.AddTimedBuff(buffType, duration);
				}
			}
		}

		private void SetStateOnHurt_SetFrozen(orig_SetFrozen orig, SetStateOnHurt self, float duration)
		{
			orig.Invoke(self, duration);
			SetDebuff(self, duration, freezeDebuff);
		}

		private void SetStateOnHurt_SetStun(orig_SetStun orig, SetStateOnHurt self, float duration)
		{
			orig.Invoke(self, duration);
			SetDebuff(self, duration, stunDebuff);
		}
	}
}