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 CustomNeedolin v0.2.0
CustomNeedolin.dll
Decompiled 5 months agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Reflection; using System.Resources; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using CustomNeedolin.Helpers; using CustomNeedolin.Settings; using DanielSteginkUtils.ExternalFiles; using DanielSteginkUtils.Helpers; using HarmonyLib; using HutongGames.PlayMaker; using HutongGames.PlayMaker.Actions; using Microsoft.CodeAnalysis; using TeamCherry.Localization; using UnityEngine; [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("CustomNeedolin")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0+b5447243bc2a85ddd48944f18ac6ea734b52b77d")] [assembly: AssemblyProduct("CustomNeedolin")] [assembly: AssemblyTitle("CustomNeedolin")] [assembly: NeutralResourcesLanguage("EN")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [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 BepInEx { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Microsoft.CodeAnalysis.Embedded] internal sealed class BepInAutoPluginAttribute : Attribute { public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace BepInEx.Preloader.Core.Patching { [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)] [Conditional("CodeGeneration")] [Microsoft.CodeAnalysis.Embedded] internal sealed class PatcherAutoPluginAttribute : Attribute { public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null) { } } } namespace Microsoft.CodeAnalysis { [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace CustomNeedolin { [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInPlugin("io.github.danielstegink.customneedolin", "CustomNeedolin", "0.2.0")] public class CustomNeedolin : BaseUnityPlugin { public static AudioClip? currentDefault; public const string Id = "io.github.danielstegink.customneedolin"; internal static CustomNeedolin Instance { get; private set; } public static string Name => "CustomNeedolin"; public static string Version => "0.2.0"; private void Awake() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) Instance = this; new Harmony("io.github.danielstegink.customneedolin").PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("Plugin " + Name + " (io.github.danielstegink.customneedolin) has loaded!")); } private void Start() { ConfigSettings.Initialize(((BaseUnityPlugin)this).Config); } internal void Log(string message) { ((BaseUnityPlugin)this).Logger.LogInfo((object)message); } } } namespace CustomNeedolin.Settings { public static class ConfigSettings { public static ConfigEntry<string> fileName; public static void Initialize(ConfigFile config) { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) LocalisedString val = default(LocalisedString); ((LocalisedString)(ref val))..ctor("Mods.io.github.danielstegink.customneedolin", "NAME"); LocalisedString val2 = default(LocalisedString); ((LocalisedString)(ref val2))..ctor("Mods.io.github.danielstegink.customneedolin", "DESC"); if (((LocalisedString)(ref val)).Exists && ((LocalisedString)(ref val2)).Exists) { fileName = config.Bind<string>("Modifier", LocalisedString.op_Implicit(val), "", LocalisedString.op_Implicit(val2)); } else { fileName = config.Bind<string>("Modifier", "Audio File", "", "Name of the audio file to play with the Needolin"); } fileName.SettingChanged += OnSettingChanged; } private static void OnSettingChanged(object sender, EventArgs e) { NeedolinHelper.ChangeNeedolin(fileName.Value); } } } namespace CustomNeedolin.Helpers { [HarmonyPatch(typeof(HeroController), "Start")] public static class HeroController_Start { [HarmonyPostfix] public static void Postfix(HeroController __instance) { NeedolinHelper.ChangeNeedolin(ConfigSettings.fileName.Value); } } public static class NeedolinHelper { internal static Dictionary<string, AudioClip> loadedClips = new Dictionary<string, AudioClip>(); public static void ChangeNeedolin(string fileName) { if (Needolin.NeedolinFsm == null) { CustomNeedolin.Instance.Log("Needolin FSM not found"); return; } AudioClip val = GetAudioClipFromExternalFile(fileName); if ((Object)(object)val == (Object)null) { val = Needolin.DefaultClip; } if ((Object)(object)val != (Object)null) { Needolin.SetNewDefaultClip(val); } } private static AudioClip? GetAudioClipFromExternalFile(string fileName) { if (loadedClips.TryGetValue(fileName, out AudioClip value)) { return value; } if (string.IsNullOrEmpty(fileName)) { return null; } FileInfo fileInfo = new FileInfo(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "audio", fileName + ".wav")); if (!fileInfo.Exists) { CustomNeedolin.Instance.Log("Error getting file '" + fileName + ".wav'"); return null; } using Stream stream = fileInfo.OpenRead(); if (stream == null) { CustomNeedolin.Instance.Log("Error reading file '" + fileName + ".wav'"); return null; } return GetAudioClip.GetAudioClipFromStream(stream, fileName, false); } } [HarmonyPatch(typeof(StartNeedolinAudioLoop), "OnEnter")] public static class StartNeedolinAudioLoop_OnEnter { [HarmonyPrefix] public static void Prefix(StartNeedolinAudioLoop __instance) { if (((FsmStateAction)__instance).State.Name.Equals("Start Needolin Proper")) { Needolin.ResetAudioClip(((FsmStateAction)__instance).Fsm, true, false); } } } }