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 NecoArcHoarderBugMod v1.0.9
ChdataNecoArcHoarderBug.dll
Decompiled 2 years agousing System; using System.Collections.Generic; 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 BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using LCSoundTool; using Microsoft.CodeAnalysis; 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: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: IgnoresAccessChecksTo("")] [assembly: AssemblyCompany("ChdataNecoArcHoarderBug")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Replaces Hoarder Bug with Neco Arc")] [assembly: AssemblyFileVersion("1.0.8.0")] [assembly: AssemblyInformationalVersion("1.0.8")] [assembly: AssemblyProduct("Chdata's Neco Arc Hoarder Bug Mod")] [assembly: AssemblyTitle("ChdataNecoArcHoarderBug")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.8.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 ChdataNecoArcHoarderBug { [BepInPlugin("ChdataNecoArcHoarderBug", "Chdata's Neco Arc Hoarder Bug Mod", "1.0.8")] public class NecoArcModBase : BaseUnityPlugin { private readonly Harmony harmony = new Harmony("ChdataNecoArcHoarderBug"); private static NecoArcModBase Instance; public static ManualLogSource mls; internal static ConfigEntry<bool> configIncreaseNecoArcSpawns; internal static ConfigEntry<int> configMaxEnemyPowerCount; internal static ConfigEntry<int> configNecoArcRarityWeight; internal static ConfigEntry<int> configNecoArcDay; private AudioClip soundNecoArcAngry1; private AudioClip soundNecoArcAngry2; private AudioClip soundNecoArcChitter1; private AudioClip soundNecoArcChitter2; private AudioClip soundNecoArcChitter3; private AudioClip soundNecoArcCry; private AudioClip soundNecoArcFly; public static GameObject NecoArcPrefab; public static GameObject NecoArcObject; private AssetBundle NecoArcAssetBundle; public static int DaysPassed; private void Awake() { if ((Object)(object)Instance == (Object)null) { Instance = this; } mls = Logger.CreateLogSource("ChdataNecoArcHoarderBug"); mls.LogInfo((object)"--=== CHDATA's NECO ARC MOD LOADED ===--"); mls.LogInfo((object)"--=== CHDATA's NECO ARC MOD LOADED ===--"); mls.LogInfo((object)"--=== CHDATA's NECO ARC MOD LOADED ===--"); configIncreaseNecoArcSpawns = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Increase Neco Arc Spawns", true, "Determines whether or not to increase the chance of Neco Arc spawning."); configMaxEnemyPowerCount = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Max Enemy Power Count", 10, "Power Count determines the maximum number of enemies that may spawn. The normal value for Experiment, for example, is 4."); configNecoArcRarityWeight = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Neco Arc Rarity Weight", 100, "Increases the chance of Neco Arc spawning. A normal value is 10-80. Higher = more likely."); configNecoArcDay = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Neco Arc Day", 3, "Neco Arc will have increased spawn rate on this day. -1 means all days. First day is day 1. 99 means normal spawn rates at all times... unless you reach a 99th day."); harmony.PatchAll(typeof(NecoArcModBase)); string text = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "necoarcremake_bynerro13"); mls.LogDebug((object)text); NecoArcAssetBundle = AssetBundle.LoadFromFile(text); if ((Object)(object)NecoArcAssetBundle == (Object)null) { mls.LogError((object)"Could not find Neco Arc Asset Bundle! File \"necoarcremake_bynerro13\" needs to be moved to the same folder as the .dll"); } NecoArcPrefab = NecoArcAssetBundle.LoadAsset<GameObject>("Assets/Import/NecoArc/NecoArcRemake_ByNerro13.prefab"); SkinnedMeshRenderer[] componentsInChildren = NecoArcPrefab.GetComponentsInChildren<SkinnedMeshRenderer>(true); SkinnedMeshRenderer[] array = componentsInChildren; foreach (SkinnedMeshRenderer val in array) { ((Component)val).gameObject.layer = LayerMask.NameToLayer("Enemies"); } } private void Start() { mls.LogInfo((object)"--=== START ===--"); soundNecoArcAngry1 = NecoArcAssetBundle.LoadAsset<AudioClip>("Assets/Import/NecoArc/sfx/Angry.Neco_B0AA24.wav"); soundNecoArcAngry2 = NecoArcAssetBundle.LoadAsset<AudioClip>("Assets/Import/NecoArc/sfx/Angry.Neco_B0AA48a.wav"); soundNecoArcChitter1 = NecoArcAssetBundle.LoadAsset<AudioClip>("Assets/Import/NecoArc/sfx/Chitter.Neco_B0AA01.wav"); soundNecoArcChitter2 = NecoArcAssetBundle.LoadAsset<AudioClip>("Assets/Import/NecoArc/sfx/Chitter.Neco_B2AA005.wav"); soundNecoArcChitter3 = NecoArcAssetBundle.LoadAsset<AudioClip>("Assets/Import/NecoArc/sfx/Chitter.Neco_B2AA008.wav"); soundNecoArcCry = NecoArcAssetBundle.LoadAsset<AudioClip>("Assets/Import/NecoArc/sfx/cry.Neco_B0AA06.wav"); soundNecoArcFly = NecoArcAssetBundle.LoadAsset<AudioClip>("Assets/Import/NecoArc/sfx/fly.neco33.wav"); if ((Object)(object)soundNecoArcFly == (Object)null) { mls.LogError((object)"Could not find Neco Arc Asset Bundle! File \"necoarcremake_bynerro13\" needs to be moved to the same folder as the .dll"); } SoundTool.ReplaceAudioClip("AngryScreech", soundNecoArcAngry1); SoundTool.ReplaceAudioClip("AngryScreech2", soundNecoArcAngry2); SoundTool.ReplaceAudioClip("Chitter1", soundNecoArcChitter1); SoundTool.ReplaceAudioClip("Chitter2", soundNecoArcChitter2); SoundTool.ReplaceAudioClip("Chitter3", soundNecoArcChitter3); SoundTool.ReplaceAudioClip("HoarderBugCry", soundNecoArcCry); SoundTool.ReplaceAudioClip("Fly", soundNecoArcFly); mls.LogInfo((object)"--=== All sounds are loaded! ===--"); } [HarmonyPatch(typeof(HoarderBugAI), "Start")] [HarmonyPostfix] public static void PluginDetectSummonBug(HoarderBugAI __instance) { //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Unknown result type (might be due to invalid IL or missing references) mls.LogInfo((object)"--=== Hoarder Bug Summoned ===--"); mls.LogInfo((object)"--=== Convert to Neco Arc ===--"); Transform val = ((Component)__instance).transform.Find("HoarderBugModel"); if ((Object)(object)val == (Object)null) { mls.LogInfo((object)"--=== NOT FOUND ===--"); } else { mls.LogInfo((object)"--=== FOUND ===--"); } ((Renderer)((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel").Find("Cube")).gameObject.GetComponent<SkinnedMeshRenderer>()).enabled = false; ((Renderer)((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel").Find("Cube.001")).gameObject.GetComponent<SkinnedMeshRenderer>()).enabled = false; ((Renderer)((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel").Find("AnimContainer").Find("Armature") .Find("Abdomen") .Find("Chest") .Find("Head") .Find("LeftWing")).gameObject.GetComponent<MeshRenderer>()).enabled = false; ((Renderer)((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel").Find("AnimContainer").Find("Armature") .Find("Abdomen") .Find("Chest") .Find("Head") .Find("RightWing")).gameObject.GetComponent<MeshRenderer>()).enabled = false; ((Component)((Component)__instance).gameObject.transform.Find("ScanNode")).gameObject.GetComponent<ScanNodeProperties>().headerText = "Neco Arc"; NecoArcObject = Object.Instantiate<GameObject>(NecoArcPrefab); NecoArcObject.transform.SetParent(val); NecoArcObject.transform.localPosition = Vector3.zero; NecoArcObject.transform.localRotation = Quaternion.identity; ((EnemyAI)__instance).creatureAnimator = ((Component)NecoArcObject.transform).GetComponent<Animator>(); } [HarmonyPatch(typeof(HoarderBugAI), "CalculateAnimationDirection")] [HarmonyPostfix] public static void OnCalculateAnimationDirection(HoarderBugAI __instance, float maxSpeed, ref float ___velX, ref float ___velZ) { Animator component = ((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel").Find("AnimContainer")).gameObject.GetComponent<Animator>(); if (!((Object)(object)component == (Object)null)) { component.SetFloat("VelocityX", Mathf.Clamp(___velX, 0f - maxSpeed, maxSpeed)); component.SetFloat("VelocityZ", Mathf.Clamp(___velZ, 0f - maxSpeed, maxSpeed)); } } [HarmonyPatch(typeof(HoarderBugAI), "KillEnemy")] [HarmonyPrefix] public static void OnKillEnemy(HoarderBugAI __instance, ref float ___velX, ref float ___velZ) { Animator component = ((Component)((Component)__instance).gameObject.transform.Find("HoarderBugModel").Find("AnimContainer")).gameObject.GetComponent<Animator>(); if (!((Object)(object)component == (Object)null)) { component.SetFloat("VelocityX", Mathf.Clamp(___velX, 0f, 0f)); component.SetFloat("VelocityZ", Mathf.Clamp(___velZ, 0f, 0f)); } } [HarmonyPatch(typeof(RoundManager), "LoadNewLevel")] [HarmonyPrefix] private static bool ModifiedLoad(ref SelectableLevel newLevel) { mls.LogInfo((object)("Client is host: " + ((NetworkBehaviour)RoundManager.Instance).IsHost)); if (!((NetworkBehaviour)RoundManager.Instance).IsHost) { return true; } if (newLevel.levelID == 3) { mls.LogInfo((object)"Level is company, skipping"); DaysPassed = 0; return true; } DaysPassed++; mls.LogInfo((object)$"Days passed: {DaysPassed}"); SelectableLevel val = newLevel; Dictionary<Type, int> dictionary = new Dictionary<Type, int>(); dictionary.Clear(); if (configIncreaseNecoArcSpawns.Value && (configNecoArcDay.Value == -1 || configNecoArcDay.Value == DaysPassed)) { val.maxEnemyPowerCount = configMaxEnemyPowerCount.Value; dictionary.Add(typeof(HoarderBugAI), configNecoArcRarityWeight.Value); UpdateRarity(newLevel.Enemies, dictionary); mls.LogInfo((object)"Increased Max Power Counter and Hoarder Bug Spawns"); } else { mls.LogInfo((object)"Using default spawn rate settings"); } newLevel = val; return true; } private static void UpdateRarity(List<SpawnableEnemyWithRarity> enemies, Dictionary<Type, int> componentRarity) { if (componentRarity.Count <= 0) { return; } foreach (SpawnableEnemyWithRarity enemy in enemies) { foreach (KeyValuePair<Type, int> item in componentRarity) { if ((Object)(object)enemy.enemyType.enemyPrefab.GetComponent(item.Key) == (Object)null) { continue; } enemy.rarity = item.Value; componentRarity.Remove(item.Key); break; } } } } public static class PluginInfo { public const string PLUGIN_GUID = "ChdataNecoArcHoarderBug"; public const string PLUGIN_NAME = "Chdata's Neco Arc Hoarder Bug Mod"; public const string PLUGIN_VERSION = "1.0.8"; } } namespace System.Runtime.CompilerServices { [AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)] internal sealed class IgnoresAccessChecksToAttribute : Attribute { public IgnoresAccessChecksToAttribute(string assemblyName) { } } }