Decompiled source of ChefTweaks v1.0.6

ChefTweaks.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
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 BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Chef;
using Microsoft.CodeAnalysis;
using On.EntityStates.Chef;
using On.RoR2.Projectile;
using RoR2;
using RoR2.Projectile;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;

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

		public const string PluginAuthor = "Jeffdev";

		public const string PluginName = "ChefTweaks";

		public const string PluginVersion = "1.0.6";

		public static ConfigEntry<bool> rollCancel;

		public static ConfigEntry<bool> diceAutoRecall;

		public static bool rolyReleased;

		public static bool cleaversRecalling;

		public void Awake()
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Expected O, but got Unknown
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00b7: 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)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			Log.Init(((BaseUnityPlugin)this).Logger);
			diceAutoRecall = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Dice Auto Recall", true, "Makes Dice automatically recall after 2 seconds when holding down the button (false is vanilla default)");
			rollCancel = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Roll Cancel", true, "Allows Roll to be cancelled by pressing the utility button mid use (false is vanilla default)");
			RolyPoly.FixedUpdate += new hook_FixedUpdate(RolyPoly_FixedUpdate);
			Dice.FixedUpdate += new hook_FixedUpdate(Dice_FixedUpdate);
			CleaverProjectile.ChargeCleaver += new hook_ChargeCleaver(CleaverProjectile_ChargeCleaver);
			CleaverProjectile.HandleFlyback += new hook_HandleFlyback(CleaverProjectile_HandleFlyback);
			IceBox.OnEnter += new hook_OnEnter(IceBox_OnEnter);
			if (!Chainloader.PluginInfos.ContainsKey("com.Wolfo.WolfFixes"))
			{
				Addressables.LoadAssetAsync<SkillDef>((object)"6870bda0b12690048a9701539d1e2285").WaitForCompletion().activationState = Addressables.LoadAssetAsync<SkillDef>((object)"c97062b172b41af4ebdb42c312ac1989").WaitForCompletion().activationState;
			}
		}

		private void IceBox_OnEnter(orig_OnEnter orig, IceBox self)
		{
			orig.Invoke(self);
			if (!Chainloader.PluginInfos.ContainsKey("com.Wolfo.WolfFixes") && self.hasBoost)
			{
				self.attackSoundString = "Play_Chef_Secondary_IceBox_Boosted_Fire";
				Util.PlaySound(self.blizzardSFXString, ((EntityState)self).gameObject);
			}
		}

		private void CleaverProjectile_ChargeCleaver(orig_ChargeCleaver orig, CleaverProjectile self)
		{
			orig.Invoke(self);
			if (!Chainloader.PluginInfos.ContainsKey("com.Wolfo.WolfFixes") && self.charged)
			{
				self.projectileOverlapAttack.overlapProcCoefficient = 1f;
			}
		}

		private void CleaverProjectile_HandleFlyback(orig_HandleFlyback orig, CleaverProjectile self)
		{
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (diceAutoRecall.Value && !self.charged)
			{
				self.charged = true;
				ProjectileDamage projectileDamage = self.projectileDamage;
				projectileDamage.damage *= self.chargedDamageCoefficient;
				if (self.hasEffectiveAuthority && !self.projectileController.isPrediction)
				{
					EffectManager.SimpleEffect(self.ChargeEffect, ((Component)this).transform.position, ((Component)this).transform.rotation, true);
				}
				self.ToggleGhostChargeVFX(true);
				self.Networkcharged = true;
			}
			orig.Invoke(self);
		}

		private void Dice_FixedUpdate(orig_FixedUpdate orig, Dice self)
		{
			if (diceAutoRecall.Value)
			{
				if (self.allCleaversOut && !cleaversRecalling)
				{
					self.HandleRecall();
					cleaversRecalling = true;
				}
				else if (cleaversRecalling && !self.allCleaversOut)
				{
					cleaversRecalling = false;
				}
			}
			orig.Invoke(self);
		}

		private void RolyPoly_FixedUpdate(orig_FixedUpdate orig, RolyPoly self)
		{
			orig.Invoke(self);
			if (rollCancel.Value)
			{
				if (Object.op_Implicit((Object)(object)((EntityState)self).inputBank) && ((ButtonState)(ref ((EntityState)self).inputBank.skill3)).justReleased)
				{
					rolyReleased = true;
				}
				if (Object.op_Implicit((Object)(object)((EntityState)self).inputBank) && ((ButtonState)(ref ((EntityState)self).inputBank.skill3)).justPressed && self.hasRolyPolyStarted && rolyReleased)
				{
					((EntityState)self).outer.SetNextStateToMain();
					rolyReleased = false;
				}
			}
		}
	}
	public static class Utility
	{
		[CompilerGenerated]
		private sealed class <InvokeRoutine>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public float delay;

			public Action f;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					f();
					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();
			}
		}

		public static void Invoke(this MonoBehaviour mb, Action f, float delay)
		{
			mb.StartCoroutine(InvokeRoutine(f, delay));
		}

		[IteratorStateMachine(typeof(<InvokeRoutine>d__1))]
		private static IEnumerator InvokeRoutine(Action f, float delay)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InvokeRoutine>d__1(0)
			{
				f = f,
				delay = delay
			};
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

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

		internal static void Debug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
}