Decompiled source of CumpleAxelRepo v1.0.1

plugins\CumpleAxelRepo.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
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("CumpleAxelRepo")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+c9ffc0a84130a122c7b43e8abbfae71b2ec1dd11")]
[assembly: AssemblyProduct("CumpleAxelRepo")]
[assembly: AssemblyTitle("CumpleAxelRepo")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 CumpleAxelRepo
{
	internal static class BirthdayContent
	{
		private const string BundleFile = "cumpleaxelrepoassets";

		private static AssetBundle _bundle;

		private static GameObject _cakeModel;

		private static GameObject _pinataModel;

		private static GameObject _hatModel;

		private static ValuableObject _cakeTemplate;

		private static ValuableObject _pinataTemplate;

		private static ValuableObject _candyTemplate;

		private static readonly HashSet<int> DecoratedPlayers = new HashSet<int>();

		private static readonly FieldInfo CrouchingField = AccessTools.Field(typeof(PlayerAvatar), "isCrouching");

		private static readonly FieldInfo ValueOverrideField = AccessTools.Field(typeof(ValuableObject), "dollarValueOverride");

		private static readonly FieldInfo ValueCurrentField = AccessTools.Field(typeof(ValuableObject), "dollarValueCurrent");

		private static readonly FieldInfo ValueOriginalField = AccessTools.Field(typeof(ValuableObject), "dollarValueOriginal");

		private static float _nextRegistrationAttempt;

		internal static void LoadAssets()
		{
			string text = Path.Combine(Path.GetDirectoryName(Plugin.PluginPath), "cumpleaxelrepoassets");
			_bundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)_bundle == (Object)null)
			{
				Plugin.Log.LogError((object)("No se pudo cargar el bundle de contenido: " + text + ". Pastel, piñata y gorritos quedarán desactivados."));
				return;
			}
			GameObject[] array = _bundle.LoadAllAssets<GameObject>();
			foreach (GameObject val in array)
			{
				string text2 = ((Object)val).name.ToLowerInvariant();
				if (text2.Contains("strawberrycake"))
				{
					_cakeModel = val;
				}
				else if (text2.Contains("birthdaypinata"))
				{
					_pinataModel = val;
				}
				else if (text2.Contains("birthdaypartyhat"))
				{
					_hatModel = val;
				}
			}
			Plugin.Log.LogInfo((object)$"Modelos cargados (pastel={Object.op_Implicit((Object)(object)_cakeModel)}, piñata={Object.op_Implicit((Object)(object)_pinataModel)}, gorro={Object.op_Implicit((Object)(object)_hatModel)}).");
		}

		internal static void RegisterValuables()
		{
			if ((Object)(object)_bundle == (Object)null || (Object)(object)_cakeModel == (Object)null || (Object)(object)_pinataModel == (Object)null || Object.op_Implicit((Object)(object)_cakeTemplate) || Time.unscaledTime < _nextRegistrationAttempt)
			{
				return;
			}
			_nextRegistrationAttempt = Time.unscaledTime + 4f;
			ValuableObject[] source = Resources.FindObjectsOfTypeAll<ValuableObject>();
			ValuableObject val = ((IEnumerable<ValuableObject>)source).FirstOrDefault((Func<ValuableObject, bool>)IsUsableTemplate);
			if (!Object.op_Implicit((Object)(object)val))
			{
				Plugin.Log.LogWarning((object)"No encontré una plantilla de ValuableObject para registrar el pastel y la piñata.");
				return;
			}
			_cakeTemplate = CreateValuable(val, "AxelBirthdayCake", _cakeModel, (Type)3, 15000);
			_pinataTemplate = CreateValuable(val, "AxelLuckyPinata", _pinataModel, (Type)2, 9000);
			_candyTemplate = CreateValuable(val, "AxelLuckyCandy", _pinataModel, (Type)1, 1200);
			if (Object.op_Implicit((Object)(object)_cakeTemplate))
			{
				Valuables.RegisterValuable(_cakeTemplate, new List<string>());
			}
			if (Object.op_Implicit((Object)(object)_pinataTemplate))
			{
				Valuables.RegisterValuable(_pinataTemplate, new List<string>());
			}
			if (Object.op_Implicit((Object)(object)_candyTemplate))
			{
				Valuables.RegisterValuable(_candyTemplate, new List<string>());
			}
			Plugin.Log.LogInfo((object)"Registrados los valuables de pastel frágil, piñata y caramelos con REPOLib.");
		}

		private static bool IsUsableTemplate(ValuableObject valuable)
		{
			return Object.op_Implicit((Object)(object)valuable) && Object.op_Implicit((Object)(object)((Component)valuable).gameObject) && Object.op_Implicit((Object)(object)((Component)valuable).gameObject.GetComponent<PhotonView>()) && Object.op_Implicit((Object)(object)((Component)valuable).GetComponent<Rigidbody>()) && Object.op_Implicit((Object)(object)((Component)valuable).GetComponent<PhysGrabObject>());
		}

		private static ValuableObject CreateValuable(ValuableObject source, string name, GameObject model, Type size, int initialValue)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_00c9: 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)
			GameObject val = Object.Instantiate<GameObject>(((Component)source).gameObject);
			((Object)val).name = name;
			val.SetActive(false);
			Renderer[] componentsInChildren = val.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val2 in componentsInChildren)
			{
				val2.enabled = false;
			}
			ValuableObject component = val.GetComponent<ValuableObject>();
			component.status = (Status)1;
			component.volumeType = size;
			ValueOverrideField?.SetValue(component, initialValue);
			GameObject val3 = Object.Instantiate<GameObject>(model, val.transform);
			((Object)val3).name = name + "_Visual";
			val3.transform.localPosition = Vector3.zero;
			val3.transform.localRotation = Quaternion.identity;
			val3.transform.localScale = ((name == "AxelLuckyCandy") ? (Vector3.one * 0.35f) : (Vector3.one * ((name == "AxelBirthdayCake") ? 1.35f : 0.8f)));
			if (name == "AxelBirthdayCake")
			{
				AddCandles(val3.transform);
				val.AddComponent<BirthdayCakeBehaviour>();
			}
			else if (name == "AxelLuckyPinata")
			{
				val.AddComponent<BirthdayPinataBehaviour>();
			}
			val.SetActive(true);
			return component;
		}

		private static void AddCandles(Transform parent)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("Standard");
			Material val2 = ((!Object.op_Implicit((Object)(object)val)) ? ((Material)null) : new Material(val)
			{
				color = new Color(1f, 0.9f, 0.64f)
			});
			Material val3 = ((!Object.op_Implicit((Object)(object)val)) ? ((Material)null) : new Material(val)
			{
				color = new Color(1f, 0.42f, 0.04f)
			});
			for (int i = 0; i < 5; i++)
			{
				float num = (float)(i - 2) * 0.22f;
				GameObject val4 = GameObject.CreatePrimitive((PrimitiveType)2);
				((Object)val4).name = "BirthdayCandle";
				val4.transform.SetParent(parent, false);
				val4.transform.localPosition = new Vector3(num, 0.78f, 0f);
				val4.transform.localScale = new Vector3(0.055f, 0.16f, 0.055f);
				Collider component = val4.GetComponent<Collider>();
				if (Object.op_Implicit((Object)(object)component))
				{
					Object.Destroy((Object)(object)component);
				}
				if (Object.op_Implicit((Object)(object)val2) && Object.op_Implicit((Object)(object)val4.GetComponent<Renderer>()))
				{
					val4.GetComponent<Renderer>().sharedMaterial = val2;
				}
				GameObject val5 = GameObject.CreatePrimitive((PrimitiveType)0);
				((Object)val5).name = "CandleFlame";
				val5.transform.SetParent(val4.transform, false);
				val5.transform.localPosition = new Vector3(0f, 1.05f, 0f);
				val5.transform.localScale = new Vector3(0.55f, 0.75f, 0.55f);
				Collider component2 = val5.GetComponent<Collider>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					Object.Destroy((Object)(object)component2);
				}
				if (Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val5.GetComponent<Renderer>()))
				{
					val5.GetComponent<Renderer>().sharedMaterial = val3;
				}
			}
		}

		internal static void TickHats()
		{
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			RegisterValuables();
			if (!Object.op_Implicit((Object)(object)_hatModel))
			{
				return;
			}
			PlayerAvatar[] array = Object.FindObjectsOfType<PlayerAvatar>();
			foreach (PlayerAvatar val in array)
			{
				if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.playerAvatarVisuals))
				{
					int instanceID = ((Object)val).GetInstanceID();
					if (!DecoratedPlayers.Contains(instanceID))
					{
						Transform val2 = (Object.op_Implicit((Object)(object)val.playerAvatarVisuals.headUpTransform) ? val.playerAvatarVisuals.headUpTransform : ((Component)val).transform);
						GameObject val3 = Object.Instantiate<GameObject>(_hatModel, val2);
						((Object)val3).name = "CumpleAxelRepo_PhysicsPartyHat";
						val3.transform.localPosition = new Vector3(0f, 0.15f, 0f);
						val3.transform.localRotation = Quaternion.identity;
						val3.transform.localScale = Vector3.one * 0.55f;
						BirthdayHatBehaviour birthdayHatBehaviour = val3.AddComponent<BirthdayHatBehaviour>();
						birthdayHatBehaviour.Bind(val);
						DecoratedPlayers.Add(instanceID);
					}
				}
			}
			DecoratedPlayers.RemoveWhere((int id) => !Object.FindObjectsOfType<PlayerAvatar>().Any((PlayerAvatar player) => Object.op_Implicit((Object)(object)player) && ((Object)player).GetInstanceID() == id));
		}

		internal static void ReleaseHat(PlayerAvatar player)
		{
			if (Object.op_Implicit((Object)(object)player))
			{
				BirthdayHatBehaviour componentInChildren = ((Component)player).GetComponentInChildren<BirthdayHatBehaviour>(true);
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					componentInChildren.Launch();
				}
			}
		}

		internal static bool IsCrouching(PlayerAvatar player)
		{
			return Object.op_Implicit((Object)(object)player) && CrouchingField != null && (bool)CrouchingField.GetValue(player);
		}

		internal static void SetValue(ValuableObject valuable, int value)
		{
			if (Object.op_Implicit((Object)(object)valuable))
			{
				ValueOverrideField?.SetValue(valuable, value);
				ValueCurrentField?.SetValue(valuable, (float)value);
				ValueOriginalField?.SetValue(valuable, (float)value);
			}
		}

		internal static void BreakPinata(Transform origin)
		{
			//IL_0068: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: 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_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || !Object.op_Implicit((Object)(object)_candyTemplate) || !Object.op_Implicit((Object)(object)origin))
			{
				return;
			}
			PrefabRef val = ((IEnumerable<PrefabRef>)Valuables.RegisteredValuables).FirstOrDefault((Func<PrefabRef, bool>)((PrefabRef x) => x != null && ((PrefabRef<GameObject>)(object)x).PrefabName == "AxelLuckyCandy"));
			if (val == null)
			{
				return;
			}
			for (int num = 0; num < 6; num++)
			{
				Vector3 val2 = Random.insideUnitSphere * 0.35f + Vector3.up * 0.35f;
				GameObject val3 = Valuables.SpawnValuable(val, origin.position + val2, Random.rotation);
				if (Object.op_Implicit((Object)(object)val3) && Object.op_Implicit((Object)(object)val3.GetComponent<Rigidbody>()))
				{
					val3.GetComponent<Rigidbody>().AddForce(((Vector3)(ref val2)).normalized * Random.Range(2.5f, 5f), (ForceMode)1);
				}
			}
		}

		internal static void ConfettiCream(Vector3 position)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0060: 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_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_00a4: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("CumpleAxelRepo_CakeCreamBurst");
			val.transform.position = position;
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			MainModule main = val2.main;
			((MainModule)(ref main)).duration = 0.8f;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.2f, 2.1f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(4f, 9f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(0.16f, 0.45f);
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 0.84f, 0.9f));
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1]
			{
				new Burst(0f, (short)160)
			});
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 0.25f;
			val2.Play();
			Object.Destroy((Object)(object)val, 4f);
		}

		internal static void Unload()
		{
			if (Object.op_Implicit((Object)(object)_bundle))
			{
				_bundle.Unload(false);
			}
			_bundle = null;
			DecoratedPlayers.Clear();
			_cakeModel = null;
			_pinataModel = null;
			_hatModel = null;
		}
	}
	[HarmonyPatch(typeof(RunManager), "Awake")]
	internal static class BirthdayValuableRegistrationPatch
	{
		[HarmonyPriority(0)]
		private static void Postfix()
		{
			BirthdayContent.RegisterValuables();
		}
	}
	[HarmonyPatch(typeof(PlayerHealth), "Hurt")]
	internal static class BirthdayHatHurtPatch
	{
		private static void Postfix(PlayerHealth __instance)
		{
			PlayerAvatar player = (Object.op_Implicit((Object)(object)__instance) ? ((Component)__instance).GetComponent<PlayerAvatar>() : null);
			BirthdayContent.ReleaseHat(player);
		}
	}
	internal sealed class BirthdayHatBehaviour : MonoBehaviour
	{
		private PlayerAvatar _owner;

		private bool _launched;

		private Vector3 _lastOwnerPosition;

		internal void Bind(PlayerAvatar owner)
		{
			//IL_0019: 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)
			_owner = owner;
			if (Object.op_Implicit((Object)(object)owner))
			{
				_lastOwnerPosition = ((Component)owner).transform.position;
			}
		}

		private void Update()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_004d: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_008f: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			if (!_launched && Object.op_Implicit((Object)(object)_owner))
			{
				Vector3 val = (((Component)_owner).transform.position - _lastOwnerPosition) / Mathf.Max(Time.deltaTime, 0.001f);
				_lastOwnerPosition = ((Component)_owner).transform.position;
				Vector3 val2 = (Object.op_Implicit((Object)(object)((Component)this).transform.parent) ? ((Component)this).transform.parent.InverseTransformDirection(val) : val);
				Quaternion val3 = Quaternion.Euler(Mathf.Clamp((0f - val2.z) * 1.8f, -16f, 16f), 0f, Mathf.Clamp(val2.x * 1.8f, -16f, 16f));
				((Component)this).transform.localRotation = Quaternion.Slerp(((Component)this).transform.localRotation, val3, Time.deltaTime * 9f);
				if (BirthdayContent.IsCrouching(_owner))
				{
					Launch();
				}
			}
		}

		internal void Launch()
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_0100: 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)
			if (!_launched)
			{
				_launched = true;
				((Component)this).transform.SetParent((Transform)null, true);
				Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>(true);
				foreach (Collider val in componentsInChildren)
				{
					val.enabled = true;
				}
				if (!Object.op_Implicit((Object)(object)((Component)this).GetComponentInChildren<Collider>()))
				{
					SphereCollider val2 = ((Component)this).gameObject.AddComponent<SphereCollider>();
					val2.radius = 0.28f;
					val2.center = new Vector3(0f, 0.25f, 0f);
				}
				Rigidbody val3 = ((Component)this).GetComponent<Rigidbody>();
				if (!Object.op_Implicit((Object)(object)val3))
				{
					val3 = ((Component)this).gameObject.AddComponent<Rigidbody>();
				}
				val3.isKinematic = false;
				val3.useGravity = true;
				val3.mass = 0.15f;
				val3.AddForce(Vector3.up * 2f + Random.insideUnitSphere * 1.8f, (ForceMode)1);
				val3.AddTorque(Random.insideUnitSphere * 2.5f, (ForceMode)1);
				Object.Destroy((Object)(object)((Component)this).gameObject, 12f);
			}
		}
	}
	internal sealed class BirthdayCakeBehaviour : MonoBehaviour
	{
		private ValuableObject _valuable;

		private bool _candlesOut;

		private bool _broken;

		private PhotonView _view;

		private void Awake()
		{
			_valuable = ((Component)this).GetComponent<ValuableObject>();
			_view = ((Component)this).GetComponent<PhotonView>();
		}

		private void FixedUpdate()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			Rigidbody component = ((Component)this).GetComponent<Rigidbody>();
			if (Object.op_Implicit((Object)(object)component) && !_broken && SemiFunc.IsMasterClientOrSingleplayer())
			{
				Vector3 linearVelocity = component.linearVelocity;
				float magnitude = ((Vector3)(ref linearVelocity)).magnitude;
				if (magnitude > 8f && _candlesOut)
				{
					Break();
				}
				else if (magnitude > 5f && !_candlesOut)
				{
					SnuffCandles();
				}
			}
		}

		private void OnCollisionEnter(Collision collision)
		{
			//IL_001e: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if (!SemiFunc.IsMasterClientOrSingleplayer() || _broken || collision == null)
			{
				return;
			}
			Vector3 relativeVelocity = collision.relativeVelocity;
			if (((Vector3)(ref relativeVelocity)).magnitude > 8f && _candlesOut)
			{
				Break();
				return;
			}
			relativeVelocity = collision.relativeVelocity;
			if (((Vector3)(ref relativeVelocity)).magnitude > 4.5f && !_candlesOut)
			{
				SnuffCandles();
			}
		}

		private void SnuffCandles()
		{
			if (_candlesOut || _broken)
			{
				return;
			}
			_candlesOut = true;
			Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)val).name == "CandleFlame")
				{
					((Component)val).gameObject.SetActive(false);
				}
			}
			SetCakeValue(2500);
		}

		private void Break()
		{
			if (!_broken)
			{
				_broken = true;
				if (Object.op_Implicit((Object)(object)_view) && _view.ViewID != 0)
				{
					_view.RPC("BreakRpc", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					BreakRpc();
				}
			}
		}

		[PunRPC]
		private void BreakRpc()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			BirthdayContent.ConfettiCream(((Component)this).transform.position);
			PhotonView component = ((Component)this).GetComponent<PhotonView>();
			if (Object.op_Implicit((Object)(object)component) && component.ViewID != 0 && PhotonNetwork.IsMasterClient)
			{
				PhotonNetwork.Destroy(((Component)this).gameObject);
			}
			else if (!SemiFunc.IsMultiplayer())
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void SetCakeValue(int value)
		{
			if (Object.op_Implicit((Object)(object)_view) && _view.ViewID != 0)
			{
				_view.RPC("SetValueRpc", (RpcTarget)0, new object[1] { value });
			}
			else
			{
				SetValueRpc(value);
			}
		}

		[PunRPC]
		private void SetValueRpc(int value)
		{
			BirthdayContent.SetValue(_valuable, value);
		}
	}
	internal sealed class BirthdayPinataBehaviour : MonoBehaviour
	{
		private bool _broken;

		private void OnCollisionEnter(Collision collision)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (_broken || !SemiFunc.IsMasterClientOrSingleplayer() || collision == null)
			{
				return;
			}
			Vector3 relativeVelocity = collision.relativeVelocity;
			if (!(((Vector3)(ref relativeVelocity)).magnitude < 5.5f))
			{
				_broken = true;
				PhotonView component = ((Component)this).GetComponent<PhotonView>();
				if (Object.op_Implicit((Object)(object)component) && component.ViewID != 0)
				{
					component.RPC("BreakRpc", (RpcTarget)0, Array.Empty<object>());
				}
				else
				{
					BreakRpc();
				}
			}
		}

		[PunRPC]
		private void BreakRpc()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			BirthdayContent.BreakPinata(((Component)this).transform);
			BirthdayContent.ConfettiCream(((Component)this).transform.position);
			PhotonView component = ((Component)this).GetComponent<PhotonView>();
			if (Object.op_Implicit((Object)(object)component) && component.ViewID != 0 && PhotonNetwork.IsMasterClient)
			{
				PhotonNetwork.Destroy(((Component)this).gameObject);
			}
			else if (!SemiFunc.IsMultiplayer())
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	[HarmonyPatch(typeof(ExtractionPoint), "StateComplete")]
	internal static class ExtractionCelebrationPatch
	{
		private static void Prefix(ExtractionPoint __instance, out bool __state, ref bool ___stateStart, ref bool ___isShop, ref bool ___taxReturn)
		{
			__state = ___stateStart && !___isShop && !___taxReturn;
		}

		private static void Postfix(ExtractionPoint __instance, bool __state)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			if (__state)
			{
				Plugin.Celebrate(((Component)__instance).transform.position);
			}
		}
	}
	[HarmonyPatch(typeof(EnemyGnome), "Awake")]
	internal static class GnomeSoundRegistrationPatch
	{
		private static void Postfix(EnemyGnome __instance)
		{
			Plugin.RegisterGnomeSounds(__instance);
		}
	}
	[HarmonyPatch(typeof(EnemyGnomeAnim), "Awake")]
	internal static class GnomeAnimationSoundRegistrationPatch
	{
		private static void Postfix(EnemyGnomeAnim __instance)
		{
			Plugin.RegisterGnomeAnimSounds(__instance);
		}
	}
	[HarmonyPatch(typeof(EnemyHeadGrabberAnim), "Awake")]
	internal static class HeadGrabberSoundRegistrationPatch
	{
		private static void Postfix(EnemyHeadGrabberAnim __instance)
		{
			Plugin.RegisterHeadGrabberSounds(__instance);
		}
	}
	[HarmonyPatch]
	internal static class ReplaceRegisteredMonsterSoundsPatch
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			MethodInfo[] methods = typeof(Sound).GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			foreach (MethodInfo method in methods)
			{
				if (method.Name != "Play")
				{
					continue;
				}
				ParameterInfo[] parameters = method.GetParameters();
				if (parameters.Length != 0)
				{
					Type firstArgument = parameters[0].ParameterType;
					if (firstArgument == typeof(Vector3) || firstArgument == typeof(Transform))
					{
						yield return method;
					}
				}
			}
		}

		private static bool Prefix(Sound __instance)
		{
			return !Plugin.TryReplaceMonsterSound(__instance);
		}
	}
	[HarmonyPatch(typeof(ValuableObject), "Start")]
	internal static class BirthdayMoneyTexturePatch
	{
		private static void Postfix(ValuableObject __instance)
		{
			Plugin.ApplyGiftTexture(__instance);
		}
	}
	[BepInPlugin("axel.cumpleaxelrepo", "Cumple Axel Repo", "1.0.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "axel.cumpleaxelrepo";

		public const string PluginName = "Cumple Axel Repo";

		public const string PluginVersion = "1.0.1";

		private const string BirthdayAudioFile = "CumpleAxelRepo_PartySound.mp3";

		private const string MoneyTextureFile = "CumpleAxelRepo_GiftMoney.png";

		internal static ManualLogSource Log = null;

		internal static string PluginPath = string.Empty;

		internal static AudioClip? BirthdayAudio;

		internal static Texture2D? GiftMoneyTexture;

		private static AudioClip? _fallbackHorn;

		private static readonly Dictionary<Sound, Transform> MonsterSounds = new Dictionary<Sound, Transform>();

		private Harmony? _harmony;

		private void Awake()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			PluginPath = ((BaseUnityPlugin)this).Info.Location;
			LoadMoneyTexture();
			_fallbackHorn = CreatePartyHorn();
			((MonoBehaviour)this).StartCoroutine(LoadBirthdayAudio());
			BirthdayContent.LoadAssets();
			_harmony = new Harmony("axel.cumpleaxelrepo");
			_harmony.PatchAll();
			Log.LogInfo((object)"Cumple Axel Repo 1.0.1 cargado: confeti, audio de cumpleaños, sonidos de monstruos y dinero-regalo.");
		}

		private void Update()
		{
			BirthdayContent.TickHats();
		}

		private IEnumerator LoadBirthdayAudio()
		{
			string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? Paths.PluginPath, "CumpleAxelRepo_PartySound.mp3");
			if (!File.Exists(path))
			{
				Log.LogWarning((object)"No se encontró CumpleAxelRepo_PartySound.mp3; se usará el matasuegras sintetizado.");
				yield break;
			}
			UnityWebRequest request = UnityWebRequestMultimedia.GetAudioClip(new Uri(path).AbsoluteUri, (AudioType)13);
			try
			{
				yield return request.SendWebRequest();
				if ((int)request.result != 1)
				{
					Log.LogWarning((object)("No se pudo cargar el MP3 (" + request.error + "); se usará el matasuegras sintetizado."));
					yield break;
				}
				BirthdayAudio = DownloadHandlerAudioClip.GetContent(request);
				Log.LogInfo((object)"Audio de cumpleaños cargado.");
			}
			finally
			{
				((IDisposable)request)?.Dispose();
			}
		}

		private void LoadMoneyTexture()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			string path = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location) ?? Paths.PluginPath, "CumpleAxelRepo_GiftMoney.png");
			if (!File.Exists(path))
			{
				Log.LogWarning((object)"No se encontró CumpleAxelRepo_GiftMoney.png; los objetos de dinero conservarán su textura original.");
				return;
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(val, File.ReadAllBytes(path)))
			{
				Object.Destroy((Object)(object)val);
				Log.LogWarning((object)"No se pudo decodificar la textura de dinero-regalo.");
				return;
			}
			((Object)val).name = "CumpleAxelRepo_GiftMoney";
			((Texture)val).wrapMode = (TextureWrapMode)0;
			((Texture)val).filterMode = (FilterMode)1;
			GiftMoneyTexture = val;
		}

		internal static void Celebrate(Vector3 position)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			SpawnConfetti(position);
			PlayBirthdayAudio(position, monsterSound: false);
			ShowBirthdayMessage();
		}

		internal static bool TryReplaceMonsterSound(Sound sound)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (sound == null || !MonsterSounds.TryGetValue(sound, out Transform value) || !Object.op_Implicit((Object)(object)value))
			{
				return false;
			}
			PlayBirthdayAudio(value.position, monsterSound: true);
			return true;
		}

		internal static void RegisterGnomeSounds(EnemyGnome gnome)
		{
			RegisterSound(gnome.soundHurt, ((Component)gnome).transform);
			RegisterSound(gnome.soundDeath, ((Component)gnome).transform);
			if (Object.op_Implicit((Object)(object)gnome.enemyGnomeAnim))
			{
				RegisterGnomeAnimSounds(gnome.enemyGnomeAnim);
			}
		}

		internal static void RegisterGnomeAnimSounds(EnemyGnomeAnim anim)
		{
			RegisterSound(anim.soundNotice, ((Component)anim).transform);
			RegisterSound(anim.soundPickaxeTell, ((Component)anim).transform);
		}

		internal static void RegisterHeadGrabberSounds(EnemyHeadGrabberAnim anim)
		{
			RegisterSound(anim.soundNotice, ((Component)anim).transform);
			RegisterSound(anim.soundNoticeGlobal, ((Component)anim).transform);
			RegisterSound(anim.soundAttackSwipe, ((Component)anim).transform);
		}

		private static void RegisterSound(Sound sound, Transform location)
		{
			if (sound != null && Object.op_Implicit((Object)(object)location))
			{
				MonsterSounds[sound] = location;
			}
		}

		internal static void ApplyGiftTexture(ValuableObject valuable)
		{
			if (!Object.op_Implicit((Object)(object)GiftMoneyTexture) || !Object.op_Implicit((Object)(object)valuable))
			{
				return;
			}
			bool flag = (Object)(object)((Component)valuable).GetComponentInChildren<MoneyValuable>(true) != (Object)null;
			string text = ((Object)((Component)valuable).gameObject).name.ToLowerInvariant();
			bool flag2 = text.Contains("money") || text.Contains("cash") || text.Contains("bill");
			if (!flag && !flag2)
			{
				return;
			}
			Renderer[] componentsInChildren = ((Component)valuable).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!(val is MeshRenderer) && !(val is SkinnedMeshRenderer))
				{
					continue;
				}
				Material[] materials = val.materials;
				foreach (Material val2 in materials)
				{
					if (val2.HasProperty("_MainTex"))
					{
						val2.SetTexture("_MainTex", (Texture)(object)GiftMoneyTexture);
					}
					if (val2.HasProperty("_BaseMap"))
					{
						val2.SetTexture("_BaseMap", (Texture)(object)GiftMoneyTexture);
					}
				}
			}
		}

		private static void SpawnConfetti(Vector3 position)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Expected O, but got Unknown
			GameObject val = new GameObject("CumpleAxelRepo_Confetti");
			val.transform.position = position + Vector3.up * 1.6f;
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			MainModule main = val2.main;
			((MainModule)(ref main)).duration = 1.4f;
			((MainModule)(ref main)).loop = false;
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(3.2f, 6f);
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(5f, 13f);
			((MainModule)(ref main)).startSize3D = true;
			((MainModule)(ref main)).startSizeX = new MinMaxCurve(0.12f, 0.24f);
			((MainModule)(ref main)).startSizeY = new MinMaxCurve(0.06f, 0.12f);
			((MainModule)(ref main)).startSizeZ = new MinMaxCurve(0.015f, 0.035f);
			((MainModule)(ref main)).startRotation3D = true;
			((MainModule)(ref main)).startRotationX = new MinMaxCurve(0f, 6.28f);
			((MainModule)(ref main)).startRotationY = new MinMaxCurve(0f, 6.28f);
			((MainModule)(ref main)).startRotationZ = new MinMaxCurve(0f, 6.28f);
			((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.9f);
			((MainModule)(ref main)).maxParticles = 900;
			Gradient val3 = new Gradient();
			val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[6]
			{
				new GradientColorKey(new Color(1f, 0.08f, 0.24f), 0f),
				new GradientColorKey(new Color(1f, 0.62f, 0.04f), 0.2f),
				new GradientColorKey(new Color(1f, 0.95f, 0.16f), 0.4f),
				new GradientColorKey(new Color(0.12f, 0.9f, 0.54f), 0.6f),
				new GradientColorKey(new Color(0.08f, 0.65f, 1f), 0.8f),
				new GradientColorKey(new Color(0.68f, 0.16f, 1f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(1f, 0f),
				new GradientAlphaKey(1f, 0.78f),
				new GradientAlphaKey(0f, 1f)
			});
			MinMaxGradient val4 = default(MinMaxGradient);
			((MinMaxGradient)(ref val4))..ctor(val3);
			((MinMaxGradient)(ref val4)).mode = (ParticleSystemGradientMode)4;
			MinMaxGradient startColor = val4;
			((MainModule)(ref main)).startColor = startColor;
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1]
			{
				new Burst(0f, (short)700)
			});
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
			((ShapeModule)(ref shape)).angle = 58f;
			((ShapeModule)(ref shape)).radius = 0.8f;
			ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
			component.renderMode = (ParticleSystemRenderMode)0;
			Shader val5 = Shader.Find("Particles/Standard Unlit");
			if ((Object)(object)val5 != (Object)null)
			{
				((Renderer)component).material = new Material(val5);
			}
			val2.Play();
			Object.Destroy((Object)(object)val, 8f);
		}

		private static void PlayBirthdayAudio(Vector3 position, bool monsterSound)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			AudioClip val = (((Object)(object)BirthdayAudio != (Object)null) ? BirthdayAudio : _fallbackHorn);
			if (Object.op_Implicit((Object)(object)val))
			{
				GameObject val2 = new GameObject(monsterSound ? "CumpleAxelRepo_MonsterBirthdaySound" : "CumpleAxelRepo_BirthdaySound");
				val2.transform.position = position;
				AudioSource val3 = val2.AddComponent<AudioSource>();
				val3.clip = val;
				val3.spatialBlend = (monsterSound ? 1f : 0f);
				val3.volume = (monsterSound ? 0.82f : 1f);
				val3.pitch = (monsterSound ? Random.Range(1.12f, 1.42f) : 1f);
				val3.Play();
				Object.Destroy((Object)(object)val2, val.length / val3.pitch + 0.4f);
			}
		}

		private static void ShowBirthdayMessage()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				SemiFunc.UIBigMessage("¡FELIZ CUMPLEAÑOS!", "", 24f, new Color(1f, 0.35f, 0.72f), Color.yellow);
			}
			catch (Exception ex)
			{
				Log.LogDebug((object)("No se pudo mostrar el mensaje de cumpleaños: " + ex.Message));
			}
		}

		private static AudioClip CreatePartyHorn()
		{
			int num = 37485;
			float[] array = new float[num];
			double[] array2 = new double[3] { 392.0, 493.88, 587.33 };
			for (int i = 0; i < num; i++)
			{
				double num2 = (double)i / 44100.0;
				double num3 = Math.Min(1.0, num2 * 35.0);
				double num4 = Math.Min(1.0, (0.8500000238418579 - num2) * 8.0);
				double num5 = 1.0 + 0.012 * Math.Sin(num2 * 2.0 * Math.PI * 6.0);
				double num6 = 0.0;
				double[] array3 = array2;
				foreach (double num7 in array3)
				{
					double num8 = num7 * num5;
					num6 += Math.Sin(Math.PI * 2.0 * num8 * num2);
					num6 += 0.28 * Math.Sin(Math.PI * 2.0 * num8 * 2.02 * num2);
					num6 += 0.12 * Math.Sin(Math.PI * 2.0 * num8 * 3.01 * num2);
				}
				array[i] = (float)(num6 / (double)array2.Length * 0.23 * num3 * num4);
			}
			AudioClip val = AudioClip.Create("CumpleAxelRepo_PartyHornFallback", num, 1, 44100, false);
			val.SetData(array, 0);
			return val;
		}

		private void OnDestroy()
		{
			Harmony? harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			_harmony = null;
			if (Object.op_Implicit((Object)(object)BirthdayAudio))
			{
				Object.Destroy((Object)(object)BirthdayAudio);
			}
			if (Object.op_Implicit((Object)(object)GiftMoneyTexture))
			{
				Object.Destroy((Object)(object)GiftMoneyTexture);
			}
			if (Object.op_Implicit((Object)(object)_fallbackHorn))
			{
				Object.Destroy((Object)(object)_fallbackHorn);
			}
			BirthdayContent.Unload();
			MonsterSounds.Clear();
			BirthdayAudio = null;
			GiftMoneyTexture = null;
			_fallbackHorn = null;
		}
	}
}