Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of GetMyTrophyBack v1.0.0
IronLabs.GetMyTrophyBack.dll
Decompiled 2 days agousing System; using System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("IronLabs.GetMyTrophyBack")] [assembly: AssemblyDescription("Returns trophies after guardian power selection.")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("IronLabs")] [assembly: AssemblyProduct("IronLabs.GetMyTrophyBack")] [assembly: AssemblyCopyright("Copyright © 2026 End3rbyte")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("66592EBD-C28B-46B8-996D-6D4BF2FB210F")] [assembly: AssemblyFileVersion("1.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace IronLabs.GetMyTrophyBack; [BepInPlugin("IronLabs.GetMyTrophyBack", "IronLabs.GetMyTrophyBack", "1.0.0")] public sealed class GetMyTrophyBackPlugin : BaseUnityPlugin { private const string PluginGuid = "IronLabs.GetMyTrophyBack"; private const string PluginName = "IronLabs.GetMyTrophyBack"; private const string PluginVersion = "1.0.0"; private readonly Harmony _harmony = new Harmony("IronLabs.GetMyTrophyBack"); private static bool _patchesApplied; private void Awake() { ModLog.Initialize(((BaseUnityPlugin)this).Logger, "IronLabs.GetMyTrophyBack"); PatchOwnNamespace(); ModLog.LogInfo("IronLabs.GetMyTrophyBack 1.0.0 is loaded."); } private void PatchOwnNamespace() { if (_patchesApplied) { ModLog.LogDebug("Harmony patches are already active; skipping registration."); return; } string text = typeof(GetMyTrophyBackPlugin).Namespace; Type[] types = Assembly.GetExecutingAssembly().GetTypes(); foreach (Type type in types) { if (type.Namespace == text) { _harmony.CreateClassProcessor(type).Patch(); } } _patchesApplied = true; ModLog.LogDebug("Harmony patches were applied for the plugin namespace."); } private void OnDestroy() { if (_patchesApplied) { _harmony.UnpatchSelf(); _patchesApplied = false; } ModLog.Clear(); } } [HarmonyPatch(typeof(ItemStand), "DelayedPowerActivation")] internal static class DropTrophyAfterPowerActivationPatch { private static void Postfix(ItemStand __instance) { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && !((Object)(object)__instance.m_guardianPower == (Object)null) && !(localPlayer.GetGuardianPowerName() != ((Object)__instance.m_guardianPower).name)) { ((MonoBehaviour)__instance).StartCoroutine(TrophyDropService.DropAfterDelay(__instance)); ModLog.LogDebug("Scheduled trophy drop for " + ((Object)__instance.m_guardianPower).name + "."); } } } [HarmonyPatch(typeof(ItemStand), "Awake")] internal static class RegisterTrophyDropRpcPatch { private static void Postfix(ItemStand __instance, ZNetView ___m_nview) { if (!((Object)(object)__instance.m_guardianPower == (Object)null) && !((Object)(object)___m_nview == (Object)null) && ___m_nview.GetZDO() != null) { ___m_nview.Register("IronLabs_DropGuardianTrophy", (Action<long>)delegate(long sender) { TrophyDropService.HandleDropRequest(__instance, ___m_nview, sender); }); ModLog.LogDebug("Registered trophy drop RPC for " + ((Object)__instance.m_guardianPower).name + "."); } } } internal static class ModLog { private static ManualLogSource _logger; private static string _pluginName; internal static void Initialize(ManualLogSource logger, string pluginName) { _logger = logger; _pluginName = pluginName; } internal static void Clear() { _logger = null; _pluginName = null; } internal static void LogDebug(object message) { Write((LogLevel)32, message); } internal static void LogInfo(object message) { Write((LogLevel)16, message); } internal static void LogWarning(object message) { Write((LogLevel)4, message); } private static void Write(LogLevel level, object message) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) ManualLogSource logger = _logger; if (logger != null) { logger.Log(level, message); } } } internal static class TrophyDropService { internal const string RpcName = "IronLabs_DropGuardianTrophy"; private const float DropDelaySeconds = 5f; internal static IEnumerator DropAfterDelay(ItemStand itemStand) { yield return (object)new WaitForSeconds(5f); if (!((Object)(object)itemStand == (Object)null) && itemStand.HaveAttachment()) { ZNetView netView = GetNetView(itemStand); if ((Object)(object)netView == (Object)null || !netView.IsValid()) { ModLog.LogWarning("Could not request the trophy drop because its network view is invalid."); } else { netView.InvokeRPC("IronLabs_DropGuardianTrophy", Array.Empty<object>()); } } } internal static void HandleDropRequest(ItemStand itemStand, ZNetView netView, long sender) { if (netView.IsOwner() && itemStand.HaveAttachment()) { ZDO zDO = netView.GetZDO(); string text = zDO.GetString(ZDOVars.s_item, ""); GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text); if ((Object)(object)itemPrefab == (Object)null) { ModLog.LogWarning("Could not drop missing trophy prefab " + text + "."); return; } SpawnTrophy(itemStand, itemPrefab, zDO); ClearAttachment(netView, zDO); ModLog.LogDebug($"Dropped trophy {text} after power activation by peer {sender}."); } } private static ZNetView GetNetView(ItemStand itemStand) { if (!Object.op_Implicit((Object)(object)itemStand.m_netViewOverride)) { return ((Component)itemStand).GetComponent<ZNetView>(); } return itemStand.m_netViewOverride; } private static void SpawnTrophy(ItemStand itemStand, GameObject prefab, ZDO zdo) { //IL_0013: 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) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) GetAttachmentOffset(prefab, out var position, out var rotation); Transform dropSpawnPoint = itemStand.m_dropSpawnPoint; GameObject obj = Object.Instantiate<GameObject>(prefab, dropSpawnPoint.position + position, dropSpawnPoint.rotation * rotation); obj.GetComponent<ItemDrop>().LoadFromExternalZDO(zdo); Rigidbody component = obj.GetComponent<Rigidbody>(); if ((Object)(object)component != (Object)null) { component.linearVelocity = Vector3.up * 4f; } itemStand.m_effects.Create(dropSpawnPoint.position, Quaternion.identity, (Transform)null, 1f, -1); } private static void GetAttachmentOffset(GameObject prefab, out Vector3 position, out Quaternion rotation) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) position = Vector3.zero; rotation = Quaternion.identity; Transform val = prefab.transform.Find("attach"); if ((Object)(object)prefab.transform.Find("attachobj") != (Object)null && (Object)(object)val != (Object)null) { position = val.localPosition; rotation = val.localRotation; } } private static void ClearAttachment(ZNetView netView, ZDO zdo) { zdo.Set(ZDOVars.s_item, ""); zdo.Set(ZDOVars.s_type, 0, false); netView.InvokeRPC(ZNetView.Everybody, "SetVisualItem", new object[4] { "", 0, 0, 0 }); } }