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.Unity.IL2CPP;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityStandardAssets.Characters.FirstPerson;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("SkipWakeUpMod")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Skip Wake Up")]
[assembly: AssemblyTitle("SkipWakeUpMod")]
[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 Granny2SkipWakeUp
{
[BepInPlugin("com.granny2.skipwakeup", "Skip Wake Up", "1.0.0")]
public class Plugin : BasePlugin
{
public override void Load()
{
Harmony.CreateAndPatchAll(typeof(IntroPatches), (string)null);
((BasePlugin)this).AddComponent<SkipIntroComponent>();
}
}
[HarmonyPatch]
public class IntroPatches
{
[HarmonyPatch(typeof(startNewDay), "Start")]
[HarmonyPostfix]
public static void StartNewDay_Start_Postfix()
{
try
{
SkipIntroComponent.ResetIntroWindow();
}
catch
{
}
}
[HarmonyPatch(typeof(startNewDay), "newDay")]
[HarmonyPostfix]
public static void StartNewDay_NewDay_Postfix()
{
try
{
SkipIntroComponent.ResetIntroWindow();
}
catch
{
}
}
}
public class SkipIntroComponent : MonoBehaviour
{
private static bool isSpeedingUp = false;
private static float originalTimeScale = 1f;
private static float introTimer = 0f;
private static bool introWindowActive = false;
public SkipIntroComponent(IntPtr ptr)
: base(ptr)
{
}
public static void ResetIntroWindow()
{
RestoreNormalSpeed();
introTimer = 0f;
introWindowActive = true;
}
public static void RestoreNormalSpeed()
{
if (isSpeedingUp)
{
Time.timeScale = originalTimeScale;
isSpeedingUp = false;
}
}
private void Update()
{
if (introWindowActive)
{
introTimer += Time.unscaledDeltaTime;
if (introTimer > 15f)
{
introWindowActive = false;
RestoreNormalSpeed();
}
}
if (Input.GetKeyDown((KeyCode)98) && introWindowActive && !isSpeedingUp)
{
originalTimeScale = Time.timeScale;
Time.timeScale = 20f;
isSpeedingUp = true;
}
if (isSpeedingUp && IsPlayerMoving())
{
RestoreNormalSpeed();
introWindowActive = false;
}
}
private bool IsPlayerMoving()
{
GameObject val = GameObject.Find("Player");
if ((Object)(object)val == (Object)null)
{
return false;
}
FirstPersonController_Egen component = val.GetComponent<FirstPersonController_Egen>();
if ((Object)(object)component == (Object)null)
{
return false;
}
return ((Behaviour)component).enabled && !component.playerCaught && !component.playerEscape;
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "SkipWakeUpMod";
public const string PLUGIN_NAME = "Skip Wake Up";
public const string PLUGIN_VERSION = "1.0.0";
}
}