using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using AutoThunderstoreVersion;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ImGuiNET;
using Microsoft.CodeAnalysis;
using OverlayDearImGui.Windows;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("OverlayDearImGui.BepInEx5")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: AssemblyInformationalVersion("2.0.0+56b0830b20d078c5218c3627d661348962d8145d")]
[assembly: AssemblyProduct("OverlayDearImGui.BepInEx5")]
[assembly: AssemblyTitle("OverlayDearImGui.BepInEx5")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.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 AutoThunderstoreVersion
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
internal class AutoVersionAttribute : Attribute
{
}
}
namespace OverlayDearImGui
{
public class ConfigEntryBepInEx5<T> : IConfigEntry<T>
{
private ConfigEntry<T> _configEntry;
public ConfigEntryBepInEx5(ConfigEntry<T> configEntry)
{
_configEntry = configEntry;
}
public T Get()
{
return _configEntry.Value;
}
public void Set(T value)
{
_configEntry.Value = value;
}
}
internal class LogBepInEx5 : ILog
{
private ManualLogSource _logSource;
internal LogBepInEx5(ManualLogSource logSource)
{
_logSource = logSource;
}
private static string Format(object data, string file, string member, int line)
{
return $"[{file}:{line} ({member})] {data}";
}
void ILog.Debug(object data, string file, string member, int line)
{
_logSource.LogDebug((object)Format(data, file, member, line));
}
void ILog.Error(object data, string file, string member, int line)
{
_logSource.LogError((object)Format(data, file, member, line));
}
void ILog.Fatal(object data, string file, string member, int line)
{
_logSource.LogFatal((object)Format(data, file, member, line));
}
void ILog.Info(object data, string file, string member, int line)
{
_logSource.LogInfo((object)Format(data, file, member, line));
}
void ILog.Message(object data, string file, string member, int line)
{
_logSource.LogMessage((object)Format(data, file, member, line));
}
void ILog.Warning(object data, string file, string member, int line)
{
_logSource.LogWarning((object)Format(data, file, member, line));
}
}
[AutoVersion]
[BepInPlugin("iDeathHD.OverlayDearImGui_BepInEx5", "OverlayDearImGui_BepInEx5", "2.0.0")]
public class OverlayDearImGuiBepInEx5 : BaseUnityPlugin
{
public const string PluginGUID = "iDeathHD.OverlayDearImGui_BepInEx5";
public const string PluginAuthor = "iDeathHD";
public const string PluginName = "OverlayDearImGui_BepInEx5";
private static Thread _renderThread;
private static bool _isMyUIOpen = true;
private static float _lastRefreshTime = float.NegativeInfinity;
private static GameObject[] _cachedInstances = Array.Empty<GameObject>();
public const string PluginVersion = "2.0.0";
private void Awake()
{
Log.Init((ILog)(object)new LogBepInEx5(((BaseUnityPlugin)this).Logger));
ConfigEntryBepInEx5<VirtualKey> toggleKey = new ConfigEntryBepInEx5<VirtualKey>(((BaseUnityPlugin)this).Config.Bind<VirtualKey>("Keybinds", "OverlayToggle", (VirtualKey)45, "Key for toggling the overlay."));
_renderThread = new Thread((ThreadStart)delegate
{
//IL_0000: Unknown result type (might be due to invalid IL or missing references)
try
{
new Overlay().Render((string)null, "UnityWndClass", Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "Assets"), Paths.ConfigPath, (IConfigEntry<VirtualKey>)toggleKey);
}
catch (Exception ex)
{
Log.Error((object)ex, "/home/runner/work/OverlayDearImGui/OverlayDearImGui/OverlayDearImGui.BepInEx5/OverlayDearImGuiBepInEx5.cs", "Awake", 48);
}
});
_renderThread.Start();
}
private void Update()
{
Overlay.UpdateOverlayDrawData();
}
private static void MyUI()
{
//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
if (ImGui.BeginMainMenuBar())
{
if (ImGui.BeginMenu("Debug", true))
{
if (ImGui.MenuItem("Open Debug Window", (string)null, _isMyUIOpen))
{
_isMyUIOpen = !_isMyUIOpen;
}
ImGui.EndMenu();
}
ImGui.EndMainMenuBar();
}
if (!_isMyUIOpen)
{
return;
}
if (Time.realtimeSinceStartup - _lastRefreshTime >= 2f)
{
_cachedInstances = Object.FindObjectsOfType<GameObject>();
_lastRefreshTime = Time.realtimeSinceStartup;
}
if (!ImGui.Begin("GameObject Debug Viewer", (ImGuiWindowFlags)64))
{
return;
}
ImGui.Text($"Found {_cachedInstances.Length} GameObject instances:");
for (int i = 0; i < _cachedInstances.Length; i++)
{
GameObject val = _cachedInstances[i];
if (!((Object)(object)val == (Object)null))
{
string name = ((Object)val.gameObject).name;
Vector3 position = val.transform.position;
bool activeInHierarchy = val.gameObject.activeInHierarchy;
ImGui.Separator();
ImGui.Text($"[{i}] Name: {name}");
ImGui.Text($" Active: {activeInHierarchy}");
ImGui.Text($" Position: {position}");
}
}
ImGui.End();
}
}
}