Please disclose if your mod was created primarily 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 CurseOfEmbrion v1.2.1
CurseOfEmbrion.dll
Decompiled 4 months agousing System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Unity.Netcode; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: AssemblyTitle("CurseOfEmbrion")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("CurseOfEmbrion")] [assembly: AssemblyCopyright("Copyright © 2024")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("8fa82371-2f2d-46f1-9f7f-aa36ef467f88")] [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")] namespace CurseOfEmbrion { internal class ConfigManager { public static ConfigEntry<int> curseChance; public static ConfigEntry<bool> onlyBirdsOnCurse; public static ConfigEntry<bool> playAlertNoise; public static ConfigEntry<float> alertNoiseVolume; public static void Init() { curseChance = ((BaseUnityPlugin)CurseOfEmbrionMod.instance).Config.Bind<int>("General Settings", "curseChance", 10, "The chance for the curse to apply each moon. Can be set to a minimum of 0 (never occurs) and a maximum of 100 (always occurs)."); onlyBirdsOnCurse = ((BaseUnityPlugin)CurseOfEmbrionMod.instance).Config.Bind<bool>("General Settings", "onlyBirdsOnCurse", false, "Forces all outside enemies to be Old Birds when the curse is present."); playAlertNoise = ((BaseUnityPlugin)CurseOfEmbrionMod.instance).Config.Bind<bool>("General Settings", "playAlertNoise", true, "Plays an alert noise when the curse is active."); alertNoiseVolume = ((BaseUnityPlugin)CurseOfEmbrionMod.instance).Config.Bind<float>("General Settings", "alertNoiseVolume", 1f, "The volume of the alert noise. Can be set to a minimum of .1 and a maximum of 1."); } } [BepInPlugin("eXish.CurseOfEmbrion", "CurseOfEmbrion", "1.2.1")] public class CurseOfEmbrionMod : BaseUnityPlugin { private const string mGUID = "eXish.CurseOfEmbrion"; private const string mName = "CurseOfEmbrion"; private const string mVersion = "1.2.1"; private readonly Harmony harmony = new Harmony("eXish.CurseOfEmbrion"); internal static CurseOfEmbrionMod instance; internal static ManualLogSource log; internal static AssetBundle bundle; internal static AudioClip alertNoise; internal static List<SpawnableEnemyWithRarity> outsideEnemies; internal static string levelDescription; internal static int outsidePowerCount; private void Awake() { if ((Object)(object)instance == (Object)null) { instance = this; } log = ((BaseUnityPlugin)this).Logger; ConfigManager.Init(); if (ConfigManager.curseChance.Value < 0 || ConfigManager.curseChance.Value > 100) { log.LogWarning((object)$"The value \"{ConfigManager.curseChance.Value}\" is not valid for setting \"curseChance\"! The default will be used instead."); } if (ConfigManager.alertNoiseVolume.Value < 0.1f || ConfigManager.alertNoiseVolume.Value > 1f) { log.LogWarning((object)$"The value \"{ConfigManager.alertNoiseVolume.Value}\" is not valid for setting \"alertNoiseVolume\"! The default will be used instead."); } string text = ((BaseUnityPlugin)instance).Info.Location.TrimEnd("CurseOfEmbrion.dll".ToCharArray()); bundle = AssetBundle.LoadFromFile(text + "curseofembrion"); if ((Object)(object)bundle != (Object)null) { alertNoise = bundle.LoadAsset<AudioClip>("Assets/CurseOfEmbrion/AlertNoise.wav"); } else { log.LogError((object)"Unable to locate the asset file! The alert noise will not play!"); } harmony.PatchAll(); log.LogInfo((object)"CurseOfEmbrion-1.2.1 loaded!"); } } } namespace CurseOfEmbrion.Patches { [HarmonyPatch(typeof(StartOfRound))] internal class StartOfRoundPatch { [HarmonyPatch("StartGame")] [HarmonyPrefix] private static void StartGamePatch(StartOfRound __instance) { if (!((NetworkBehaviour)__instance).IsHost) { return; } int num = ConfigManager.curseChance.Value; if (num < 0 || num > 100) { num = (int)((ConfigEntryBase)ConfigManager.curseChance).DefaultValue; } if (!__instance.currentLevel.spawnEnemiesAndScrap || Random.Range(1, 101) > num) { return; } bool flag = false; SelectableLevel val = __instance.levels.Where((SelectableLevel x) => x.PlanetName == "5 Embrion").First(); SpawnableEnemyWithRarity val2 = val.OutsideEnemies.Where((SpawnableEnemyWithRarity x) => ((Object)x.enemyType).name == "RadMech").First(); CurseOfEmbrionMod.levelDescription = __instance.currentLevel.LevelDescription; SelectableLevel currentLevel = __instance.currentLevel; currentLevel.LevelDescription += "\n\n<color=red>Curse of Embrion</color>"; CurseOfEmbrionMod.outsidePowerCount = __instance.currentLevel.maxOutsideEnemyPowerCount; __instance.currentLevel.maxOutsideEnemyPowerCount = val.maxOutsideEnemyPowerCount; CurseOfEmbrionMod.outsideEnemies = __instance.currentLevel.OutsideEnemies.ToList(); for (int i = 0; i < __instance.currentLevel.OutsideEnemies.Count; i++) { if (((Object)__instance.currentLevel.OutsideEnemies[i].enemyType).name == "RadMech") { flag = true; __instance.currentLevel.OutsideEnemies[i] = val2; } else { __instance.currentLevel.OutsideEnemies[i].rarity = ((!ConfigManager.onlyBirdsOnCurse.Value) ? (__instance.currentLevel.OutsideEnemies[i].rarity / 4) : 0); } } if (!flag) { __instance.currentLevel.OutsideEnemies.Add(val2); } } [HarmonyPatch("EndOfGame")] [HarmonyPrefix] private static void EndOfGamePatch(StartOfRound __instance) { if (((NetworkBehaviour)__instance).IsHost && CurseOfEmbrionMod.outsideEnemies != null) { __instance.currentLevel.OutsideEnemies = CurseOfEmbrionMod.outsideEnemies; __instance.currentLevel.maxOutsideEnemyPowerCount = CurseOfEmbrionMod.outsidePowerCount; __instance.currentLevel.LevelDescription = CurseOfEmbrionMod.levelDescription; CurseOfEmbrionMod.outsideEnemies = null; } } [HarmonyPatch("openingDoorsSequence")] [HarmonyPrefix] private static void OpeningDoorsSequencePatch(StartOfRound __instance) { if ((Object)(object)CurseOfEmbrionMod.bundle != (Object)null && ConfigManager.playAlertNoise.Value && __instance.currentLevel.LevelDescription.Contains("Curse of Embrion")) { CurseOfEmbrionMod.log.LogInfo((object)"This moon has been cursed with Curse of Embrion!"); float num = ConfigManager.alertNoiseVolume.Value; if (num < 0.1f || num > 1f) { num = (float)((ConfigEntryBase)ConfigManager.alertNoiseVolume).DefaultValue; } HUDManager.Instance.UIAudio.PlayOneShot(CurseOfEmbrionMod.alertNoise, num); } } } }