Decompiled source of PapersPleasePlus v1.0.0
plugins/PapersPleasePlus.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; 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 System.Security; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.Unity.IL2CPP; using HarmonyLib; using Il2CppInterop.Runtime.InteropTypes; using Il2CppInterop.Runtime.InteropTypes.Arrays; using Il2CppSystem; using Microsoft.CodeAnalysis; using PapersPleasePlus.Core; using PapersPleasePlus.Gameplay; using PapersPleasePlus.Interface; using PapersPleasePlus.Triche; using UnityEngine; using app; using app.aud; using app.ent; using app.vis; using data; using data.loc; using haxe.ds; using haxe.io; using play; using play.day; using play.day.booth; using play.night; using play.night.ent; using play.screen; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")] [assembly: AssemblyCompany("PapersPleasePlus")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("PapersPleasePlus")] [assembly: AssemblyTitle("PapersPleasePlus")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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 PapersPleasePlus { public enum CitationMode { Normal, SansAmende, Aucune } internal static class ModConfig { private const string Triche = "Triche"; private const string Gameplay = "Gameplay"; private const string Interface = "Interface"; public static ConfigEntry<KeyCode> ToucheMenu; public static ConfigEntry<bool> FamilleJamaisMalade; public static ConfigEntry<CitationMode> ModeCitations; public static ConfigEntry<float> DelaiDisparitionCitation; public static ConfigEntry<bool> RemettreCompteurCitationsAZero; public static ConfigEntry<bool> GelHorlogeInspection; public static ConfigEntry<float> VitesseHorlogeInspection; public static ConfigEntry<int> LimiteEntrants; public static ConfigEntry<KeyCode> ToucheFinDeJournee; public static ConfigEntry<bool> AmeliorationsAToutMoment; public static ConfigEntry<int> AmeliorationsPremierSoir; public static ConfigEntry<int> PrixInspection; public static ConfigEntry<int> PrixTampons; public static ConfigEntry<int> PrixReglement; public static ConfigEntry<int> PrixDoubleClic; public static ConfigEntry<int> PrixNormal; public static ConfigEntry<int> PrixBlocNotes; public static ConfigEntry<bool> HistoireJorji; public static void Init(ConfigFile cfg) { //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Expected O, but got Unknown //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Expected O, but got Unknown FamilleJamaisMalade = cfg.Bind<bool>("Triche", "FamilleJamaisMalade", false, "La famille ne tombe jamais malade (et les malades sont guéris chaque soir)."); ModeCitations = cfg.Bind<CitationMode>("Triche", "ModeCitations", CitationMode.Normal, "Normal = jeu d'origine. SansAmende = la citation s'imprime mais ne coûte rien. Aucune = la citation s'imprime puis disparaît et ne compte pas dans le bilan de la journée."); DelaiDisparitionCitation = cfg.Bind<float>("Triche", "DelaiDisparitionCitation", 6f, new ConfigDescription("Mode Aucune : nombre de secondes avant que la citation disparaisse du bureau.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>())); RemettreCompteurCitationsAZero = cfg.Bind<bool>("Triche", "RemettreCompteurCitationsAZero", false, "Action ponctuelle : remet à 0 le total de citations de la partie en cours (celui qui décide du cadre excellence / suffisance / présence) au début de la prochaine journée, puis se remet tout seul sur false. Modifie la sauvegarde."); GelHorlogeInspection = cfg.Bind<bool>("Triche", "GelHorlogeInspection", false, "L'heure de service ne s'écoule plus pendant qu'un entrant est dans la cabine. Dialogues, animations et événements continuent normalement."); VitesseHorlogeInspection = cfg.Bind<float>("Triche", "VitesseHorlogeInspection", 0f, new ConfigDescription("Vitesse de l'horloge pendant l'inspection quand le gel est actif. 0 = arrêt complet, 0.25 = quatre fois plus lent, 1 = normal.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); LimiteEntrants = cfg.Bind<int>("Triche", "LimiteEntrants", 0, new ConfigDescription("Termine la journée après ce nombre d'entrants (0 = pas de limite). Ne descend jamais sous le minimum imposé par le jeu pour la journée.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 200), Array.Empty<object>())); ToucheFinDeJournee = cfg.Bind<KeyCode>("Triche", "ToucheFinDeJournee", (KeyCode)289, "Touche pour terminer la journée (si le minimum d'entrants du jour n'est pas atteint, la fin est programmée pour ce moment-là ; rappuyer annule). None = désactivé."); InitGameplay(cfg); InitContent(cfg); ToucheMenu = cfg.Bind<KeyCode>("Interface", "ToucheMenu", (KeyCode)290, "Touche pour ouvrir / fermer le panneau du mod dans le jeu (la touche ² fonctionne toujours en plus)."); } private static void InitGameplay(ConfigFile cfg) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: Expected O, but got Unknown //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Expected O, but got Unknown //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Expected O, but got Unknown AmeliorationsAToutMoment = cfg.Bind<bool>("Gameplay", "AmeliorationsAToutMoment", false, "Toutes les améliorations de cabine non possédées sont proposées chaque soir dans le bilan, sans attendre leur jour normal. Achetée en avance, une amélioration coûte son prix fixe (plus cher si elle arrive tard dans l'histoire) ; à partir de son soir normal, elle coûte PrixNormal."); AmeliorationsPremierSoir = cfg.Bind<int>("Gameplay", "AmeliorationsPremierSoir", 1, new ConfigDescription("Premier soir où les améliorations sont proposées (1 = dès la fin du jour 1).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 30), Array.Empty<object>())); AcceptableValueRange<int> val = new AcceptableValueRange<int>(0, 500); PrixInspection = cfg.Bind<int>("Gameplay", "PrixInspection", 15, new ConfigDescription("Prix de la touche ESPACE (inspection) achetée avant son soir normal (5).", (AcceptableValueBase)(object)val, Array.Empty<object>())); PrixTampons = cfg.Bind<int>("Gameplay", "PrixTampons", 25, new ConfigDescription("Prix de la touche TAB (tampons) achetée avant son soir normal (8).", (AcceptableValueBase)(object)val, Array.Empty<object>())); PrixReglement = cfg.Bind<int>("Gameplay", "PrixReglement", 35, new ConfigDescription("Prix des onglets du règlement achetés avant leur soir normal (11).", (AcceptableValueBase)(object)val, Array.Empty<object>())); PrixDoubleClic = cfg.Bind<int>("Gameplay", "PrixDoubleClic", 45, new ConfigDescription("Prix du double-clic (inspection rapide) acheté avant son soir normal (14).", (AcceptableValueBase)(object)val, Array.Empty<object>())); PrixBlocNotes = cfg.Bind<int>("Gameplay", "PrixBlocNotes", 40, new ConfigDescription("Prix de l'amélioration du mod « Bloc-notes » (clic droit en mode inspection pour noter).", (AcceptableValueBase)(object)val, Array.Empty<object>())); PrixNormal = cfg.Bind<int>("Gameplay", "PrixNormal", 5, new ConfigDescription("Prix à partir du soir normal de l'amélioration (5 comme dans le jeu d'origine).", (AcceptableValueBase)(object)val, Array.Empty<object>())); } private static void InitContent(ConfigFile cfg) { HistoireJorji = cfg.Bind<bool>("Gameplay", "HistoireJorji", true, "Histoire « Le pacte de Jorji » : coopérer avec le trafic de drogue de Jorji (jours 19 à 31). Prise en compte au prochain lancement du jeu."); } public static void LogSummary() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Expected O, but got Unknown //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_00f6: Unknown result type (might be due to invalid IL or missing references) ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Triche] Famille jamais malade : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(FamilleJamaisMalade.Value); } logger.LogInfo(val); val = new BepInExInfoLogInterpolatedStringHandler(21, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Triche] Citations : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<CitationMode>(ModeCitations.Value); } logger.LogInfo(val); val = new BepInExInfoLogInterpolatedStringHandler(34, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Triche] Gel horloge : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(GelHorlogeInspection.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (vitesse "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(VitesseHorlogeInspection.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } logger.LogInfo(val); val = new BepInExInfoLogInterpolatedStringHandler(49, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Triche] Limite d'entrants : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(LimiteEntrants.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" | Fin de journée : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<KeyCode>(ToucheFinDeJournee.Value); } logger.LogInfo(val); val = new BepInExInfoLogInterpolatedStringHandler(87, 7, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Gameplay] Améliorations à tout moment : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(AmeliorationsAToutMoment.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("(dès le soir "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(AmeliorationsPremierSoir.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ; prix en avance "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(PrixInspection.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(PrixTampons.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(PrixReglement.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(PrixDoubleClic.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", ensuite "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(PrixNormal.Value); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } logger.LogInfo(val); } } [BepInPlugin("thomas.paperspleaseplus", "Papers Please Plus", "1.0.0")] public class Plugin : BasePlugin { public const string Guid = "thomas.paperspleaseplus"; public const string Name = "Papers Please Plus"; public const string Version = "1.0.0"; internal static ManualLogSource Logger; public override void Load() { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Expected O, but got Unknown Logger = ((BasePlugin)this).Log; ModConfig.Init(((BasePlugin)this).Config); new Harmony("thomas.paperspleaseplus").PatchAll(typeof(Plugin).Assembly); try { ((BasePlugin)this).AddComponent<ModMenu>(); Logger.LogInfo((object)("[Interface] Panneau installé (touche " + ((object)ModConfig.ToucheMenu.Value/*cast due to .constrained prefix*/).ToString() + ").")); } catch (Exception ex) { Logger.LogError((object)("[Interface] Impossible d'installer le panneau : " + ex)); } ManualLogSource logger = Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(9, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Papers Please Plus"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" chargé."); } logger.LogInfo(val); ModConfig.LogSummary(); } } } namespace PapersPleasePlus.Triche { [HarmonyPatch] internal static class CitationsPatches { private static CitationMode Mode => ModConfig.ModeCitations.Value; [HarmonyPatch(typeof(Day), "addCitation")] [HarmonyPrefix] private static void BeforeAddCitation(Day __instance) { if (Mode == CitationMode.Aucune) { GameState.RemoveCitationPapers(); Array citations = __instance.citations; if (citations != null && citations.length > 0) { citations.splice(0, citations.length); } } } [HarmonyPatch(typeof(Day), "addCitation")] [HarmonyPostfix] private static void AfterAddCitation(Citation __result, string __0) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(38, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Citations] Citation du jeu (mode "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<CitationMode>(Mode); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(__0); } logger.LogInfo(val); if (__result != null) { if (Mode == CitationMode.SansAmende || Mode == CitationMode.Aucune) { __result.penaltyCost = 0; } if (Mode == CitationMode.Aucune) { GameState.CitationRemoveAt = Time.realtimeSinceStartup + ModConfig.DelaiDisparitionCitation.Value; } } } [HarmonyPatch(typeof(StoryState), "incStat")] [HarmonyPrefix] private static bool StoryIncStat(string __0) { return !ShouldBlockStat(__0); } [HarmonyPatch(typeof(Day), "incStat")] [HarmonyPrefix] private static bool DayIncStat(string __0) { return !ShouldBlockStat(__0); } [HarmonyPatch(typeof(FactSet), "incInt")] [HarmonyPrefix] private static bool FactIncInt(string __0) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Expected O, but got Unknown if (!ShouldBlockStat(__0)) { return true; } ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(55, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Citations] Compteur « "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(__0); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" » non incrémenté (mode Aucune)."); } logger.LogInfo(val); return false; } private static bool ShouldBlockStat(string key) { if (Mode == CitationMode.Aucune && key != null) { return key.IndexOf("NumCitations", StringComparison.Ordinal) >= 0; } return false; } [HarmonyPatch(typeof(Day), "get_penaltyCost")] [HarmonyPostfix] private static void NoPenaltyCost(ref int __result) { if (Mode != CitationMode.Normal) { __result = 0; } } [HarmonyPatch(typeof(Day), "get_numPenalties")] [HarmonyPostfix] private static void NoPenalties(ref int __result) { if (Mode != CitationMode.Normal) { __result = 0; } } [HarmonyPatch(typeof(Day), "getSummary")] [HarmonyPrefix] private static void BeforeSummary(Day __instance) { if (Mode == CitationMode.Aucune) { Array citations = __instance.citations; if (citations != null && citations.length > 0) { citations.splice(0, citations.length); } } } } [HarmonyPatch] internal static class FamillePatches { private static bool Active => ModConfig.FamilleJamaisMalade.Value; [HarmonyPatch(typeof(FamilyMember), "updateSickness")] [HarmonyPrefix] private static bool BlockSickness() { return !Active; } [HarmonyPatch(typeof(FamilyMember), "get_isSick")] [HarmonyPostfix] private static void NotSick(ref bool __result) { if (Active) { __result = false; } } [HarmonyPatch(typeof(FamilyMember), "get_isVerySick")] [HarmonyPostfix] private static void NotVerySick(ref bool __result) { if (Active) { __result = false; } } [HarmonyPatch(typeof(Family), "applyBudget")] [HarmonyPostfix] private static void AfterBudget(Family __instance) { Heal(__instance); } [HarmonyPatch(typeof(Family), "applyEvent")] [HarmonyPostfix] private static void AfterEvent(Family __instance) { Heal(__instance); } [HarmonyPatch(typeof(Family), "applyOp")] [HarmonyPostfix] private static void AfterOp(Family __instance) { Heal(__instance); } private static void Heal(Family family) { if (!Active || family == null) { return; } Array members = family.members; if (members == null) { return; } for (int i = 0; i < members.length; i++) { Object obj = members.__get(i); FamilyMember obj2 = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<FamilyMember>() : null); Stat val = ((obj2 != null) ? obj2.sick : null); if (val != null && val.val != 0) { val.val = 0; } } } } internal static class Horloge { public static double Offset; public static IntPtr ClockPtr = IntPtr.Zero; private static bool _wasFrozen; private static double _lastEffective = double.NaN; public static bool PlayingOurBell; private static bool _bellPlayed; private const double MaxNaturalStep = 1.0; public static bool Frozen { get { if (_wasFrozen && GameState.InDay) { return ModConfig.GelHorlogeInspection.Value; } return false; } } public static double EffectiveTime(Clock clock) { return RawTime(clock) - Offset; } public static double RawTime(Clock clock) { return clock.sysCurTime - clock.sysStartTime; } public static void OnClockUpdated(Clock clock, double rawBefore) { Booth currentBooth = GameState.CurrentBooth; if (currentBooth == null) { return; } Clock boothClock; try { boothClock = currentBooth.boothClock; } catch (Exception) { GameState.CurrentBooth = null; return; } if (boothClock == null || ((Il2CppObjectBase)boothClock).Pointer != ((Il2CppObjectBase)clock).Pointer) { return; } if (ClockPtr != ((Il2CppObjectBase)clock).Pointer) { ClockPtr = ((Il2CppObjectBase)clock).Pointer; Offset = 0.0; _wasFrozen = false; _lastEffective = double.NaN; _bellPlayed = false; GameState.EndDayRequested = false; } Day day = currentBooth.day; if (!GameState.IsStoryDay(day)) { Offset = 0.0; return; } double num = GameState.DayEndTime(day); double num2 = RawTime(clock); double num3 = num2 - Offset; if (Offset != 0.0 && !_bellPlayed && _lastEffective < num && num3 >= num) { _bellPlayed = true; PlayBell(currentBooth); } _lastEffective = num3; bool flag = currentBooth.engine != null && currentBooth.engine.numTravelers >= day.minTravelers; if ((GameState.EndDayRequested && flag) || LimitReached(currentBooth, day)) { GameState.EndDayRequested = false; if (num3 <= num) { Offset = num2 - (num + 1.0); } } else { if (!ModConfig.GelHorlogeInspection.Value) { return; } double num4 = num2 - rawBefore; if (!(num4 <= 0.0) && !(num4 > 1.0)) { bool flag2 = currentBooth.autoIsWorking(); if (flag2 != _wasFrozen) { _wasFrozen = flag2; Plugin.Logger.LogInfo((object)(flag2 ? "Horloge gelée (inspection en cours)." : "Horloge relancée.")); } if (flag2) { double num5 = ModConfig.VitesseHorlogeInspection.Value; Offset += num4 * (1.0 - num5); } } } } private static void PlayBell(Booth booth) { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown PlayingOurBell = true; try { Trunk trunk = ((Ent)booth).trunk; if (trunk == null) { return; } EntEnv trunkEnv = trunk.trunkEnv; if (trunkEnv != null) { Speaker speaker = trunkEnv.speaker; if (speaker != null) { speaker.play("time-up"); } } } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(18, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Sonnerie de 18h : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } logger.LogWarning(val); } finally { PlayingOurBell = false; } } private static bool LimitReached(Booth booth, Day day) { int value = ModConfig.LimiteEntrants.Value; if (value <= 0) { return false; } BoothEngine engine = booth.engine; if (engine == null) { return false; } return engine.numTravelers >= Math.Max(value, day.minTravelers); } } [HarmonyPatch(typeof(Clock), "update")] internal static class ClockUpdatePatch { private static void Prefix(Clock __instance, out double __state) { __state = Horloge.RawTime(__instance); } private static void Postfix(Clock __instance, double __state) { Horloge.OnClockUpdated(__instance, __state); } } [HarmonyPatch] internal static class ShiftTimePatches { private static void Shift(Booth booth, out double savedStart) { savedStart = double.NaN; if (Horloge.Offset != 0.0 && booth != null) { Clock boothClock = booth.boothClock; if (boothClock != null && !(((Il2CppObjectBase)boothClock).Pointer != Horloge.ClockPtr)) { savedStart = boothClock.sysStartTime; boothClock.sysStartTime = savedStart + Horloge.Offset; } } } private static void Restore(Booth booth, double savedStart) { if (!double.IsNaN(savedStart) && booth != null) { Clock boothClock = booth.boothClock; if (boothClock != null) { boothClock.sysStartTime = savedStart; } } } [HarmonyPatch(typeof(Booth), "get_timeIsUp")] [HarmonyPrefix] private static void BeforeTimeIsUp(Booth __instance, out double __state) { Shift(__instance, out __state); } [HarmonyPatch(typeof(Booth), "get_timeIsUp")] [HarmonyPostfix] private static void AfterTimeIsUp(Booth __instance, double __state) { Restore(__instance, __state); } [HarmonyPatch(typeof(Booth), "isBefore6PM")] [HarmonyPrefix] private static void BeforeIsBefore6PM(Booth __instance, out double __state) { Shift(__instance, out __state); } [HarmonyPatch(typeof(Booth), "isBefore6PM")] [HarmonyPostfix] private static void AfterIsBefore6PM(Booth __instance, double __state) { Restore(__instance, __state); } } [HarmonyPatch(typeof(ConsoleEnt), "set_hour")] internal static class ConsoleHourPatch { private static void Prefix(ConsoleEnt __instance, ref double __0) { if (Horloge.Offset == 0.0) { return; } Booth currentBooth = GameState.CurrentBooth; if (currentBooth == null || currentBooth.consoleEnt == null || ((Il2CppObjectBase)currentBooth.consoleEnt).Pointer != ((Il2CppObjectBase)__instance).Pointer) { return; } Clock boothClock = currentBooth.boothClock; Day day = currentBooth.day; if (boothClock != null && !(((Il2CppObjectBase)boothClock).Pointer != Horloge.ClockPtr) && GameState.IsStoryDay(day)) { double num = GameState.DayEndTime(day); if (!(num <= 0.0)) { double val = 6.0 + 12.0 * Horloge.EffectiveTime(boothClock) / num; __0 = Math.Max(6.0, Math.Min(18.0, val)); } } } } [HarmonyPatch(typeof(Speaker), "play")] internal static class TimeUpBellPatch { private static bool Prefix(string __0, ref int __result) { if (Horloge.PlayingOurBell || Horloge.Offset == 0.0 || __0 != "time-up") { return true; } Booth currentBooth = GameState.CurrentBooth; Clock val = ((currentBooth != null) ? currentBooth.boothClock : null); if (val == null || ((Il2CppObjectBase)val).Pointer != Horloge.ClockPtr || !GameState.IsStoryDay(currentBooth.day)) { return true; } __result = 0; return false; } } } namespace PapersPleasePlus.Interface { public struct UiRect { public double X; public double Y; public double W; public double H; public UiRect(double x, double y, double w, double h) { X = x; Y = y; W = w; H = h; } public bool Contains(double px, double py) { if (px >= X && px < X + W && py >= Y) { return py < Y + H; } return false; } } internal sealed class GameUi { public enum Align { Left, Right, Center } private sealed class Slot { public Text Text; public Font Font; public string Str; public uint Color; public uint Bg; public int PadX = -1; public int PadY = -1; } private sealed class RectSlot { public Sprite Sprite; public double W = -1.0; public double H = -1.0; public uint Color = 305419896u; } public const int Layer = 50; private readonly Dictionary<string, Font> _fonts = new Dictionary<string, Font>(); private static readonly Dictionary<string, MethodInfo> _setters = new Dictionary<string, MethodInfo>(); private readonly List<Slot> _pool = new List<Slot>(); private int _next; private Drawer _drawer; public double MouseX = -1.0; public double MouseY = -1.0; private List<(UiRect rect, Action action)> _clicks = new List<(UiRect, Action)>(); private List<(UiRect rect, Action action)> _lastClicks = new List<(UiRect, Action)>(); public double ClipTop = double.MinValue; public double ClipBottom = double.MaxValue; private Text _measure; private Font _measureFont; private readonly List<RectSlot> _rects = new List<RectSlot>(); private int _nextRect; private bool _rectFailed; public Font GetFont(string id) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown if (_fonts.TryGetValue(id, out var value)) { return value; } value = null; bool flag = default(bool); try { StringMap fontDefs = FontLib.fontDefs; object obj; if (fontDefs == null) { obj = null; } else { Object obj2 = fontDefs.get(id); if (obj2 == null) { obj = null; } else { FontDef obj3 = ((Il2CppObjectBase)obj2).TryCast<FontDef>(); obj = ((obj3 != null) ? obj3.font : null); } } value = (Font)obj; } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(26, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Interface] Police « "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(id); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" » : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } logger.LogWarning(val); } if (value == null) { ManualLogSource logger2 = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(36, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Interface] Police « "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(id); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" » introuvable."); } logger2.LogWarning(val); } _fonts[id] = value; return value; } private static void HxSet<T>(T target, string name, object value) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown string text = typeof(T).Name + "." + name; if (!_setters.TryGetValue(text, out var value2)) { value2 = typeof(T).GetMethods(BindingFlags.Instance | BindingFlags.Public).FirstOrDefault((MethodInfo x) => x.Name == "set_" + name && x.ReturnType != typeof(void) && x.GetParameters().Length == 1); _setters[text] = value2; if (value2 == null) { ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(37, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Interface] Setter Haxe "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" introuvable."); } logger.LogWarning(val); } } value2?.Invoke(target, new object[1] { value }); } public bool Hover(UiRect r) { return r.Contains(MouseX, MouseY); } public void HandleClick(double x, double y) { //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown bool flag = default(bool); foreach (var (uiRect, action) in _lastClicks) { if (!uiRect.Contains(x, y)) { continue; } try { action(); break; } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(21, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Interface] Action : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logger.LogError(val); break; } } } public void NoClip() { ClipTop = double.MinValue; ClipBottom = double.MaxValue; } private bool Clipped(double y, double h) { if (!(y < ClipTop)) { return y + h > ClipBottom; } return true; } public void Begin(Drawer drawer) { NoClip(); _drawer = drawer; _next = 0; _nextRect = 0; List<(UiRect, Action)> clicks = _clicks; List<(UiRect, Action)> lastClicks = _lastClicks; _lastClicks = clicks; _clicks = lastClicks; _clicks.Clear(); } public void Skip() { _clicks.Clear(); _lastClicks.Clear(); } public void OnClick(UiRect r, Action action) { if (!Clipped(r.Y, r.H)) { _clicks.Add((r, action)); } } public UiRect Label(double x, double y, string text, Font font, uint color, uint bg = 0u, int padX = 0, int padY = 0, Align align = Align.Left, double boxW = 0.0) { //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Expected O, but got Unknown if (font == null || _drawer == null) { return new UiRect(x, y, 0.0, 0.0); } if (_next == _pool.Count) { _pool.Add(new Slot()); } Slot slot = _pool[_next++]; if (slot.Text == null || slot.Font != font) { slot.Text = new Text(font); ((Visual)slot.Text).layer = 50; slot.Font = font; slot.Str = null; slot.Color = 0u; slot.Bg = 0u; slot.PadX = -1; slot.PadY = -1; } Text text2 = slot.Text; if (slot.PadX != padX) { HxSet<Text>(text2, "paddingX", padX); slot.PadX = padX; } if (slot.PadY != padY) { HxSet<Text>(text2, "paddingY", padY); slot.PadY = padY; } if (slot.Color != color) { HxSet<Text>(text2, "color", color); slot.Color = color; } if (slot.Bg != bg) { HxSet<Text>(text2, "backgroundColor", bg); slot.Bg = bg; } if (slot.Str != text) { HxSet<Text>(text2, "text", text); slot.Str = text; } double num = ((Visual)text2).width(); double h = ((Visual)text2).height(); double num2 = align switch { Align.Right => x - num, Align.Center => x + Math.Round((boxW - num) / 2.0), _ => x, }; if (!Clipped(y, h)) { _drawer.add(new PointData(num2, y), (Visual)(object)text2, (Object)null); } return new UiRect(num2, y, num, h); } public double Measure(string text, Font font, int padX = 0) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown if (font == null) { return 0.0; } if (_measure == null) { _measure = new Text(font); } if (_measureFont != font) { HxSet<Text>(_measure, "font", font); _measureFont = font; } HxSet<Text>(_measure, "paddingX", padX); HxSet<Text>(_measure, "text", text); return ((Visual)_measure).width(); } public void Rect(UiRect r, uint argb) { //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Expected O, but got Unknown //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Expected O, but got Unknown //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Expected O, but got Unknown //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Expected O, but got Unknown //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Expected O, but got Unknown if (_rectFailed || _drawer == null || r.W <= 0.0 || r.H <= 0.0) { return; } try { if (_nextRect == _rects.Count) { Rect val = new Rect((Object)null, (Object)null, (Object)null, (Object)null); val.x = 0.0; val.y = 0.0; val.w = 1.0; val.h = 1.0; Sprite val2 = new Sprite(new PartData(Image.white1x1, val)); ((Visual)val2).layer = 50; _rects.Add(new RectSlot { Sprite = val2 }); } RectSlot rectSlot = _rects[_nextRect++]; if (rectSlot.W != r.W) { HxSet<Sprite>(rectSlot.Sprite, "scaleX", r.W); rectSlot.W = r.W; } if (rectSlot.H != r.H) { HxSet<Sprite>(rectSlot.Sprite, "scaleY", r.H); rectSlot.H = r.H; } if (rectSlot.Color != argb) { ColorData val3 = new ColorData((Object)null, (Object)null, (Object)null, (Object)null); val3.a = (float)((argb >> 24) & 0xFF) / 255f; val3.r = (float)((argb >> 16) & 0xFF) / 255f; val3.g = (float)((argb >> 8) & 0xFF) / 255f; val3.b = (float)(argb & 0xFF) / 255f; HxSet<Sprite>(rectSlot.Sprite, "color", val3); rectSlot.Color = argb; } _drawer.add(new PointData(r.X, r.Y), (Visual)(object)rectSlot.Sprite, (Object)null); } catch (Exception ex) { _rectFailed = true; ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(39, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[Interface] Rectangles indisponibles : "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex); } logger.LogError(val4); } } public void Check(double x, double y, double size, bool on, uint border, uint fill, uint inner) { Rect(new UiRect(x, y, size, size), border); Rect(new UiRect(x + 1.0, y + 1.0, size - 2.0, size - 2.0), inner); if (on) { Rect(new UiRect(x + 3.0, y + 3.0, size - 6.0, size - 6.0), fill); } } public void Box(UiRect r, Font font, uint color) { if (font != null) { int padX = Math.Max(0, (int)Math.Round((r.W - (double)font.spaceWidth) / 2.0)); int padY = Math.Max(0, (int)Math.Round((r.H - (double)font.lineHeight) / 2.0)); Label(r.X, r.Y, ".", font, 0u, color, padX, padY); } } } [HarmonyPatch(typeof(Input), "update")] internal static class InputBlockPatch { private static bool _logged; private static bool _blocking; private static void Postfix(Input __instance) { //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Expected O, but got Unknown ModMenu.PollKey("jeu"); try { Pointer mainPointer = __instance.getMainPointer(); PointData val = ((mainPointer != null) ? mainPointer.worldPos : null); if (val == null) { return; } bool justDown = mainPointer.justDown; bool down = mainPointer.down; bool flag = ModMenu.HandlePointer(val.x, val.y, justDown); if (!flag) { flag = Notepad.HandlePointer(val.x, val.y, justDown); } else { Notepad.HandlePointer(-1.0, -1.0, justDown: false); } if (!flag) { flag = NightShop.HandlePointer(val.x, val.y, justDown); } else { NightShop.HandlePointer(-1.0, -1.0, justDown: false); } if (flag && justDown) { _blocking = true; } if (_blocking) { mainPointer.justDown = false; mainPointer.justUp = false; mainPointer.down = false; mainPointer.justDoubleClicked = false; __instance.maskAllPointersDownUntilRelease(); if (!down) { _blocking = false; } } } catch (Exception ex) { if (!_logged) { _logged = true; ManualLogSource logger = Plugin.Logger; bool flag2 = default(bool); BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(45, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Interface] Lecture du pointeur impossible : "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } logger.LogWarning(val2); } } } } [HarmonyPatch(typeof(Trunk), "draw")] internal static class TrunkDrawPatch { private static bool _notepadLogged; private static void Postfix(Trunk __instance, Drawer __0) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown Res res = null; try { EntEnv trunkEnv = __instance.trunkEnv; res = ((trunkEnv != null) ? trunkEnv.res : null); } catch (Exception) { } NightShop.Draw(__0, res); try { Notepad.Draw(__0, res); } catch (Exception ex2) { if (!_notepadLogged) { _notepadLogged = true; ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(22, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Bloc-notes] Dessin : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex2); } logger.LogError(val); } } ModMenu.DrawGame(__0, res); } } public class ModMenu : MonoBehaviour { public static bool Visible; public static UiRect PanelRect = new UiRect(6.0, 6.0, 280.0, 60.0); private static readonly GameUi Ui = new GameUi(); private static bool _loggedUpdate; private static bool _loggedDraw; private static bool _broken; private static int _lastToggleFrame = -1; private const uint CPanel = 4028373527u; private const uint CHeader = 4281018147u; private const uint CButton = 4282004782u; private const uint CHover = 4284109640u; private const uint CRed = 4289738284u; private const uint CInk = 4292464828u; private const uint CDim = 4288320130u; private const uint CWhite = uint.MaxValue; private const int VK_CAPITAL = 20; private static int _capsToggle = -1; private static int _capsChangedFrame = -1000; private static bool _capsApiBroken; private static double _scroll; private static double _maxScroll; private static bool _wheelBroken; private static Res _res; private static Font _font; private static Font _title; private static double _y; private static double _lh; private const double PanelW = 300.0; private const double Pad = 10.0; private const double Indent = 18.0; private const double Gap = 4.0; private const double ValueW = 40.0; private static double Left => PanelRect.X + 10.0; private static double Right => PanelRect.X + PanelRect.W - 10.0; private static double RowH => _lh + 7.0; public ModMenu(IntPtr ptr) : base(ptr) { } [DllImport("user32.dll")] private static extern short GetKeyState(int vk); [DllImport("user32.dll")] private static extern short GetAsyncKeyState(int vk); private static void TrackCapsLock() { if (_capsApiBroken) { return; } try { int num = GetKeyState(20) & 1; if (_capsToggle != -1 && num != _capsToggle) { _capsChangedFrame = Time.frameCount; } _capsToggle = num; } catch (Exception) { _capsApiBroken = true; } } private static bool CapsLockRecentlyUsed() { try { if (Input.GetKey((KeyCode)301)) { return true; } } catch (Exception) { } if (!_capsApiBroken) { try { if ((GetAsyncKeyState(20) & 0x8000) != 0) { return true; } } catch (Exception) { _capsApiBroken = true; } } return Time.frameCount - _capsChangedFrame < 30; } public static void PollKey(string source) { //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Expected O, but got Unknown //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown TrackCapsLock(); if (Time.frameCount == _lastToggleFrame || Notepad.Typing) { return; } bool flag2 = default(bool); try { KeyCode value = ModConfig.ToucheMenu.Value; bool flag = (int)value != 0 && Input.GetKeyDown(value); if (!flag) { string inputString = Input.inputString; flag = inputString != null && inputString.IndexOf('²') >= 0; if (flag && CapsLockRecentlyUsed()) { flag = false; } } if (flag) { _lastToggleFrame = Time.frameCount; Visible = !Visible; ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(28, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Interface] Panneau "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(Visible ? "ouvert" : "fermé"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (via "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(source); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } logger.LogInfo(val); } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(49, 2, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Interface] Lecture de la touche impossible ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(source); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") : "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } logger2.LogWarning(val2); } } private void Update() { if (!_loggedUpdate) { _loggedUpdate = true; Plugin.Logger.LogInfo((object)"[Interface] Update actif."); } PollKey("Update"); } public static bool HandlePointer(double x, double y, bool justDown) { Ui.MouseX = x; Ui.MouseY = y; if (!Visible || !PanelRect.Contains(x, y)) { return false; } float num = ReadWheel(); if (num != 0f) { _scroll -= num * 40f; } if (justDown) { Ui.HandleClick(x, y); } return true; } private static float ReadWheel() { //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Expected O, but got Unknown //IL_000e: Unknown result type (might be due to invalid IL or missing references) if (_wheelBroken) { return 0f; } try { return Input.mouseScrollDelta.y; } catch (Exception) { try { return Input.GetAxis("Mouse ScrollWheel") * 10f; } catch (Exception ex2) { _wheelBroken = true; ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(66, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Interface] Molette illisible ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex2.Message); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(") : utilise la barre de défilement."); } logger.LogWarning(val); return 0f; } } } private static double ScreenHeight() { try { int kDesktopPixelHeight = Layout.kDesktopPixelHeight; if (kDesktopPixelHeight > 100) { return kDesktopPixelHeight; } } catch (Exception) { } return 320.0; } public static void DrawGame(Drawer drawer, Res res) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Expected O, but got Unknown if (!Visible || _broken) { Ui.Skip(); return; } try { if (!_loggedDraw) { _loggedDraw = true; Plugin.Logger.LogInfo((object)"[Interface] Dessin via le moteur du jeu actif."); } if (res != null) { _res = res; } Ui.Begin(drawer); Draw(); } catch (Exception ex) { _broken = true; ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(48, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Interface] Le panneau ne peut pas s'afficher : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex); } logger.LogError(val); } } private static void Draw() { //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) if (_font == null) { _font = Ui.GetFont("large"); } if (_title == null) { _title = Ui.GetFont("title_tall") ?? _font; } if (_font == null) { return; } _lh = _font.lineHeight; PanelRect.W = 300.0; UiRect panelRect = PanelRect; Ui.Box(panelRect, _font, 4028373527u); double num = Math.Max(_title.lineHeight, _lh) + 10.0; Ui.Box(new UiRect(panelRect.X, panelRect.Y, panelRect.W, num), _font, 4281018147u); Ui.Label(Left, panelRect.Y + 5.0, "PAPERS PLEASE PLUS", _title, 4289738284u); Ui.Label(Right, panelRect.Y + 5.0 + ((double)_title.lineHeight - _lh) / 2.0, Lang.T($"{ModConfig.ToucheMenu.Value} : FERMER", $"{ModConfig.ToucheMenu.Value}: CLOSE"), _font, 4288320130u, 0u, 0, 0, GameUi.Align.Right); double num2 = Math.Max(num + 40.0, ScreenHeight() - panelRect.Y - 6.0); double num3 = panelRect.Y + num; double num4 = panelRect.Y + num2; _scroll = Math.Max(0.0, Math.Min(_scroll, _maxScroll)); Ui.ClipTop = num3 + 2.0; Ui.ClipBottom = num4 - 3.0; _y = num3 + 8.0 - _scroll; Section(Lang.T("TRICHE", "CHEATS")); Toggle(ModConfig.FamilleJamaisMalade, Lang.T("Famille jamais malade", "Family never sick")); Choice("Citations", (int)ModConfig.ModeCitations.Value, new string[3] { Lang.T("Normal", "Normal"), Lang.T("Sans amende", "No fine"), Lang.T("Aucune", "None") }, delegate(int i) { ModConfig.ModeCitations.Value = (CitationMode)i; }); Note(ModConfig.ModeCitations.Value switch { CitationMode.SansAmende => Lang.T("Imprimées et comptées, mais gratuites.", "Printed and counted, but free."), CitationMode.Aucune => Lang.T("Retirées du bureau et jamais comptées.", "Removed from the desk, never counted."), _ => Lang.T("Comme dans le jeu d'origine.", "As in the original game."), }); if (ModConfig.ModeCitations.Value == CitationMode.Aucune) { int num5 = GameState.CitationCounter(); if (num5 > 0) { WideButton(Lang.T($"Effacer les {num5} citations déjà comptées", $"Clear the {num5} citations already counted"), GameState.ResetCitationCounter); } } Toggle(ModConfig.GelHorlogeInspection, Lang.T("Gel de l'horloge à l'inspection", "Freeze clock while inspecting")); if (ModConfig.GelHorlogeInspection.Value) { float value = ModConfig.VitesseHorlogeInspection.Value; int current = ((!(value <= 0.01f)) ? ((value <= 0.3f) ? 1 : 2) : 0); Choice(Lang.T("Vitesse", "Speed"), current, new string[3] { Lang.T("Arrêt", "Stop"), Lang.T("x0,25", "x0.25"), Lang.T("x0,5", "x0.5") }, delegate(int i) { ModConfig.VitesseHorlogeInspection.Value = i switch { 1 => 0.25f, 0 => 0f, _ => 0.5f, }; }); } Stepper(Lang.T("Limite d'entrants", "Entrant limit"), ModConfig.LimiteEntrants, 1, 0, 200, (int v) => (v != 0) ? v.ToString() : Lang.T("aucune", "none")); DayStatus(); Section("GAMEPLAY"); Toggle(ModConfig.AmeliorationsAToutMoment, Lang.T("Améliorations à tout moment", "Upgrades at any time")); if (ModConfig.AmeliorationsAToutMoment.Value) { Stepper(Lang.T("Inspection", "Inspect"), ModConfig.PrixInspection, 5, 0, 500, (int v) => $"{v} cr"); Stepper(Lang.T("Tampons", "Stamps"), ModConfig.PrixTampons, 5, 0, 500, (int v) => $"{v} cr"); Stepper(Lang.T("Règlement", "Rulebook"), ModConfig.PrixReglement, 5, 0, 500, (int v) => $"{v} cr"); Stepper(Lang.T("Double-clic", "Double-click"), ModConfig.PrixDoubleClic, 5, 0, 500, (int v) => $"{v} cr"); Stepper(Lang.T("Bloc-notes", "Notepad"), ModConfig.PrixBlocNotes, 5, 0, 500, (int v) => $"{v} cr"); } Toggle(ModConfig.HistoireJorji, Lang.T("Histoire : le pacte de Jorji", "Story: Jorji's pact")); Note(Lang.T("Pris en compte au prochain lancement.", "Applies on next game launch.")); _y += 6.0; Ui.NoClip(); double num6 = _y + _scroll - num3; double num7 = num2 - num; _maxScroll = Math.Max(0.0, num6 - num7); PanelRect.H = num + Math.Min(num6, num7); if (_maxScroll > 0.0) { ScrollBar(num3, num7, num6); } } private static void ScrollBar(double top, double viewH, double contentH) { UiRect track = new UiRect(PanelRect.X + PanelRect.W - 7.0, top + 3.0, 5.0, viewH - 6.0); double thumbH = Math.Max(_lh, Math.Round(track.H * viewH / contentH)); double y = track.Y + Math.Round((track.H - thumbH) * _scroll / _maxScroll); Ui.Box(track, _font, 4282004782u); Ui.Box(new UiRect(track.X, y, track.W, thumbH), _font, Ui.Hover(track) ? 4289738284u : 4288320130u); UiRect r = new UiRect(track.X - 3.0, track.Y, track.W + 6.0, track.H); Ui.OnClick(r, delegate { double val = (Ui.MouseY - track.Y - thumbH / 2.0) / Math.Max(1.0, track.H - thumbH); _scroll = Math.Max(0.0, Math.Min(1.0, val)) * _maxScroll; }); } private static void DayStatus() { (int, int)? tuple = GameState.DayProgress(); if (tuple.HasValue) { var (num, num2) = tuple.Value; Separator(); Pair(Lang.T("Entrants", "Entrants"), $"{num} / {num2} min.", (num >= num2) ? 4292464828u : 4288320130u); string value = ((!ModConfig.GelHorlogeInspection.Value) ? Lang.T("normale", "normal") : (Horloge.Frozen ? Lang.T("GELÉE", "FROZEN") : Lang.T("en marche", "running"))); Pair(Lang.T("Horloge", "Clock"), value, Horloge.Frozen ? 4289738284u : 4292464828u); WideButton(GameState.EndDayRequested ? Lang.T("Fin programmée - annuler", "End scheduled - cancel") : ((num < num2) ? Lang.T("Programmer la fin de journée", "Schedule end of day") : Lang.T("Terminer la journée", "End the day")), GameState.ToggleEndDay, GameState.EndDayRequested); } } private static void Section(string title) { _y += 4.0; Ui.Label(Left, _y, title, _font, 4289738284u); _y += _lh + 6.0; } private static void Separator() { _y += 4.0; } private static void Note(string text) { Ui.Label(Left + 18.0, _y - 2.0, text, _font, 4288320130u); _y += RowH - 1.0; } private static void Pair(string label, string value, uint valueColor) { Ui.Label(Left + 18.0, _y, label, _font, 4292464828u); Ui.Label(Right, _y, value, _font, valueColor, 0u, 0, 0, GameUi.Align.Right); _y += RowH - 2.0; } private static void Toggle(ConfigEntry<bool> entry, string title) { Choice(title, entry.Value ? 1 : 0, new string[2] { Lang.T("Non", "No"), Lang.T("Oui", "Yes") }, delegate(int i) { entry.Value = i == 1; }, 0.0); } private static UiRect ButtonAt(double x, double y, string text, Action action, bool on, double minW = 0.0) { double num = Math.Max(minW, Ui.Measure(text, _font, 4)); UiRect uiRect = new UiRect(x, y - 1.0, num, _lh + 2.0); bool flag = Ui.Hover(uiRect); uint color = (on ? 4289738284u : (flag ? 4284109640u : 4282004782u)); Ui.Box(uiRect, _font, color); Ui.Label(x, y, text, _font, (on || flag) ? uint.MaxValue : 4292464828u, 0u, 0, 0, GameUi.Align.Center, num); Ui.OnClick(uiRect, action); return uiRect; } private static void WideButton(string text, Action action, bool on = false) { _y += 1.0; ButtonAt(Left + 18.0, _y, text, action, on, Right - Left - 18.0); _y += RowH + 2.0; } private static void Choice(string label, int current, string[] options, Action<int> set, double indent = 18.0) { Ui.Label(Left + indent, _y, label, _font, 4292464828u); double num = 0.0; foreach (string text in options) { num += Ui.Measure(text, _font, 4) + 4.0; } double num2 = Right - num + 4.0; for (int j = 0; j < options.Length; j++) { int index = j; num2 += ButtonAt(num2, _y, options[j], delegate { if (index != current) { set(index); } }, j == current).W + 4.0; } _y += RowH + 1.0; } private static void Stepper(string label, ConfigEntry<int> entry, int step, int min, int max, Func<int, string> format) { Ui.Label(Left + 18.0, _y, label, _font, 4292464828u); double num = Ui.Measure("+", _font, 4); double num2 = Ui.Measure("-", _font, 4); double num3 = Right - num; double num4 = num3 - 4.0 - 40.0; ButtonAt(num4 - 4.0 - num2, _y, "-", delegate { entry.Value = Math.Max(min, entry.Value - step); }, on: false); Ui.Label(num4, _y, format(entry.Value), _font, 4292464828u, 0u, 0, 0, GameUi.Align.Center, 40.0); ButtonAt(num3, _y, "+", delegate { entry.Value = Math.Min(max, entry.Value + step); }, on: false); _y += RowH + 1.0; } } internal static class NightShop { private struct Slot { public Ameliorations.Offer Offer; public UiRect Rect; public bool Owned; } public static BudgetEnt CurrentBudget; public static int LastBudgetFrame = -1000; public static double PosX; public static double PosY; public static double StepX; public static double StepY; public static double SlotW; public static double SlotH; public static bool HaveLayout; public static bool SizeFromGame; private static bool _sizeLogged; public static readonly HashSet<string> Selected = new HashSet<string>(); private static IntPtr _budgetPtr = IntPtr.Zero; private static readonly GameUi Ui = new GameUi(); private static string _message; private static float _messageUntil; private const uint COwned = 4283329102u; private const uint CSlot = 3760924451u; private const uint CHover = 4032451400u; private const uint CRed = 4289738284u; private const uint CInk = 4292464828u; private const uint CDim = 4288320130u; private const uint CWhite = uint.MaxValue; private static readonly List<Slot> _slots = new List<Slot>(); private static double _bottom; private static Font _font; private static Font _small; public static bool Active { get { if (ModConfig.AmeliorationsAToutMoment.Value && HaveLayout && CurrentBudget != null) { return Time.frameCount - LastBudgetFrame < 3; } return false; } } private static Family Family { get { BudgetEnt currentBudget = CurrentBudget; if (currentBudget == null) { return null; } return currentBudget.family; } } private static int Night { get { Family family = Family; int? obj; if (family == null) { obj = null; } else { Summary daySummary = family.daySummary; obj = ((daySummary != null) ? new int?(daySummary.id) : ((int?)null)); } int? num = obj; return num.GetValueOrDefault(); } } public static int SelectedCost() { int night = Night; int num = 0; foreach (Ameliorations.Offer allOffer in Ameliorations.AllOffers) { if (Selected.Contains(allOffer.Tag)) { num += Ameliorations.PriceFor(allOffer, night); } } return num; } private static int BudgetLeft() { try { Family family = Family; int? obj; if (family == null) { obj = null; } else { Budget budget = family.budget; obj = ((budget != null) ? new int?(budget.total) : ((int?)null)); } int? num = obj; return num.GetValueOrDefault(); } catch (Exception) { return 0; } } private static void ComputeSlots() { _slots.Clear(); _bottom = 0.0; Family family = Family; StoryState val = ((family != null) ? family.storyState : null); Array kValidUpgradesDesktop = StoryState.kValidUpgradesDesktop; if (val == null || kValidUpgradesDesktop == null) { return; } PointData val2 = ((Ent)CurrentBudget).worldPos(); for (int i = 0; i < kValidUpgradesDesktop.length; i++) { _bottom = Math.Max(_bottom, val2.y + PosY + (double)i * StepY + SlotH); Object obj = kValidUpgradesDesktop.__get(i); Upgrade val3 = ((obj != null) ? ((Il2CppObjectBase)obj).TryCast<Upgrade>() : null); if (val3 != null) { Ameliorations.Offer offer = Ameliorations.Find(val3); if (offer != null && !val.hasUpgrade(val3) && Night >= ModConfig.AmeliorationsPremierSoir.Value) { _slots.Add(new Slot { Offer = offer, Rect = new UiRect(val2.x + PosX + (double)i * StepX, val2.y + PosY + (double)i * StepY, SlotW, SlotH) }); } } } if (Night >= ModConfig.AmeliorationsPremierSoir.Value) { int num = kValidUpgradesDesktop.length; Ameliorations.Offer[] modOffers = Ameliorations.ModOffers; foreach (Ameliorations.Offer offer2 in modOffers) { UiRect rect = new UiRect(val2.x + PosX + (double)num * StepX, val2.y + PosY + (double)num * StepY, SlotW, SlotH); _slots.Add(new Slot { Offer = offer2, Rect = rect, Owned = offer2.Owned(val) }); _bottom = Math.Max(_bottom, rect.Y + rect.H); num++; } } } private static void ReadSlotSizeFromImage(Res res) { //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Expected O, but got Unknown if (SizeFromGame || res == null) { return; } try { Image image = res.getImage("assets/Upgrades.png"); if (image != null && image.width > 0 && image.height > 0) { if (image.width >= image.height) { SlotW = (double)image.width / 5.0; SlotH = image.height; } else { SlotW = image.width; SlotH = (double)image.height / 5.0; } SizeFromGame = true; } } catch (Exception ex) { ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExWarningLogInterpolatedStringHandler val = new BepInExWarningLogInterpolatedStringHandler(35, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Améliorations] Image des icônes : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ex.Message); } logger.LogWarning(val); } } public static void Draw(Drawer drawer, Res res) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown if (!Active) { Ui.Skip(); return; } ReadSlotSizeFromImage(res); if (!_sizeLogged) { _sizeLogged = true; ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(51, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Améliorations] Taille des places : "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(SlotW); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(SlotH); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(SizeFromGame ? "lue dans le jeu" : "estimée"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("), pas ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(StepX); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(StepY); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } logger.LogInfo(val); } if (((Il2CppObjectBase)CurrentBudget).Pointer != _budgetPtr) { _budgetPtr = ((Il2CppObjectBase)CurrentBudget).Pointer; Selected.Clear(); } if (_font == null) { _font = Ui.GetFont("large"); } if (_small == null) { _small = Ui.GetFont("regular") ?? _font; } if (_small == null) { return; } ComputeSlots(); if (_slots.Count == 0) { Ui.Skip(); return; } Ui.Begin(drawer); int night = Night; foreach (Slot slot in _slots) { UiRect rect = slot.Rect; double y = rect.Y + Math.Round((rect.H - (double)_small.lineHeight) / 2.0); if (slot.Owned) { Ui.Box(rect, _small, 4283329102u); Ui.Label(rect.X, y, slot.Offer.ShortText, _small, 4292464828u, 0u, 0, 0, GameUi.Align.Center, rect.W); continue; } bool flag2 = Selected.Contains(slot.Offer.Tag); bool flag3 = Ui.Hover(rect); int value = Ameliorations.PriceFor(slot.Offer, night); Ui.Box(rect, _small, flag2 ? 4289738284u : (flag3 ? 4032451400u : 3760924451u)); Ui.Label(rect.X, y, slot.Offer.ShortText, _small, (flag2 || flag3) ? uint.MaxValue : 4292464828u, 0u, 0, 0, GameUi.Align.Center, rect.W); Ui.Label(rect.X + rect.W + 4.0, y, $"{value} cr", _small, flag2 ? 4289738284u : (flag3 ? uint.MaxValue : 4288320130u)); Ameliorations.Offer offer = slot.Offer; Ui.OnClick(rect, delegate { Toggle(offer, night); }); } UiRect rect2 = _slots[0].Rect; double y2 = _bottom + 4.0; int num = SelectedCost(); bool num2 = Time.realtimeSinceStartup < _messageUntil; string text = (num2 ? _message : ((num > 0) ? Lang.T($"Achats {num} cr, reste {BudgetLeft() - num} cr", $"Buying {num} cr, left {BudgetLeft() - num} cr") : Lang.T("Cliquer pour acheter", "Click to buy"))); uint color = (num2 ? 4289738284u : ((num > 0) ? 4292464828u : 4288320130u)); Ui.Label(rect2.X, y2, text, _small, color); } private static void Toggle(Ameliorations.Offer offer, int night) { if (!Selected.Remove(offer.Tag)) { int num = Ameliorations.PriceFor(offer, night); if (BudgetLeft() - SelectedCost() - num < 0) { _message = Lang.T("Pas assez d'argent", "Not enough money"); _messageUntil = Time.realtimeSinceStartup + 2f; } else { Selected.Add(offer.Tag); } } } public static bool HandlePointer(double x, double y, bool justDown) { Ui.MouseX = x; Ui.MouseY = y; if (!Active) { return false; } foreach (Slot slot in _slots) { if (slot.Owned) { continue; } UiRect rect = slot.Rect; if (rect.Contains(x, y)) { if (justDown) { Ui.HandleClick(x, y); } return true; } } return false; } } [HarmonyPatch(typeof(BudgetEnt), "draw")] internal static class BudgetEntDrawPatch { private static void Postfix(BudgetEnt __instance) { NightShop.CurrentBudget = __instance; NightShop.LastBudgetFrame = Time.frameCount; } } [HarmonyPatch] internal static class FamilyVisualsCtorPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(FamilyVisuals), "__hx_ctor_play_night_FamilyVisuals", (Type[])null, (Type[])null); } private static void Postfix(FamilyVisuals __0) { //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Expected O, but got Unknown bool flag = default(bool); try { PointData upgradesPos = __0.upgradesPos0; PointData upgradesStep = __0.upgradesStep; if (upgradesPos != null && upgradesStep != null) { NightShop.PosX = upgradesPos.x; NightShop.PosY = upgradesPos.y; NightShop.StepX = upgradesStep.x; NightShop.StepY = upgradesStep.y; if (!NightShop.SizeFromGame) { double num = Math.Max(Math.Abs(upgradesStep.x), Math.Abs(upgradesStep.y)); NightShop.SlotH = Math.Max(10.0, num - 2.0); NightShop.SlotW = NightShop.SlotH * 3.0; } NightShop.HaveLayout = true; ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(57, 6, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Améliorations] Places : départ ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(upgradesPos.x); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(upgradesPos.y); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("), pas ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(upgradesStep.x); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(", "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(upgradesStep.y); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("), "); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("taille "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(NightShop.SlotW); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<double>(NightShop.SlotH); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("."); } logger.LogInfo(val); } } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(38, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Améliorations] Places introuvables : "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } logger2.LogWarning(val2); } } } [HarmonyPatch] internal static class FamilyVisualsDimCtorPatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(FamilyVisualsDim), "__hx_ctor_play_night_FamilyVisualsDim", (Type[])null, (Type[])null); } private static void Postfix(FamilyVisualsDim __0) { try { if (__0.kUpgradeWidth > 0.0 && __0.kUpgradeHeight > 0.0) { NightShop.SlotW = __0.kUpgradeWidth; NightShop.SlotH = __0.kUpgradeHeight; NightShop.SizeFromGame = true; } } catch (Exception) { } } } internal static class Notepad { private sealed class Note { public string Path; public string Label; public string Value; public Sprite Face; public double FaceW; public double FaceH; } private const int MaxNotes = 10; private static readonly List<Note> Notes = new List<Note>(); private static readonly GameUi Ui = new GameUi(); private static bool _open; private static double _t; private static int _dayId = int.MinValue; private static UiRect _tab; private static UiRect _tabDrawn; private static UiRect _panel; private static bool _layoutLogged; private static bool _warned; private static string _flash; private static float _flashUntil; private static Font _font; private static Font _small; public static bool Typing; private static string _typed = ""; private const int MaxTyped = 28; private const uint CPaper = 4075084996u; private const uint CInk = 4282004264u; private const uint CDim = 4286213724u; private const uint CTab = 4073570207u; private const uint CTabHover = 4293450944u; private const uint CRed = 4289738284u; private const uint CLine = 1073741824u; private static readonly List<(UiRect rect, Note note)> _noteRects = new List<(UiRect, Note)>(); private const uint CHoverNote = 805306368u; public static bool Active { get { if (!GameState.InDay || GameState.CurrentBooth == null) { return false; } Day day = GameState.CurrentBooth.day; if (day == null || !GameState.IsStoryDay(day)) { return false; } return Ameliorations.Notepad.OwnedNow(); } } private static void StartTyping() { Typing = true; _typed = ""; _open = true; } private static void StopTyping(bool save) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Expected O, but got Unknown Typing = false; string text = _typed.Trim(); _typed = ""; if (save && text.Length != 0) { if (Notes.Count >= 10) { Notes.RemoveAt(0); } Notes.Add(new Note { Path = "typed:" + Guid.NewGuid(), Label = Lang.T("Note", "Note"), Value = text }); ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(43, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Bloc-notes] Note écrite : « "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" » ("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(Notes.Count); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" note(s))."); } logger.LogInfo(val); } } public static void PollTyping() { if (!Typing) { return; } if (!Active) { Typing = false; return; } string text = ""; try { text = Input.inputString ?? ""; } catch (Exception) { } bool flag = false; try { flag = Input.GetKeyDown((KeyCode)27); } catch (Exception) { } if (flag) { StopTyping(save: false); return; } bool flag2 = false; try { flag2 = Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271); } catch (Exception) { } string text2 = text; foreach (char c in text2) { switch (c) { case '\b': if (_typed.Length > 0) { _typed = _typed.Substring(0, _typed.Length - 1); } break; case '\n': case '\r': StopTyping(save: true); return; default: if (!char.IsControl(c) && c != '²' && _typed.Length < 28) { _typed += char.ToUpperInvariant(c); } break; } } if (flag2) { StopTyping(save: true); } } private static void CheckNewDay() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown Booth currentBooth = GameState.CurrentBooth; Day val = ((currentBooth != null) ? currentBooth.day : null); int num = -1; try { int? obj; if (val == null) { obj = null; } else { FactSet facts = val.facts; obj = ((facts != null) ? new int?(facts.getValueInt("Game/Day", (Object)null)) : ((int?)null)); } num = obj ?? (-1); } catch (Exception) { } if (num != _dayId) { ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(55, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Bloc-notes] Nouvelle journée ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(_dayId); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" -> "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") : bloc-notes vidé."); } logger.LogInfo(val2); _dayId = num; Notes.Clear(); _open = false; _t = 0.0; Typing = false; LenseCapture.Live = null; } } private static bool ComputeLayout() { //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Expected O, but got Unknown //IL_00cb: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Expected O, but got Unknown try { double num = 182.0; double num2 = 114.0; double num3 = 388.0; double num4 = 206.0; string text = "secours"; Rect val = null; try { Booth currentBooth = GameState.CurrentBooth; object obj; if (currentBooth == null) { obj = null; } else { EntEnv env = ((Ent)currentBooth).env; if (env == null) { obj = null; } else { Layout layout = env.layout; obj = ((layout != null) ? layout.desk : null); } } val = (Rect)obj; } catch (Exception) { } if (val != null && val.w > 20.0 && val.h > 20.0) { num = val.x; num2 = val.y; num3 = val.w; num4 = val.h; text = "jeu"; } if (!_layoutLogged) { _layoutLogged = true; ManualLogSource logger = Plugin.Logger; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(36, 5, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Bloc-notes] Zone du bureau ("); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") : "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<double>(num); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(","); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<double>(num2); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<double>(num3); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("x"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<double>(num4); } logger.LogInfo(val2); } double num5 = Math.Min(200.0, num3 - 8.0); double num6 = num + num3 - num5 - 4.0; _tab = new UiRect(num6 + num5 - 60.0, num2, 56.0, 13.0); _panel = new UiRect(num6, num2, num5, num4 - 6.0); return true; } catch (Exception ex2) { if (!_warned) { _warned = true; ManualLogSource logger2 = Plugin.Logger; bool flag2 = default(bool); BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(32, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Bloc-notes] Zone introuvable : "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex2.Message); } logger2.LogWarning(val3); } return false; } } public static bool HandlePointer(double x, double y, bool justDown) { Ui.MouseX = x; Ui.MouseY = y; if (!Active) { return false; } CheckNewDay(); bool flag = _tabDrawn.Contains(x, y) || (_t > 0.01 && CurrentPanelRect().Contains(x, y)); if (Input.GetMouseButtonDown(1)) { if (flag) { foreach (var (uiRect, item) in _noteRects) { if (uiRect.Contains(x, y)) { Notes.Remove(item); Flash(Lang.T("Note retirée", "Note removed")); break; } } } else { RightClick(x, y); } } if (!flag) { return false; } if (justDown) { Ui.HandleClick(x, y); } return true; } private static UiRect CurrentPanelRect() { double h = Math.Round(PanelHeight() * _t); return new UiRect(_panel.X, _panel.Y, _panel.W, h); } private static void RightClick(double x, double y) { //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Expected O, but got Unknown //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Expected O, but got Unknown //IL_022d: Unknown result type (might be due to invalid IL or missing references) //IL_0234: Expected O, but got Unknown Booth currentBooth = GameState.CurrentBooth; Inspectable val = null; string text = "aucun"; bool flag2 = default(bool); BepInExInfoLogInterpolatedStringHandler val3; try { InspectUi val2 = ((currentBooth != null) ? currentBooth.inspectUi : null); bool flag = val2 != null && val2.open; if (val2 != null && flag) { NotepadPick.Begin(); try { val2.selectInspectableAt(new PointData(x, y)); } finally { val = NotepadPick.End(); } if (val != null) { text = "sélection interceptée"; } } ManualLogSource logger = Plugin.Logger; val3 = new BepInExInfoLogInterpolatedStringHandler(55, 5, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Bloc-notes] Clic droit en "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<double>(x, "0"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(","); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<double>(y, "0"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" : inspection "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(flag ? "ouverte" : "fermée"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", élément "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" : "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(((val != null) ? val.factPath : null) ?? "-"); } logger.LogInfo(val3); } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val4 = new BepInExWarningLogInterpolatedStringHandler(38, 1, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("[Bloc-notes] Élément sous la souris : "); ((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex); } logger2.LogWarning(val4); } string path = ((val != null) ? val.factPath : null); if (string.IsNullOrEmpty(path)) { return; } int num = Notes.FindIndex((Note n) => n.Path == path); if (num >= 0) { Notes.RemoveAt(num); Flash(Lang.T("Note retirée", "Note removed")); return; } Note note = MakeNote(currentBooth, path); if (note == null) { return; } if (note.Face == null && note.Value == "?") { Flash(Lang.T("Rien à lire ici : utilise ÉCRIRE", "Nothing to read here: use WRITE")); return; } if (Notes.Count >= 10) { Notes.RemoveAt(0); } Notes.Add(note); Flash(Lang.T("Noté", "Noted")); ManualLogSource logger3 = Plugin.Logger; val3 = new BepInExInfoLogInterpolatedStringHandler(20, 3, ref flag2); if (flag2) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Bloc-notes] "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(path); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" = « "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(note.Value); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" »"); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>((note.Face != null) ? " (photo)" : ""); } logger3.LogInfo(val3); } private static void Flash(string s) { _flash = s; _flashUntil = Time.realtimeSinceStartup + 1.2f; } private static Note MakeNote(Booth booth, string path) { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Expected O, but got Unknown //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0252: Expected O, but got Unknown //IL_016f: Unknown result type (might be due to invalid IL or missing references) //IL_017a: Expected O, but got Unknown //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Expected O, but got Unknown //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Expected O, but got Unknown //IL_01ff: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Expected O, but got Unknown BoothEnv val = ((booth != null) ? booth.boothEnv : null); string text = null; bool flag = default(bool); try { FactValue val2 = ((val != null) ? val.getFactValue(path) : null); if (val2 != null) { text = val2.localizedText; if (string.IsNullOrEmpty(text)) { text = val2.text; } if (val2.name != null) { string text2 = null; try { text2 = val2.name.getFormatted("First Last"); } catch (Exception) { } if (string.IsNullOrWhiteSpace(text2) || text2.Contains("First") || text2.Contains("Last")) { text2 = (val2.name.first + " " + val2.name.last).Trim(); } if (!string.IsNullOrEmpty(text2)) { text = text2; } } } } catch (Exception ex2) { ManualLogSource logger = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(26, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Bloc-notes] Valeur de "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(path); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" : "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex2.Message); } logger.LogWarning(val3); } Note note = new Note { Path = path, Label = LabelFor(path), Value = (text ?? "") }; if (text != null && text.Length > 2 && (text.StartsWith("M-") || text.StartsWith("F-"))) { try { EntEnv env = ((Ent)booth).env; Db obj = ((env != null) ? env.db : null); FaceSpec val4 = FaceSpec.fromString(new Rand(1), text); object obj2; if (obj == null) { obj2 = null; } else { FaceLib faceLib = obj.faceLib; obj2 = ((faceLib != null) ? faceLib.makeFace(val4, false) : null); } Image val5 = ((obj2 != null) ? ((Face)obj2).headOnlyImage : null); if (val5 != null) { Rect val6 = new Rect((Object)null, (Object)null, (Object)null, (Object)null); val6.x = 0.0; val6.y = 0.0; val6.w = val5.width; val6.h = val5.height; note.Face = new Sprite(new PartData(val5, val6)); ((Visual)note.Face).layer = 50; note.FaceW = val5.width; note.FaceH = val5.height; note.Value = ""; } } catch (Exception ex3) { ManualLogSource logger2 = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val3 = new BepInExWarningLogInterpolatedStringHandler(25, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[Bloc-notes] Photo de "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(path); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" : "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex3.Message); } logger2.LogWarning(val3); } } if (note.Face == null && string.IsNullOrWhiteSpace(note.Value)) { note.Value = "?"; } return note; } private static string LabelFor(string path) { string[] array = path.Split('/'); StringBuilder stringBuilder = new StringBuilder(); for (int i = Math.Max(0, array.Length - 2); i < array.Length; i++) { if (stringBuilder.Length > 0) { stringBuilder.Append(" · "); } string text = array[i]; for (int j = 0; j < text.Length; j++) { if (j > 0 && char.IsUpper(text[j]) && char.IsLower(text[j - 1])) { stringBuilder.Append(' '); } stringBuilder.Append(text[j]); } } return stringBuilder.ToString(); } private static double PanelHeight() { if (_small == null) { return 40.0; } double num = _small.lineHeight; double num2 = 18.0 + num; if (Notes.Count == 0) { num2 += num * 2.0 + 4.0; } double num3 = 0.0; foreach (Note note in Notes) { if (note.Face != null) { num3 = Math.Max(num3, note.FaceH); } else { num2 += num * 2.0 + 2.0; } } if (num3 > 0.0) { num2 += num3 + num + 6.0; } num2 += num + 8.0; if (Typing) { num2 += num + 4.0; } return Math.Min(num2, _panel.H); } public static void Draw(Drawer drawer, Res res) { //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Expected O, but got Unknown PollTyping(); if (!Active) { Ui.Skip(); return; } CheckNewDay(); if (!ComputeLayout()) { Ui.Skip(); return; } if (_font == null) { _font = Ui.GetFont("large"); } if (_small == null) { _small = Ui.GetFont("regular") ?? _font; } if (_small == null) { Ui.Skip(); return; } double num = (_open ? 1 : 0); double num2 = Time.unscaledDeltaTime * 5f; _t = ((_t < num) ? Math.Min(num, _t + num2) : Math.Max(num, _t - num2)); Ui.Begin(drawer); double lh = _small.lineHeight; UiRect pr; double x; if (_t > 0.01) { pr = CurrentPanelRect(); double num3 = PanelHeight(); double num4 = pr.H - num3; Ui.Box(pr, _small, 4075084996u); double num5 = _panel.Y + num4 + 16.0; x = _panel.X + 6.0; double num6 = _panel.X + _panel.W - 6.0; Line(num5, Lang.T("BLOC-NOTES", "NOTEPAD"), 4282004264u); num5 += lh + 2.0; if (Notes.Count == 0) { Line(num5, Lang.T("Clic droit sur un élément (inspection)", "Right-click an item (inspect mode)"), 4286213724u); Line(num5 + lh, Lang.T("ou ÉCRIRE pour taper une note.", "or WRITE to type a note."), 4286213724u); num5 += lh * 2.0 + 4.0; } _noteRects.Clear(); foreach (Note note in Notes) { if (note.Face != null) { continue; } UiRect uiRect = new UiRect(x - 2.0, num5, num6 - x + 4.0, lh * 2.0); int num7; if (Ui.Hover(uiRect) && uiRect.Y >= pr.Y) { num7 = ((uiRect.Y + uiRect.H <= pr.Y + pr.H) ? 1 : 0); if (num7 != 0) { Ui.Box(uiRect, _small, 805306368u); } } else { num7 = 0; } Line(num5, note.Label, 4286213724u); Line(num5 + lh, Fit(note.Value, num6 - x - 14.0), 4282004264u); if (num7 != 0) { DeleteCross(num6 - 8.0, num5, note); } _noteRects.Add((uiRect, note)); num5 += lh * 2.0 + 2.0; } double num8 = x; double num9 = 0.0; foreach (Note note2 in Notes) { if (note2.Face == null) { continue; } if (num8 + note2.FaceW > num6) { break; } double num10 = num5 + 2.0; if (num10 >= pr.Y && num10 + note2.FaceH <= pr.Y + pr.H) { UiRect uiRect2 = new UiRect(num8, num10, note2.FaceW, note2.FaceH); drawer.add(new PointData(num8, num10), (Visual)(object)note2.Face, (Object)null); if (Ui.Hover(uiRect2)) { DeleteCross(num8 + note2.FaceW - 8.0, num10, note2); } _noteRects.Add((uiRect2, note2)); } num9 = Math.Max(num9, note2.FaceH); num8 += note2.FaceW + 6.0; } if (num9 > 0.0) { num5 += num9 + 6.0; } if (Typing) { bool flag = (int)(Time.realtimeSinceStartup * 2f) % 2 == 0; Line(num5 + 2.0, "> " + _typed + (flag ? "_" : ""), 4289738284u); num5 += lh + 4.0; } double num11 = num5 + 2.0; if (num11 + lh <= pr.Y + pr.H) { string text = (Typing ? Lang.T("OK (ENTRÉE)", "OK (ENTER)") : Lang.T("ÉCRIRE", "WRITE")); double w = Ui.Measure(text, _small, 3); UiRect r = new UiRect(x, num11, w, lh); bool flag2 = Ui.Hover(r); Ui.Label(r.X, r.Y, text, _small, flag2 ? uint.MaxValue : 4282004264u, flag2 ? 4282004264u : 0u, 3); Ui.OnClick(r, delegate { if (Typing) { StopTyping(save: true); } else { StartTyping(); } }); if (Notes.Count > 0 && !Typing) { string text2 = Lang.T("VIDER", "CLEAR"); double num12 = Ui.Measure(text2, _small, 3); UiRect r2 = new UiRect(num6 - num12, num11, num12, lh); bool flag3 = Ui.Hover(r2); Ui.Label(r2.X, r2.Y, text2, _small, flag3 ? uint.MaxValue : 4289738284u, flag3 ? 4289738284u : 0u, 3); Ui.OnClick(r2, delegate { Notes.Clear(); }); } } } UiRect tab = _tab; if (_t > 0.01) { tab.Y = _panel.Y + Math.Round(PanelHeight() * _t) - 1.0; } bool flag4 = Ui.Hover(tab); string text3 = ((Notes.Count > 0) ? $"NOTES {Notes.Count}" : "NOTES"); Ui.Box(tab, _small, flag4 ? 4293450944u : 4073570207u); Ui.Label(tab.X, tab.Y + Math.Round((tab.H - lh) / 2.0), text3, _small, 4282004264u, 0u, 0, 0, GameUi.Align.Center, tab.W); Ui.OnClick(tab, delegate { _open = !_open; if (!_open && Typing) { StopTyping(save: false); } }); _tabDrawn = tab; if (_flash != null && Time.realtimeSinceStartup < _flashUntil) { Ui.Label(tab.X + tab.W + 4.0, tab.Y, _flash, _small, 4282004264u, 4073570207u, 2); } void Line(double ly, string s, uint color) { if (ly >= pr.Y && ly + lh <= pr.Y + pr.H) { Ui.Label(x, ly, s, _small, color); } } } private static void DeleteCross(double cx, double cy, Note n) { new UiRect(cx, cy, 8.0, _small.lineHeight); Ui.Label(cx, cy, "X", _small, uint.MaxValue, 4289738284u, 1); Ui.OnClick(new UiRect(cx - 2.0, cy - 1.0, 12.0, _small.lineHeight + 2), delegate { Notes.Remove(n); }); } private static string Fit(string s, double maxW) { if (string.IsNullOrEmpty(s) || _small == null) { return s; } if (Ui.Measure(s, _small) <= maxW) { return s; } while (s.Length > 1 && Ui.Measure(s + "..", _small) > maxW) { s = s.Substring(0, s.Length - 1); } return s + ".."; } } [HarmonyPatch(typeof(InspectLense), "reactHighlightInspectableAt")] internal static class LenseCapture { public static InspectLense Live; public static Inspectable LastHighlight; public static int LastHighlightFrame; private static void Postfix(InspectLense __instance) { Live = __instance; try { Inspectable highlightInspectable = __instance.highlightInspectable; if (highlightInspectable != null) { LastHighlight = highlightInspectable; LastHighlightFrame = Time.frameCount; } } catch (Exception) { } } } [HarmonyPatch] internal static class KeyBlockPatches { private static IEnumerable<MethodBase> TargetMethods() { Type t = typeof(Input); string[] array = new string[4] { "getKeyDown", "getKeyUp", "getKeyJustDown", "getKeyJustUp" }; foreach (string text in array) { MethodInfo methodInfo = AccessTools.Method(t, text, new Type[1] { typeof(int) }, (Type[])null); if (methodInfo != null) { yield return methodInfo; } } MethodInfo methodInfo2 = AccessTools.Method(t, "getAnyKeyJustDown", (Type[])null, (Type[])null); if (methodInfo2 != null) { yield return methodInfo2; } } private static bool Prefix(ref bool __result) { if (!Notepad.Typing) { return true; } __result = false; return false; } } [HarmonyPatch(typeof(InspectLense), "update")] internal static class LenseUpdateCapture { private static void Postfix(InspectLense __instance) { if (LenseCapture.Live == null) { LenseCapture.Live = __instance; } } } [HarmonyPatch(typeof(InspectUi), "selectInspectable")] [HarmonyPriority(800)] internal static class NotepadPick { private static bool _capturing; private static Inspectable _picked; public static void Begin() { _capturing = true; _picked = null; } public static Inspectable End() { _capturing = false; Inspectable picked = _picked; _picked = null; return picked; } private static bool Prefix(Inspectable __0) { if (!_capturing) { return true; } _picked = __0; return false; } } } namespace PapersPleasePlus.Gameplay { internal static class Ameliorations { internal sealed class Offer { public string Label; public int NormalNight; public Func<Upgrade> Get; public Func<int> EarlyPrice; public string Tag; public string Short; public string ShortEn; public string ModFact; private static readonly HashSet<(IntPtr, string)> _logged = new HashSet<(IntPtr, string)>(); public string ShortText => Lang.T(Short, ShortEn ?? Short); public bool IsModUpgrade => ModFact != null; public bool Owned(StoryState story) { if (story == null) { return false; } if (IsModUpgrade) { if (SessionOwned.Contains(SessionKey(story))) { return true; } try { FactSet facts = story.facts; return ((facts != null) ? facts.getValueText(ModFact, "") : null) == "YES"; } catch (Exception) { return false; } } return story.hasUpgrade(Get()); } public void Give(StoryState story) { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Expected O, but got Unknown //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown if (story == null) { return; } if (!IsModUpgrade) { story.giveUpgrade(Get()); return; } SessionOwned.Add(SessionKey(story)); bool flag = default(bool); try { FactSet facts = story.facts; if (facts != null) { facts.setValueText(ModFact, "YES"); } FactSet facts2 = story.facts; string text = ((facts2 != null) ? facts2.getValueText(ModFact, "") : null); ManualLogSource logger = Plugin.Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(34, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Améliorations] "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(ModFact); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" = « "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" » (partie "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(story.saveId); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")."); } logger.LogInfo(val); } catch (Exception ex) { ManualLogSource logger2 = Plugin.Logger; BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(37, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[Améliorations] Enregistrement de "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ModFact); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" : "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); } logger2.LogWarning(val2); } } private string SessionKey(StoryState story) { string text = null; try { text = story.saveId; } catch (Exception) { } return (text ?? "?") + "|" + ModFact; } public bool OwnedNow() { //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_014e: Expected O, but got Unknown try { object obj; if (!GameState.InDay) { obj = null; } else { Booth currentBooth = GameState.CurrentBooth; obj = ((currentBooth != null) ? currentBooth.day : null); } Day val = (Day)obj; StoryState val2 = ((val != null) ? val.storyState : null) ?? GameState.LastStoryState; bool flag = false; try { object obj2; if (val == null) { obj2 =