using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ULTRAKILL.Cheats;
using UnityEngine;
using UnityEngine.AI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("TimeStop")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("TimeStop")]
[assembly: AssemblyTitle("TimeStop")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
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.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
internal sealed class NullableContextAttribute : Attribute
{
public readonly byte Flag;
public NullableContextAttribute(byte P_0)
{
Flag = P_0;
}
}
}
namespace TimeStop
{
[BepInPlugin("com.banana.timestop", "TimeStop", "1.0.3")]
public class Main : BaseUnityPlugin
{
private struct AnimatorState
{
public Animator animator;
public float speed;
}
private struct RigidbodyState
{
public Vector3 velocity;
public Vector3 angularVelocity;
public bool wasKinematic;
}
public static bool IsActive;
private List<AnimatorState> pausedAnimators = new List<AnimatorState>();
private Dictionary<Rigidbody, RigidbodyState> rbs = new Dictionary<Rigidbody, RigidbodyState>();
public Harmony Harmony;
private void Start()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
Harmony = new Harmony("com.banana.timestop");
Harmony.PatchAll();
}
private void Update()
{
if (Input.GetKeyDown((KeyCode)116))
{
ToggleTimeStop();
}
}
private void FixedUpdate()
{
if (IsActive)
{
ApplyTimeStop();
}
}
private void ToggleTimeStop()
{
IsActive = !IsActive;
if (!IsActive)
{
ResetTimeStop();
}
}
private void ApplyTimeStop()
{
//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_00f8: 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_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
Rigidbody[] array = Object.FindObjectsOfType<Rigidbody>();
Rigidbody[] array2 = array;
foreach (Rigidbody val in array2)
{
if ((Object)(object)val != (Object)null && (Object)(object)val != (Object)(object)MonoSingleton<NewMovement>.Instance?.rb)
{
if (rbs.ContainsKey(val) && val.isKinematic)
{
rbs[val] = new RigidbodyState
{
velocity = rbs[val].velocity,
angularVelocity = rbs[val].angularVelocity,
wasKinematic = rbs[val].wasKinematic
};
}
else
{
rbs[val] = new RigidbodyState
{
velocity = val.velocity,
angularVelocity = val.angularVelocity,
wasKinematic = val.isKinematic
};
}
val.isKinematic = true;
}
}
ParticleSystem[] array3 = Object.FindObjectsOfType<ParticleSystem>();
for (int j = 0; j < array3.Length; j++)
{
if (array3[j].isPlaying)
{
ParticleSystem obj = array3[j];
if (obj != null)
{
obj.Pause();
}
}
}
NewMovement instance = MonoSingleton<NewMovement>.Instance;
Animator[] array4 = Object.FindObjectsOfType<Animator>();
foreach (Animator val2 in array4)
{
if (!((Object)(object)val2 == (Object)null) && !ShouldSkipAnimator(val2, instance) && !ContainsAnimator(pausedAnimators, val2))
{
pausedAnimators.Add(new AnimatorState
{
animator = val2,
speed = val2.speed
});
val2.speed = 0f;
}
}
NavMeshAgent[] array5 = Object.FindObjectsOfType<NavMeshAgent>();
NavMeshAgent[] array6 = array5;
foreach (NavMeshAgent val3 in array6)
{
if ((Object)(object)val3 != (Object)null && val3.isOnNavMesh)
{
val3.isStopped = true;
}
}
}
private void ResetTimeStop()
{
//IL_006c: Unknown result type (might be due to invalid IL or missing references)
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
((BaseUnityPlugin)this).Logger.LogInfo((object)"Resetting TimeStop");
foreach (KeyValuePair<Rigidbody, RigidbodyState> rb in rbs)
{
Rigidbody key = rb.Key;
RigidbodyState value = rb.Value;
if ((Object)(object)key != (Object)null && (Object)(object)key != (Object)(object)MonoSingleton<NewMovement>.Instance?.rb)
{
key.velocity = value.velocity;
key.angularVelocity = value.angularVelocity;
key.isKinematic = value.wasKinematic;
}
}
rbs.Clear();
ParticleSystem[] array = Object.FindObjectsOfType<ParticleSystem>();
foreach (ParticleSystem val in array)
{
if ((Object)(object)val != (Object)null)
{
MainModule main = val.main;
if ((!((MainModule)(ref main)).loop || !val.isStopped) && val.isPaused)
{
val.Play();
}
}
}
for (int j = 0; j < pausedAnimators.Count; j++)
{
if ((Object)(object)pausedAnimators[j].animator != (Object)null)
{
pausedAnimators[j].animator.speed = pausedAnimators[j].speed;
}
}
pausedAnimators.Clear();
NavMeshAgent[] array2 = Object.FindObjectsOfType<NavMeshAgent>();
NavMeshAgent[] array3 = array2;
foreach (NavMeshAgent val2 in array3)
{
if ((Object)(object)val2 != (Object)null && val2.isOnNavMesh)
{
val2.isStopped = false;
}
}
}
private bool ShouldSkipAnimator(Animator animator, NewMovement newMovement)
{
if ((Object)(object)newMovement?.punch?.currentPunch?.anim == (Object)(object)animator)
{
return true;
}
GunControl instance = MonoSingleton<GunControl>.instance;
if ((Object)(object)instance?.currentWeapon != (Object)null)
{
Animator componentInChildren = instance.currentWeapon.GetComponentInChildren<Animator>();
if ((Object)(object)componentInChildren == (Object)(object)animator)
{
return true;
}
}
return false;
}
private bool ContainsAnimator(List<AnimatorState> list, Animator animator)
{
for (int i = 0; i < list.Count; i++)
{
if ((Object)(object)list[i].animator == (Object)(object)animator)
{
return true;
}
}
return false;
}
}
[HarmonyPatch(typeof(Explosion), "FixedUpdate")]
public class StopExplosion
{
public static bool Prefix()
{
return !Main.IsActive;
}
}
[HarmonyPatch(typeof(TimeBomb), "Update")]
public class StopMagnet
{
public static bool Prefix()
{
return !Main.IsActive;
}
}
[HarmonyPatch(typeof(PhysicalShockwave))]
public class PhysicalShockwavePatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPostfix(PhysicalShockwave __instance)
{
if (__instance.fading)
{
((MonoBehaviour)__instance).StartCoroutine(TimeStopCoroutine((MonoBehaviour)(object)__instance, (Action)__instance.GetDestroyed, __instance.speed / 10f));
}
}
[HarmonyPatch("Update")]
[HarmonyPrefix]
public static bool UpdatePrefix(PhysicalShockwave __instance)
{
//IL_001d: 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_004a: Unknown result type (might be due to invalid IL or missing references)
//IL_0061: Unknown result type (might be due to invalid IL or missing references)
//IL_007a: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: Unknown result type (might be due to invalid IL or missing references)
if (!Main.IsActive)
{
((Component)__instance).transform.localScale = new Vector3(((Component)__instance).transform.localScale.x + Time.deltaTime * __instance.speed, ((Component)__instance).transform.localScale.y, ((Component)__instance).transform.localScale.z + Time.deltaTime * __instance.speed);
if (!__instance.fading && (((Component)__instance).transform.localScale.x > __instance.maxSize || ((Component)__instance).transform.localScale.z > __instance.maxSize))
{
__instance.fading = true;
ScaleNFade[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<ScaleNFade>();
for (int i = 0; i < componentsInChildren.Length; i++)
{
((Behaviour)componentsInChildren[i]).enabled = true;
}
((MonoBehaviour)__instance).StartCoroutine(TimeStopCoroutine((MonoBehaviour)(object)__instance, (Action)__instance.GetDestroyed, __instance.speed / 10f));
}
}
return false;
}
private static IEnumerator TimeStopCoroutine(MonoBehaviour instance, Action action, float delay)
{
float elapsedTime = 0f;
while (elapsedTime < delay)
{
if (!Main.IsActive)
{
elapsedTime += Time.deltaTime;
}
yield return null;
}
action();
}
}
[HarmonyPatch(typeof(Countdown), "Update")]
public class StopCountdown
{
public static bool Prefix()
{
return !Main.IsActive;
}
}
[HarmonyPatch(typeof(Vector3), "MoveTowards")]
public class StopMoveTowards
{
public static bool Prefix(ref Vector3 __result, Vector3 current, Vector3 target, float maxDistanceDelta)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if (Main.IsActive)
{
__result = current;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Quaternion), "RotateTowards")]
public class StopMoveTowardsQuaternion
{
public static bool Prefix(ref Quaternion __result, Quaternion from, Quaternion to, float maxDegreesDelta)
{
//IL_000c: Unknown result type (might be due to invalid IL or missing references)
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
if (Main.IsActive)
{
__result = from;
return false;
}
return true;
}
}
[HarmonyPatch(typeof(Nail), "Start")]
public class SawbladeStartPatch
{
[HarmonyPrefix]
public static bool Prefix(Nail __instance)
{
((MonoBehaviour)__instance).StartCoroutine(ModifiedStart(__instance));
return false;
}
private static IEnumerator ModifiedStart(Nail instance)
{
Nail instance2 = instance;
if (instance2.sawblade)
{
instance2.removeTimeMultiplier = 3f;
}
if (instance2.magnets.Count == 0)
{
yield return TimeStopCoroutine((MonoBehaviour)(object)instance2, delegate
{
instance2.RemoveTime();
}, 5f * instance2.removeTimeMultiplier);
}
yield return TimeStopCoroutine((MonoBehaviour)(object)instance2, delegate
{
instance2.MasterRemoveTime();
}, 60f);
instance2.startPosition = ((Component)instance2).transform.position;
yield return TimeStopCoroutine((MonoBehaviour)(object)instance2, delegate
{
instance2.SlowUpdate();
}, 2f);
}
private static IEnumerator TimeStopCoroutine(MonoBehaviour instance, Action action, float delay)
{
float elapsedTime = 0f;
while (elapsedTime < delay)
{
if (!Main.IsActive)
{
elapsedTime += Time.deltaTime;
}
yield return null;
}
action();
}
}
[HarmonyPatch(typeof(RevolverBeam), "Update")]
public class StopBeamDisappear
{
public static bool Prefix()
{
return !Main.IsActive;
}
}
[HarmonyPatch(typeof(EnemyIdentifier))]
public class EnemyBehaviorPatch
{
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
public static void AttackEnemiesPostfix(ref bool __result)
{
if (Main.IsActive)
{
__result = false;
}
}
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
[HarmonyPostfix]
public static void IgnorePlayerPostfix(ref bool __result)
{
if (Main.IsActive)
{
__result = true;
}
}
}
[HarmonyPatch(typeof(RemoveOnTime))]
public class RemoveOnTimePatch
{
[HarmonyPatch("Start")]
[HarmonyPostfix]
public static void StartPostfix(RemoveOnTime __instance)
{
if (__instance.useAudioLength)
{
((MonoBehaviour)__instance).StartCoroutine(RemoveCoroutine(__instance));
return;
}
((MonoBehaviour)__instance).CancelInvoke("Remove");
((MonoBehaviour)__instance).StartCoroutine(RemoveCoroutine(__instance));
}
private static IEnumerator RemoveCoroutine(RemoveOnTime instance)
{
float elapsedTime = 0f;
float targetTime;
if (instance.useAudioLength)
{
AudioSource audioSource = ((Component)instance).GetComponent<AudioSource>();
targetTime = audioSource.clip.length * audioSource.pitch;
}
else
{
targetTime = instance.time + Random.Range(0f - instance.randomizer, instance.randomizer);
}
while (elapsedTime < targetTime)
{
if (!Main.IsActive)
{
elapsedTime += Time.deltaTime;
}
yield return null;
}
((Component)instance).SendMessage("Remove");
}
[HarmonyPatch("Remove")]
[HarmonyPrefix]
public static bool RemovePrefix(RemoveOnTime __instance)
{
if (__instance.affectedByNoCooldowns && NoWeaponCooldown.NoCooldown)
{
((MonoBehaviour)__instance).StartCoroutine(RemoveCoroutine(__instance));
return false;
}
return true;
}
}
}
namespace System.Runtime.CompilerServices
{
[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
internal sealed class IgnoresAccessChecksToAttribute : Attribute
{
internal IgnoresAccessChecksToAttribute(string assemblyName)
{
}
}
}