using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("FewerPasscodeNotes")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Decreases the number of passcode notes.")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0-BE667+e0faf16b8338f58b521f954ca51ad4a57db6ddb8")]
[assembly: AssemblyProduct("FewerPasscodeNotes")]
[assembly: AssemblyTitle("FewerPasscodeNotes")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
internal sealed class NullableAttribute : Attribute
{
public readonly byte[] NullableFlags;
public NullableAttribute(byte P_0)
{
NullableFlags = new byte[1] { P_0 };
}
public NullableAttribute(byte[] P_0)
{
NullableFlags = P_0;
}
}
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
namespace FewerPasscodeNotes
{
[BepInPlugin("FewerPasscodeNotes", "Fewer Passcode Notes", "1.0.0")]
[BepInProcess("Shadows of Doubt.exe")]
public class Plugin : BasePlugin
{
[HarmonyPatch]
public class Human_WriteNote
{
private static NewGameLocation _lastLocation = null;
private static bool _lastLocationDenied = true;
public static bool Prefix(ref Interactable __result, NewGameLocation placement)
{
bool flag = _lastLocationDenied;
if ((Object)(object)_lastLocation != (Object)(object)placement)
{
_lastLocation = placement;
flag = _notes > 0 && _rng.NextDouble() < 0.6;
}
_lastLocation = placement;
_lastLocationDenied = flag;
if (flag)
{
__result = null;
return false;
}
return true;
}
public static MethodBase TargetMethod()
{
return (from method in AccessTools.GetTypesFromAssembly(typeof(Human).Assembly).SelectMany((Type type) => type.GetMethods())
where method.DeclaringType == typeof(Human) && method.Name.Equals("WriteNote") && method.GetParameters()[0].ParameterType == typeof(NoteObject)
select method).Cast<MethodBase>().First();
}
}
[HarmonyPatch(typeof(Human), "PickPassword")]
public class Human_PickPassword
{
[HarmonyPriority(10)]
public static bool Prefix(ref Human __instance)
{
_notes++;
return true;
}
public static void Postfix()
{
_notes--;
}
}
[HarmonyPatch(typeof(NewRoom), "PickPassword")]
public class NewRoom_PickPassword
{
[HarmonyPriority(10)]
public static bool Prefix()
{
_notes++;
return true;
}
public static void Postfix()
{
_notes--;
}
}
[HarmonyPatch(typeof(NewAddress), "PickPassword")]
public class NewAddress_PickPassword
{
[HarmonyPriority(10)]
public static bool Prefix()
{
_notes++;
return true;
}
public static void Postfix()
{
_notes--;
}
}
private const string PluginGuid = "FewerPasscodeNotes";
private const string PluginName = "Fewer Passcode Notes";
private const string PluginVersion = "1.0.0";
private const double ReduceNotesCountByThisPergentage = 0.6;
private static Random _rng;
private static Harmony Harmony;
private static int _notes;
public override void Load()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Expected O, but got Unknown
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Expected O, but got Unknown
//IL_005f: Unknown result type (might be due to invalid IL or missing references)
//IL_0065: Expected O, but got Unknown
Harmony = new Harmony("FewerPasscodeNotes");
ManualLogSource log = ((BasePlugin)this).Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("FewerPasscodeNotes");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
Harmony.PatchAll();
ManualLogSource log2 = ((BasePlugin)this).Log;
val = new BepInExInfoLogInterpolatedStringHandler(19, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("FewerPasscodeNotes");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is patched!");
}
log2.LogInfo(val);
_rng = new Random(DateTime.Now.Millisecond);
}
public override bool Unload()
{
Harmony.UnpatchSelf();
return ((BasePlugin)this).Unload();
}
}
}