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 FriendlyMines v1.0.2
BepinEx/plugins/AlvorianKnights-FriendlyMine/FriendlyMineMod.dll
Decompiled 9 months agousing System.Collections; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using LethalLib.Modules; 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: AssemblyTitle("FriendlyMineMod")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FriendlyMineMod")] [assembly: AssemblyCopyright("Copyright © 2025")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("30487db2-ba41-4dd5-a389-7038ee1ba80b")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyVersion("1.0.0.0")] [BepInPlugin("kito.alvoria.landmine", "Friendly Mine Scrap", "1.0.2")] public class FriendlyMineMod : BaseUnityPlugin { private class LandmineLoader : MonoBehaviour { private FriendlyMineMod parent; private int rarity; public void Initialize(FriendlyMineMod mod, int rarityValue) { parent = mod; rarity = rarityValue; SceneManager.sceneLoaded += OnSceneLoaded; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { if (!parent.itemRegistered) { ((MonoBehaviour)this).StartCoroutine(RegisterAfterDelay()); } } private IEnumerator RegisterAfterDelay() { yield return (object)new WaitForSeconds(1.5f); AssetBundle mineBundle = null; foreach (AssetBundle ab in AssetBundle.GetAllLoadedAssetBundles()) { if (((Object)ab).name.ToLower().Contains("scrap_mine")) { mineBundle = ab; break; } } if ((Object)(object)mineBundle == (Object)null) { ((BaseUnityPlugin)parent).Logger.LogError((object)"[FriendlyMineMod] Failed to find scrap_mine bundle in loaded bundles."); yield break; } Item item = mineBundle.LoadAsset<Item>("Landmine"); if ((Object)(object)item == (Object)null) { ((BaseUnityPlugin)parent).Logger.LogError((object)"[FriendlyMineMod] Could not load 'Landmine' Item from bundle."); yield break; } if ((Object)(object)item.spawnPrefab == (Object)null) { ((BaseUnityPlugin)parent).Logger.LogError((object)"[FriendlyMineMod] 'Landmine' item has no spawnPrefab assigned!"); yield break; } Item itemClone = Object.Instantiate<Item>(item); itemClone.spawnPrefab = item.spawnPrefab; ((Object)itemClone).name = "Landmine(Clone)"; NetworkPrefabs.RegisterNetworkPrefab(itemClone.spawnPrefab); Items.RegisterScrap(itemClone, rarity, (LevelTypes)(-1)); parent.itemRegistered = true; ((BaseUnityPlugin)parent).Logger.LogInfo((object)$"[FriendlyMineMod] Landmine registered (rarity {rarity}) on all moons."); } } private bool itemRegistered = false; private GameObject coroutineHost; private ConfigEntry<bool> isEnabled; private ConfigEntry<int> rarity; private void Awake() { isEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable or disable the Landmine item."); rarity = ((BaseUnityPlugin)this).Config.Bind<int>("Scrap", "Rarity", 30, "Rarity weight of the Landmine item. Higher = more common."); if (!isEnabled.Value) { ((BaseUnityPlugin)this).Logger.LogInfo((object)"[FriendlyMineMod] Landmine is disabled via config."); return; } ((BaseUnityPlugin)this).Logger.LogInfo((object)"[FriendlyMineMod] Scene hook registered."); SceneManager.sceneLoaded += OnSceneLoaded; } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Expected O, but got Unknown if (!itemRegistered && isEnabled.Value && (Object)(object)coroutineHost == (Object)null) { coroutineHost = new GameObject("LandmineCoroutineRunner"); Object.DontDestroyOnLoad((Object)(object)coroutineHost); coroutineHost.AddComponent<LandmineLoader>().Initialize(this, rarity.Value); } } }