using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using OccaSoftware.Buto.Runtime;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.1", FrameworkDisplayName = ".NET Framework 4.6.1")]
[assembly: AssemblyCompany("NoLoadingScreen")]
[assembly: AssemblyConfiguration("R")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NoLoadingScreen")]
[assembly: AssemblyTitle("NoLoadingScreen")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.tawoly.NoLS", "No Loading Screen", "2.0.2")]
public class NoLoadingScreen : BaseUnityPlugin
{
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("com.tawoly.NoLS");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"NoLoadingScreenMod: Loaded and Harmony-Patches active");
}
}
[HarmonyPatch(typeof(LoadingScreen), "Show")]
public static class LoadingScreenShowPatch
{
[CompilerGenerated]
private sealed class <FadeFog>d__4 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public ButoVolumetricFog fog;
public float duration;
public float targetDensity;
private float <startDensity>5__1;
private float <startTime>5__2;
private float <t>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FadeFog>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
if ((Object)(object)fog == (Object)null)
{
return false;
}
<startDensity>5__1 = ((VolumeParameter<float>)(object)fog.fogDensity).value;
<startTime>5__2 = Time.time;
break;
case 1:
<>1__state = -1;
break;
}
if (Time.time < <startTime>5__2 + duration)
{
<t>5__3 = (Time.time - <startTime>5__2) / duration;
((VolumeParameter<float>)(object)fog.fogDensity).value = Mathf.Lerp(<startDensity>5__1, targetDensity, <t>5__3);
<>2__current = null;
<>1__state = 1;
return true;
}
((VolumeParameter<float>)(object)fog.fogDensity).value = targetDensity;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static Volume volume;
private static ButoVolumetricFog fog;
[HarmonyPostfix]
[HarmonyPatch("Show")]
public static void OnShow(LoadingScreen __instance, float fadeTime = 2f)
{
CreateLSFog();
((MonoBehaviour)__instance).StartCoroutine(FadeFog(fog, 2f, 100f));
Image component = ((Component)__instance).GetComponent<Image>();
if (!((Object)(object)component == (Object)null))
{
((Behaviour)component).enabled = false;
}
}
[HarmonyPostfix]
[HarmonyPatch("Hide")]
public static void OnHide(LoadingScreen __instance, float fadeTime = 2f)
{
((MonoBehaviour)__instance).StartCoroutine(FadeFog(fog, 2f, 0f));
}
[IteratorStateMachine(typeof(<FadeFog>d__4))]
private static IEnumerator FadeFog(ButoVolumetricFog fog, float duration, float targetDensity)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FadeFog>d__4(0)
{
fog = fog,
duration = duration,
targetDensity = targetDensity
};
}
public static bool FindButoFogVolume(out Volume foundVolume)
{
Volume[] array = Object.FindObjectsOfType<Volume>();
ButoVolumetricFog val2 = default(ButoVolumetricFog);
foreach (Volume val in array)
{
if (!((Object)(object)val.profile == (Object)null) && val.profile.TryGet<ButoVolumetricFog>(ref val2))
{
foundVolume = val;
return true;
}
}
foundVolume = null;
return false;
}
private static void CreateLSFog()
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Expected O, but got Unknown
if (!((Object)(object)volume != (Object)null) && FindButoFogVolume(out var foundVolume))
{
GameObject val = new GameObject("LoadingScreenFog");
volume = val.AddComponent<Volume>();
volume.isGlobal = true;
volume.priority = foundVolume.priority + 1f;
volume.profile = Object.Instantiate<VolumeProfile>(foundVolume.profile);
ButoVolumetricFog val2 = default(ButoVolumetricFog);
if (volume.profile.TryGet<ButoVolumetricFog>(ref val2))
{
fog = val2;
}
}
}
}