using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using CpasSorcierShipMod.Properties;
using HarmonyLib;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("CpasSorcierShipMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CpasSorcierShipMod")]
[assembly: AssemblyCopyright("Copyright © 2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("30DF3888-6E13-4F0E-B639-7A5CB495E8FB")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CpasSorcierShipMod.Properties
{
[GeneratedCode("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[DebuggerNonUserCode]
[CompilerGenerated]
internal class Resources
{
private static ResourceManager resourceMan;
private static CultureInfo resourceCulture;
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static ResourceManager ResourceManager
{
get
{
if (resourceMan == null)
{
resourceMan = new ResourceManager("CpasSorcierShipMod.Properties.Resources", typeof(Resources).Assembly);
}
return resourceMan;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
internal static CultureInfo Culture
{
get
{
return resourceCulture;
}
set
{
resourceCulture = value;
}
}
internal static byte[] CPasSorcierAssetBundle => (byte[])ResourceManager.GetObject("CPasSorcierAssetBundle", resourceCulture);
internal Resources()
{
}
}
}
namespace CPasSorcierShipMod
{
[BepInPlugin("BlueWidge_CPasSorcierShipMod", "CPasSorcierShip", "1.0.4")]
public class CPasSorcierShipModHandler : BaseUnityPlugin
{
[HarmonyPatch(typeof(StartOfRound))]
internal class StartOfRoundPatch
{
private static bool m_isLanding;
[HarmonyPatch("StartGame")]
[HarmonyPostfix]
private static void PlayAllezMarcelStartGame()
{
((MonoBehaviour)StartOfRound.Instance).StartCoroutine(PlayAllezMarcel());
}
[HarmonyPatch("ChangeLevelClientRpc")]
[HarmonyPostfix]
private static void PlayAllezMarcelChangeLevel()
{
((MonoBehaviour)StartOfRound.Instance).StartCoroutine(WaitForChangingLevelConfirmation());
}
private static IEnumerator PlayAllezMarcel()
{
if (!Object.op_Implicit((Object)(object)_speakerAudioSource))
{
_speakerAudioSource = StartOfRound.Instance.speakerAudioSource;
if (!Object.op_Implicit((Object)(object)_speakerAudioSource))
{
((BaseUnityPlugin)_instance).Logger.LogError((object)"Couldn't retrieve speaker audiosource in PlayAllezMarcelPatch");
yield break;
}
}
if (!((Object)(object)_speakerAudioSource.clip == (Object)(object)_AllezMarcelAudioClip))
{
_speakerAudioSource.clip = _AllezMarcelAudioClip;
_speakerAudioSource.Play();
((BaseUnityPlugin)_instance).Logger.LogInfo((object)"Playing _AllezMarcelAudioClip");
yield return (object)new WaitUntil((Func<bool>)(() => m_isLanding || _speakerAudioSource.time >= _AllezMarcelAudioClip.length - FadeDuration));
if (!m_isLanding)
{
float volume = _speakerAudioSource.volume;
((BaseUnityPlugin)_instance).Logger.LogInfo((object)"Calling fade out in PlayAllezMarcel");
((MonoBehaviour)StartOfRound.Instance).StartCoroutine(FadeOut(volume));
}
}
}
private static IEnumerator WaitForChangingLevelConfirmation()
{
yield return (object)new WaitUntil((Func<bool>)(() => StartOfRound.Instance.travellingToNewLevel));
((MonoBehaviour)StartOfRound.Instance).StartCoroutine(PlayAllezMarcel());
}
[HarmonyPatch("openingDoorsSequence")]
[HarmonyPostfix]
private static void PlayTruckBrakeSound()
{
((MonoBehaviour)StartOfRound.Instance).StartCoroutine(WaitUntilLanding());
}
private static IEnumerator WaitUntilLanding()
{
yield return (object)new WaitForSeconds(2f);
yield return (object)new WaitUntil((Func<bool>)(() => ((Component)StartOfRound.Instance.shipAnimator).transform.position.x < 20f));
if (!Object.op_Implicit((Object)(object)_speakerAudioSource))
{
_speakerAudioSource = StartOfRound.Instance.speakerAudioSource;
if (!Object.op_Implicit((Object)(object)_speakerAudioSource))
{
((BaseUnityPlugin)_instance).Logger.LogError((object)"Couldn't retrieve speaker audiosource in PlayTruckBrakeSound");
yield break;
}
}
((MonoBehaviour)StartOfRound.Instance).StartCoroutine(FadeFromMarcelToLanding());
}
private static IEnumerator FadeFromMarcelToLanding()
{
m_isLanding = true;
float startingVolume = _speakerAudioSource.volume;
yield return ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(FadeOut(startingVolume));
_speakerAudioSource.Stop();
_speakerAudioSource.clip = _LandingAudioClip;
_speakerAudioSource.Play();
((BaseUnityPlugin)_instance).Logger.LogInfo((object)"Playing _LandingAudioClip");
yield return ((MonoBehaviour)StartOfRound.Instance).StartCoroutine(FadeIn(startingVolume));
yield return (object)new WaitUntil((Func<bool>)(() => !_speakerAudioSource.isPlaying));
_speakerAudioSource.PlayOneShot(StartOfRound.Instance.disableSpeakerSFX);
}
}
private const string _modGUID = "BlueWidge_CPasSorcierShipMod";
private const string _modName = "CPasSorcierShip";
private const string _modVersion = "1.0.4";
private readonly Harmony _harmony = new Harmony("BlueWidge_CPasSorcierShipMod");
private static CPasSorcierShipModHandler _instance;
private static AudioClip _AllezMarcelAudioClip;
private static AudioClip _LandingAudioClip;
private static AudioSource _speakerAudioSource;
private static readonly float FadeDuration = 2f;
private void Awake()
{
if ((Object)(object)_instance == (Object)null)
{
_instance = this;
}
_harmony.PatchAll(typeof(CPasSorcierShipModHandler));
_harmony.PatchAll(typeof(StartOfRoundPatch));
AssetBundle val = AssetBundle.LoadFromMemory(Resources.CPasSorcierAssetBundle);
if (!Object.op_Implicit((Object)(object)val))
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Couldn't retrieve CPasSorcierAssetBundle");
((Behaviour)this).enabled = false;
return;
}
_AllezMarcelAudioClip = val.LoadAsset<AudioClip>("Assets/Resources/AllezMarcel.mp3");
_LandingAudioClip = val.LoadAsset<AudioClip>("Assets/Resources/Landing.mp3");
if (!Object.op_Implicit((Object)(object)_AllezMarcelAudioClip) || !Object.op_Implicit((Object)(object)_LandingAudioClip) || !_AllezMarcelAudioClip.LoadAudioData() || !_LandingAudioClip.LoadAudioData())
{
((BaseUnityPlugin)this).Logger.LogInfo((object)"Couldn't retrieve all audio clips");
((Behaviour)this).enabled = false;
}
((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded CPasSorcierShip");
}
private static IEnumerator FadeIn(float p_startingVolume)
{
float startTime = Time.time;
while (_speakerAudioSource.volume < p_startingVolume)
{
((BaseUnityPlugin)_instance).Logger.LogInfo((object)("Current volume in FadeIn : " + _speakerAudioSource.volume));
float volume = Mathf.Clamp01((Time.time - startTime) / FadeDuration);
_speakerAudioSource.volume = volume;
yield return null;
}
_speakerAudioSource.volume = p_startingVolume;
}
private static IEnumerator FadeOut(float p_startingVolume)
{
float startTime = Time.time;
while (_speakerAudioSource.volume > 0f)
{
float num = Mathf.Clamp01((Time.time - startTime) / FadeDuration);
_speakerAudioSource.volume = p_startingVolume - num;
yield return null;
}
_speakerAudioSource.volume = 0f;
}
}
}