using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using MelonLoader;
using Microsoft.CodeAnalysis;
using QuestShadows;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(QuestShadowsMod), "QuestShadows", "0.1.1", "Nova", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("QuestShadows")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("QuestShadows")]
[assembly: AssemblyTitle("QuestShadows")]
[assembly: NeutralResourcesLanguage("en-US")]
[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 QuestShadows
{
public class QuestShadowsMod : MelonMod
{
private float nextScanTime;
private bool initialScanDone;
private const float ShadowDistance = 10f;
private const float ShadowStrength = 0.85f;
public override void OnInitializeMelon()
{
((MelonBase)this).LoggerInstance.Msg("Quest Shadows v0.1.1 loaded.");
ApplyGlobalSettings();
nextScanTime = Time.time + 5f;
}
public override void OnUpdate()
{
if (!initialScanDone && Time.time >= nextScanTime)
{
ApplyGlobalSettings();
EnableDirectionalLightShadows();
initialScanDone = true;
nextScanTime = Time.time + 15f;
}
else if (initialScanDone && Time.time >= nextScanTime)
{
ApplyGlobalSettings();
EnableDirectionalLightShadows();
nextScanTime = Time.time + 15f;
}
}
private void ApplyGlobalSettings()
{
try
{
QualitySettings.shadows = (ShadowQuality)1;
QualitySettings.shadowDistance = 10f;
QualitySettings.shadowResolution = (ShadowResolution)0;
QualitySettings.shadowCascades = 2;
((MelonBase)this).LoggerInstance.Msg("Global shadow settings applied.");
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Error("Global shadow settings failed: " + ex.Message);
}
}
private void EnableDirectionalLightShadows()
{
//IL_0082: Unknown result type (might be due to invalid IL or missing references)
//IL_0088: Invalid comparison between Unknown and I4
try
{
Light[] array = Il2CppArrayBase<Light>.op_Implicit(Resources.FindObjectsOfTypeAll<Light>());
int num = 0;
int num2 = 0;
Light[] array2 = array;
foreach (Light val in array2)
{
if ((Object)(object)val == (Object)null)
{
continue;
}
num++;
GameObject gameObject = ((Component)val).gameObject;
if (!((Object)(object)gameObject == (Object)null) && gameObject.activeInHierarchy && ((Behaviour)val).enabled && (int)val.type == 1)
{
try
{
val.shadows = (LightShadows)1;
val.shadowStrength = 0.85f;
val.shadowBias = 0.05f;
val.shadowNormalBias = 0.4f;
num2++;
((MelonBase)this).LoggerInstance.Msg("Enabled shadows on light: " + ((Object)gameObject).name);
}
catch (Exception ex)
{
((MelonBase)this).LoggerInstance.Warning("Could not modify light " + ((Object)gameObject).name + ": " + ex.Message);
}
}
}
((MelonBase)this).LoggerInstance.Msg("Light scan complete. Found: " + num + " | Directional shadows enabled: " + num2);
}
catch (Exception ex2)
{
((MelonBase)this).LoggerInstance.Error("Light scan failed: " + ex2.Message);
}
}
}
}