using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Fusion;
using HarmonyLib;
using Il2CppInterop.Runtime.Injection;
using Microsoft.CodeAnalysis;
using ModSettingsMenu.Api;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("NIGHTMAREMODE")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5c4ad36bd678f9ea6705e410467f8d2a508c5b77")]
[assembly: AssemblyProduct("NIGHTMARE Mode")]
[assembly: AssemblyTitle("NIGHTMAREMODE")]
[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 NIGHTMAREMODE
{
internal enum DeathResetMode
{
Never,
AnyoneDies,
EveryoneDies
}
internal static class NightmareSettings
{
public static ConfigEntry<bool> Enabled;
public static ConfigEntry<float> QuotaScaling;
public static ConfigEntry<bool> ShouldSpawnThieves;
public static ConfigEntry<int> SpawnInterval;
public static ConfigEntry<int> SpawnChance;
public static ConfigEntry<float> ThiefCaughtPayout;
public static ConfigEntry<float> DamageTakenScaling;
public static ConfigEntry<float> SpiderHealthScaling;
public static ConfigEntry<float> SpiderSpeedScaling;
public static ConfigEntry<bool> ShouldLimitCustomerPatience;
public static ConfigEntry<int> CustomerPatienceSeconds;
public static ConfigEntry<int> BoxContentAmount;
public static ConfigEntry<float> VentPushOutSpeed;
public static ConfigEntry<DeathResetMode> DeathReset;
public static ConfigEntry<bool> QuotaReset;
internal static void Bind(ConfigFile config)
{
//IL_007f: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Expected O, but got Unknown
//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
//IL_00b7: Expected O, but got Unknown
//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
//IL_01ab: Expected O, but got Unknown
//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
//IL_01d8: Expected O, but got Unknown
Enabled = config.Bind<bool>("1General", "Enabled", true, "Enable this mod.");
QuotaScaling = BindRounded(config, "2Quota", "Quota Scaling", 3f, 1f, 10f, "Adjust the quota multiplier.");
ShouldSpawnThieves = config.Bind<bool>("3Thieves", "1Should Spawn Thieves", true, "Enable or disable thief spawns.");
SpawnInterval = config.Bind<int>("3Thieves", "2Spawn Interval", 20, new ConfigDescription("Adjust the spawn interval for thieves, in seconds.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 60), Array.Empty<object>()));
SpawnChance = config.Bind<int>("3Thieves", "3Spawn Chance", 50, new ConfigDescription("Adjust the spawn chance for thieves.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
ThiefCaughtPayout = BindRounded(config, "3Thieves", "4Thief Caught Payout", 0f, 0f, 10f, "Adjust how much money you get back when a thief is caught.");
DamageTakenScaling = BindRounded(config, "4Damage", "Damage Taken Scaling", 3f, 1f, 10f, "Adjust the damage taken multiplier.");
SpiderHealthScaling = BindRounded(config, "5Spider", "Spider Health Scaling", 4f, 1f, 10f, "Adjust the spider health multiplier.");
SpiderSpeedScaling = BindRounded(config, "5Spider", "Spider Speed Scaling", 2f, 1f, 10f, "Adjust the spider speed multiplier.");
ShouldLimitCustomerPatience = config.Bind<bool>("6Customers", "1Should Limit Customer Patience", true, "Force every customer to have a patience timer.");
CustomerPatienceSeconds = config.Bind<int>("6Customers", "2Customer Patience Seconds", 60, new ConfigDescription("Adjust how many seconds customers wait before leaving.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 180), Array.Empty<object>()));
BoxContentAmount = config.Bind<int>("7Boxes", "Box Content", 5, new ConfigDescription("Adjust how many products a product box holds.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 15), Array.Empty<object>()));
VentPushOutSpeed = BindRounded(config, "8Vents", "Vent Push Out Speed", 2.3f, 0.1f, 10f, "Adjust how fast the vent pushes a player back out (game default 1.15).", 2);
DeathReset = config.Bind<DeathResetMode>("9GameReset", "1Death Reset Mode", DeathResetMode.AnyoneDies, "When a death wipes the run. Never = deaths never reset. AnyoneDies = a single death ends the run for everyone. EveryoneDies = only a full team wipe ends the run.");
QuotaReset = config.Bind<bool>("9GameReset", "2Quota Reset", true, "Wipe the run when the day ends without the quota being met.");
}
private static ConfigEntry<float> BindRounded(ConfigFile config, string section, string key, float defaultValue, float min, float max, string description, int decimals = 1)
{
//IL_001b: Unknown result type (might be due to invalid IL or missing references)
//IL_0025: Expected O, but got Unknown
ConfigEntry<float> entry = config.Bind<float>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>()));
float factor = Mathf.Pow(10f, (float)decimals);
entry.SettingChanged += delegate
{
entry.Value = Mathf.Round(entry.Value * factor) / factor;
};
return entry;
}
}
[BepInPlugin("nightmaremode", "NIGHTMARE Mode", "1.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Plugin : BasePlugin
{
internal static ManualLogSource Log;
public override void Load()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
//IL_0040: Expected O, but got Unknown
Log = ((BasePlugin)this).Log;
NightmareSettings.Bind(((BasePlugin)this).Config);
RegisterModSettingsMenu();
RegisterRuntimeObjects();
new Harmony("net.heisenkebab.nightmaremode").PatchAll();
ManualLogSource log = Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(19, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Plugin ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("NIGHTMARE Mode");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" is loaded!");
}
log.LogInfo(val);
}
private static void RegisterModSettingsMenu()
{
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Expected O, but got Unknown
ModSettingsRegistry.Register("nightmaremode", new ModSettingsModOptions
{
Name = "NIGHTMARE Mode",
Description = "A mod that makes the game a nightmare",
Author = "Heisenkebab",
Version = "1.0.0",
ThunderstoreTeam = "Heisenkebab_Mods",
ThunderstoreModName = "NIGHTMARE_Mode"
});
}
private void RegisterRuntimeObjects()
{
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000f: Unknown result type (might be due to invalid IL or missing references)
//IL_0015: Expected O, but got Unknown
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
ClassInjector.RegisterTypeInIl2Cpp<ThiefSpawnTimer>();
GameObject val = new GameObject("NightmareModeThiefTimer");
Object.DontDestroyOnLoad((Object)val);
val.AddComponent<ThiefSpawnTimer>();
ClassInjector.RegisterTypeInIl2Cpp<NightmareRunEnder>();
GameObject val2 = new GameObject("NightmareModeRunEnder");
Object.DontDestroyOnLoad((Object)val2);
NightmareRunEnder.Instance = val2.AddComponent<NightmareRunEnder>();
}
}
internal class NightmareRunEnder : MonoBehaviour
{
internal const float QuotaMissedDelay = 4f;
internal const float DeathDelay = 3f;
internal static NightmareRunEnder Instance;
private float _secondsUntilEnd = -1f;
public static bool RunIsDead;
internal static string PendingEndMessage;
public NightmareRunEnder(IntPtr ptr)
: base(ptr)
{
}
internal void Schedule(float delaySeconds)
{
_secondsUntilEnd = Mathf.Max(delaySeconds, 0.05f);
}
private void Update()
{
if (!(_secondsUntilEnd < 0f))
{
_secondsUntilEnd -= Time.unscaledDeltaTime;
if (!(_secondsUntilEnd > 0f))
{
_secondsUntilEnd = -1f;
EndNow();
}
}
}
private void EndNow()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0056: Expected O, but got Unknown
//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
//IL_00ab: Expected O, but got Unknown
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//IL_001c: Expected O, but got Unknown
int currentSaveSlot = SaveManager.CurrentSaveSlot;
bool flag = default(bool);
try
{
SaveSystem.ResetSave(currentSaveSlot);
ManualLogSource log = Plugin.Log;
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(37, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[NightmareRunEnder] Wiped save slot ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(currentSaveSlot);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
}
log.LogInfo(val);
}
catch (Exception ex)
{
ManualLogSource log2 = Plugin.Log;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(40, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[NightmareRunEnder] ResetSave(");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(currentSaveSlot);
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(") failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex);
}
log2.LogError(val2);
}
try
{
PlatformManager.Instance.HandleEndSessionReturn((NetworkErrors)0);
}
catch (Exception ex2)
{
ManualLogSource log3 = Plugin.Log;
BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(51, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[NightmareRunEnder] HandleEndSessionReturn failed: ");
((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Exception>(ex2);
}
log3.LogError(val2);
}
}
internal static void ShowEndReason(string playerMessage)
{
if (string.IsNullOrEmpty(PendingEndMessage))
{
PendingEndMessage = playerMessage;
}
}
internal static void EndRun(string reason, float delaySeconds, string playerMessage)
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0024: Expected O, but got Unknown
ShowEndReason(playerMessage);
if (!RunIsDead)
{
RunIsDead = true;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(37, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("NIGHTMARE: run ended - ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(reason);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (ending in ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(delaySeconds);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s)");
}
log.LogInfo(val);
if ((Object)(object)Instance == (Object)null)
{
Plugin.Log.LogError((object)"NIGHTMARE: run ender was never registered, cannot end run.");
}
else
{
Instance.Schedule(delaySeconds);
}
}
}
}
internal enum SaveGameMode
{
Story,
Endless
}
internal class ThiefSpawnTimer : MonoBehaviour
{
private float _timer;
public ThiefSpawnTimer(IntPtr ptr)
: base(ptr)
{
}
private void Update()
{
if (!NightmareSettings.Enabled.Value || !NightmareSettings.ShouldSpawnThieves.Value)
{
return;
}
_timer += Time.deltaTime;
if (!(_timer < (float)NightmareSettings.SpawnInterval.Value))
{
_timer = 0f;
CurrentDayManager instance = CurrentDayManager.Instance;
if (!((Object)(object)instance == (Object)null) && instance.startedDay && ((NetworkBehaviour)instance).HasStateAuthority && Random.value < (float)NightmareSettings.SpawnChance.Value / 100f)
{
Plugin.Log.LogInfo((object)"[ThiefSpawnTimer] Roll succeeded, spawning thief.");
instance.SpawnThief();
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "nightmaremode";
public const string PLUGIN_NAME = "NIGHTMARE Mode";
public const string PLUGIN_VERSION = "1.0.0";
}
}
namespace NIGHTMAREMODE.Patches
{
[HarmonyPatch(typeof(PickupObject), "Spawned")]
public static class BoxContentsPatch
{
private static void Postfix(PickupObject __instance)
{
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Expected O, but got Unknown
if (NightmareSettings.Enabled.Value && !((Object)(object)((SimulationBehaviour)__instance).Object == (Object)null) && ((SimulationBehaviour)__instance).Object.HasStateAuthority && (__instance.itemStorage > 0 || __instance.itemStorage2 > 0) && __instance.itemStorage == 15)
{
int value = NightmareSettings.BoxContentAmount.Value;
int itemStorage = __instance.itemStorage;
int itemStorage2 = __instance.itemStorage2;
__instance.ChangeAmountOfItems(value, 0);
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(63, 6, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[PickupObject] Change box contents to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" on objectIndex ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(__instance.objectIndex);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(itemStorage);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(itemStorage2);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(__instance.itemStorage);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("/");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(__instance.itemStorage2);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
}
log.LogInfo(val);
}
}
}
[HarmonyPatch(typeof(StoreBrowseBehaviour), "Spawned")]
public static class CustomerPatiencePatch
{
private static void Postfix(StoreBrowseBehaviour __instance)
{
//IL_0071: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
if (!NightmareSettings.Enabled.Value || !NightmareSettings.ShouldLimitCustomerPatience.Value || (Object)(object)__instance.patienceCanvas == (Object)null || !((NetworkBehaviour)__instance).HasStateAuthority)
{
return;
}
Image componentInChildren = __instance.patienceCanvas.GetComponentInChildren<Image>(true);
if (!((Object)(object)componentInChildren == (Object)null))
{
__instance.patienceBar = componentInChildren;
__instance.hasPatience = true;
__instance.maxPatience = NightmareSettings.CustomerPatienceSeconds.Value;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Forced customer patience, max ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(NightmareSettings.CustomerPatienceSeconds.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("s");
}
log.LogInfo(val);
}
}
}
[HarmonyPatch(typeof(PlayerManager), "TakeDamage")]
public static class PlayerDamagePatch
{
private static void Prefix(ref float damage, ref bool significantAnim, ref string type, PlayerManager __instance)
{
if (NightmareSettings.Enabled.Value)
{
damage *= NightmareSettings.DamageTakenScaling.Value;
}
}
}
[HarmonyPatch(typeof(SaveManager), "Rpc_ActuallyGameplayValuesForClients")]
public static class ScaleSaveManagerQuotaPatch
{
private static void Prefix(ref float quota, SaveManager __instance)
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Expected O, but got Unknown
if (NightmareSettings.Enabled.Value && ((NetworkBehaviour)__instance).HasStateAuthority)
{
quota *= NightmareSettings.QuotaScaling.Value;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(37, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Scaled SaveManager gameplay quota to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(quota);
}
log.LogInfo(val);
}
}
}
[HarmonyPatch(typeof(EndOfDayReport), "Rpc_UpdateVariables")]
public static class ScaleEndOfDayReportQuotaPatch
{
private static void Prefix(ref float quota, EndOfDayReport __instance)
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: Expected O, but got Unknown
if (!NightmareSettings.Enabled.Value)
{
return;
}
StoreManager instance = StoreManager.Instance;
if (Object.op_Implicit((Object)(object)instance))
{
quota = instance.quota;
__instance.eodValues.mandatoryRevenue = instance.quota;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Scaled end-of-day quota to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(quota);
}
log.LogInfo(val);
}
}
}
[HarmonyPatch(typeof(PlayerManager), "Rpc_Die")]
public static class ResetOnDeathPatch
{
private static void Postfix(PlayerManager __instance)
{
if (!NightmareSettings.Enabled.Value)
{
return;
}
DeathResetMode value = NightmareSettings.DeathReset.Value;
string text = "Your whole team died. The save file has been wiped.";
string text2 = "You died. The save file has been wiped.";
FusionNetworkManager instance = FusionNetworkManager.Instance;
if ((Object)(object)instance == (Object)null)
{
Plugin.Log.LogError((object)"[ResetOnDeath] Instance of FusionNetworkManager does not exist");
return;
}
bool flag = instance.IsSoloMode();
if ((((NetworkBehaviour)__instance).HasStateAuthority && value == DeathResetMode.EveryoneDies) || (flag && value != DeathResetMode.Never))
{
NightmareRunEnder.EndRun("everyone died", 3f, flag ? text2 : text);
}
else
{
NightmareRunEnder.ShowEndReason(text);
}
}
}
[HarmonyPatch(typeof(PlayerManager), "Rpc_Downed")]
public static class ResetOnDownPatch
{
private static void Postfix(PlayerManager __instance)
{
if (NightmareSettings.Enabled.Value)
{
DeathResetMode value = NightmareSettings.DeathReset.Value;
string playerMessage = "A player died. The save file has been wiped.";
if (((NetworkBehaviour)__instance).HasStateAuthority && value == DeathResetMode.AnyoneDies)
{
NightmareRunEnder.EndRun("a player died", 3f, playerMessage);
}
else
{
NightmareRunEnder.ShowEndReason(playerMessage);
}
}
}
}
[HarmonyPatch(typeof(EndOfDayReport), "ShowQuota")]
public static class ResetOnMissingQuotaPatch
{
private static void Postfix(EndOfDayReport __instance)
{
if (NightmareSettings.Enabled.Value && NightmareSettings.QuotaReset.Value && !__instance.alreadyCompleted && !__instance.hitQuota)
{
if (((NetworkBehaviour)__instance).HasStateAuthority)
{
NightmareRunEnder.EndRun("quota missed", 4f, "You missed the quota. The save file has been wiped.");
}
else
{
NightmareRunEnder.ShowEndReason("You missed the quota. The save file has been wiped.");
}
}
}
}
[HarmonyPatch(typeof(SaveSystem), "SaveState")]
public static class BlockSaveOnDeadRun
{
private static bool Prefix()
{
return !NightmareRunEnder.RunIsDead;
}
}
[HarmonyPatch(typeof(MainMenu), "Start")]
public static class RunEndedMessagePatch
{
private static void Postfix(MainMenu __instance)
{
NightmareRunEnder.RunIsDead = false;
RunEndedPanelPatch.ActiveMessage = NightmareRunEnder.PendingEndMessage;
NightmareRunEnder.PendingEndMessage = null;
if (!string.IsNullOrEmpty(RunEndedPanelPatch.ActiveMessage))
{
__instance.ShowDisconnectedMessage(true, (NetworkErrors)2);
}
}
}
[HarmonyPatch(typeof(MainMenu), "ShowDisconnectedMessage")]
public static class RunEndedPanelPatch
{
internal static string ActiveMessage;
private static void Postfix(MainMenu __instance, bool show, NetworkErrors _errorType)
{
if (show && !string.IsNullOrEmpty(ActiveMessage))
{
if ((Object)(object)__instance.networkErrorObjTitleText != (Object)null)
{
((TMP_Text)__instance.networkErrorObjTitleText).text = "NIGHTMARE MODE";
}
if ((Object)(object)__instance.networkErrorObjDescText != (Object)null)
{
((TMP_Text)__instance.networkErrorObjDescText).text = ActiveMessage;
}
}
}
}
[HarmonyPatch(typeof(Spider), "Rpc_ChangeHittableHealth")]
public static class SpiderHealthPatch
{
private static void Prefix(ref float health, Spider __instance)
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
if (NightmareSettings.Enabled.Value && ((SimulationBehaviour)__instance).Object.HasStateAuthority)
{
float num = health;
health *= NightmareSettings.SpiderHealthScaling.Value;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(31, 3, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Scaled enemy health to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(NightmareSettings.SpiderHealthScaling.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x (");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(num);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(health);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")");
}
log.LogInfo(val);
}
}
}
[HarmonyPatch(typeof(Spider), "Start")]
public static class SpiderSpeedPatch
{
private static void Prefix(Spider __instance)
{
//IL_0073: Unknown result type (might be due to invalid IL or missing references)
//IL_0079: Expected O, but got Unknown
if (NightmareSettings.Enabled.Value)
{
__instance.normalSpeed *= NightmareSettings.SpiderSpeedScaling.Value;
__instance.runSpeed *= NightmareSettings.SpiderSpeedScaling.Value;
__instance.annoyedSpeed *= NightmareSettings.SpiderSpeedScaling.Value;
__instance.rampageSpeed *= NightmareSettings.SpiderSpeedScaling.Value;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(17, 1, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Scaled speed to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<float>(NightmareSettings.SpiderSpeedScaling.Value);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("x");
}
log.LogInfo(val);
}
}
}
[HarmonyPatch(typeof(StoreManager), "ThiefCaught")]
public static class ThiefMoneyPatch
{
private static bool Prefix(StoreManager __instance)
{
if (!NightmareSettings.Enabled.Value)
{
return true;
}
float value = NightmareSettings.ThiefCaughtPayout.Value;
if (value <= 0f)
{
return false;
}
__instance.ChangeRevenue("Items Returned", value);
return false;
}
}
[HarmonyPatch(typeof(RestockShelf), "RemoveAtStart")]
public static class TutorialShelfPatch
{
private static void Prefix(RestockShelf __instance)
{
//IL_006f: Unknown result type (might be due to invalid IL or missing references)
//IL_0075: Expected O, but got Unknown
if (!NightmareSettings.Enabled.Value || !__instance.tutorialShelf || !((SimulationBehaviour)__instance).Object.HasStateAuthority)
{
return;
}
SaveManager instance = SaveManager.Instance;
if (!((Object)(object)instance == (Object)null) && instance.curDay == 1 && SaveManager.GetGameMode(SaveManager.CurrentSaveSlot) == 0)
{
int num = NightmareSettings.BoxContentAmount.Value * 2;
int removeAtStartAmount = __instance.removeAtStartAmount;
__instance.removeAtStartAmount = num;
ManualLogSource log = Plugin.Log;
bool flag = default(bool);
BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(35, 2, ref flag);
if (flag)
{
((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[Restock] Set items to ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" instead of ");
((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(removeAtStartAmount);
}
log.LogInfo(val);
}
}
}
[HarmonyPatch(typeof(VentTrigger), "Rpc_EnterExitVent")]
public static class VentPushOutSpeedPatch
{
private static readonly int MySpeed = Animator.StringToHash("MySpeed");
private static void Postfix(VentTrigger __instance)
{
if (NightmareSettings.Enabled.Value && !((Object)(object)__instance.ventPushOutAnim == (Object)null) && __instance.playersInVent != null && __instance.playersInside >= 1)
{
__instance.ventPushOutAnim.SetFloat(MySpeed, NightmareSettings.VentPushOutSpeed.Value);
}
}
}
}