using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.NET.Common;
using BepInExResoniteShim;
using FrooxEngine;
using HarmonyLib;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(/*Could not decode attribute arguments.*/)]
[assembly: TargetFramework(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
[assembly: AssemblyCompany("eia485, kazu0617, rampa3")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("4.1.0.0")]
[assembly: AssemblyInformationalVersion("4.1.0+5c2eb1ab5670038c242200ffc544b7fe411f7275")]
[assembly: AssemblyProduct("ExposePatchedMethods")]
[assembly: AssemblyTitle("ExposePatchedMethods")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/EIA485/NeosExposePatchedMethods")]
[assembly: AssemblyVersion("4.1.0.0")]
[module: RefSafetyRules(11)]
namespace ExposePatchedMethods;
[ResonitePlugin("net.eia485.ExposePatchedMethods", "ExposePatchedMethods", "4.1.0", "eia485, kazu0617, rampa3", "https://github.com/EIA485/NeosExposePatchedMethods")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class ExposePatchedMethods : BasePlugin
{
[Flags]
private enum NameMetadata
{
None = 0,
Guid = 1,
Version = 2,
Author = 4,
Link = 8,
All = 0xF
}
[HarmonyPatch]
private class Patches
{
[HarmonyPostfix]
[HarmonyPatch(typeof(Userspace), "OnAttach")]
private static void UserspaceOnAttachPostfix(Userspace __instance)
{
if (ExposeUserspace.Value)
{
GenList(((Worker)__instance).World.RootSlot);
}
if (UserSpaceModNamesMeta.Value != 0)
{
GenList(((Worker)__instance).World.RootSlot, UserSpaceModNamesMeta.Value);
}
}
[HarmonyPostfix]
[HarmonyPatch(/*Could not decode attribute arguments.*/)]
private static void LocalUserSetterPostfix(User value)
{
//IL_0020: Unknown result type (might be due to invalid IL or missing references)
//IL_002a: Expected O, but got Unknown
//IL_0025: Unknown result type (might be due to invalid IL or missing references)
User value2 = value;
((Worker)value2).World.RunInUpdates(0, (Action)delegate
{
LinkRef<UserRoot> obj = (LinkRef<UserRoot>)AccessTools.Field(typeof(User), "userRoot").GetValue((object)value2);
((SyncRef<UserRoot>)(object)obj).OnTargetChange += OnLocalUserRootChanged;
OnLocalUserRootChanged((SyncRef<UserRoot>)(object)obj);
});
}
}
[CompilerGenerated]
private static class <>O
{
public static SlotChildEvent <0>__Slot_ChildAdded;
}
private static ConfigEntry<bool> ExposeUserspace;
private static ConfigEntry<bool> ExposeEverywhere;
private static ConfigEntry<NameMetadata> UserSpaceModNamesMeta;
private static ConfigEntry<NameMetadata> EverywhereModNamesMeta;
private static HashSet<string> harmonyIds;
public static HashSet<string> HarmonyIds
{
get
{
if (harmonyIds == null)
{
harmonyIds = new HashSet<string>();
global::System.Collections.Generic.IEnumerator<MethodBase> enumerator = Harmony.GetAllPatchedMethods().GetEnumerator();
try
{
while (((global::System.Collections.IEnumerator)enumerator).MoveNext())
{
global::System.Collections.Generic.IEnumerator<string> enumerator2 = Harmony.GetPatchInfo(enumerator.Current).Owners.GetEnumerator();
try
{
while (((global::System.Collections.IEnumerator)enumerator2).MoveNext())
{
string current = enumerator2.Current;
HarmonyIds.Add(current);
}
}
finally
{
((global::System.IDisposable)enumerator2)?.Dispose();
}
}
}
finally
{
((global::System.IDisposable)enumerator)?.Dispose();
}
}
return harmonyIds;
}
}
public override void Load()
{
ExposeUserspace = ((BasePlugin)this).Config.Bind<bool>("ExposePatchedMethods", "Show in userspace", true, "Enables showing harmony ids under the root of UserSpace.");
ExposeEverywhere = ((BasePlugin)this).Config.Bind<bool>("ExposePatchedMethods", "Show Everywhere", false, "Enables showing harmony ids in WorldSpace. They show under your user root");
UserSpaceModNamesMeta = ((BasePlugin)this).Config.Bind<NameMetadata>("ExposePatchedMethods", "Show Names in userspace w/ metadata", NameMetadata.All, "Enables showing mod names under the root of UserSpace. also allows you to select what metadata to show");
EverywhereModNamesMeta = ((BasePlugin)this).Config.Bind<NameMetadata>("ExposePatchedMethods", "Show Names Everywhere w/ metadata", NameMetadata.All, "Enables showing mod names in WorldSpace. They show under your user root. also allows you to select what metadata to show");
((BasePlugin)this).HarmonyInstance.PatchAll();
}
private static void OnLocalUserRootChanged(SyncRef<UserRoot> userRoot)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Expected O, but got Unknown
if (userRoot.Target != null)
{
Slot slot = ((Component)userRoot.Target).Slot;
object obj = <>O.<0>__Slot_ChildAdded;
if (obj == null)
{
SlotChildEvent val = Slot_ChildAdded;
<>O.<0>__Slot_ChildAdded = val;
obj = (object)val;
}
slot.ChildAdded += (SlotChildEvent)obj;
}
}
private static void Slot_ChildAdded(Slot slot, Slot child)
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_004b: Expected O, but got Unknown
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Expected O, but got Unknown
Slot slot2 = slot;
Slot obj = slot2;
object obj2 = <>O.<0>__Slot_ChildAdded;
if (obj2 == null)
{
SlotChildEvent val = Slot_ChildAdded;
<>O.<0>__Slot_ChildAdded = val;
obj2 = (object)val;
}
obj.ChildAdded -= (SlotChildEvent)obj2;
slot2.RunInUpdates(1, (Action)delegate
{
if (ExposeEverywhere.Value)
{
GenList(slot2);
}
if (EverywhereModNamesMeta.Value != 0)
{
GenList(slot2, EverywhereModNamesMeta.Value);
}
});
}
private static void GenList(Slot slot, NameMetadata metadata)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_0054: Unknown result type (might be due to invalid IL or missing references)
Slot val = Enumerable.FirstOrDefault<Slot>((global::System.Collections.Generic.IEnumerable<Slot>)(object)slot.Children, (Func<Slot, bool>)((Slot s) => s.Name == "Loaded mod names")) ?? slot.AddSlot("Loaded mod names", false);
Enumerator<string, PluginInfo> enumerator = ((BaseChainloader<BasePlugin>)(object)NetChainloader.Instance).Plugins.Values.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
PluginInfo current = enumerator.Current;
Slot val2 = val.AddSlot(current.Metadata.Name, true);
if (metadata != 0)
{
((SyncField<string>)(object)((ContainerWorker<Component>)(object)val2).AttachComponent<DynamicVariableSpace>(true, (Action<DynamicVariableSpace>)null).SpaceName).Value = "modMetaData";
}
if (((global::System.Enum)metadata).HasFlag((global::System.Enum)NameMetadata.Version))
{
DynamicVariableHelper.CreateVariable<string>(val2, "modMetaData/Version", ((object)current.Metadata.Version).ToString(), true);
}
if (((global::System.Enum)metadata).HasFlag((global::System.Enum)NameMetadata.Guid))
{
DynamicVariableHelper.CreateVariable<string>(val2, "modMetaData/GUID", current.Metadata.GUID, true);
}
BepInPlugin metadata2 = MetadataHelper.GetMetadata(current.Instance);
ResonitePlugin val3 = (ResonitePlugin)(object)((metadata2 is ResonitePlugin) ? metadata2 : null);
if (val3 != null)
{
if (((global::System.Enum)metadata).HasFlag((global::System.Enum)NameMetadata.Author))
{
DynamicVariableHelper.CreateVariable<string>(val2, "modMetaData/Author", val3.Author, true);
}
if (((global::System.Enum)metadata).HasFlag((global::System.Enum)NameMetadata.Link))
{
DynamicVariableHelper.CreateVariable<string>(val2, "modMetaData/Link", val3.Link, true);
}
}
}
}
finally
{
((global::System.IDisposable)enumerator).Dispose();
}
}
private static void GenList(Slot slot)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0045: 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)
Slot val = Enumerable.FirstOrDefault<Slot>((global::System.Collections.Generic.IEnumerable<Slot>)(object)slot.Children, (Func<Slot, bool>)((Slot s) => s.Name == "Loaded mods")) ?? slot.AddSlot("Loaded mods", false);
Enumerator<string> enumerator = HarmonyIds.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
string current = enumerator.Current;
val.AddSlot(current, true);
}
}
finally
{
((global::System.IDisposable)enumerator).Dispose();
}
}
}
public static class PluginMetadata
{
public const string GUID = "net.eia485.ExposePatchedMethods";
public const string NAME = "ExposePatchedMethods";
public const string VERSION = "4.1.0";
public const string AUTHORS = "eia485, kazu0617, rampa3";
public const string REPOSITORY_URL = "https://github.com/EIA485/NeosExposePatchedMethods";
}