using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; 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: AssemblyTitle("OubliePasDeSaveClaire")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OubliePasDeSaveClaire")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("77a55fef-6f54-446e-9151-1de85d4bc283")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace OubliePasDeSaveClaire; [BepInPlugin("Xelan.OubliePasDeSaveClaire", "OubliePasDeSaveClaire", "1.0.0")] public class OubliePasDeSaveClaire : BaseUnityPlugin { private const string modGUID = "Xelan.OubliePasDeSaveClaire"; private const string modName = "OubliePasDeSaveClaire"; private const string modVersion = "1.0.0"; private readonly Harmony harmony = new Harmony("Xelan.OubliePasDeSaveClaire"); private static OubliePasDeSaveClaire Instance; public static ManualLogSource mls; public static ConfigEntry SaveReminder; public static ConfigEntry LoadReminder; public static ConfigEntry Pourcentage; public static AudioClip saveSound; public static AudioClip savePasSound; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("Xelan.OubliePasDeSaveClaire"); LoadConfig(); LoadAssets(); harmony.PatchAll(); mls.LogInfo((object)"╔═══════════════════════════════════════════════╗"); mls.LogInfo((object)"║ OubliePasDeSaveClaire is UP ! ║"); mls.LogInfo((object)"╚═══════════════════════════════════════════════╝"); } private void LoadConfig() { SaveReminder = ((BaseUnityPlugin)this).Config.Bind("Message", "SaveReminder", "CLAAAAIIIIRREE faut SAAAAVE", "Phrase pour ne pas oublier de save"); LoadReminder = ((BaseUnityPlugin)this).Config.Bind("Message", "LoadReminder", "CLAAAAIIIIRREE faut Loooaaad", "Phrase pour dire qu'il faut re-load"); Pourcentage = ((BaseUnityPlugin)this).Config.Bind("Message", "Pourcentage", 75, "Pourcentage à partir duquel il faut Load"); } private void LoadAssets() { string location = ((BaseUnityPlugin)Instance).Info.Location; string text = "OubliePasDeSaveClaire.dll"; string text2 = location.TrimEnd(text.ToCharArray()); string text3 = text2 + "savesound"; AssetBundle val = AssetBundle.LoadFromFile(text3); if (val == null) { mls.LogError((object)"Impossible de charger le son :'("); return; } saveSound = val.LoadAsset("assets/audio/saveclaire.wav"); savePasSound = val.LoadAsset("assets/audio/savepasclaire.wav"); } public static void DisplayTip(string title, string msg, bool isWarning = false) { HUDManager.Instance.DisplayTip(title, msg, isWarning, false, "LC_Tip1"); } } [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("EndOfGame")] [HarmonyPostfix] public static void EndOfGame_Postfix(StartOfRound __instance, int scrapCollected) { if (__instance != null && ((NetworkBehaviour)__instance).IsHost) { int correctPourcentage = getCorrectPourcentage(); float totalScrapValueInLevel = RoundManager.Instance.totalScrapValueInLevel; float num = scrapCollected; float waitingTime = 18f; bool shouldISave; if (RoundManager.Instance.currentLevel.sceneName == "CompanyBuilding") { shouldISave = TimeOfDay.Instance.timeUntilDeadline > 0f || TimeOfDay.Instance.profitQuota - TimeOfDay.Instance.quotaFulfilled <= 0; waitingTime = 5f; } else { shouldISave = num / totalScrapValueInLevel * 100f >= (float)correctPourcentage; } ((MonoBehaviour)__instance).StartCoroutine(DisplayAndPlayReminder(shouldISave, waitingTime)); } } private static int getCorrectPourcentage() { int value = OubliePasDeSaveClaire.Pourcentage.Value; if (value < 0) { return 0; } if (value > 100) { return 100; } return value; } private static IEnumerator DisplayAndPlayReminder(bool shouldISave, float waitingTime) { yield return (object)new WaitForSeconds(waitingTime); AudioSource speaker = StartOfRound.Instance.speakerAudioSource; if (speaker == null) { yield break; } if (shouldISave) { OubliePasDeSaveClaire.DisplayTip("Lobby save \ud83d\ude0e", OubliePasDeSaveClaire.SaveReminder.Value); if ((Object)(object)OubliePasDeSaveClaire.saveSound != (Object)null) { speaker.PlayOneShot(OubliePasDeSaveClaire.saveSound); } } else { OubliePasDeSaveClaire.DisplayTip("Lobby load :'(", OubliePasDeSaveClaire.LoadReminder.Value); if ((Object)(object)OubliePasDeSaveClaire.savePasSound != (Object)null) { speaker.PlayOneShot(OubliePasDeSaveClaire.savePasSound); } } } }