using System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Logging; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; using com.github.zehsteam.MetadataUtils.Modules; using com.github.zehsteam.MetadataUtils.Objects; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("Zehs")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright © 2026 Zehs")] [assembly: AssemblyFileVersion("1.1.1.0")] [assembly: AssemblyInformationalVersion("1.1.1+45627603d3869d4ee4f5fb1b7e7df530461a2c7c")] [assembly: AssemblyProduct("MetadataUtils")] [assembly: AssemblyTitle("com.github.zehsteam.MetadataUtils")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.1.1.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 com.github.zehsteam.MetadataUtils { internal static class Logger { public static ManualLogSource ManualLogSource { get; private set; } public static void Initialize(ManualLogSource manualLogSource) { ManualLogSource = manualLogSource; } public static void LogDebug(object data) { Log((LogLevel)32, data); } public static void LogInfo(object data) { Log((LogLevel)16, data); } public static void LogMessage(object data) { Log((LogLevel)8, data); } public static void LogWarning(object data) { Log((LogLevel)4, data); } public static void LogError(object data) { Log((LogLevel)2, data); } public static void LogFatal(object data) { Log((LogLevel)1, data); } public static void Log(LogLevel logLevel, object data) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) ManualLogSource manualLogSource = ManualLogSource; if (manualLogSource != null) { manualLogSource.Log(logLevel, data); } } } [BepInPlugin("com.github.zehsteam.MetadataUtils", "MetadataUtils", "1.1.1")] internal class Plugin : BaseUnityPlugin { internal static Plugin Instance { get; private set; } private void Awake() { Instance = this; Logger.Initialize(Logger.CreateLogSource("com.github.zehsteam.MetadataUtils")); Logger.LogInfo("MetadataUtils has awoken!"); MetadataRegistry.Initialize(); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "com.github.zehsteam.MetadataUtils"; public const string PLUGIN_NAME = "MetadataUtils"; public const string PLUGIN_VERSION = "1.1.1"; } } namespace com.github.zehsteam.MetadataUtils.Objects { public class Metadata { private Dictionary _entries = new Dictionary(); public Scene Scene { get; private set; } public Metadata(Scene scene) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) Scene = scene; } public bool Has(string key) { return _entries.ContainsKey(key); } public T Get(string key, T defaultValue = default(T)) { if (TryGet(key, out var value)) { return value; } return defaultValue; } public bool TryGet(string key, out T value) { if (_entries.TryGetValue(key, out var value2) && value2 is T val) { value = val; return true; } value = default(T); return false; } public void Set(string key, T value) { _entries[key] = value; } public void Set(Metadata metadata) { if (metadata != null) { _entries = metadata._entries; } } public bool Remove(string key) { return _entries.Remove(key); } } } namespace com.github.zehsteam.MetadataUtils.Modules { public static class MetadataRegistry { private static readonly Dictionary _entries = new Dictionary(); internal static void Initialize() { SceneManager.sceneUnloaded += HandleSceneUnloaded; } public static bool HasMetadata(Object obj) { return _entries.ContainsKey(obj); } public static Metadata GetOrCreate(Object obj) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (_entries.TryGetValue(obj, out var value)) { return value; } Scene scene = ExtractScene(obj); Metadata metadata = new Metadata(scene); _entries[obj] = metadata; return metadata; } public static bool TryGet(Object obj, out Metadata metadata) { return _entries.TryGetValue(obj, out metadata); } public static bool Remove(Object obj) { return _entries.Remove(obj); } private static Scene ExtractScene(Object obj) { //IL_000b: 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: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) GameObject val = (GameObject)(object)((obj is GameObject) ? obj : null); if (val != null) { return val.scene; } Component val2 = (Component)(object)((obj is Component) ? obj : null); if (val2 != null) { return val2.gameObject.scene; } return default(Scene); } private static void RemoveMetadataForScene(Scene scene) { //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) Dictionary dictionary = new Dictionary(_entries); foreach (KeyValuePair item in dictionary) { if (item.Value.Scene == scene) { _entries.Remove(item.Key); } } } private static void HandleSceneUnloaded(Scene scene) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) RemoveMetadataForScene(scene); } } } namespace com.github.zehsteam.MetadataUtils.Extensions { public static class ComponentExtensions { private const bool _defaultTargetGameObject = true; public static bool HasMetadata(this Component component, bool targetGameObject = true) { return MetadataRegistry.HasMetadata(GetObject(component, targetGameObject)); } public static Metadata GetOrCreateMetadata(this Component component, bool targetGameObject = true) { return MetadataRegistry.GetOrCreate(GetObject(component, targetGameObject)); } public static bool TryGetMetadata(this Component component, out Metadata metadata, bool targetGameObject = true) { return MetadataRegistry.TryGet(GetObject(component, targetGameObject), out metadata); } public static bool RemoveMetadata(this Component component, bool targetGameObject = true) { return MetadataRegistry.Remove(GetObject(component, targetGameObject)); } private static Object GetObject(Component component, bool targetGameObject) { if (!targetGameObject) { return (Object)(object)component; } return (Object)(object)component.gameObject; } } public static class GameObjectExtensions { public static bool HasMetadata(this GameObject gameObject) { return MetadataRegistry.HasMetadata((Object)(object)gameObject); } public static Metadata GetOrCreateMetadata(this GameObject gameObject) { return MetadataRegistry.GetOrCreate((Object)(object)gameObject); } public static bool TryGetMetadata(this GameObject gameObject, out Metadata metadata) { return MetadataRegistry.TryGet((Object)(object)gameObject, out metadata); } public static bool RemoveMetadata(this GameObject gameObject) { return MetadataRegistry.Remove((Object)(object)gameObject); } } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }