using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Reflection;
using MelonLoader;
using Microsoft.CodeAnalysis;
using NullHT;
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(FXAAImplement), "FXAAImplement", "1.0.0", "NullHT", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("FXAAImplement")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FXAAImplement")]
[assembly: AssemblyTitle("FXAAImplement")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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]
[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 NullHT
{
public class FXAAImplement : MelonMod
{
public override void OnSceneWasInitialized(int buildIndex, string sceneName)
{
MelonLogger.Msg("[FXAA] Scene \"" + sceneName + "\" initialized successfully. Searching for cameras...");
ApplyFXAAToCameras();
}
private void ApplyFXAAToCameras()
{
try
{
Il2CppReferenceArray<Object> val = Object.FindObjectsOfType(Type.GetType("UnityEngine.Camera, UnityEngine.CoreModule"));
if (val == null || ((Il2CppArrayBase<Object>)(object)val).Length == 0)
{
MelonLogger.Warning("[FXAA] Warning: No active cameras found in this scene.");
return;
}
int num = 0;
foreach (Object item in (Il2CppArrayBase<Object>)(object)val)
{
if (item == (Object)null)
{
continue;
}
Camera val2 = ((Il2CppObjectBase)item).TryCast<Camera>();
if ((Object)(object)val2 == (Object)null || (Object)(object)((Component)val2).gameObject == (Object)null)
{
continue;
}
string name = ((Object)((Component)val2).gameObject).name;
if (!name.Contains("MainCamera") && !name.Contains("Head") && !name.Contains("VR"))
{
continue;
}
val2.allowMSAA = false;
Component val3 = null;
Il2CppArrayBase<Component> components = ((Component)val2).gameObject.GetComponents<Component>();
foreach (Component item2 in components)
{
if ((Object)(object)item2 != (Object)null && ((MemberInfo)((Object)item2).GetIl2CppType()).Name.Contains("UniversalAdditionalCameraData"))
{
val3 = item2;
break;
}
}
if ((Object)(object)val3 != (Object)null)
{
PropertyInfo property = ((object)val3).GetType().GetProperty("antialiasing");
if (property != null)
{
property.SetValue(val3, 1, null);
MelonLogger.Msg("[FXAA] Anti-aliasing successfully activated for camera: " + name);
num++;
}
}
}
if (num > 0)
{
MelonLogger.Msg($"[FXAA] Done! Anti-aliasing settings successfully applied to {num} camera(s).");
}
else
{
MelonLogger.Msg("[FXAA] No primary player cameras detected in this scene.");
}
}
catch (Exception ex)
{
MelonLogger.Error("[FXAA] Critical error occurred while attempting to apply anti-aliasing: " + ex.Message);
}
}
}
}