Decompiled source of MyStingersDontSpoils v2.2.0

plugins/com.github.MiiMii1205.MyStingersDontSpoils.dll

Decompiled 2 weeks ago
using System;
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.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MyStingersDontSpoils.Patches;
using Unity.Mathematics;
using UnityEngine;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("com.github.MiiMii1205.MyStingersDontSpoils")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.2.0.0")]
[assembly: AssemblyInformationalVersion("2.2.0")]
[assembly: AssemblyProduct("com.github.MiiMii1205.MyStingersDontSpoils")]
[assembly: AssemblyTitle("MyStingersDontSpoils")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.2.0.0")]
[module: UnverifiableCode]
[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 BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace MyStingersDontSpoils
{
	[BepInPlugin("com.github.MiiMii1205.MyStingersDontSpoils", "MyStingersDontSpoils", "2.2.0")]
	public class MyStingersDontSpoilsPlugin : BaseUnityPlugin
	{
		private static bool _isLoaded;

		public const string Id = "com.github.MiiMii1205.MyStingersDontSpoils";

		internal static ManualLogSource Log { get; private set; }

		public static AudioClip[] SunriseShoreStingers { get; private set; }

		public static AudioClip[] SunsetShoreStingers { get; private set; }

		public static AudioClip[] NightStingers { get; private set; }

		public static string Name => "MyStingersDontSpoils";

		public static string Version => "2.2.0";

		private void Awake()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			GameObject val = Resources.Load<GameObject>("Character");
			AmbienceAudio componentInChildren = val.GetComponentInChildren<AmbienceAudio>(true);
			SetStingers(componentInChildren);
			Harmony val2 = new Harmony("com.github.MiiMii1205.MyStingersDontSpoils");
			val2.PatchAll(typeof(AmbiencePatcher));
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
		}

		public static void SetStingers(AmbienceAudio ambienceAudio)
		{
			if (_isLoaded)
			{
				return;
			}
			AudioClip[] sunRiseStinger = ambienceAudio.sunRiseStinger;
			foreach (AudioClip val in sunRiseStinger)
			{
				string name = ((Object)val).name;
				if ((name == "Music Stinger Shore Sunrise 1" || name == "Music Stinger Shore Sunrise 2") ? true : false)
				{
					SunriseShoreStingers = CollectionExtensions.AddToArray<AudioClip>(SunriseShoreStingers, val);
				}
			}
			AudioClip[] sunSetStinger = ambienceAudio.sunSetStinger;
			foreach (AudioClip val2 in sunSetStinger)
			{
				string name = ((Object)val2).name;
				if ((name == "Music Stinger Shore Sunset 1" || name == "Music Stinger Shore Sunset 2") ? true : false)
				{
					SunsetShoreStingers = CollectionExtensions.AddToArray<AudioClip>(SunsetShoreStingers, val2);
				}
			}
			AudioClip[] nightStinger = ambienceAudio.nightStinger;
			foreach (AudioClip val3 in nightStinger)
			{
				string name = ((Object)val3).name;
				if ((name == "Music Stinger Night 1" || name == "Music Stinger Night 2") ? true : false)
				{
					NightStingers = CollectionExtensions.AddToArray<AudioClip>(NightStingers, val3);
				}
			}
			_isLoaded = true;
		}
	}
}
namespace MyStingersDontSpoils.Patches
{
	public static class AmbiencePatcher
	{
		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static void PlayNightStingers(AmbienceAudio ao, Vector3 pos)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			ao.t = 3;
			PlayStingerIfTimeEnabled(ao, pos, IEnumerableExtensions.RandomElement<AudioClip>((IEnumerable<AudioClip>)MyStingersDontSpoilsPlugin.NightStingers));
		}

		private static void PlaySunriseStingers(AmbienceAudio ao, Vector3 pos)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_003f: Expected I4, but got Unknown
			//IL_0042: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Invalid comparison between Unknown and I4
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Invalid comparison between Unknown and I4
			ao.t = 1;
			BiomeType currentBiome = Singleton<MapHandler>.Instance.GetCurrentBiome();
			Segment currentSegment = Singleton<MapHandler>.Instance.GetCurrentSegment();
			switch ((int)currentSegment)
			{
			case 0:
			case 3:
			case 4:
			case 5:
			case 6:
				PlayStingerIfTimeEnabled(ao, pos, IEnumerableExtensions.RandomElement<AudioClip>((IEnumerable<AudioClip>)MyStingersDontSpoilsPlugin.SunriseShoreStingers));
				break;
			case 1:
				PlayStingerIfTimeEnabled(ao, pos, ((int)currentBiome == 1) ? ao.tropicsSunrise : ao.rootsSunrise);
				if ((double)ao.priorityMusicTimer <= 0.0)
				{
					ao.tropicsSunTime2 = true;
				}
				break;
			case 2:
				PlayStingerIfTimeEnabled(ao, pos, ((int)currentBiome == 2) ? ao.alpineSunrise : ao.desertSunrise);
				if ((double)ao.priorityMusicTimer <= 0.0)
				{
					ao.alpineSunTime2 = true;
				}
				break;
			default:
				throw new ArgumentOutOfRangeException("GetCurrentSegment");
			}
		}

		private static bool CanPlaySegmentClimbStinger(Segment segment, AmbienceAudio ao, Vector3 pos)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected I4, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_00a9: 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)
			switch ((int)segment)
			{
			case 0:
				if (pos.z > ao.beachStingerZ)
				{
					return !ao.playedBeach;
				}
				return false;
			case 1:
				if (pos.z > ao.tropicsStingerZ)
				{
					return !ao.playedTropicsOrRoots;
				}
				return false;
			case 2:
				if (pos.z > ao.alpineStingerZ)
				{
					return !ao.playedAlpineOrMesa;
				}
				return false;
			case 3:
				if (pos.z > ao.calderaStingerZ)
				{
					return !ao.playedCalderaOrGloom;
				}
				return false;
			case 4:
				if (pos.y > ao.kilnStingerY)
				{
					return !ao.playedKiln;
				}
				return false;
			case 5:
				if (pos.z > ao.peaksTingerZ)
				{
					return !ao.playedPeak;
				}
				return false;
			case 6:
				if (pos.y > ao.nadirStingerY)
				{
					return !ao.playedNadir;
				}
				return false;
			default:
				throw new ArgumentOutOfRangeException("segment");
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static void PlaySegmentClimbStinger(Segment segment, AmbienceAudio ao, AudioClip clip, float volume)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			ao.mainMusic.clip = clip;
			ao.mainMusic.volume = volume;
			ao.mainMusic.Play();
			ao.priorityMusicTimer = 120f;
			Debug.Log((object)$"Played {segment} stinger");
		}

		private static void PlayClimbStingers(AmbienceAudio ao, Vector3 pos)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected I4, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0076: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Invalid comparison between Unknown and I4
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Invalid comparison between Unknown and I4
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Invalid comparison between Unknown and I4
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Invalid comparison between Unknown and I4
			Segment val = Singleton<MapHandler>.Instance.GetCurrentSegment();
			BiomeType currentBiome = Singleton<MapHandler>.Instance.GetCurrentBiome();
			if (Singleton<MapHandler>.Instance.inNadir && (int)val != 6)
			{
				val = (Segment)6;
			}
			switch ((int)val)
			{
			case 6:
				if (CanPlaySegmentClimbStinger(val, ao, pos))
				{
					ao.playedNadir = true;
					PlaySegmentClimbStinger(val, ao, ao.climbStingerNadir, 0.75f);
				}
				break;
			case 0:
				if (CanPlaySegmentClimbStinger(val, ao, pos))
				{
					ao.playedBeach = true;
					PlaySegmentClimbStinger(val, ao, ao.climbStingerBeach, 0.35f);
				}
				break;
			case 1:
				if (CanPlaySegmentClimbStinger(val, ao, pos))
				{
					ao.playedTropicsOrRoots = true;
					PlaySegmentClimbStinger(val, ao, ((int)currentBiome == 1) ? ao.climbStingerTropics : ao.climbStingerRoots, 0.5f);
				}
				break;
			case 2:
				if (CanPlaySegmentClimbStinger(val, ao, pos))
				{
					ao.playedAlpineOrMesa = true;
					PlaySegmentClimbStinger(val, ao, ((int)currentBiome == 2) ? ao.climbStingerAlpine : ao.climbStingerMesa, 0.4f);
				}
				break;
			case 3:
				if (!CanPlaySegmentClimbStinger(val, ao, pos))
				{
					break;
				}
				if (ao.volcano)
				{
					if (ao._volcanoObj == null)
					{
						ao._volcanoObj = GameObject.Find("VolcanoModel");
					}
				}
				ao.playedCalderaOrGloom = true;
				PlaySegmentClimbStinger(val, ao, ((int)currentBiome == 3) ? ao.climbStingerCaldera : ao.climbStingerGloom, 0.75f);
				break;
			case 4:
				if (CanPlaySegmentClimbStinger((Segment)5, ao, pos))
				{
					ao.playedPeak = true;
					PlaySegmentClimbStinger((Segment)5, ao, ao.climbStingerPeak, 1f);
				}
				else if (CanPlaySegmentClimbStinger(val, ao, pos))
				{
					ao.inKiln -= Time.deltaTime;
					if (ao.inKiln < -2f)
					{
						ao.playedKiln = true;
						PlaySegmentClimbStinger(val, ao, ((int)currentBiome == 3) ? ao.climbStingerKiln : ao.climbStingerCitadel, 0.6f);
					}
				}
				else
				{
					ao.inKiln = 0f;
				}
				break;
			case 5:
				if (CanPlaySegmentClimbStinger(val, ao, pos))
				{
					ao.playedPeak = true;
					PlaySegmentClimbStinger(val, ao, ao.climbStingerPeak, 1f);
				}
				break;
			default:
				throw new ArgumentOutOfRangeException("currentSegment");
			}
		}

		private static void PlaySunsetStingers(AmbienceAudio ao, Vector3 pos)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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_003f: Expected I4, but got Unknown
			//IL_0042: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Invalid comparison between Unknown and I4
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Invalid comparison between Unknown and I4
			ao.t = 2;
			BiomeType currentBiome = Singleton<MapHandler>.Instance.GetCurrentBiome();
			Segment currentSegment = Singleton<MapHandler>.Instance.GetCurrentSegment();
			switch ((int)currentSegment)
			{
			case 0:
			case 3:
			case 4:
			case 5:
			case 6:
				PlayStingerIfTimeEnabled(ao, pos, IEnumerableExtensions.RandomElement<AudioClip>((IEnumerable<AudioClip>)MyStingersDontSpoilsPlugin.SunsetShoreStingers));
				break;
			case 1:
				PlayStingerIfTimeEnabled(ao, pos, ((int)currentBiome == 1) ? ao.tropicsSunset : ao.rootsSunset);
				if ((double)ao.priorityMusicTimer <= 0.0)
				{
					ao.tropicsSunTime1 = true;
				}
				break;
			case 2:
				PlayStingerIfTimeEnabled(ao, pos, ((int)currentBiome == 2) ? ao.alpineSunset : ao.desertSunset);
				if ((double)ao.priorityMusicTimer <= 0.0)
				{
					ao.alpineSunTime1 = true;
				}
				break;
			default:
				throw new ArgumentOutOfRangeException("GetCurrentSegment");
			}
		}

		[MethodImpl(MethodImplOptions.AggressiveInlining)]
		private static void PlayStingerIfTimeEnabled(AmbienceAudio ao, Vector3 pos, AudioClip? clip = null)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_000d: Invalid comparison between Unknown and I4
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Segment currentSegment = Singleton<MapHandler>.Instance.GetCurrentSegment();
			if ((int)currentSegment >= 4)
			{
				return;
			}
			if (ao.volcano)
			{
				if (pos.z < ao.calderaStingerZ)
				{
					if (Object.op_Implicit((Object)(object)clip))
					{
						ao.stingerSource.clip = clip;
					}
					ao.stingerSource.Play();
				}
			}
			else
			{
				if (Object.op_Implicit((Object)(object)clip))
				{
					ao.stingerSource.clip = clip;
				}
				ao.stingerSource.Play();
			}
		}

		[HarmonyPatch(typeof(AmbienceAudio), "Update")]
		[HarmonyPrefix]
		public static void AmbianceUpdatePatch(AmbienceAudio __instance, ref bool __runOriginal)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			__runOriginal = false;
			Transform transform = __instance.character.refs.head.transform;
			if (__instance.character.inAirport)
			{
				return;
			}
			__instance.naturelessTerrain -= 6f * Time.deltaTime;
			__instance.ambienceVolumes.SetBool(__instance.ANIM_NATURELESS, __instance.naturelessTerrain > 0f);
			__instance.ambienceVolumes.SetBool(__instance.ANIM_TOMB, __instance.inTomb);
			try
			{
				__instance.reverb.room = (int)math.remap(0f, 1f, -4000f, -100f, math.saturate(1f - math.remap(0f, 0.3f, 0f, 1f, math.saturate(LightVolume.Instance().SamplePositionAlpha(transform.position, false)))));
			}
			catch
			{
				Debug.LogError((object)"You probably need to bake the lightmap");
			}
			if (Object.op_Implicit((Object)(object)__instance._volcanoObj))
			{
				__instance._volcanoTime -= Time.deltaTime;
				if ((double)__instance._volcanoTime <= 0.0)
				{
					__instance.volcano = false;
					__instance._volcanoTime = 0f;
					((Behaviour)__instance.reverb).enabled = true;
				}
				if ((double)__instance._volcanoTime > 0.0)
				{
					__instance.volcano = true;
					((Behaviour)__instance.reverb).enabled = false;
				}
				if (Vector3.SqrMagnitude(__instance._volcanoObj.transform.position - transform.position) < 40000f)
				{
					__instance._volcanoTime = 10f;
				}
				__instance.ambienceVolumes.SetBool(__instance.ANIM_VOLCANO, __instance.volcano);
			}
			if (Object.op_Implicit((Object)(object)Singleton<MapHandler>.Instance) && Singleton<MapHandler>.Instance.inNadir)
			{
				__instance.ambienceVolumes.SetBool(__instance.ANIM_NATURELESS, true);
				__instance.ambienceVolumes.SetBool(__instance.ANIM_CITADEL, true);
			}
			else
			{
				__instance.ambienceVolumes.SetBool(__instance.ANIM_CITADEL, false);
				if (Object.op_Implicit((Object)(object)__instance._citadelAmbience))
				{
					if (Vector3.SqrMagnitude(((Component)__instance._citadelAmbience).transform.position - transform.position) < 48400f)
					{
						__instance.ambienceVolumes.SetBool(__instance.ANIM_NATURELESS, true);
						__instance.ambienceVolumes.SetBool(__instance.ANIM_CITADEL, true);
					}
					else
					{
						__instance.ambienceVolumes.SetBool(__instance.ANIM_CITADEL, false);
					}
				}
			}
			if (Object.op_Implicit((Object)(object)__instance.ambienceVolumes) && Object.op_Implicit((Object)(object)__instance.dayNight))
			{
				__instance.ambienceVolumes.SetFloat(__instance.ANIM_HEIGHT, transform.position.y);
				__instance.ambienceVolumes.SetFloat(__instance.ANIM_TIME, __instance.dayNight.timeOfDay);
				if ((double)transform.position.z > (double)__instance.alpineStingerZ - 500.0 && !__instance.alpineSunTime1 && Singleton<MapHandler>.Instance.BiomeIsPresent((BiomeType)6))
				{
					__instance.ambienceVolumes.SetBool(__instance.ANIM_DESERT, true);
				}
				if (!__instance.inTomb)
				{
					float timeOfDay = __instance.dayNight.timeOfDay;
					if (timeOfDay > 5.5f)
					{
						if (!(timeOfDay < 6.5f))
						{
							if (timeOfDay > 19.5f)
							{
								if (!(timeOfDay < 20f))
								{
									if (timeOfDay > 21.2f && timeOfDay < 26f && __instance.t != 3)
									{
										PlayNightStingers(__instance, transform.position);
									}
								}
								else if (__instance.t != 2)
								{
									PlaySunsetStingers(__instance, transform.position);
								}
							}
						}
						else if (__instance.t != 1)
						{
							PlaySunriseStingers(__instance, transform.position);
						}
					}
				}
			}
			__instance.priorityMusicTimer -= Time.deltaTime;
			CharacterData data = __instance.character.data;
			if (data != null && data.sinceDead > 0.5f && !Character.localCharacter.warping && !data.passedOut && data != null && !data.dead && !data.fullyPassedOut && !__instance.inTomb)
			{
				PlayClimbStingers(__instance, transform.position);
			}
			else
			{
				__instance.stingerSource.volume = Mathf.Lerp(__instance.stingerSource.volume, 0f, 0.05f);
				__instance.mainMusic.volume = Mathf.Lerp(__instance.mainMusic.volume, 0f, 0.05f);
			}
			if (__instance.priorityMusicTimer > 0f)
			{
				__instance.stingerSource.volume = Mathf.Lerp(__instance.stingerSource.volume, 0f, 0.05f);
			}
			else
			{
				__instance.stingerSource.volume = Mathf.Lerp(__instance.stingerSource.volume, 0.35f, 0.05f);
				__instance.priorityMusicTimer = 0f;
			}
			if (__instance.inTomb)
			{
				if (transform.position.z > 700f && !__instance.playedTomb)
				{
					__instance.playedTomb = true;
					__instance.mainMusic.clip = __instance.tombClimb;
					__instance.mainMusic.Play();
				}
				__instance.mainMusic.volume = 0.5f;
			}
			if (transform.position.y > 450f)
			{
				__instance.inTomb = false;
			}
		}
	}
}
namespace MyStingersDontSpoils.Data
{
	public enum StingerStates
	{
		NONE,
		SUNRISE,
		SUNSET,
		NIGHT
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}