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 FishUtilities v1.0.0
FishUtilities.dll
Decompiled 2 years agousing System; using 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 HarmonyLib; 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("FishUtilities")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("FishUtilities")] [assembly: AssemblyCopyright("Copyright © 2023")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("2cb22880-ade3-4ead-a42b-2971dd728704")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.0.0.0")] namespace FishUtilities; public static class RandomHelper { public static TSource NextFromCollection<TSource>(this Random rand, IList<TSource> collection) { int index = rand.Next(collection.Count()); return collection[index]; } } public static class TerminalHelper { public static TerminalKeyword GetKeyword(this Terminal terminal, string keywordName) { return terminal.terminalNodes.allKeywords.First((TerminalKeyword kw) => ((Object)kw).name == keywordName); } public static bool TryGetKeyword(this Terminal terminal, string keywordName, out TerminalKeyword keyword) { try { keyword = terminal.GetKeyword(keywordName); return true; } catch { keyword = null; return false; } } public static TerminalNode GetNodeAfterConfirmation(this TerminalNode node) { return node.terminalOptions.First((CompatibleNoun cn) => ((Object)cn.noun).name.Equals("confirm", StringComparison.InvariantCultureIgnoreCase)).result; } public static bool TryGetNodeAfterConfirmation(this TerminalNode node, out TerminalNode confirmNode) { try { confirmNode = node.GetNodeAfterConfirmation(); return true; } catch { confirmNode = null; return false; } } public static void AddKeyword(this Terminal terminal, TerminalKeyword newKeyword) { terminal.terminalNodes.allKeywords = CollectionExtensions.AddToArray<TerminalKeyword>(terminal.terminalNodes.allKeywords, newKeyword); } public static void AddKeywords(this Terminal terminal, params TerminalKeyword[] newKeywords) { terminal.terminalNodes.allKeywords = CollectionExtensions.AddRangeToArray<TerminalKeyword>(terminal.terminalNodes.allKeywords, newKeywords); } public static void AddCompatibleNounToKeyword(this Terminal terminal, string keywordName, CompatibleNoun newCompatibleNoun) { TerminalKeyword val = ((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword kw) => ((Object)kw).name == keywordName)) ?? throw new ArgumentException("Failed to find keyword with name " + keywordName); val.compatibleNouns = CollectionExtensions.AddToArray<CompatibleNoun>(val.compatibleNouns, newCompatibleNoun); } public static void AddCompatibleNounToKeyword(this Terminal terminal, Func<TerminalKeyword, bool> predicate, CompatibleNoun newCompatibleNoun) { TerminalKeyword val = terminal.terminalNodes.allKeywords.FirstOrDefault(predicate) ?? throw new ArgumentException("Failed to find keyword that matches provided predicate"); val.compatibleNouns = CollectionExtensions.AddToArray<CompatibleNoun>(val.compatibleNouns, newCompatibleNoun); } public static void AddCompatibleNounsToKeyword(this Terminal terminal, string keywordName, params CompatibleNoun[] newCompatibleNouns) { TerminalKeyword val = ((IEnumerable<TerminalKeyword>)terminal.terminalNodes.allKeywords).FirstOrDefault((Func<TerminalKeyword, bool>)((TerminalKeyword kw) => ((Object)kw).name == keywordName)) ?? throw new ArgumentException("Failed to find keyword with name " + keywordName); val.compatibleNouns = CollectionExtensions.AddRangeToArray<CompatibleNoun>(val.compatibleNouns, newCompatibleNouns); } public static void AddCompatibleNounsToKeyword(this Terminal terminal, Func<TerminalKeyword, bool> predicate, params CompatibleNoun[] newCompatibleNouns) { TerminalKeyword val = terminal.terminalNodes.allKeywords.FirstOrDefault(predicate) ?? throw new ArgumentException("Failed to find keyword that matches provided predicate"); val.compatibleNouns = CollectionExtensions.AddRangeToArray<CompatibleNoun>(val.compatibleNouns, newCompatibleNouns); } }