using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Material_Finder;
using MelonLoader;
using UnityEngine;
using UnityEngine.SceneManagement;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: MelonInfo(typeof(MaterialFinder), "Material Finder", "1.0.1", "Hologram Null", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace Material_Finder;
public static class BuildInfo
{
public const string Name = "Material Finder";
public const string Author = "Hologram Null";
public const string Version = "1.0.1";
}
public class MaterialFinder : MelonMod
{
[CompilerGenerated]
private sealed class <RepeatScan>d__4 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public MaterialFinder <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <RepeatScan>d__4(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003f: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (<>4__this.running)
{
<>4__this.ScanMaterials();
<>2__current = (object)new WaitForSeconds(5f);
<>1__state = 1;
return true;
}
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();
}
}
[CompilerGenerated]
private sealed class <SceneWatcher>d__5 : IEnumerator<object>, IDisposable, IEnumerator
{
private int <>1__state;
private object <>2__current;
public MaterialFinder <>4__this;
private int <current>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <SceneWatcher>d__5(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Expected O, but got Unknown
//IL_007e: Unknown result type (might be due to invalid IL or missing references)
//IL_0083: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
break;
case 1:
<>1__state = -1;
break;
}
if (<>4__this.running)
{
Scene activeScene = SceneManager.GetActiveScene();
<current>5__1 = ((Scene)(ref activeScene)).buildIndex;
if (<current>5__1 != <>4__this.lastSceneBuildIndex)
{
<>4__this.lastSceneBuildIndex = <current>5__1;
<>4__this.loggedMaterials.Clear();
activeScene = SceneManager.GetActiveScene();
MelonLogger.Msg("=== Scene Loaded: " + ((Scene)(ref activeScene)).name + " ===");
<>4__this.ScanMaterials();
}
<>2__current = (object)new WaitForSeconds(0.25f);
<>1__state = 1;
return true;
}
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 int lastSceneBuildIndex = -1;
private bool running = true;
private HashSet<string> loggedMaterials = new HashSet<string>();
public override void OnInitializeMelon()
{
//IL_000d: Unknown result type (might be due to invalid IL or missing references)
//IL_0012: Unknown result type (might be due to invalid IL or missing references)
MelonLogger.Msg("=== Material Finder Initialized ===");
Scene activeScene = SceneManager.GetActiveScene();
lastSceneBuildIndex = ((Scene)(ref activeScene)).buildIndex;
MelonCoroutines.Start(RepeatScan());
MelonCoroutines.Start(SceneWatcher());
}
[IteratorStateMachine(typeof(<RepeatScan>d__4))]
private IEnumerator RepeatScan()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <RepeatScan>d__4(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<SceneWatcher>d__5))]
private IEnumerator SceneWatcher()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <SceneWatcher>d__5(0)
{
<>4__this = this
};
}
private void ScanMaterials()
{
Il2CppArrayBase<Renderer> val = Object.FindObjectsOfType<Renderer>();
if (val == null || val.Length == 0)
{
return;
}
foreach (Renderer item2 in val)
{
if ((Object)(object)item2 == (Object)null)
{
continue;
}
Il2CppReferenceArray<Material> sharedMaterials = item2.sharedMaterials;
if (sharedMaterials == null)
{
continue;
}
foreach (Material item3 in (Il2CppArrayBase<Material>)(object)sharedMaterials)
{
if (!((Object)(object)item3 == (Object)null))
{
string text = (((Object)(object)((Component)item2).gameObject != (Object)null) ? ((Object)((Component)item2).gameObject).name : "(unknown)");
string text2 = ((!string.IsNullOrEmpty(((Object)item3).name)) ? ((Object)item3).name : "(unnamed)");
string text3 = (((Object)(object)item3.shader != (Object)null && !string.IsNullOrEmpty(((Object)item3.shader).name)) ? ((Object)item3.shader).name : "(no shader)");
string item = text + "|" + text2 + "|" + text3;
if (!loggedMaterials.Contains(item))
{
loggedMaterials.Add(item);
MelonLogger.Msg("Object: " + text + " Material: " + text2 + " Shader: " + text3);
}
}
}
}
}
public override void OnApplicationQuit()
{
running = false;
}
}