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("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("com.github.MiiMii1205.MyStingersDontSpoils")]
[assembly: AssemblyTitle("MyStingersDontSpoils")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.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;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace 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", "1.0.2")]
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 => "1.0.2";
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
{
private static readonly int Natureless = Animator.StringToHash("Natureless");
private static readonly int Tomb = Animator.StringToHash("Tomb");
private static readonly int Volcano = Animator.StringToHash("Volcano");
private static readonly int Height = Animator.StringToHash("Height");
private static readonly int Time1 = Animator.StringToHash("Time");
private static readonly int Desert = Animator.StringToHash("Desert");
[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_003b: Expected I4, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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_0053: Invalid comparison between Unknown and I4
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: 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:
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_001e: Expected I4, but got Unknown
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: 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_0071: 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_00a5: 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.playedCaldera;
}
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;
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_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Expected I4, but got Unknown
//IL_0039: Unknown result type (might be due to invalid IL or missing references)
//IL_003b: 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_0062: 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_0095: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_0109: Unknown result type (might be due to invalid IL or missing references)
//IL_017a: Unknown result type (might be due to invalid IL or missing references)
//IL_017c: 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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_0076: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Invalid comparison between Unknown and I4
//IL_00a7: 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_00ab: Invalid comparison between Unknown and I4
//IL_012b: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_018b: Unknown result type (might be due to invalid IL or missing references)
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_015b: Unknown result type (might be due to invalid IL or missing references)
Segment currentSegment = Singleton<MapHandler>.Instance.GetCurrentSegment();
BiomeType currentBiome = Singleton<MapHandler>.Instance.GetCurrentBiome();
switch ((int)currentSegment)
{
case 0:
if (CanPlaySegmentClimbStinger(currentSegment, ao, pos))
{
ao.playedBeach = true;
PlaySegmentClimbStinger(currentSegment, ao, ao.climbStingerBeach, 0.35f);
}
break;
case 1:
if (CanPlaySegmentClimbStinger(currentSegment, ao, pos))
{
ao.playedTropicsOrRoots = true;
PlaySegmentClimbStinger(currentSegment, ao, ((int)currentBiome == 1) ? ao.climbStingerTropics : ao.climbStingerRoots, 0.5f);
}
break;
case 2:
if (CanPlaySegmentClimbStinger(currentSegment, ao, pos))
{
ao.playedAlpineOrMesa = true;
PlaySegmentClimbStinger(currentSegment, ao, ((int)currentBiome == 2) ? ao.climbStingerAlpine : ao.climbStingerMesa, 0.4f);
}
break;
case 3:
if (CanPlaySegmentClimbStinger(currentSegment, ao, pos))
{
if (ao.volcanoObj == null)
{
ao.volcanoObj = GameObject.Find("VolcanoModel");
}
ao.playedCaldera = true;
PlaySegmentClimbStinger(currentSegment, ao, ao.climbStingerCaldera, 0.75f);
}
break;
case 4:
if (CanPlaySegmentClimbStinger((Segment)5, ao, pos))
{
ao.playedPeak = true;
PlaySegmentClimbStinger((Segment)5, ao, ao.climbStingerPeak, 1f);
}
else if (CanPlaySegmentClimbStinger(currentSegment, ao, pos))
{
ao.inKiln -= Time.deltaTime;
if (ao.inKiln < -2f)
{
ao.playedKiln = true;
PlaySegmentClimbStinger(currentSegment, ao, ao.climbStingerKiln, 0.6f);
}
}
else
{
ao.inKiln = 0f;
}
break;
case 5:
if (CanPlaySegmentClimbStinger(currentSegment, ao, pos))
{
ao.playedPeak = true;
PlaySegmentClimbStinger(currentSegment, 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_003b: Expected I4, but got Unknown
//IL_003e: Unknown result type (might be due to invalid IL or missing references)
//IL_0050: 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_0053: Invalid comparison between Unknown and I4
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0086: 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:
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_0008: Unknown result type (might be due to invalid IL or missing references)
if (!ao.volcano && pos.z < ao.calderaStingerZ)
{
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_00ab: Unknown result type (might be due to invalid IL or missing references)
//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: 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_016c: Unknown result type (might be due to invalid IL or missing references)
//IL_0434: 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_028d: Unknown result type (might be due to invalid IL or missing references)
//IL_0324: Unknown result type (might be due to invalid IL or missing references)
//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
__runOriginal = false;
Transform transform = ((Component)__instance.character.refs.head).transform;
if (__instance.character.inAirport)
{
return;
}
__instance.naturelessTerrain -= 6f * Time.deltaTime;
__instance.ambienceVolumes.SetBool(Natureless, __instance.naturelessTerrain > 0f);
__instance.ambienceVolumes.SetBool(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)))));
}
catch
{
Debug.LogError((object)"You probably need to bake the lightmap");
}
if (Object.op_Implicit((Object)(object)__instance.volcanoObj))
{
__instance.vulcanoT -= Time.deltaTime;
if ((double)__instance.vulcanoT <= 0.0)
{
__instance.volcano = false;
__instance.vulcanoT = 0f;
((Behaviour)__instance.reverb).enabled = true;
}
if ((double)__instance.vulcanoT > 0.0)
{
__instance.volcano = true;
((Behaviour)__instance.reverb).enabled = false;
}
if (Vector3.SqrMagnitude(__instance.volcanoObj.transform.position - transform.position) < 40000f)
{
__instance.vulcanoT = 10f;
}
__instance.ambienceVolumes.SetBool(Volcano, __instance.volcano);
}
if (Object.op_Implicit((Object)(object)__instance.ambienceVolumes) && Object.op_Implicit((Object)(object)__instance.dayNight))
{
__instance.ambienceVolumes.SetFloat(Height, transform.position.y);
__instance.ambienceVolumes.SetFloat(Time1, __instance.dayNight.timeOfDay);
if ((double)transform.position.z > (double)__instance.alpineStingerZ - 500.0 && !__instance.alpineSunTime1 && Singleton<MapHandler>.Instance.BiomeIsPresent((BiomeType)6))
{
__instance.ambienceVolumes.SetBool(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)
{
}
}
}