Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of ToriiTracks v0.10.23
plugins/SenshiSaga-ToriiTracks/ToriiTracks.dll
Decompiled 2 weeks agousing 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.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; 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: AssemblyTitle("ToriiTracks")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ToriiTracks")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("512EF403-4431-4BCE-8C81-9704EC2CF78B")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")] [assembly: AssemblyVersion("1.0.0.0")] namespace ToriiTracks; [BepInPlugin("senshisaga.toriitracks", "Torii Tracks", "0.10.23")] public class ToriiTracksPlugin : BaseUnityPlugin { public const string PluginGuid = "senshisaga.toriitracks"; public const string PluginName = "Torii Tracks"; public const string PluginVersion = "0.10.23"; public static ToriiTracksPlugin Instance; public float vanillaMusicMultiplier = 1f; private Harmony _harmony; public static ConfigEntry<string> SongConfig; public static ConfigEntry<string> HornSoundConfig; public static ConfigEntry<string> RaidSongConfig; public static ConfigEntry<bool> EnableRaidWarningsConfig; public static ConfigEntry<float> VolumeConfig; public static ConfigEntry<float> HornVolumeConfig; public static ConfigEntry<float> HornAudibleDistanceConfig; public static ConfigEntry<float> RaidVolumeConfig; public static ConfigEntry<float> BaseRadiusConfig; public static ConfigEntry<float> UIScaleConfig; public static ConfigEntry<float> UIOffsetXConfig; public static ConfigEntry<float> UIOffsetYConfig; public static ConfigEntry<float> BiomePopupCooldownConfig; public static ConfigEntry<float> EntryDelayConfig; public static ConfigEntry<float> FadeInTimeConfig; public static ConfigEntry<float> FadeOutTimeConfig; public static List<Sign> AllSigns = new List<Sign>(); private Dictionary<string, string> _songPathMap = new Dictionary<string, string>(); private Dictionary<string, string> _soundPathMap = new Dictionary<string, string>(); private Dictionary<string, string> _raidSongPathMap = new Dictionary<string, string>(); private Dictionary<string, AudioClip> _songClipMap = new Dictionary<string, AudioClip>(); private Dictionary<string, AudioClip> _soundClipMap = new Dictionary<string, AudioClip>(); private Dictionary<string, AudioClip> _raidSongClipMap = new Dictionary<string, AudioClip>(); public List<string> songFilesList = new List<string>(); private AudioSource _audioSource; private AudioSource _hornAudioSource; private AudioSource _raidAudioSource; private AudioClip _currentClip; private AudioClip _hornClip; private AudioClip _raidClip; private Coroutine _audioTransition; private Coroutine _sleepFadeCoroutine; private Coroutine _popupDelayCoroutine; private float _checkTimer; private bool _musicInBase; private bool _popupInBase; private bool _wasPlayerNull = true; private bool _wasRaidActive; private bool _isSleeping; private int _exitSecondsCount; private string _lastBaseName = ""; private float _lastMasterVolume = -1f; public bool isHandlingHornRaid; private Random _random = new Random(); private string _activeLoadedSongKey = ""; private static Sign _activeTargetSign; private static bool _showConfigWindow; private static float _uiRadiusTemp = 25f; private static string _uiRadiusTextTemp = "25"; private static int _uiSongIndexTemp; private Vector2 _songScrollPos; private static GUIStyle _windowStyle; private static GUIStyle _headerStyle; private static GUIStyle _labelStyle; private static GUIStyle _buttonStyle; private static GUIStyle _textFieldStyle; private static GUIStyle _boxStyle; private void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Expected O, but got Unknown //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Expected O, but got Unknown //IL_0401: Unknown result type (might be due to invalid IL or missing references) //IL_040b: Expected O, but got Unknown //IL_043e: Unknown result type (might be due to invalid IL or missing references) //IL_0448: Expected O, but got Unknown //IL_047b: Unknown result type (might be due to invalid IL or missing references) //IL_0485: Expected O, but got Unknown //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_04c2: Expected O, but got Unknown //IL_04ef: Unknown result type (might be due to invalid IL or missing references) //IL_04f9: Expected O, but got Unknown //IL_051a: Unknown result type (might be due to invalid IL or missing references) //IL_0524: Expected O, but got Unknown //IL_0557: Unknown result type (might be due to invalid IL or missing references) //IL_0561: Expected O, but got Unknown //IL_0594: Unknown result type (might be due to invalid IL or missing references) //IL_059e: Expected O, but got Unknown //IL_05cb: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Expected O, but got Unknown //IL_0608: Unknown result type (might be due to invalid IL or missing references) //IL_0612: Expected O, but got Unknown //IL_0645: Unknown result type (might be due to invalid IL or missing references) //IL_064f: Expected O, but got Unknown //IL_0682: Unknown result type (might be due to invalid IL or missing references) //IL_068c: Expected O, but got Unknown //IL_06bf: Unknown result type (might be due to invalid IL or missing references) //IL_06c9: Expected O, but got Unknown //IL_06fc: Unknown result type (might be due to invalid IL or missing references) //IL_0706: Expected O, but got Unknown Instance = this; _harmony = new Harmony("senshisaga.toriitracks"); string path = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? Paths.PluginPath; string path2 = Path.Combine(path, "BaseMusic"); string path3 = Path.Combine(path, "HornSounds"); string path4 = Path.Combine(path, "RaidMusic"); if (!Directory.Exists(path2)) { Directory.CreateDirectory(path2); } if (!Directory.Exists(path3)) { Directory.CreateDirectory(path3); } if (!Directory.Exists(path4)) { Directory.CreateDirectory(path4); } string[] array = (from s in Directory.GetFiles(path2, "*.*", SearchOption.AllDirectories) where s.EndsWith(".wav", StringComparison.OrdinalIgnoreCase) || s.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase) || s.EndsWith(".ogg", StringComparison.OrdinalIgnoreCase) orderby s select s).ToArray(); List<string> list = new List<string> { "None" }; songFilesList.Clear(); string[] array2 = array; foreach (string text in array2) { string fileName = Path.GetFileName(text); if (!list.Contains(fileName)) { list.Add(fileName); songFilesList.Add(fileName); _songPathMap[fileName] = text; } } string[] array3 = (from s in Directory.GetFiles(path3, "*.*", SearchOption.AllDirectories) where s.EndsWith(".wav", StringComparison.OrdinalIgnoreCase) || s.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase) || s.EndsWith(".ogg", StringComparison.OrdinalIgnoreCase) orderby s select s).ToArray(); List<string> list2 = new List<string> { "None" }; string[] array4 = array3; foreach (string text2 in array4) { string fileName2 = Path.GetFileName(text2); if (!list2.Contains(fileName2)) { list2.Add(fileName2); _soundPathMap[fileName2] = text2; } } string[] array5 = (from s in Directory.GetFiles(path4, "*.*", SearchOption.AllDirectories) where s.EndsWith(".wav", StringComparison.OrdinalIgnoreCase) || s.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase) || s.EndsWith(".ogg", StringComparison.OrdinalIgnoreCase) orderby s select s).ToArray(); List<string> list3 = new List<string> { "Random", "None" }; string[] array6 = array5; foreach (string text3 in array6) { string fileName3 = Path.GetFileName(text3); if (!list3.Contains(fileName3)) { list3.Add(fileName3); _raidSongPathMap[fileName3] = text3; } } string text4 = ((list.Count > 1) ? list[1] : "None"); string text5 = ((list2.Count > 1) ? list2[1] : "None"); string text6 = ((list3.Count > 2) ? list3[2] : "None"); SongConfig = ((BaseUnityPlugin)this).Config.Bind<string>("1. Base Music", "Song", text4, new ConfigDescription("Select the default background song to play in your base.", (AcceptableValueBase)(object)new AcceptableValueList<string>(list.ToArray()), Array.Empty<object>())); VolumeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("1. Base Music", "Base Music Volume", 0.5f, new ConfigDescription("Maximum volume of the base music.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); BaseRadiusConfig = ((BaseUnityPlugin)this).Config.Bind<float>("1. Base Music", "Base Radius", 25f, new ConfigDescription("Default radius around a sign to be inside.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(5f, 150f), Array.Empty<object>())); UIScaleConfig = ((BaseUnityPlugin)this).Config.Bind<float>("1. Base Music", "Sign Options UI Scale", 1f, new ConfigDescription("Global scale of all sign configuration windows and backdrops.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>())); UIOffsetXConfig = ((BaseUnityPlugin)this).Config.Bind<float>("1. Base Music", "Sign Options UI Offset X", 0f, new ConfigDescription("Horizontal screen offset position from center for the sign configuration window.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-800f, 800f), Array.Empty<object>())); UIOffsetYConfig = ((BaseUnityPlugin)this).Config.Bind<float>("1. Base Music", "Sign Options UI Offset Y", 0f, new ConfigDescription("Vertical screen offset position from center for the sign configuration window.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-500f, 500f), Array.Empty<object>())); HornSoundConfig = ((BaseUnityPlugin)this).Config.Bind<string>("2. Raid War Horn", "War Horn Sound", text5, new ConfigDescription("Select the war horn sound file to play when a raid triggers.", (AcceptableValueBase)(object)new AcceptableValueList<string>(list2.ToArray()), Array.Empty<object>())); EnableRaidWarningsConfig = ((BaseUnityPlugin)this).Config.Bind<bool>("2. Raid War Horn", "Enable Raid Warnings", true, new ConfigDescription("Enable or disable the custom war horn sound and raid delay when a raid triggers.", (AcceptableValueBase)null, Array.Empty<object>())); HornVolumeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("2. Raid War Horn", "War Horn Volume", 0.8f, new ConfigDescription("Volume of the war horn sound effect.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); HornAudibleDistanceConfig = ((BaseUnityPlugin)this).Config.Bind<float>("2. Raid War Horn", "Raid Audible Distance", 500f, new ConfigDescription("Maximum distance in meters players can hear the raid war horn. All players within this range can hear the horn.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(50f, 3000f), Array.Empty<object>())); RaidSongConfig = ((BaseUnityPlugin)this).Config.Bind<string>("3. Raid Music", "Raid Song", text6, new ConfigDescription("Select a raid song or choose Random for a different track each raid.", (AcceptableValueBase)(object)new AcceptableValueList<string>(list3.ToArray()), Array.Empty<object>())); RaidVolumeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("3. Raid Music", "Raid Target Volume", 0.7f, new ConfigDescription("Maximum volume of the raid music.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); EntryDelayConfig = ((BaseUnityPlugin)this).Config.Bind<float>("4. Audio Transitions (In Seconds)", "Entry Buffer Delay", 2f, new ConfigDescription("Seconds to wait inside the base before music starts.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); FadeInTimeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("4. Audio Transitions (In Seconds)", "Fade In Time", 5f, new ConfigDescription("Seconds it takes to fade to max volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>())); FadeOutTimeConfig = ((BaseUnityPlugin)this).Config.Bind<float>("4. Audio Transitions (In Seconds)", "Fade Out Time", 5f, new ConfigDescription("Seconds it takes to fade to silence when leaving.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>())); BiomePopupCooldownConfig = ((BaseUnityPlugin)this).Config.Bind<float>("5. Biome Popup", "Cooldown Duration (Seconds)", 120f, new ConfigDescription("Duration in seconds to wait before the base biome popup can show again after leaving. Set to 0 to disable the cooldown.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 600f), Array.Empty<object>())); SongConfig.SettingChanged += delegate { LoadSong(GetResolvedSong(null)); }; HornSoundConfig.SettingChanged += delegate { LoadHornSound(); }; VolumeConfig.SettingChanged += delegate { if (_musicInBase && !_isSleeping && _audioTransition == null && (Object)(object)_audioSource != (Object)null && _audioSource.isPlaying) { _audioSource.volume = GetEffectiveVolume(); } }; RaidVolumeConfig.SettingChanged += delegate { if (!_isSleeping && (Object)(object)_raidAudioSource != (Object)null && _raidAudioSource.isPlaying) { _raidAudioSource.volume = GetEffectiveRaidVolume(); } }; _audioSource = ((Component)this).gameObject.AddComponent<AudioSource>(); _audioSource.loop = true; _audioSource.spatialBlend = 0f; _audioSource.volume = 0f; _hornAudioSource = ((Component)this).gameObject.AddComponent<AudioSource>(); _hornAudioSource.loop = false; _hornAudioSource.spatialBlend = 0f; _hornAudioSource.volume = 1f; _raidAudioSource = ((Component)this).gameObject.AddComponent<AudioSource>(); _raidAudioSource.loop = true; _raidAudioSource.spatialBlend = 0f; _raidAudioSource.volume = 0f; _harmony.PatchAll(); ((MonoBehaviour)this).StartCoroutine(PreloadAllAudioFiles()); } private IEnumerator PreloadAllAudioFiles() { foreach (KeyValuePair<string, string> item in _songPathMap) { yield return LoadClipIntoCache(item.Value, _songClipMap); } foreach (KeyValuePair<string, string> item2 in _soundPathMap) { yield return LoadClipIntoCache(item2.Value, _soundClipMap); } foreach (KeyValuePair<string, string> item3 in _raidSongPathMap) { yield return LoadClipIntoCache(item3.Value, _raidSongClipMap); } LoadSong(GetResolvedSong(null)); LoadHornSound(); } private IEnumerator LoadClipIntoCache(string path, Dictionary<string, AudioClip> cache) { string url = "file:///" + path.Replace("\\", "/"); AudioType audioType = (AudioType)0; if (path.EndsWith(".ogg", StringComparison.OrdinalIgnoreCase)) { audioType = (AudioType)14; } else if (path.EndsWith(".mp3", StringComparison.OrdinalIgnoreCase)) { audioType = (AudioType)13; } else if (path.EndsWith(".wav", StringComparison.OrdinalIgnoreCase)) { audioType = (AudioType)20; } UnityWebRequest uwr = UnityWebRequestMultimedia.GetAudioClip(url, audioType); try { yield return uwr.SendWebRequest(); if ((int)uwr.result != 2 && (int)uwr.result != 3) { AudioClip clip = DownloadHandlerAudioClip.GetContent(uwr); if ((Object)(object)clip != (Object)null) { string fileName = Path.GetFileName(path); cache[fileName] = clip; } } } finally { ((IDisposable)uwr)?.Dispose(); } } private static Texture2D MakeTex(int width, int height, Color col) { //IL_0011: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002e: Expected O, but got Unknown Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < array.Length; i++) { array[i] = col; } Texture2D val = new Texture2D(width, height); val.SetPixels(array); val.Apply(); return val; } private static void InitStyles() { //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Expected O, but got Unknown //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Expected O, but got Unknown //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: 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_0170: Expected O, but got Unknown //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_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_0212: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0240: Unknown result type (might be due to invalid IL or missing references) //IL_0245: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0271: Expected O, but got Unknown //IL_0288: 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_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02e7: Unknown result type (might be due to invalid IL or missing references) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_0301: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_032d: Expected O, but got Unknown //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) if (_windowStyle == null) { _windowStyle = new GUIStyle(GUI.skin.window); _windowStyle.normal.background = MakeTex(2, 2, Color32.op_Implicit(new Color32((byte)35, (byte)30, (byte)26, (byte)250))); _windowStyle.onNormal.background = _windowStyle.normal.background; _windowStyle.normal.textColor = Color32.op_Implicit(new Color32((byte)240, (byte)190, (byte)70, byte.MaxValue)); _windowStyle.fontSize = 14; _windowStyle.fontStyle = (FontStyle)1; _headerStyle = new GUIStyle(GUI.skin.label); _headerStyle.normal.textColor = Color32.op_Implicit(new Color32((byte)240, (byte)190, (byte)70, byte.MaxValue)); _headerStyle.fontSize = 13; _headerStyle.fontStyle = (FontStyle)1; _labelStyle = new GUIStyle(GUI.skin.label); _labelStyle.normal.textColor = Color32.op_Implicit(new Color32((byte)235, (byte)230, (byte)220, byte.MaxValue)); _labelStyle.fontSize = 12; _buttonStyle = new GUIStyle(GUI.skin.button); _buttonStyle.normal.background = MakeTex(2, 2, Color32.op_Implicit(new Color32((byte)60, (byte)52, (byte)45, byte.MaxValue))); _buttonStyle.hover.background = MakeTex(2, 2, Color32.op_Implicit(new Color32((byte)85, (byte)74, (byte)64, byte.MaxValue))); _buttonStyle.active.background = MakeTex(2, 2, Color32.op_Implicit(new Color32((byte)110, (byte)96, (byte)84, byte.MaxValue))); _buttonStyle.normal.textColor = Color32.op_Implicit(new Color32((byte)240, (byte)235, (byte)225, byte.MaxValue)); _buttonStyle.hover.textColor = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)240, (byte)150, byte.MaxValue)); _buttonStyle.fontSize = 12; _textFieldStyle = new GUIStyle(GUI.skin.textField); _textFieldStyle.normal.background = MakeTex(2, 2, Color32.op_Implicit(new Color32((byte)20, (byte)18, (byte)16, byte.MaxValue))); _textFieldStyle.focused.background = MakeTex(2, 2, Color32.op_Implicit(new Color32((byte)30, (byte)27, (byte)24, byte.MaxValue))); _textFieldStyle.normal.textColor = Color32.op_Implicit(new Color32((byte)240, (byte)235, (byte)225, byte.MaxValue)); _textFieldStyle.focused.textColor = Color.white; _textFieldStyle.fontSize = 12; _boxStyle = new GUIStyle(GUI.skin.box); _boxStyle.normal.background = MakeTex(2, 2, Color32.op_Implicit(new Color32((byte)45, (byte)40, (byte)35, byte.MaxValue))); } } public static float GetEffectiveVolume() { float num = ((VolumeConfig != null) ? VolumeConfig.Value : 0.5f); float num2 = PlayerPrefs.GetFloat("MasterVolume", AudioListener.volume); return num * num2; } public static float GetEffectiveHornVolume() { float num = ((HornVolumeConfig != null) ? HornVolumeConfig.Value : 0.8f); float num2 = PlayerPrefs.GetFloat("MasterVolume", AudioListener.volume); return num * num2; } public static float GetEffectiveRaidVolume() { float num = ((RaidVolumeConfig != null) ? RaidVolumeConfig.Value : 0.7f); float num2 = PlayerPrefs.GetFloat("MasterVolume", AudioListener.volume); return num * num2; } public string GetResolvedSong(Sign sign) { string result = SongConfig.Value; if ((Object)(object)sign != (Object)null) { string storedSong = sign.GetStoredSong(null); if (!string.IsNullOrEmpty(storedSong)) { result = storedSong; } } return result; } private IEnumerator FadeAudio(AudioSource source, float startVol, float targetVol, float duration) { if (!((Object)(object)source == (Object)null)) { float t = 0f; while (t < duration) { t += Time.deltaTime; source.volume = Mathf.Lerp(startVol, targetVol, Mathf.Clamp01(t / duration)); yield return null; } source.volume = targetVol; } } public void OnSleepStart() { _isSleeping = true; if (_sleepFadeCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_sleepFadeCoroutine); } _sleepFadeCoroutine = ((MonoBehaviour)this).StartCoroutine(FadeAllAudioToZero(1f)); } public void OnSleepStop() { _isSleeping = false; if (_sleepFadeCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_sleepFadeCoroutine); } _sleepFadeCoroutine = ((MonoBehaviour)this).StartCoroutine(RestoreAudioAfterSleep()); } private IEnumerator FadeAllAudioToZero(float duration) { float startBase = (((Object)(object)_audioSource != (Object)null) ? _audioSource.volume : 0f); float startRaid = (((Object)(object)_raidAudioSource != (Object)null) ? _raidAudioSource.volume : 0f); float startHorn = (((Object)(object)_hornAudioSource != (Object)null) ? _hornAudioSource.volume : 0f); float t = 0f; while (t < duration) { t += Time.deltaTime; float norm = Mathf.Clamp01(t / duration); if ((Object)(object)_audioSource != (Object)null) { _audioSource.volume = Mathf.Lerp(startBase, 0f, norm); } if ((Object)(object)_raidAudioSource != (Object)null) { _raidAudioSource.volume = Mathf.Lerp(startRaid, 0f, norm); } if ((Object)(object)_hornAudioSource != (Object)null) { _hornAudioSource.volume = Mathf.Lerp(startHorn, 0f, norm); } yield return null; } if ((Object)(object)_audioSource != (Object)null) { _audioSource.volume = 0f; } if ((Object)(object)_raidAudioSource != (Object)null) { _raidAudioSource.volume = 0f; } if ((Object)(object)_hornAudioSource != (Object)null) { _hornAudioSource.volume = 0f; } } private IEnumerator RestoreAudioAfterSleep() { float targetBase = ((_musicInBase && !_wasRaidActive) ? GetEffectiveVolume() : 0f); float targetRaid = (_wasRaidActive ? GetEffectiveRaidVolume() : 0f); if (_wasRaidActive && (Object)(object)_raidAudioSource != (Object)null && (Object)(object)_raidClip != (Object)null && !_raidAudioSource.isPlaying) { _raidAudioSource.clip = _raidClip; _raidAudioSource.volume = 0f; _raidAudioSource.Play(); } else if (!_wasRaidActive && _musicInBase && (Object)(object)_audioSource != (Object)null && (Object)(object)_currentClip != (Object)null && !_audioSource.isPlaying) { _audioSource.clip = _currentClip; _audioSource.volume = 0f; _audioSource.Play(); } float startBase = (((Object)(object)_audioSource != (Object)null) ? _audioSource.volume : 0f); float startRaid = (((Object)(object)_raidAudioSource != (Object)null) ? _raidAudioSource.volume : 0f); float t = 0f; float duration = 1.5f; while (t < duration) { t += Time.deltaTime; float norm = Mathf.Clamp01(t / duration); if ((Object)(object)_audioSource != (Object)null) { _audioSource.volume = Mathf.Lerp(startBase, targetBase, norm); } if ((Object)(object)_raidAudioSource != (Object)null) { _raidAudioSource.volume = Mathf.Lerp(startRaid, targetRaid, norm); } yield return null; } if ((Object)(object)_audioSource != (Object)null) { _audioSource.volume = targetBase; } if ((Object)(object)_raidAudioSource != (Object)null) { _raidAudioSource.volume = targetRaid; } } private void LoadSong(string songKey) { if (string.IsNullOrEmpty(songKey) || songKey == "None" || !_songClipMap.ContainsKey(songKey)) { _currentClip = null; _activeLoadedSongKey = ""; if (_audioSource.isPlaying) { _audioSource.Stop(); } if (_musicInBase && _audioTransition == null) { vanillaMusicMultiplier = 1f; } return; } _activeLoadedSongKey = songKey; _currentClip = _songClipMap[songKey]; if (_musicInBase && !_isSleeping && (Object)(object)_currentClip != (Object)null && !_wasRaidActive) { _audioSource.clip = _currentClip; if (_audioTransition == null) { _audioSource.volume = GetEffectiveVolume(); } if (!_audioSource.isPlaying) { _audioSource.Play(); } } } private void LoadHornSound() { if (HornSoundConfig.Value == "None" || !_soundClipMap.ContainsKey(HornSoundConfig.Value)) { _hornClip = null; } else { _hornClip = _soundClipMap[HornSoundConfig.Value]; } } public void StartRaidMusic() { if (RaidSongConfig.Value == "None" || _raidSongClipMap.Count == 0) { return; } AudioClip val = null; if (RaidSongConfig.Value == "Random") { List<string> list = _raidSongClipMap.Keys.ToList(); if (list.Count > 0) { string key = list[_random.Next(list.Count)]; val = _raidSongClipMap[key]; } } else if (_raidSongClipMap.ContainsKey(RaidSongConfig.Value)) { val = _raidSongClipMap[RaidSongConfig.Value]; } if ((Object)(object)val != (Object)null) { _raidClip = val; if ((Object)(object)_raidAudioSource != (Object)null && !_isSleeping) { _raidAudioSource.clip = _raidClip; _raidAudioSource.volume = 0f; _raidAudioSource.Play(); ((MonoBehaviour)this).StartCoroutine(FadeAudio(_raidAudioSource, 0f, GetEffectiveRaidVolume(), 1.5f)); } } } public void StopRaidMusic() { ((MonoBehaviour)this).StartCoroutine(StopRaidMusicRoutine()); } private IEnumerator StopRaidMusicRoutine() { if ((Object)(object)_raidAudioSource != (Object)null && _raidAudioSource.isPlaying) { yield return ((MonoBehaviour)this).StartCoroutine(FadeAudio(_raidAudioSource, _raidAudioSource.volume, 0f, 1.5f)); _raidAudioSource.Stop(); } Sign closestSign = GetClosestSign(); string desiredSong = GetResolvedSong(closestSign); if (desiredSong != _activeLoadedSongKey && desiredSong != "None") { LoadSong(desiredSong); } if (_musicInBase && !_isSleeping && (Object)(object)_audioSource != (Object)null && (Object)(object)_currentClip != (Object)null) { _audioSource.clip = _currentClip; _audioSource.volume = 0f; if (!_audioSource.isPlaying) { _audioSource.Play(); } yield return ((MonoBehaviour)this).StartCoroutine(FadeAudio(_audioSource, 0f, GetEffectiveVolume(), FadeInTimeConfig.Value)); } } public void HandleDelayedRaid(RandEventSystem eventSystem, string eventName, Vector3 pos) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) ((MonoBehaviour)this).StartCoroutine(PlayHornAndResumeRaid(eventSystem, eventName, pos)); } private IEnumerator PlayHornAndResumeRaid(RandEventSystem eventSystem, string eventName, Vector3 pos) { //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) isHandlingHornRaid = true; if ((Object)(object)_audioSource != (Object)null && _audioSource.isPlaying) { yield return ((MonoBehaviour)this).StartCoroutine(FadeAudio(_audioSource, _audioSource.volume, 0f, 1f)); _audioSource.Pause(); } if ((Object)(object)_hornClip != (Object)null && (Object)(object)_hornAudioSource != (Object)null && !_isSleeping && (Object)(object)Player.m_localPlayer != (Object)null) { float distance = Vector3.Distance(((Component)Player.m_localPlayer).transform.position, pos); float maxDistance = ((HornAudibleDistanceConfig != null) ? HornAudibleDistanceConfig.Value : 500f); if (distance <= maxDistance) { float distanceFactor = 1f - distance / maxDistance; float finalHornVol = GetEffectiveHornVolume() * distanceFactor; _hornAudioSource.PlayOneShot(_hornClip, finalHornVol); } yield return null; while (_hornAudioSource.isPlaying) { yield return null; } } else { yield return (object)new WaitForSeconds(2f); } isHandlingHornRaid = false; RandEventSystemRaidPatch.SkipNextPatch = true; if ((Object)(object)eventSystem != (Object)null) { eventSystem.SetRandomEventByName(eventName, pos); } } private void Update() { if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)ZNet.instance == (Object)null) { _wasPlayerNull = true; _musicInBase = false; _popupInBase = false; _wasRaidActive = false; _isSleeping = false; _exitSecondsCount = 0; _lastBaseName = ""; if (_popupDelayCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_popupDelayCoroutine); _popupDelayCoroutine = null; } if ((Object)(object)_audioSource != (Object)null && _audioSource.isPlaying) { _audioSource.Stop(); } if ((Object)(object)_raidAudioSource != (Object)null && _raidAudioSource.isPlaying) { _raidAudioSource.Stop(); } return; } if (_wasPlayerNull) { _wasPlayerNull = false; _musicInBase = false; _popupInBase = false; _wasRaidActive = false; _isSleeping = false; _exitSecondsCount = 0; _lastBaseName = ""; _checkTimer = 0.9f; } if ((Input.GetKey((KeyCode)308) || Input.GetKey((KeyCode)307)) && Input.GetKeyDown((KeyCode)101) && !_showConfigWindow) { GameObject value = Traverse.Create((object)Player.m_localPlayer).Field("m_hovering").GetValue<GameObject>(); if ((Object)(object)value != (Object)null) { Sign componentInParent = value.GetComponentInParent<Sign>(); if ((Object)(object)componentInParent != (Object)null) { Piece component = ((Component)componentInParent).GetComponent<Piece>(); if ((Object)(object)component != (Object)null && component.GetCreator() == Player.m_localPlayer.GetPlayerID()) { _activeTargetSign = componentInParent; _uiRadiusTemp = componentInParent.GetStoredRadius(BaseRadiusConfig.Value); _uiRadiusTextTemp = _uiRadiusTemp.ToString("F1"); string storedSong = componentInParent.GetStoredSong("None"); _uiSongIndexTemp = 0; for (int i = 0; i < songFilesList.Count; i++) { if (songFilesList[i].Equals(storedSong, StringComparison.OrdinalIgnoreCase)) { _uiSongIndexTemp = i + 1; break; } } _showConfigWindow = true; } } } } bool flag = (Object)(object)RandEventSystem.instance != (Object)null && Traverse.Create((object)RandEventSystem.instance).Field("m_randomEvent").GetValue() != null; if (flag && !_wasRaidActive) { _wasRaidActive = true; StartRaidMusic(); } else if (!flag && _wasRaidActive) { _wasRaidActive = false; StopRaidMusic(); } float num = PlayerPrefs.GetFloat("MasterVolume", AudioListener.volume); if (!Mathf.Approximately(num, _lastMasterVolume)) { _lastMasterVolume = num; if (!_isSleeping) { if ((Object)(object)_audioSource != (Object)null && _audioSource.isPlaying && _audioTransition == null && _musicInBase) { _audioSource.volume = GetEffectiveVolume(); } if ((Object)(object)_raidAudioSource != (Object)null && _raidAudioSource.isPlaying) { _raidAudioSource.volume = GetEffectiveRaidVolume(); } } } _checkTimer += Time.deltaTime; if (_checkTimer >= 1f) { _checkTimer = 0f; CheckBaseStatus(); } } public Sign GetClosestSign() { //IL_002f: 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_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)Player.m_localPlayer == (Object)null) { return null; } long playerID = Player.m_localPlayer.GetPlayerID(); Vector3 position = ((Component)Player.m_localPlayer).transform.position; float value = BaseRadiusConfig.Value; float num = float.MaxValue; Sign result = null; foreach (Sign allSign in AllSigns) { ZNetView component = ((Component)allSign).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { continue; } Piece component2 = ((Component)allSign).GetComponent<Piece>(); if (!((Object)(object)component2 == (Object)null) && component2.GetCreator() == playerID) { float storedRadius = allSign.GetStoredRadius(value); float num2 = Vector3.Distance(position, ((Component)allSign).transform.position); if (num2 <= storedRadius && num2 < num) { num = num2; result = allSign; } } } return result; } public string GetClosestBaseName() { Sign closestSign = GetClosestSign(); if ((Object)(object)closestSign != (Object)null && !string.IsNullOrWhiteSpace(closestSign.GetText())) { string text = closestSign.GetText().Trim(); if (!string.IsNullOrEmpty(text) && text != "...") { return text; } } return "Base"; } private void CheckBaseStatus() { AllSigns.RemoveAll((Sign s) => (Object)(object)s == (Object)null); Sign closestSign = GetClosestSign(); bool flag = (Object)(object)closestSign != (Object)null; string resolvedSong = GetResolvedSong(closestSign); if (flag) { if (!_musicInBase) { _musicInBase = true; if (resolvedSong != _activeLoadedSongKey && resolvedSong != "None") { LoadSong(resolvedSong); } if (_audioTransition != null) { ((MonoBehaviour)this).StopCoroutine(_audioTransition); } _audioTransition = ((MonoBehaviour)this).StartCoroutine(HandleAudioTransition(entering: true)); } else if (resolvedSong != _activeLoadedSongKey && resolvedSong != "None") { LoadSong(resolvedSong); } } else if (_musicInBase) { _musicInBase = false; if (_audioTransition != null) { ((MonoBehaviour)this).StopCoroutine(_audioTransition); } _audioTransition = ((MonoBehaviour)this).StartCoroutine(HandleAudioTransition(entering: false)); } if (flag) { string closestBaseName = GetClosestBaseName(); if (closestBaseName != _lastBaseName) { _lastBaseName = closestBaseName; _exitSecondsCount = 0; _popupInBase = true; if (_popupDelayCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_popupDelayCoroutine); } _popupDelayCoroutine = ((MonoBehaviour)this).StartCoroutine(ShowPopupAfterDelay()); return; } _exitSecondsCount = 0; if (!_popupInBase) { _popupInBase = true; if (_popupDelayCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_popupDelayCoroutine); } _popupDelayCoroutine = ((MonoBehaviour)this).StartCoroutine(ShowPopupAfterDelay()); } return; } float num = ((BiomePopupCooldownConfig != null) ? BiomePopupCooldownConfig.Value : 120f); if (num <= 0f) { _popupInBase = false; _exitSecondsCount = 0; } else if (_popupInBase) { _exitSecondsCount++; if ((float)_exitSecondsCount >= num) { _exitSecondsCount = 0; _popupInBase = false; if (_popupDelayCoroutine != null) { ((MonoBehaviour)this).StopCoroutine(_popupDelayCoroutine); _popupDelayCoroutine = null; } } } else { _exitSecondsCount = 0; } } private IEnumerator ShowPopupAfterDelay() { float entryDelay = ((EntryDelayConfig != null) ? EntryDelayConfig.Value : 2f); float fadeIn = ((FadeInTimeConfig != null) ? FadeInTimeConfig.Value : 5f); float totalDelay = entryDelay + fadeIn * 0.75f; yield return (object)new WaitForSeconds(totalDelay); if ((Object)(object)GetClosestSign() != (Object)null && (Object)(object)MessageHud.instance != (Object)null) { MessageHud.instance.ShowBiomeFoundMsg(GetClosestBaseName(), false); } _popupDelayCoroutine = null; } private IEnumerator HandleAudioTransition(bool entering) { if (entering) { yield return (object)new WaitForSeconds(EntryDelayConfig.Value); if ((Object)(object)_currentClip != (Object)null && !_wasRaidActive && !_isSleeping) { if (!_audioSource.isPlaying) { _audioSource.clip = _currentClip; _audioSource.volume = 0f; _audioSource.Play(); } float t = 0f; float startVol = _audioSource.volume; float targetVol = GetEffectiveVolume(); float startVanilla = vanillaMusicMultiplier; while (t < FadeInTimeConfig.Value) { t += Time.deltaTime; float normalizedTime = t / FadeInTimeConfig.Value; _audioSource.volume = Mathf.Lerp(startVol, targetVol, normalizedTime); vanillaMusicMultiplier = Mathf.Lerp(startVanilla, 0f, normalizedTime); yield return null; } _audioSource.volume = targetVol; vanillaMusicMultiplier = 0f; } } else { float t2 = 0f; float startVol2 = _audioSource.volume; float startVanilla2 = vanillaMusicMultiplier; while (t2 < FadeOutTimeConfig.Value) { t2 += Time.deltaTime; float normalizedTime2 = t2 / FadeOutTimeConfig.Value; _audioSource.volume = Mathf.Lerp(startVol2, 0f, normalizedTime2); vanillaMusicMultiplier = Mathf.Lerp(startVanilla2, 1f, normalizedTime2); yield return null; } _audioSource.volume = 0f; _audioSource.Stop(); vanillaMusicMultiplier = 1f; } _audioTransition = null; } private void OnGUI() { //IL_00bd: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) if (_showConfigWindow && !((Object)(object)_activeTargetSign == (Object)null)) { InitStyles(); float num = ((UIScaleConfig != null) ? UIScaleConfig.Value : 1f); float num2 = ((UIOffsetXConfig != null) ? UIOffsetXConfig.Value : 0f); float num3 = ((UIOffsetYConfig != null) ? UIOffsetYConfig.Value : 0f); float num4 = 350f; float num5 = 280f; float num6 = ((float)Screen.width / num - num4) / 2f + num2; float num7 = ((float)Screen.height / num - num5) / 2f + num3; Rect val = default(Rect); ((Rect)(ref val))..ctor(num6, num7, num4, num5); GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f)); GUI.Window(9999, val, new WindowFunction(DrawSignConfigWindow), "Torii Track - Sign Settings", _windowStyle); GUI.matrix = Matrix4x4.identity; } } private void DrawSignConfigWindow(int windowID) { //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0163: Unknown result type (might be due to invalid IL or missing references) //IL_0168: 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_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01e3: 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) GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.Space(10f); GUILayout.Label("Radius (m):", _headerStyle, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); float num = GUILayout.HorizontalSlider(_uiRadiusTemp, 5f, 150f, Array.Empty<GUILayoutOption>()); if (!Mathf.Approximately(num, _uiRadiusTemp)) { _uiRadiusTemp = num; _uiRadiusTextTemp = _uiRadiusTemp.ToString("F1"); } string text = GUILayout.TextField(_uiRadiusTextTemp, _textFieldStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(60f) }); if (text != _uiRadiusTextTemp) { _uiRadiusTextTemp = text; if (float.TryParse(_uiRadiusTextTemp, out var result)) { _uiRadiusTemp = Mathf.Clamp(result, 5f, 150f); } } GUILayout.EndHorizontal(); GUILayout.Space(10f); GUILayout.Label("Assigned Song:", _headerStyle, Array.Empty<GUILayoutOption>()); _songScrollPos = GUILayout.BeginScrollView(_songScrollPos, _boxStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(100f) }); object obj; if (_uiSongIndexTemp != 0) { obj = _buttonStyle; } else { GUIStyle val = new GUIStyle(_buttonStyle); val.normal.textColor = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)220, (byte)100, byte.MaxValue)); obj = (object)val; } GUIStyle val2 = (GUIStyle)obj; if (GUILayout.Button("None (Default)", val2, Array.Empty<GUILayoutOption>())) { _uiSongIndexTemp = 0; } for (int i = 0; i < songFilesList.Count; i++) { string text2 = songFilesList[i]; object obj2; if (_uiSongIndexTemp != i + 1) { obj2 = _buttonStyle; } else { GUIStyle val3 = new GUIStyle(_buttonStyle); val3.normal.textColor = Color32.op_Implicit(new Color32(byte.MaxValue, (byte)220, (byte)100, byte.MaxValue)); obj2 = (object)val3; } GUIStyle val4 = (GUIStyle)obj2; if (GUILayout.Button(text2, val4, Array.Empty<GUILayoutOption>())) { _uiSongIndexTemp = i + 1; } } GUILayout.EndScrollView(); GUILayout.Space(15f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Save", _buttonStyle, Array.Empty<GUILayoutOption>())) { _activeTargetSign.SetStoredRadius(_uiRadiusTemp); string song = ((_uiSongIndexTemp == 0) ? "None" : songFilesList[_uiSongIndexTemp - 1]); _activeTargetSign.SetStoredSong(song); _showConfigWindow = false; } if (GUILayout.Button("Cancel", _buttonStyle, Array.Empty<GUILayoutOption>())) { _showConfigWindow = false; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUI.DragWindow(); } } public static class SignDataExtensions { private const string RadiusKey = "ToriiRadius"; private const string SongKey = "ToriiSong"; public static float GetStoredRadius(this Sign sign, float defaultRadius) { if ((Object)(object)sign == (Object)null) { return defaultRadius; } ZNetView component = ((Component)sign).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return defaultRadius; } return component.GetZDO().GetFloat("ToriiRadius", defaultRadius); } public static void SetStoredRadius(this Sign sign, float radius) { if (!((Object)(object)sign == (Object)null)) { ZNetView component = ((Component)sign).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { component.ClaimOwnership(); component.GetZDO().Set("ToriiRadius", radius); } } } public static string GetStoredSong(this Sign sign, string defaultSong) { if ((Object)(object)sign == (Object)null) { return defaultSong; } ZNetView component = ((Component)sign).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return defaultSong; } return component.GetZDO().GetString("ToriiSong", defaultSong); } public static void SetStoredSong(this Sign sign, string song) { if (!((Object)(object)sign == (Object)null)) { ZNetView component = ((Component)sign).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid()) { component.ClaimOwnership(); component.GetZDO().Set("ToriiSong", song); } } } } public class SignRadiusMarker : MonoBehaviour { private GameObject _markerInstance; private CircleProjector _projector; private Piece _piece; private Sign _sign; private void Start() { _piece = ((Component)this).GetComponent<Piece>(); _sign = ((Component)this).GetComponent<Sign>(); ((MonoBehaviour)this).StartCoroutine(SetupMarkerRoutine()); } private IEnumerator SetupMarkerRoutine() { while ((Object)(object)ZNetScene.instance == (Object)null) { yield return null; } GameObject workbench = ZNetScene.instance.GetPrefab("piece_workbench"); if (!((Object)(object)workbench != (Object)null)) { yield break; } CraftingStation station = workbench.GetComponent<CraftingStation>(); if ((Object)(object)station != (Object)null && (Object)(object)station.m_areaMarker != (Object)null) { _markerInstance = Object.Instantiate<GameObject>(station.m_areaMarker, ((Component)this).transform.position, Quaternion.identity, ((Component)this).transform); _markerInstance.SetActive(false); _projector = _markerInstance.GetComponent<CircleProjector>(); Renderer rend = _markerInstance.GetComponentInChildren<Renderer>(); if ((Object)(object)rend != (Object)null) { rend.material = new Material(rend.sharedMaterial); } } } private void Update() { if ((Object)(object)_markerInstance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)_piece == (Object)null) { return; } bool flag = false; if (_piece.GetCreator() == Player.m_localPlayer.GetPlayerID() && ((Character)Player.m_localPlayer).InPlaceMode()) { flag = true; } if (_markerInstance.activeSelf != flag) { _markerInstance.SetActive(flag); } if (flag && (Object)(object)_projector != (Object)null && (Object)(object)_sign != (Object)null) { float storedRadius = _sign.GetStoredRadius(ToriiTracksPlugin.BaseRadiusConfig.Value); if (Mathf.Abs(_projector.m_radius - storedRadius) > 0.01f) { _projector.m_radius = storedRadius; _projector.m_nrOfSegments = Mathf.Max(20, Mathf.RoundToInt(storedRadius * 4f)); _markerInstance.SetActive(false); _markerInstance.SetActive(true); } } } } [HarmonyPatch(typeof(Sign), "Awake")] public static class SignAwakePatch { public static void Postfix(Sign __instance) { if (!ToriiTracksPlugin.AllSigns.Contains(__instance)) { ToriiTracksPlugin.AllSigns.Add(__instance); if ((Object)(object)((Component)__instance).gameObject.GetComponent<SignRadiusMarker>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<SignRadiusMarker>(); } } } } [HarmonyPatch(typeof(Sign), "GetHoverText")] public static class SignHoverTextPatch { public static void Postfix(Sign __instance, ref string __result) { if (!((Object)(object)__instance == (Object)null) && !((Object)(object)Player.m_localPlayer == (Object)null)) { Piece component = ((Component)__instance).GetComponent<Piece>(); if ((Object)(object)component != (Object)null && component.GetCreator() == Player.m_localPlayer.GetPlayerID()) { __result += "\n[<color=yellow>LeftAlt + E</color>] Configure Torii Track"; } } } } [HarmonyPatch(typeof(MusicMan), "Update")] public static class MusicManUpdatePatch { public static void Postfix(MusicMan __instance) { if ((Object)(object)ToriiTracksPlugin.Instance != (Object)null && ToriiTracksPlugin.Instance.vanillaMusicMultiplier < 1f) { AudioSource value = Traverse.Create((object)__instance).Field("m_musicSource").GetValue<AudioSource>(); if ((Object)(object)value != (Object)null) { value.volume *= ToriiTracksPlugin.Instance.vanillaMusicMultiplier; } } } } [HarmonyPatch(typeof(RandEventSystem), "SetRandomEventByName", new Type[] { typeof(string), typeof(Vector3) })] public static class RandEventSystemRaidPatch { public static bool SkipNextPatch; public static bool Prefix(RandEventSystem __instance, string name, Vector3 pos) { //IL_0064: Unknown result type (might be due to invalid IL or missing references) if (SkipNextPatch) { SkipNextPatch = false; return true; } if (ToriiTracksPlugin.EnableRaidWarningsConfig != null && !ToriiTracksPlugin.EnableRaidWarningsConfig.Value) { return true; } if ((Object)(object)ToriiTracksPlugin.Instance == (Object)null) { return true; } if (ToriiTracksPlugin.Instance.isHandlingHornRaid) { return true; } ToriiTracksPlugin.Instance.HandleDelayedRaid(__instance, name, pos); return false; } } [HarmonyPatch(typeof(Game), "SleepStart")] public static class GameSleepStartPatch { public static void Postfix() { if ((Object)(object)ToriiTracksPlugin.Instance != (Object)null) { ToriiTracksPlugin.Instance.OnSleepStart(); } } } [HarmonyPatch(typeof(Game), "SleepStop")] public static class GameSleepStopPatch { public static void Postfix() { if ((Object)(object)ToriiTracksPlugin.Instance != (Object)null) { ToriiTracksPlugin.Instance.OnSleepStop(); } } }