using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppTMPro;
using Il2CppVolumetricAudio;
using Il2Cppmadeinfairyland.fairyengine;
using Il2Cppmadeinfairyland.forsakenfrontiers.actor.player.datadeck;
using Il2Cppmadeinfairyland.forsakenfrontiers.train;
using Il2Cppmadeinfairyland.forsakenfrontiers.ui.PauseMenu.OptionsMenu.Audio;
using MelonLoader;
using Microsoft.CodeAnalysis;
using TrainVolumeSlider;
using TrainVolumeSlider.Patches;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "TrainVolumeSlider", "0.0.0", "Adi", null)]
[assembly: MelonGame("made in fairyland", "Forsaken Frontiers")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("TrainVolumeSlider")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TrainVolumeSlider")]
[assembly: AssemblyTitle("TrainVolumeSlider")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.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.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace TrainVolumeSlider
{
public class Core : MelonMod
{
public override void OnInitializeMelon()
{
((MelonBase)this).HarmonyInstance.PatchAll(typeof(FFMasterVolumeSliderPatches));
((MelonBase)this).LoggerInstance.Msg("Initialized.");
}
}
[RegisterTypeInIl2Cpp]
public class TrainVolumeSlider : MonoBehaviour
{
private VA_AudioSource[] audioSources;
private Slider volumeSlider;
private Action<bool> actionOnToggleDataDeck;
public void OnVolumeChanged(float volume)
{
VA_AudioSource[] array = audioSources;
for (int i = 0; i < array.Length; i++)
{
array[i].baseVolume = volume;
}
PlayerPrefs.SetFloat("TrainBackgroundVolume", volume);
PlayerPrefs.Save();
}
public void OnToggleDataDeck(bool toggled)
{
}
public IEnumerator WaitTillHookToPlayer()
{
yield return (object)new WaitUntil(Func<bool>.op_Implicit((Func<bool>)(() => (Object)(object)FairyEngine.LocalPlayer != (Object)null)));
((Component)FairyEngine.LocalPlayer).GetComponentInChildren<FFDataDeck>().EvtOnToggledDataDeck += Action<bool>.op_Implicit(actionOnToggleDataDeck);
audioSources = Il2CppArrayBase<VA_AudioSource>.op_Implicit(((Component)FFTrain.Instance).GetComponentsInChildren<VA_AudioSource>());
float @float = PlayerPrefs.GetFloat("TrainBackgroundVolume", 0.37f);
volumeSlider.value = @float;
OnVolumeChanged(@float);
}
public static TrainVolumeSlider CreateSlider(GameObject reference)
{
GameObject obj = Object.Instantiate<GameObject>(reference);
((Object)obj.transform).name = "Train Volume Slider";
obj.transform.SetParent(reference.transform.parent, false);
obj.transform.SetAsLastSibling();
((TMP_Text)obj.GetComponentInChildren<TextMeshProUGUI>()).text = "train";
Object.Destroy((Object)(object)obj.GetComponent<FFMasterVolumeSlider>());
Slider component = obj.GetComponent<Slider>();
((UnityEventBase)component.onValueChanged).RemoveAllListeners();
TrainVolumeSlider trainVolumeSlider = obj.AddComponent<TrainVolumeSlider>();
((UnityEvent<float>)(object)component.onValueChanged).AddListener(UnityAction<float>.op_Implicit((Action<float>)trainVolumeSlider.OnVolumeChanged));
trainVolumeSlider.volumeSlider = component;
return trainVolumeSlider;
}
public void Start()
{
actionOnToggleDataDeck = OnToggleDataDeck;
MelonCoroutines.Start(WaitTillHookToPlayer());
}
public void OnDestroy()
{
((Component)FairyEngine.LocalPlayer).GetComponentInChildren<FFDataDeck>().EvtOnToggledDataDeck -= Action<bool>.op_Implicit(actionOnToggleDataDeck);
}
public TrainVolumeSlider(IntPtr ptr)
: base(ptr)
{
}
}
}
namespace TrainVolumeSlider.Patches
{
internal class FFMasterVolumeSliderPatches
{
[HarmonyPatch(typeof(FFMasterVolumeSlider), "Start")]
[HarmonyPrefix]
private static void FFMasterVolumeSliderStartPrefix(FFMasterVolumeSlider __instance)
{
TrainVolumeSlider.CreateSlider(((Component)__instance).gameObject);
}
}
}