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 System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
using UnityEngine;
[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: IgnoresAccessChecksTo("AmazingAssets.TerrainToMesh")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("ClientNetworkTransform")]
[assembly: IgnoresAccessChecksTo("com.olegknyazev.softmask")]
[assembly: IgnoresAccessChecksTo("DissonanceVoip")]
[assembly: IgnoresAccessChecksTo("EasyTextEffects")]
[assembly: IgnoresAccessChecksTo("Facepunch Transport for Netcode for GameObjects")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging")]
[assembly: IgnoresAccessChecksTo("Unity.Animation.Rigging.DocCodeExamples")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Jobs")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.Common")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.MetricTypes")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStats")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Component")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsMonitor.Implementation")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetStatsReporting")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkProfiler.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Multiplayer.Tools.NetworkSolutionInterface")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Components")]
[assembly: IgnoresAccessChecksTo("Unity.Netcode.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Networking.Transport")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Csg")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.KdTree")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Poly2Tri")]
[assembly: IgnoresAccessChecksTo("Unity.ProBuilder.Stl")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Config.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.HighDefinition.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Authentication")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Analytics")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Configuration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Device")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Environments.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Internal")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Networking")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Registration")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Scheduler")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Telemetry")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Core.Threading")]
[assembly: IgnoresAccessChecksTo("Unity.Services.QoS")]
[assembly: IgnoresAccessChecksTo("Unity.Services.Relay")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualEffectGraph.Runtime")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: AssemblyCompany("NoteBoxz.TreasureSoundTrack")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("LCTreatureTrackerOST")]
[assembly: AssemblyTitle("NoteBoxz.TreasureSoundTrack")]
[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 LCTreatureTrackerOST
{
[BepInPlugin("NoteBoxz.TreasureSoundTrack", "LCTreatureTrackerOST", "1.0.2")]
public class LCTreatureTrackerOST : BaseUnityPlugin
{
public static string tempDir = string.Empty;
public static LCTreatureTrackerOST Instance { get; private set; } = null;
internal static ManualLogSource Logger { get; private set; } = null;
internal static Harmony? Harmony { get; set; }
public static ConfigEntry<float> MasterVolume { get; private set; } = null;
public static ConfigEntry<float> IndoorVolume { get; private set; } = null;
public static ConfigEntry<float> OutdoorVolume { get; private set; } = null;
public static ConfigEntry<float> SpaceVolume { get; private set; } = null;
public static ConfigEntry<float> CrouchFade { get; private set; } = null;
public static ConfigEntry<float> DarknessFade { get; private set; } = null;
public static ConfigEntry<bool> FadeTransition { get; private set; } = null;
public static ConfigEntry<float> FadeTransitionDuration { get; private set; } = null;
public static ConfigEntry<bool> ApplyIndoorReverb { get; private set; } = null;
public static ConfigEntry<bool> PlayOutdoorTracks { get; private set; } = null;
public static ConfigEntry<bool> PlayIndoorTracks { get; private set; } = null;
public static ConfigEntry<bool> PlaySpaceTracks { get; private set; } = null;
public static ConfigEntry<bool> PlayWeatherTracks { get; private set; } = null;
public static ConfigEntry<bool> PlayModdedTracks { get; private set; } = null;
public static ConfigEntry<bool> PlayChallengeTracks { get; private set; } = null;
public static ConfigEntry<bool> ReplaceDropshipMusic { get; private set; } = null;
public static ConfigEntry<bool> PlayDeathMusic { get; private set; } = null;
public static ConfigEntry<bool> PlayGameoverMusic { get; private set; } = null;
public static ConfigEntry<bool> LastDayPitchShift { get; private set; } = null;
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Instance = this;
Patch();
BindConfigs();
Logger.LogInfo((object)"NoteBoxz.TreasureSoundTrack v1.0.2 has loaded!");
}
private void BindConfigs()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_005a: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_009a: Unknown result type (might be due to invalid IL or missing references)
//IL_00a0: Expected O, but got Unknown
//IL_00da: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Expected O, but got Unknown
ConfigDescription val = new ConfigDescription("This is the master volume for the OST. 0.0 is silent, 1.0 is full volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>());
MasterVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Master Volume", 1f, val);
val = new ConfigDescription("This is the volume for indoor tracks. 0.0 is silent, 1.0 is full volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>());
IndoorVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Indoor Volume", 0.25f, val);
val = new ConfigDescription("This is the volume for outdoor tracks. 0.0 is silent, 1.0 is full volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>());
OutdoorVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Outdoor Volume", 0.35f, val);
val = new ConfigDescription("This is the volume for lobby tracks. 0.0 is silent, 1.0 is full volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>());
SpaceVolume = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Lobby Volume", 0.25f, val);
CrouchFade = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Crouch Fade", 0.5f, "How quiter the music gets when the player is crouching, multiplied by volume, set to 1.0 to disable");
DarknessFade = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Darkness Fade", 0.5f, "How quiter the music gets when the player is in darkness, multiplied by volume, set to 1.0 to disable");
FadeTransition = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Fade Transition", true, "If true, the music will fade in and out when changing tracks. If false, it will change instantly.");
FadeTransitionDuration = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Fade Transition Duration", 1f, "The duration of the fade transition in seconds. Only applies if FadeTransition is true.");
ApplyIndoorReverb = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Apply Indoor Reverb", true, "If true, a reverb effect will be applied to indoor tracks.");
PlayOutdoorTracks = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Play Outdoor Tracks", true, "If true, outdoor tracks will be played when the player is outdoors.");
PlayIndoorTracks = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Play Indoor Tracks", true, "If true, indoor tracks will be played when the player is indoors.");
PlaySpaceTracks = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Play Lobby Tracks", true, "If true, lobby tracks will be played when the player is in lobby.");
PlayWeatherTracks = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Play Weather Tracks", true, "If true, certain tracks will override the outdoor/indoor trackes depeding on the weather.");
PlayModdedTracks = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Play Modded Tracks", true, "If true, spesfic tracks for modded moons will play");
PlayChallengeTracks = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Play Challenge Tracks", true, "If true, a spesfic challenge moon track will be played when the player is on a challenge moon.");
ReplaceDropshipMusic = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Replace Dropship Music", true, "If true, the dropship music will be replaced with tracks.");
PlayDeathMusic = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Play Death Music", true, "If true, the 'too bad!' track will be played when the player dies.");
PlayGameoverMusic = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Play Gameover Music", true, "If true, a modded track will be played when the game is over.");
LastDayPitchShift = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Last Day Pitch-Shift", true, "if true, on the last day before selling, if the player has not beaten the qouta, the music change pitch depending on if the qouta will be beaten");
}
internal static void Patch()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
//IL_0018: Expected O, but got Unknown
if (Harmony == null)
{
Harmony = new Harmony("NoteBoxz.TreasureSoundTrack");
}
Logger.LogDebug((object)"Patching...");
Harmony.PatchAll();
Logger.LogDebug((object)"Finished patching!");
}
internal static void Unpatch()
{
Logger.LogDebug((object)"Unpatching...");
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
Logger.LogDebug((object)"Finished unpatching!");
}
private void OnApplicationQuit()
{
if (Directory.Exists(tempDir))
{
try
{
Directory.Delete(tempDir, recursive: true);
Logger.LogInfo((object)"Temporary directory cleaned up on application quit.");
}
catch (Exception arg)
{
Logger.LogError((object)$"Failed to clean up temporary directory on quit: {arg}");
}
}
}
}
public enum Area
{
None,
InSpace,
Outdoors,
Indoors
}
public class MusicManager : MonoBehaviour
{
[CompilerGenerated]
private sealed class <FadeTrackTransition>d__42 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public AudioClip newTrack;
public bool loops;
public MusicManager <>4__this;
private float <transitionDuration>5__1;
private float <startVolume>5__2;
private float <timer>5__3;
private float? <time>5__4;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FadeTrackTransition>d__42(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<transitionDuration>5__1 = LCTreatureTrackerOST.FadeTransitionDuration.Value;
<startVolume>5__2 = <>4__this.audioSource.volume;
<timer>5__3 = 0f;
goto IL_00bd;
case 1:
<>1__state = -1;
goto IL_00bd;
case 2:
{
<>1__state = -1;
break;
}
IL_00bd:
if (<timer>5__3 < <transitionDuration>5__1)
{
<timer>5__3 += Time.deltaTime;
<>4__this.audioSource.volume = Mathf.Lerp(<startVolume>5__2, 0f, <timer>5__3 / <transitionDuration>5__1);
<>2__current = null;
<>1__state = 1;
return true;
}
if ((Object)(object)newTrack == (Object)null)
{
<>4__this.audioSource.Stop();
<>4__this.fadeCoroutine = null;
return false;
}
<time>5__4 = null;
if (<>4__this.LastTrackPosition.HasValue && (Object)(object)<>4__this.LastTrackPosition.Value.Item1 == (Object)(object)newTrack)
{
<time>5__4 = <>4__this.LastTrackPosition.Value.Item2;
}
<>4__this.LastTrackPosition = (<>4__this.CurrentTrack, <>4__this.audioSource.time);
<>4__this.CurrentTrack = newTrack;
<>4__this.audioSource.clip = <>4__this.CurrentTrack;
<>4__this.audioSource.volume = 0f;
<>4__this.audioSource.Play();
<>4__this.audioSource.loop = loops;
if (<time>5__4.HasValue)
{
<>4__this.audioSource.time = <time>5__4.Value;
}
<>4__this.Logger.LogMessage((object)("- Now playing: " + ((Object)<>4__this.CurrentTrack).name));
<timer>5__3 = 0f;
break;
}
if (<timer>5__3 < <transitionDuration>5__1)
{
<timer>5__3 += Time.deltaTime;
<>4__this.audioSource.volume = Mathf.Lerp(0f, <startVolume>5__2, <timer>5__3 / <transitionDuration>5__1);
<>2__current = null;
<>1__state = 2;
return true;
}
<>4__this.audioSource.volume = <startVolume>5__2;
<>4__this.fadeCoroutine = null;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <LoadAssetBundleAsync>d__39 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public MusicManager <>4__this;
private string <assemblyLocation>5__1;
private string <bundlePath>5__2;
private AssetBundleCreateRequest <request>5__3;
private AssetBundle <assetBundle>5__4;
private AudioClip[] <>s__5;
private int <>s__6;
private AudioClip <clip>5__7;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <LoadAssetBundleAsync>d__39(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<assemblyLocation>5__1 = null;
<bundlePath>5__2 = null;
<request>5__3 = null;
<assetBundle>5__4 = null;
<>s__5 = null;
<clip>5__7 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>4__this.Logger.LogInfo((object)"Loading songs...");
<assemblyLocation>5__1 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
if (<assemblyLocation>5__1 == null)
{
throw new InvalidOperationException("Unable to determine assembly location.");
}
<bundlePath>5__2 = Path.Combine(<assemblyLocation>5__1, "tttrackerost");
<request>5__3 = AssetBundle.LoadFromFileAsync(<bundlePath>5__2);
<>2__current = <request>5__3;
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<assetBundle>5__4 = <request>5__3.assetBundle;
if ((Object)(object)<assetBundle>5__4 == (Object)null)
{
throw new InvalidOperationException("Failed to load AssetBundle.");
}
Songs.Clear();
<>s__5 = <assetBundle>5__4.LoadAllAssets<AudioClip>();
for (<>s__6 = 0; <>s__6 < <>s__5.Length; <>s__6++)
{
<clip>5__7 = <>s__5[<>s__6];
Songs.Add(<clip>5__7);
<>4__this.Logger.LogDebug((object)("Loaded song: " + ((Object)<clip>5__7).name));
<clip>5__7 = null;
}
<>s__5 = null;
<>4__this.Logger.LogInfo((object)$"Loaded {Songs.Count} songs from AssetBundle.");
BundleLoaded = true;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
public static MusicManager Instance = null;
public static HashSet<AudioClip> Songs = new HashSet<AudioClip>();
public (AudioClip, float)? LastTrackPosition = null;
public static Dictionary<string, string> SpaceMoonMap = new Dictionary<string, string>
{
{ "experimentation", "1.05 Episode 1" },
{ "assurance", "1.05 Episode 1" },
{ "vow", "1.05 Episode 1" },
{ "offense", "1.27 Episode 2" },
{ "march", "1.27 Episode 2" },
{ "adamance", "1.27 Episode 2" },
{ "rend", "1.37 Episode 3" },
{ "dine", "1.37 Episode 3" },
{ "titan", "1.37 Episode 3" },
{ "artifice", "1.53 Bonus Episode" },
{ "embrion", "1.53 Bonus Episode" },
{ "Gordion", "none" },
{ "Sect-0", "none" }
};
public static Dictionary<int, float> MoonPrices = new Dictionary<int, float>();
public static Dictionary<string, string> OutdoorPlanetMap = new Dictionary<string, string>
{
{ "experimentation", "1.06 Plucky Pass Beginnings" },
{ "assurance", "1.07 Walleye Tumble Temple" },
{ "vow", "1.15 Piranha Creeper Cove" },
{ "offense", "1.07 Walleye Tumble Temple" },
{ "march", "1.16 Briny Bowl Swimming Hole" },
{ "adamance", "1.06 Plucky Pass Beginnings" },
{ "rend", "1.39 Biddybud Snow Stroll" },
{ "dine", "1.39 Biddybud Snow Stroll" },
{ "titan", "1.20 Blizzard on the Star Express" },
{ "embrion", "1.09 Spinwheel Library" },
{ "artifice", "1.58 Secret of the Inverted Pyramid" },
{ "gordion", "1.08 Touchstone Trouble" },
{ "Bozoros", "1.42 Razzle-Dazzle Slider" },
{ "Zeranos", "1.61 Uptown, Downtown." },
{ "Sect-0", "1.34 Windup Stairs" }
};
public static Dictionary<int, string> IndoorInteriorMap = new Dictionary<int, string>
{
{ 0, "1.32 Sliding Slab Shuffle" },
{ 1, "1.19 Bizarre Doors of Boo Mansion" },
{ 2, "1.32 Sliding Slab Shuffle" },
{ 3, "1.32 Sliding Slab Shuffle" },
{ 4, "1.10 Mine Cart Tunnel" }
};
private bool QuedTrackUpdate = false;
private Coroutine? fadeCoroutine = null;
private float qoutaCheckInterval = 1f;
private bool lastIndoors = false;
private int lastHour = 0;
public (GameObject, float)? VolumeQuiter = null;
public Dictionary<GameObject, Func<bool>> MuteSpaceConditions = new Dictionary<GameObject, Func<bool>>();
public Dictionary<GameObject, Func<bool>> MuteOutsideInsideConditions = new Dictionary<GameObject, Func<bool>>();
public bool LightOn = true;
public AudioSource audioSource { get; private set; } = null;
public AudioReverbFilter audioReverbFilter { get; private set; } = null;
private ManualLogSource Logger => LCTreatureTrackerOST.Logger;
public static bool BundleLoaded { get; private set; } = false;
public static Area CurrentArea { get; set; } = Area.None;
public AudioClip CurrentTrack { get; private set; } = null;
private void Awake()
{
Instance = this;
audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
audioSource.playOnAwake = false;
audioSource.loop = true;
audioReverbFilter = ((Component)this).gameObject.AddComponent<AudioReverbFilter>();
audioReverbFilter.reverbPreset = (AudioReverbPreset)0;
((MonoBehaviour)this).StartCoroutine(LoadAssetBundleAsync());
UpdateTracks();
}
[IteratorStateMachine(typeof(<LoadAssetBundleAsync>d__39))]
private IEnumerator LoadAssetBundleAsync()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <LoadAssetBundleAsync>d__39(0)
{
<>4__this = this
};
}
public void LateUpdate()
{
UpdateCurArea();
if (!BundleLoaded || CurrentArea == Area.None)
{
if (audioSource.isPlaying)
{
audioSource.Stop();
}
audioSource.volume = 0f;
return;
}
if (QuedTrackUpdate)
{
UpdateTracks();
QuedTrackUpdate = false;
}
if (StartOfRound.Instance.localPlayerController.isInsideFactory != lastIndoors)
{
lastIndoors = StartOfRound.Instance.localPlayerController.isInsideFactory;
UpdateTracks();
}
if (TimeOfDay.Instance.hour != lastHour)
{
lastHour = TimeOfDay.Instance.hour;
UpdateTracks();
}
audioReverbFilter.reverbPreset = (AudioReverbPreset)((CurrentArea == Area.Indoors && LCTreatureTrackerOST.ApplyIndoorReverb.Value) ? 3 : 0);
if (fadeCoroutine == null)
{
UpdateVolume();
}
if (LCTreatureTrackerOST.LastDayPitchShift.Value)
{
UpdatePitch();
}
else
{
audioSource.pitch = 1f;
}
}
public void SetTrack(string trackName, bool Loops = true)
{
if (trackName == "none")
{
if (LCTreatureTrackerOST.FadeTransition.Value && audioSource.isPlaying)
{
if (fadeCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(fadeCoroutine);
fadeCoroutine = null;
}
fadeCoroutine = ((MonoBehaviour)this).StartCoroutine(FadeTrackTransition(null, Loops));
}
else
{
audioSource.Stop();
}
LastTrackPosition = null;
Logger.LogMessage((object)"- Stopped playing track.");
return;
}
AudioClip song = GetSong(trackName);
if ((Object)(object)song == (Object)null)
{
Logger.LogError((object)("Track '" + trackName + "' not found."));
}
else
{
if (!((Object)(object)CurrentTrack != (Object)(object)song))
{
return;
}
if (LCTreatureTrackerOST.FadeTransition.Value && audioSource.isPlaying)
{
if (fadeCoroutine != null)
{
((MonoBehaviour)this).StopCoroutine(fadeCoroutine);
fadeCoroutine = null;
}
fadeCoroutine = ((MonoBehaviour)this).StartCoroutine(FadeTrackTransition(song, Loops));
return;
}
float? num = null;
if (LastTrackPosition.HasValue && (Object)(object)LastTrackPosition.Value.Item1 == (Object)(object)song)
{
num = LastTrackPosition.Value.Item2;
}
LastTrackPosition = (CurrentTrack, audioSource.time);
CurrentTrack = song;
audioSource.clip = CurrentTrack;
audioSource.Play();
audioSource.loop = Loops;
if (num.HasValue)
{
audioSource.time = num.Value;
}
Logger.LogMessage((object)("- Now playing: " + ((Object)CurrentTrack).name));
}
}
[IteratorStateMachine(typeof(<FadeTrackTransition>d__42))]
private IEnumerator FadeTrackTransition(AudioClip newTrack, bool loops)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FadeTrackTransition>d__42(0)
{
<>4__this = this,
newTrack = newTrack,
loops = loops
};
}
public void UpdateTracks()
{
if (!BundleLoaded || CurrentArea == Area.None)
{
QuedTrackUpdate = true;
Logger.LogWarning((object)"MusicManager: Bundle not loaded or area is None, won't update tracks.");
return;
}
if (StartOfRound.Instance.localPlayerController.isPlayerDead)
{
Logger.LogWarning((object)"Player is dead, won't update tracks.");
return;
}
UpdateCurArea();
Logger.LogInfo((object)$"Updating tracks... {CurrentArea}");
string planetName = StartOfRound.Instance.currentLevel.PlanetName.ToLower();
int currentDungeonType = RoundManager.Instance.currentDungeonType;
if (StartOfRound.Instance.isChallengeFile && LCTreatureTrackerOST.PlayChallengeTracks.Value)
{
SetTrack("1.64 Mummy-Me Maze Forever");
return;
}
switch (CurrentArea)
{
case Area.InSpace:
HandleSpaceMusic(planetName, currentDungeonType);
break;
case Area.Outdoors:
HandleOutdoorMusic(planetName);
break;
case Area.Indoors:
HandleIndoorMusic(currentDungeonType);
break;
default:
audioSource.Stop();
break;
}
}
private void HandleSpaceMusic(string planetName, int levelId)
{
if (StartOfRound.Instance.gameStats.daysSpent == 0)
{
SetTrack("1.02 Practice Room");
return;
}
foreach (KeyValuePair<string, string> item in SpaceMoonMap)
{
if (planetName.Contains(item.Key))
{
SetTrack(item.Value);
return;
}
}
foreach (KeyValuePair<int, float> moonPrice in MoonPrices)
{
if (levelId == moonPrice.Key)
{
if (moonPrice.Value <= 0f)
{
SetTrack("1.05 Episode 1");
}
else if (moonPrice.Value < 1000f)
{
SetTrack("1.27 Episode 2");
}
else
{
SetTrack("1.37 Episode 3");
}
return;
}
}
SetTrack("none");
}
private void HandleOutdoorMusic(string planetName)
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Invalid comparison between Unknown and I4
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Invalid comparison between Unknown and I4
if (StartOfRound.Instance.gameStats.daysSpent == 0)
{
bool flag = (int)TimeOfDay.Instance.currentLevelWeather == 5;
SetTrack(flag ? "2.08 Captain Toad's Fiery Finale" : "1.03 Prologue");
return;
}
if ((int)TimeOfDay.Instance.currentLevelWeather == 5 && LCTreatureTrackerOST.PlayWeatherTracks.Value)
{
SetTrack("1.12 Spinwheel Bullet Bill Base");
return;
}
if (planetName.Contains("march") && TimeOfDay.Instance.hour >= 14)
{
SetTrack("1.17 Briny Bowl Swimming Hole (Underwater)");
return;
}
if (planetName.Contains("artifice") && TimeOfDay.Instance.hour >= 14)
{
SetTrack("1.59 Secret of the Inverted Pyramid (Night)");
return;
}
foreach (KeyValuePair<string, string> item in OutdoorPlanetMap)
{
if (planetName.Contains(item.Key))
{
SetTrack(item.Value);
return;
}
}
SetTrack(LCTreatureTrackerOST.PlayModdedTracks.Value ? "2.06 Captain Toad Goes Forth" : "none");
}
private void HandleIndoorMusic(int levelId)
{
string text = StartOfRound.Instance.currentLevel.PlanetName.ToLower();
if (LCTreatureTrackerOST.PlayModdedTracks.Value)
{
if (text.Contains("bozoros"))
{
SetTrack("1.43 Razzle-Dazzle Slider (Inside)");
return;
}
if (text.Contains("zeranos"))
{
SetTrack("1.62 Uptown, Downtown (Underground)");
return;
}
if (text.Contains("sect-0"))
{
SetTrack("2.07 Captain Toad Plays Peek-a-Boo");
return;
}
}
foreach (KeyValuePair<int, string> item in IndoorInteriorMap)
{
if (item.Key == levelId)
{
SetTrack(item.Value);
return;
}
}
SetTrack(LCTreatureTrackerOST.PlayModdedTracks.Value ? "1.56 Shadow-Play Alley" : "none");
}
private void UpdateCurArea()
{
if ((Object)(object)StartOfRound.Instance == (Object)null || (Object)(object)StartOfRound.Instance.localPlayerController == (Object)null)
{
CurrentArea = Area.None;
}
else if (StartOfRound.Instance.inShipPhase)
{
LightOn = true;
CurrentArea = Area.InSpace;
if (!LCTreatureTrackerOST.PlaySpaceTracks.Value)
{
CurrentArea = Area.None;
}
}
else if (StartOfRound.Instance.localPlayerController.isInsideFactory)
{
CurrentArea = Area.Indoors;
if (!LCTreatureTrackerOST.PlayIndoorTracks.Value)
{
CurrentArea = Area.None;
}
}
else
{
CurrentArea = Area.Outdoors;
if (!LCTreatureTrackerOST.PlayOutdoorTracks.Value)
{
CurrentArea = Area.None;
}
}
}
private void UpdatePitch()
{
if (StartOfRound.Instance.localPlayerController.isPlayerDead)
{
audioSource.pitch = 1f;
}
else if (TimeOfDay.Instance.daysUntilDeadline == 0)
{
qoutaCheckInterval -= Time.deltaTime;
if (qoutaCheckInterval <= 0f)
{
qoutaCheckInterval = 1f;
audioSource.pitch = (CouldBeatQouta() ? 1f : 0.8f);
}
}
else if (TimeOfDay.Instance.daysUntilDeadline == 1 && CurrentArea != Area.InSpace)
{
qoutaCheckInterval -= Time.deltaTime;
if (qoutaCheckInterval <= 0f)
{
qoutaCheckInterval = 1f;
bool flag = CouldBeatQouta();
audioSource.pitch = Mathf.Lerp(flag ? 1f : 1.25f, flag ? 1f : 0.8f, TimeOfDay.Instance.normalizedTimeOfDay);
}
}
else
{
audioSource.pitch = 1f;
}
}
private void UpdateVolume()
{
//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
bool flag = false;
bool flag2 = false;
if (CurrentArea == Area.InSpace)
{
foreach (KeyValuePair<GameObject, Func<bool>> muteSpaceCondition in MuteSpaceConditions)
{
if ((Object)(object)muteSpaceCondition.Key == (Object)null || !muteSpaceCondition.Key.activeSelf)
{
flag = true;
break;
}
if (muteSpaceCondition.Value())
{
flag2 = true;
break;
}
}
}
else
{
foreach (KeyValuePair<GameObject, Func<bool>> muteOutsideInsideCondition in MuteOutsideInsideConditions)
{
if ((Object)(object)muteOutsideInsideCondition.Key == (Object)null || !muteOutsideInsideCondition.Key.activeSelf)
{
flag = true;
break;
}
if (muteOutsideInsideCondition.Value() && Vector3.Distance(muteOutsideInsideCondition.Key.transform.position, ((Component)StartOfRound.Instance.localPlayerController).transform.position) < 15f)
{
flag2 = true;
break;
}
}
}
if (flag)
{
List<GameObject> list = (from kvp in MuteSpaceConditions
where (Object)(object)kvp.Key == (Object)null || !kvp.Key.activeSelf
select kvp.Key).ToList();
foreach (GameObject item in list)
{
MuteSpaceConditions.Remove(item);
}
LCTreatureTrackerOST.Logger.LogInfo((object)$"MusicManager: Removed {list.Count} null or inactive objects from MuteSpaceConditions.");
}
if (flag2)
{
audioSource.volume = 0f;
LCTreatureTrackerOST.Logger.LogInfo((object)"MusicManager: Muted music due to conditions.");
return;
}
Area currentArea = CurrentArea;
if (1 == 0)
{
}
float num = currentArea switch
{
Area.InSpace => LCTreatureTrackerOST.SpaceVolume.Value,
Area.Outdoors => LCTreatureTrackerOST.OutdoorVolume.Value,
Area.Indoors => LCTreatureTrackerOST.IndoorVolume.Value,
_ => 0f,
};
if (1 == 0)
{
}
float num2 = Mathf.Clamp(num, 0f, LCTreatureTrackerOST.MasterVolume.Value);
if (VolumeQuiter.HasValue)
{
if ((Object)(object)VolumeQuiter.Value.Item1 == (Object)null || !VolumeQuiter.Value.Item1.activeSelf)
{
VolumeQuiter = null;
}
else
{
num2 *= VolumeQuiter.Value.Item2;
}
}
if (!LightOn && CurrentArea == Area.Indoors)
{
num2 *= LCTreatureTrackerOST.DarknessFade.Value;
}
audioSource.volume = num2;
}
public static AudioClip GetSong(string name)
{
if (string.IsNullOrEmpty(name))
{
throw new ArgumentException("Song name cannot be null or empty.", "name");
}
foreach (AudioClip song in Songs)
{
if (((Object)song).name.ToLower().Contains(name.ToLower()))
{
return song;
}
}
throw new KeyNotFoundException("Song '" + name + "' not found in the music library.");
}
private bool CouldBeatQouta()
{
GrabbableObject[] array = Object.FindObjectsOfType<GrabbableObject>();
float num = 0f;
GrabbableObject[] array2 = array;
foreach (GrabbableObject val in array2)
{
if (val.isInShipRoom && val.isInElevator)
{
num += (float)val.scrapValue;
}
}
return num >= (float)(TimeOfDay.Instance.profitQuota - TimeOfDay.Instance.quotaFulfilled);
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "NoteBoxz.TreasureSoundTrack";
public const string PLUGIN_NAME = "LCTreatureTrackerOST";
public const string PLUGIN_VERSION = "1.0.2";
}
}
namespace LCTreatureTrackerOST.Patches
{
[HarmonyPatch(typeof(BoomboxItem))]
public class BoomboxItemPatch
{
[HarmonyPatch("StartMusic")]
[HarmonyPostfix]
private static void StartPostfix(BoomboxItem __instance)
{
BoomboxItem __instance2 = __instance;
if (!MusicManager.Instance.MuteSpaceConditions.ContainsKey(((Component)__instance2).gameObject))
{
MusicManager.Instance.MuteSpaceConditions.Add(((Component)__instance2).gameObject, () => __instance2.isPlayingMusic);
MusicManager.Instance.MuteOutsideInsideConditions.Add(((Component)__instance2).gameObject, () => __instance2.isPlayingMusic);
LCTreatureTrackerOST.Logger.LogInfo((object)("BoomboxItemPatch: Added " + ((Object)((Component)__instance2).gameObject).name + " to MuteSpaceConditions."));
}
}
}
[HarmonyPatch(typeof(CozyLights))]
public class CozyLightsPatch
{
[HarmonyPatch("SetAudio")]
[HarmonyPostfix]
private static void SetAudioPatch(CozyLights __instance)
{
CozyLights __instance2 = __instance;
if ((Object)(object)((Component)__instance2).transform.parent != (Object)null && ((Object)((Component)__instance2).transform.parent).name.Contains("DiscoBallContainer") && !MusicManager.Instance.MuteSpaceConditions.ContainsKey(((Component)__instance2).gameObject))
{
MusicManager.Instance.MuteSpaceConditions.Add(((Component)__instance2).gameObject, () => __instance2.cozyLightsOn);
LCTreatureTrackerOST.Logger.LogInfo((object)("CozyLightsPatch: Added " + ((Object)((Component)__instance2).gameObject).name + " to MuteSpaceConditions."));
}
}
}
[HarmonyPatch(typeof(GameNetworkManager))]
public class GameNetworkManagerPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPostfix(GameNetworkManager __instance)
{
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
if ((Object)(object)MusicManager.Instance != (Object)null)
{
LCTreatureTrackerOST.Logger.LogWarning((object)"MusicManager already initialized, skippis.");
return;
}
GameObject val = new GameObject("Toad_MusicManager");
MusicManager.Instance = val.AddComponent<MusicManager>();
Object.DontDestroyOnLoad((Object)(object)val);
}
}
[HarmonyPatch(typeof(ItemDropship))]
public class ItemDropshipPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void Start(ItemDropship __instance)
{
if (!LCTreatureTrackerOST.ReplaceDropshipMusic.Value)
{
LCTreatureTrackerOST.Logger.LogDebug((object)"ItemDropshipPatch: ReplaceDropshipMusic is false, skipping music replacement.");
return;
}
AudioSource[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<AudioSource>(true);
foreach (AudioSource val in componentsInChildren)
{
if (((Object)val).name == "Music")
{
AudioSource[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<AudioSource>(true);
foreach (AudioSource val2 in componentsInChildren2)
{
val2.clip = MusicManager.GetSong("1.44 Retro Ramp-Up");
LCTreatureTrackerOST.Logger.LogDebug((object)("Changed music for " + ((Object)((Component)val2).gameObject).name + " to " + ((Object)val2.clip).name));
}
}
if (((Object)val).name == "TruckDeliveryMusic")
{
AudioSource[] componentsInChildren3 = ((Component)val).GetComponentsInChildren<AudioSource>(true);
foreach (AudioSource val3 in componentsInChildren3)
{
val3.clip = MusicManager.GetSong("2.01 Super Pickax");
LCTreatureTrackerOST.Logger.LogDebug((object)("Changed music for " + ((Object)((Component)val3).gameObject).name + " to " + ((Object)val3.clip).name));
}
}
}
}
}
[HarmonyPatch(typeof(PlayerControllerB))]
public class PlayerControllerBPatch
{
[HarmonyPatch("KillPlayer")]
[HarmonyPostfix]
private static void KillPlayerPostfix(PlayerControllerB __instance)
{
if (((NetworkBehaviour)__instance).IsOwner && __instance.isPlayerDead && LCTreatureTrackerOST.PlayDeathMusic.Value)
{
MusicManager.Instance.audioSource.Stop();
MusicManager.Instance.audioSource.PlayOneShot(MusicManager.GetSong("2.02 Too Bad!"));
}
}
[HarmonyPatch("Update")]
[HarmonyPostfix]
private static void UpdatePostfix(PlayerControllerB __instance)
{
if (__instance.isCrouching && !MusicManager.Instance.VolumeQuiter.HasValue && LCTreatureTrackerOST.CrouchFade.Value != 1f)
{
MusicManager.Instance.VolumeQuiter = (((Component)__instance).gameObject, LCTreatureTrackerOST.CrouchFade.Value);
}
if (!__instance.isCrouching && MusicManager.Instance.VolumeQuiter.HasValue && (Object)(object)MusicManager.Instance.VolumeQuiter.Value.Item1 == (Object)(object)((Component)__instance).gameObject)
{
MusicManager.Instance.VolumeQuiter = null;
}
}
}
[HarmonyPatch(typeof(RadMechAI))]
public class RadMechAIPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void Start(RadMechAI __instance)
{
RadMechAI __instance2 = __instance;
if (!MusicManager.Instance.MuteOutsideInsideConditions.ContainsKey(((Component)__instance2).gameObject))
{
MusicManager.Instance.MuteOutsideInsideConditions.Add(((Component)__instance2).gameObject, () => __instance2.isAlerted);
LCTreatureTrackerOST.Logger.LogInfo((object)("RadMechAIPatch: Added " + ((Object)((Component)__instance2).gameObject).name + " to MuteSpaceConditions."));
}
}
}
[HarmonyPatch(typeof(RoundManager))]
public class RoundManagerPatch
{
[HarmonyPatch("turnOnLights")]
[HarmonyPostfix]
private static void TurnOnAllLightsPostfix(RoundManager __instance, bool turnOn)
{
if (turnOn)
{
MusicManager.Instance.LightOn = true;
}
else
{
MusicManager.Instance.LightOn = false;
}
MusicManager.Instance.UpdateTracks();
}
}
[HarmonyPatch(typeof(StartOfRound))]
public class StartOfRoundPatch
{
[CompilerGenerated]
private sealed class <PlayGameOverMusic>d__3 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <PlayGameOverMusic>d__3(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(MusicManager.GetSong("2.02 Too Bad!").length + 0.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>2__current = (object)new WaitUntil((Func<bool>)(() => StartOfRound.Instance.shipIsLeaving));
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
StartOfRound.Instance.allPlayersDeadAudio = MusicManager.GetSong("2.03 Game Over");
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPostfix(StartOfRound __instance)
{
TerminalNodesList terminalNodes = Object.FindObjectOfType<Terminal>().terminalNodes;
foreach (TerminalNode terminalNode in terminalNodes.terminalNodes)
{
LCTreatureTrackerOST.Logger.LogInfo((object)$"checking node {((Object)terminalNode).name} with cost {terminalNode.itemCost} and reroute {terminalNode.buyRerouteToMoon}");
if (terminalNode.buyRerouteToMoon != -1 && terminalNode.buyRerouteToMoon != -2)
{
MusicManager.MoonPrices[terminalNode.buyRerouteToMoon] = terminalNode.itemCost;
LCTreatureTrackerOST.Logger.LogInfo((object)$"Setting moon price for {((Object)terminalNode).name} to {terminalNode.itemCost}");
}
}
}
[HarmonyPatch("ShipLeaveAutomatically")]
[HarmonyPostfix]
private static void ShipLeaveAutomaticallyPostfix(StartOfRound __instance, bool leavingOnMidnight = false)
{
if (!(!LCTreatureTrackerOST.PlayGameoverMusic.Value || !__instance.allPlayersDead || leavingOnMidnight))
{
((MonoBehaviour)__instance).StartCoroutine(PlayGameOverMusic());
}
}
[HarmonyPatch("ShipLeave")]
[HarmonyPostfix]
private static void ShipLeavePostfix(StartOfRound __instance)
{
if (__instance.shipIsLeaving && !__instance.allPlayersDead)
{
MusicManager.Instance.SetTrack("none");
}
}
[IteratorStateMachine(typeof(<PlayGameOverMusic>d__3))]
private static IEnumerator PlayGameOverMusic()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <PlayGameOverMusic>d__3(0);
}
[HarmonyPatch("ChangeLevel")]
[HarmonyPostfix]
private static void ChangeLevelPostfix(StartOfRound __instance)
{
MusicManager.Instance.UpdateTracks();
}
[HarmonyPatch("openingDoorsSequence")]
[HarmonyPostfix]
private static void StartGamePostfix(StartOfRound __instance)
{
MusicManager.Instance.UpdateTracks();
}
[HarmonyPatch("SetShipReadyToLand")]
[HarmonyPostfix]
private static void SetShipReadyToLandPostfix(StartOfRound __instance)
{
MusicManager.Instance.UpdateTracks();
}
}
[HarmonyPatch(typeof(Terminal))]
public class TerminalPatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
private static void StartPostfix(Terminal __instance)
{
LCTreatureTrackerOST.Logger.LogInfo((object)"TerminalPatch: StartPostfix called");
TerminalKeyword val = ((IEnumerable<TerminalKeyword>)__instance.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)delegate(TerminalKeyword k)
{
int result;
if (k.defaultVerb?.word == "route")
{
CompatibleNoun[] compatibleNouns2 = k.defaultVerb.compatibleNouns;
result = ((compatibleNouns2 != null && compatibleNouns2.Length > 1) ? 1 : 0);
}
else
{
result = 0;
}
return (byte)result != 0;
});
if ((Object)(object)val == (Object)null)
{
return;
}
LCTreatureTrackerOST.Logger.LogInfo((object)("TerminalPatch: Found keyword '" + val.word + "' with default verb '" + ((Object)val.defaultVerb).name + "'"));
CompatibleNoun[] compatibleNouns = val.defaultVerb.compatibleNouns;
foreach (CompatibleNoun val2 in compatibleNouns)
{
if ((Object)(object)val2?.result == (Object)null)
{
continue;
}
CompatibleNoun[] terminalOptions = val2.result.terminalOptions;
foreach (CompatibleNoun val3 in terminalOptions)
{
if (!((Object)(object)val3?.result == (Object)null) && val3.result.buyRerouteToMoon > -1 && val3.result.buyRerouteToMoon != -2)
{
MusicManager.MoonPrices[val3.result.buyRerouteToMoon] = val3.result.itemCost;
LCTreatureTrackerOST.Logger.LogInfo((object)$"Setting moon price for {val3.result.buyRerouteToMoon}({((Object)val3.result).name}) to {val3.result.itemCost}");
}
}
}
}
}
[HarmonyPatch(typeof(TVScript))]
public class TVScriptPatch
{
[HarmonyPatch("SwitchTVLocalClient")]
[HarmonyPostfix]
private static void StartPostfix(TVScript __instance)
{
TVScript __instance2 = __instance;
if (!MusicManager.Instance.MuteSpaceConditions.ContainsKey(((Component)__instance2).gameObject))
{
MusicManager.Instance.MuteSpaceConditions.Add(((Component)__instance2).gameObject, () => __instance2.tvOn);
LCTreatureTrackerOST.Logger.LogInfo((object)("TVScriptPatch: Added " + ((Object)((Component)__instance2).gameObject).name + " to MuteSpaceConditions."));
}
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
public IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}