Decompiled source of MasterChef v1.1.1

MasterChef.dll

Decompiled 9 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 EntityStates;
using EntityStates.Chef;
using Microsoft.CodeAnalysis;
using On.EntityStates.Chef;
using R2API;
using RoR2;
using RoR2.Projectile;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;

[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("MasterChef")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MasterChef")]
[assembly: AssemblyTitle("MasterChef")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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;
		}
	}
}
namespace MasterChef
{
	public class AutoRecall : MonoBehaviour
	{
		private CleaverProjectile cleaverProjectile;

		private void Start()
		{
			cleaverProjectile = ((Component)this).GetComponent<CleaverProjectile>();
		}

		private void FixedUpdate()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)cleaverProjectile) && (int)cleaverProjectile.boomerangState == 3)
			{
				cleaverProjectile.boomerangState = (BoomerangState)1;
			}
		}
	}
	public class DiceNux : BaseState
	{
		public static GameObject CleaverPrefab;

		public static GameObject BoostedCleaverPrefab;

		public GameObject effectPrefab;

		public GameObject effectEnhancedPrefab;

		public float baseDuration = 2f;

		public float damageCoefficient = 1.2f;

		public float boostedDamageCoefficient = 1.2f;

		public float force = 20f;

		public string attackString;

		public static string returnString;

		public string yesChefAttackString;

		public static string yesChefReturnString;

		public float recoilAmplitude;

		public float bloom;

		public float recallAnimationTransitionTime = 0.2f;

		public float approximateCleaverDistance = 80f;

		internal float duration;

		internal ChefController chefController;

		internal bool hasBoost;

		internal void CacheOriginalFields()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			Dice val = new Dice();
			effectPrefab = val.effectPrefab;
			effectEnhancedPrefab = val.effectEnhancedPrefab;
			baseDuration = val.baseDuration;
			damageCoefficient = 1.5f;
			boostedDamageCoefficient = val.boostedDamageCoefficient;
			force = val.force;
			attackString = val.attackString;
			returnString = val.returnString;
			yesChefAttackString = val.yesChefAttackString;
			yesChefReturnString = val.yesChefReturnString;
			recoilAmplitude = val.recoilAmplitude;
			bloom = val.bloom;
			recallAnimationTransitionTime = val.recallAnimationTransitionTime;
			approximateCleaverDistance = val.approximateCleaverDistance;
		}

		internal void FireCleaverProjectile(Ray aimRay)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_00f1: 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)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			if (!((EntityState)this).isAuthority)
			{
				return;
			}
			GameObject projectilePrefab;
			int[] array;
			if (hasBoost)
			{
				projectilePrefab = BoostedCleaverPrefab;
				array = new int[3] { 8, 4, 4 };
			}
			else
			{
				projectilePrefab = CleaverPrefab;
				array = new int[1] { 1 };
			}
			int num = array.Length;
			for (int i = 0; i < num; i++)
			{
				int num2 = array[i];
				float num3 = (float)(i % 2) * (0.5f / (float)num2);
				for (int j = 0; j < num2; j++)
				{
					FireProjectileInfo val = default(FireProjectileInfo);
					val.projectilePrefab = projectilePrefab;
					val.position = ((Ray)(ref aimRay)).origin;
					float num4 = (num3 + (float)j / (float)num2) * MathF.PI * 2f;
					float num5 = Mathf.Acos(0.02f + (float)i / (float)num);
					float num6 = Mathf.Sin(num5) * Mathf.Sin(num4);
					float num7 = Mathf.Cos(num5);
					float num8 = Mathf.Sin(num5) * Mathf.Cos(num4);
					Quaternion val2 = Quaternion.LookRotation(new Vector3(num6, num7, num8));
					val.rotation = Util.QuaternionSafeLookRotation(((Ray)(ref aimRay)).direction) * val2;
					val.owner = ((EntityState)this).gameObject;
					val.damage = base.damageStat * damageCoefficient;
					val.damageTypeOverride = DamageTypeCombo.op_Implicit((DamageType)0);
					val.force = force;
					val.crit = Util.CheckRoll(base.critStat, ((EntityState)this).characterBody.master);
					if (!NetworkServer.active && Object.op_Implicit((Object)(object)chefController))
					{
						chefController.CacheCleaverProjectileFireInfo(val);
					}
					ProjectileManager.instance.FireProjectile(val);
				}
			}
		}

		public override void OnEnter()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			CacheOriginalFields();
			((BaseState)this).OnEnter();
			if (!Object.op_Implicit((Object)(object)chefController))
			{
				chefController = ((EntityState)this).GetComponent<ChefController>();
			}
			chefController.characterBody = ((EntityState)this).characterBody;
			chefController.spreadBloom = bloom;
			hasBoost = ((EntityState)this).characterBody.HasBuff(Buffs.Boosted);
			if (hasBoost)
			{
				damageCoefficient = boostedDamageCoefficient;
				if (NetworkServer.active)
				{
					((EntityState)this).characterBody.RemoveBuff(Buffs.Boosted);
				}
			}
			chefController.NetworkcatchDirtied = false;
			chefController.recallCleaver = false;
			Ray aimRay = ((BaseState)this).GetAimRay();
			TrajectoryAimAssist.ApplyTrajectoryAimAssist(ref aimRay, approximateCleaverDistance, ((EntityState)this).gameObject, 1f);
			duration = baseDuration / base.attackSpeedStat;
			((BaseState)this).StartAimMode(duration + 2f, false);
			PlayThrowCleaverAnimation();
			((BaseState)this).AddRecoil(-1f * recoilAmplitude, -1.5f * recoilAmplitude, -0.25f * recoilAmplitude, 0.25f * recoilAmplitude);
			DoMouthMuzzle();
			FireCleaverProjectile(aimRay);
		}

		internal void PlayThrowCleaverAnimation()
		{
			if (hasBoost)
			{
				((EntityState)this).PlayAnimation("Gesture, Override", "FireSliceAndDice", "FireSliceAndDice.playbackRate", duration, 0f);
				((EntityState)this).PlayAnimation("Gesture, Additive", "FireSliceAndDice", "FireSliceAndDice.playbackRate", duration, 0f);
				Util.PlaySound(yesChefAttackString, ((EntityState)this).gameObject);
			}
			else
			{
				((EntityState)this).PlayAnimation("Gesture, Override", "FireDice", "FireDice.playbackRate", duration, 0f);
				((EntityState)this).PlayAnimation("Gesture, Additive", "FireDice", "FireDice.playbackRate", duration, 0f);
				Util.PlaySound(attackString, ((EntityState)this).gameObject);
			}
		}

		internal void DoMouthMuzzle()
		{
			GameObject val = (hasBoost ? effectEnhancedPrefab : effectPrefab);
			if (Object.op_Implicit((Object)(object)val))
			{
				EffectManager.SimpleMuzzleFlash(val, ((Component)((EntityState)this).characterBody.aimOriginTransform).gameObject, "MouthMuzzle", false);
			}
		}

		public override void FixedUpdate()
		{
			((EntityState)this).FixedUpdate();
			if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge > duration)
			{
				((EntityState)this).outer.SetNextStateToMain();
			}
		}

		public override void OnExit()
		{
			chefController.SetYesChefHeatState(false);
			if (NetworkServer.active)
			{
				((EntityState)this).characterBody.RemoveBuff(Buffs.boostedFireEffect);
			}
			if (((EntityState)this).isAuthority)
			{
				chefController.ClearSkillOverrides();
			}
			((EntityState)this).OnExit();
		}

		public override InterruptPriority GetMinimumInterruptPriority()
		{
			return (InterruptPriority)1;
		}
	}
	[BepInPlugin("com.Nuxlar.MasterChef", "MasterChef", "1.1.1")]
	public class MasterChef : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_FirePrimaryAttack <>9__7_0;

			public static hook_OnEnter <>9__7_1;

			public static hook_GetIdealVelocity <>9__7_2;

			internal void <Awake>b__7_0(orig_FirePrimaryAttack orig, Sear self, string muzzle)
			{
			}

			internal void <Awake>b__7_1(orig_OnEnter orig, Sear self)
			{
				Sear.baseExitDuration = 0.25f;
				Sear.baseEntryDuration = 0.25f;
				self.flamethrowerStarted = true;
				orig.Invoke(self);
			}

			internal Vector3 <Awake>b__7_2(orig_GetIdealVelocity orig, RolyPoly self)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				Vector3 forward = ((EntityState)self).characterDirection.forward;
				return ((Vector3)(ref forward)).normalized * ((EntityState)self).characterBody.moveSpeed * self.speedMultiplierTemp;
			}
		}

		private GameObject chefBody = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Chef/ChefBody.prefab").WaitForCompletion();

		private SkillDef glazeDef = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC2/Chef/ChefGlaze.asset").WaitForCompletion();

		private SkillDef yesChefDef = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC2/Chef/YesChef.asset").WaitForCompletion();

		private SkillDef rollDef = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC2/Chef/ChefRolyPoly.asset").WaitForCompletion();

		private GameObject searProjectile = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Chef/BoostedSearFireballProjectile.prefab").WaitForCompletion();

		private GameObject diceProjectile = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Chef/ChefCleaver.prefab").WaitForCompletion();

		private GameObject diceBoostedProjectile = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/DLC2/Chef/ChefDiceEnhanced.prefab").WaitForCompletion();

		public void Awake()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Expected O, but got Unknown
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Expected O, but got Unknown
			bool flag = default(bool);
			ContentAddition.AddEntityState<DiceNux>(ref flag);
			DiceNux.CleaverPrefab = diceProjectile;
			DiceNux.BoostedCleaverPrefab = diceBoostedProjectile;
			diceProjectile.AddComponent<AutoRecall>();
			searProjectile.GetComponent<ProjectileDamage>().damageType = new DamageTypeCombo(DamageTypeCombo.op_Implicit((DamageType)128), (DamageTypeExtended)67108864);
			GenericSkill[] components = chefBody.GetComponents<GenericSkill>();
			foreach (GenericSkill val in components)
			{
				if (!val.skillName.Contains("Dice"))
				{
					Object.Destroy((Object)(object)val);
				}
			}
			FamilyChanges();
			glazeDef.baseRechargeInterval = 8f;
			yesChefDef.baseRechargeInterval = 10f;
			SkillDef skillDef = chefBody.GetComponent<SkillLocator>().primary.skillFamily.variants[0].skillDef;
			skillDef.activationState = new SerializableEntityStateType(typeof(DiceNux));
			skillDef.skillDescriptionToken = "Throw a cleaver through enemies for <style=cIsDamage>150% damage</style>. Dealing <style=cIsDamage>225% damage</style> on the return trip.";
			skillDef.mustKeyPress = false;
			skillDef.hideStockCount = true;
			skillDef.stockToConsume = 0;
			skillDef.baseMaxStock = 1;
			skillDef.dontAllowPastMaxStocks = true;
			skillDef.rechargeStock = 0;
			skillDef.requiredStock = 0;
			object obj = <>c.<>9__7_0;
			if (obj == null)
			{
				hook_FirePrimaryAttack val2 = delegate
				{
				};
				<>c.<>9__7_0 = val2;
				obj = (object)val2;
			}
			Sear.FirePrimaryAttack += (hook_FirePrimaryAttack)obj;
			object obj2 = <>c.<>9__7_1;
			if (obj2 == null)
			{
				hook_OnEnter val3 = delegate(orig_OnEnter orig, Sear self)
				{
					Sear.baseExitDuration = 0.25f;
					Sear.baseEntryDuration = 0.25f;
					self.flamethrowerStarted = true;
					orig.Invoke(self);
				};
				<>c.<>9__7_1 = val3;
				obj2 = (object)val3;
			}
			Sear.OnEnter += (hook_OnEnter)obj2;
			object obj3 = <>c.<>9__7_2;
			if (obj3 == null)
			{
				hook_GetIdealVelocity val4 = delegate(orig_GetIdealVelocity orig, RolyPoly self)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_001e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0029: Unknown result type (might be due to invalid IL or missing references)
					Vector3 forward = ((EntityState)self).characterDirection.forward;
					return ((Vector3)(ref forward)).normalized * ((EntityState)self).characterBody.moveSpeed * self.speedMultiplierTemp;
				};
				<>c.<>9__7_2 = val4;
				obj3 = (object)val4;
			}
			RolyPoly.GetIdealVelocity += (hook_GetIdealVelocity)obj3;
		}

		private void FamilyChanges()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			SkillLocator component = chefBody.GetComponent<SkillLocator>();
			GenericSkill val = chefBody.AddComponent<GenericSkill>();
			val.skillName = "chefSecondaryNux";
			SkillFamily val2 = ScriptableObject.CreateInstance<SkillFamily>();
			((Object)val2).name = "chefSecondaryFamilyNux";
			val2.variants = (Variant[])(object)new Variant[1]
			{
				new Variant
				{
					skillDef = glazeDef
				}
			};
			val._skillFamily = val2;
			ContentAddition.AddSkillFamily(val2);
			component.secondary = val;
			GenericSkill val3 = chefBody.AddComponent<GenericSkill>();
			val3.skillName = "chefUtilityNux";
			SkillFamily val4 = ScriptableObject.CreateInstance<SkillFamily>();
			((Object)val4).name = "chefUtilityFamilyNux";
			val4.variants = (Variant[])(object)new Variant[1]
			{
				new Variant
				{
					skillDef = rollDef
				}
			};
			val3._skillFamily = val4;
			ContentAddition.AddSkillFamily(val2);
			component.utility = val3;
			GenericSkill val5 = chefBody.AddComponent<GenericSkill>();
			val5.skillName = "chefSpecialNux";
			SkillFamily val6 = ScriptableObject.CreateInstance<SkillFamily>();
			((Object)val6).name = "chefSecondaryFamilyNux";
			val6.variants = (Variant[])(object)new Variant[1]
			{
				new Variant
				{
					skillDef = yesChefDef
				}
			};
			val5._skillFamily = val6;
			ContentAddition.AddSkillFamily(val6);
			component.special = val5;
		}
	}
}